126 lines
3.8 KiB
C#
126 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using MP.INVE;
|
|
using MP.INVE.Shared;
|
|
using MP.INVE.Components;
|
|
using MP.INVE.Data;
|
|
using MP.Data.DatabaseModels;
|
|
|
|
namespace MP.INVE.Components
|
|
{
|
|
public partial class ListQrOpr
|
|
{
|
|
[Parameter]
|
|
public SelectQrOperatoreParams currParams { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public bool isLoading { get; set; }
|
|
|
|
[Inject]
|
|
protected MiDataService MIService { get; set; } = null!;
|
|
[Inject]
|
|
private IConfiguration Configuration { get; set; } = null!;
|
|
protected List<AnagOperatoriModel>? elencoOPeratori = new List<AnagOperatoriModel>();
|
|
protected List<AnagOperatoriModel>? SearchRecords = new List<AnagOperatoriModel>();
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
await Task.Delay(50);
|
|
if (firstRender)
|
|
{
|
|
await reloadData(true);
|
|
}
|
|
}
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await reloadData(true);
|
|
}
|
|
private int _idOperatore = 0;
|
|
protected int idOperatore
|
|
{
|
|
get => _idOperatore;
|
|
set => _idOperatore = value;
|
|
}
|
|
private string _authKey = "";
|
|
protected string authKey
|
|
{
|
|
get => _authKey;
|
|
set => _authKey = value;
|
|
}
|
|
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; }
|
|
protected string rawCode
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
answ = $"{BaseUrlTab}MatrOpr={idOperatore}&UserAuthKey={authKey}";
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private async Task reloadData(bool first)
|
|
{
|
|
elencoOPeratori = null;
|
|
isLoading = true;
|
|
SearchRecords = MIService.ElencoOperatori();
|
|
totalCount = SearchRecords.Count;
|
|
elencoOPeratori = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
await Task.Delay(1);
|
|
|
|
if (first)
|
|
{
|
|
if (elencoOPeratori != null)
|
|
{
|
|
|
|
foreach (var item in elencoOPeratori)
|
|
{
|
|
idOperatore = item.MatrOpr;
|
|
authKey = MIService.EncriptData(item.authKey);
|
|
|
|
await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{item.MatrOpr}");
|
|
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{item.MatrOpr}", rawCode);
|
|
}
|
|
}
|
|
}
|
|
isLoading = false;
|
|
}
|
|
private int numRecord
|
|
{
|
|
get => currParams.NumRec;
|
|
set
|
|
{
|
|
currParams.NumRec = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
private int currPage
|
|
{
|
|
get => currParams.CurrPage;
|
|
set
|
|
{
|
|
currParams.CurrPage = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => currParams.TotCount;
|
|
set => currParams.TotCount = value;
|
|
}
|
|
}
|
|
} |