Files
mapo-core/MP.INVE/Components/ProcSess.razor.cs
T
2022-12-28 15:18:44 +01:00

92 lines
2.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.Data.DatabaseModels;
using MP.INVE.Data;
using MP.INVE.Pages;
using Blazored.LocalStorage;
using MP.Data.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}");
}
}
}
}
}