Files
2025-03-14 18:34:38 +01:00

76 lines
2.3 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 ProcSess
{
[Parameter]
public string lastScanSessione { get; set; } = "0";
[Parameter]
public int idOpr { get; set; } = 0;
[Parameter]
public string authKey { 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 bool isLoading = false;
protected InventorySessionModel? currSess = new InventorySessionModel();
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
}
protected override async Task OnParametersSetAsync()
{
await Task.Delay(1);
await reloadData(false);
}
private async Task reloadData(bool first)
{
currSess = null;
isLoading = true;
await Task.Delay(1);
if (lastScanSessione != null)
{
currSess = MIService.InventSessByID(int.Parse(lastScanSessione));
}
isLoading = false;
}
protected async void connetti(int sessionId, string magazzinoId)
{
var decrypt = MIService.DeriptData(authKey);
var log = MIService.loginOperatore(idOpr, decrypt);
if (log)
{
if (currSess != null)
{
InveSessDTO currSess = new InveSessDTO()
{
MatrOpr = idOpr,
InveSessID = sessionId,
MagID = magazzinoId,
hashAuthKey = authKey,
dtExp = DateTime.Now.AddHours(8)
};
await localStorage.SetItemAsync("SessioneCorrente", currSess);
NavManager.NavigateTo($"Acquisizione?idSess={sessionId}&idOpr={idOpr}&codMag={magazzinoId}");
}
}
}
}
}