84 lines
2.9 KiB
C#
84 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Data.DbModels;
|
|
using MP.INVE.Data;
|
|
using Blazored.LocalStorage;
|
|
using MP.Core.DTO;
|
|
|
|
namespace MP.INVE.Components
|
|
{
|
|
public partial class ProcOperatore
|
|
{
|
|
[Parameter]
|
|
public string lastScanOperatore { get; set; } = "0";
|
|
[Parameter]
|
|
public int sessionId { get; set; } = 0;
|
|
[Parameter]
|
|
public string magazzinoId { get; set; } = "";
|
|
[Inject]
|
|
protected MiDataService MIService { get; set; } = null!;
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; } = null!;
|
|
[Inject]
|
|
protected ILocalStorageService localStorage { get; set; } = null!;
|
|
[Inject]
|
|
protected MessageService MsgService { get; set; } = null!;
|
|
|
|
|
|
protected AnagOperatoriModel? operatoreScelto = new AnagOperatoriModel();
|
|
protected List<AnagOperatoriModel>? elencoOperatori = new List<AnagOperatoriModel>();
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await Task.Delay(1);
|
|
elencoOperatori = MIService.ElencoOperatori();
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await Task.Delay(1);
|
|
await reloadData(false);
|
|
}
|
|
private async Task reloadData(bool first)
|
|
{
|
|
if (elencoOperatori != null && lastScanOperatore != null)
|
|
{
|
|
operatoreScelto = elencoOperatori.Where(x => x.MatrOpr == int.Parse(lastScanOperatore)).FirstOrDefault();
|
|
}
|
|
await Task.Delay(1);
|
|
}
|
|
public int MatrOpr { get; set; } = 0;
|
|
public int InveSessID { get; set; } = 0;
|
|
public string MagID { get; set; } = "";
|
|
public string hashAuthKey { get; set; } = "";
|
|
public DateTime dtExp { get; set; }
|
|
protected async void connetti(int matrOpr, string authKey)
|
|
{
|
|
|
|
var log = MIService.loginOperatore(matrOpr, authKey);
|
|
if (log)
|
|
{
|
|
if (operatoreScelto != null)
|
|
{
|
|
|
|
string hash = MIService.EncriptData(operatoreScelto.authKey);
|
|
OperatoreDTO sessionOpr = new OperatoreDTO
|
|
{
|
|
MatrOpr = operatoreScelto.MatrOpr,
|
|
Nome = operatoreScelto.Nome,
|
|
Cognome = operatoreScelto.Cognome,
|
|
hashAuthKey = hash,
|
|
dtExp = DateTime.Now.AddMinutes(1)
|
|
};
|
|
|
|
#if false
|
|
await localStorage.SetItemAsync("MatrOpr", currOpr);
|
|
localStorage.SetItemAsync("idSessione", inveSessionId);
|
|
#endif
|
|
await MsgService.setCurrOperDtoAsync(sessionOpr);
|
|
|
|
NavManager.NavigateTo($"Acquisizione?idSess={sessionId}&idOpr={matrOpr}&codMag={magazzinoId}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |