Files
Samuele E. Locatelli 50d65eebaa MP.DATA, riorganizzazioni varie:
- renaming classi gestione DbModels in
- spostamento anagrafica flussi da auth a generale
2025-03-08 10:40:09 +01:00

150 lines
3.9 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DbModels;
using MP.INVE.Data;
namespace MP.INVE.Components
{
public partial class ListQrOpr
{
#region Public Properties
[Parameter]
public SelectQrOperatoreParams currParams { get; set; } = null!;
[Parameter]
public bool isLoading { get; set; }
[Parameter]
public EventCallback<int> TotalChanged { get; set; }
#endregion Public Properties
#region Protected Fields
protected List<AnagOperatoriModel>? elencoOperatori = new List<AnagOperatoriModel>();
protected List<AnagOperatoriModel>? SearchRecords = new List<AnagOperatoriModel>();
#endregion Protected Fields
#region Protected Properties
protected string authKey
{
get => _authKey;
set => _authKey = value;
}
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; }
protected int idOperatore
{
get => _idOperatore;
set => _idOperatore = value;
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MiDataService MIService { get; set; } = null!;
protected string rawCode
{
get
{
string answ = "";
answ = $"{BaseUrlTab}MatrOpr={idOperatore}&UserAuthKey={authKey}";
return answ;
}
}
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
if (lastParams == null || !currParams.Equals(lastParams))
{
lastParams = currParams.Clone();
await reloadData(true);
}
}
#endregion Protected Methods
#region Private Fields
private string _authKey = "";
private int _idOperatore = 0;
private int _totalCount = 0;
#endregion Private Fields
#region Private Properties
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private int currPage
{
get => currParams.CurrPage;
}
private SelectQrOperatoreParams? lastParams { get; set; } = null;
private int numRecord
{
get => currParams.NumRec;
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
TotalChanged.InvokeAsync(value);
}
}
}
#endregion Private Properties
#region Private Methods
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;
}
#endregion Private Methods
}
}