Files
mapo-core/MP.INVE/Components/ProcSess.razor.cs
T

97 lines
3.1 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 InventorySessionModel? sessioneScelta = new InventorySessionModel();
protected List<InventorySessionModel>? elencoSessioni = new List<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)
{
await Task.Delay(1);
if (lastScanSessione != null)
{
sessioneScelta = MIService.InventSessByID(int.Parse(lastScanSessione));
}
}
protected async void connetti(int sessionId, string magazzinoId)
{
var decrypt = MIService.DeriptData(authKey);
var log = MIService.loginOperatore(idOpr, decrypt);
if (log)
{
if (sessioneScelta != null)
{
//string hash = MIService.EncriptData(sessioneScelta.authKey);
#if false
OperatoreDTO sessionOpr = new OperatoreDTO
{
MatrOpr = idOpr,
Nome = sessioneScelta.Nome,
Cognome = sessioneScelta.Cognome,
hashAuthKey = authKey,
dtExp = DateTime.Now.AddMinutes(1)
};
#endif
#if false
await localStorage.SetItemAsync("MatrOpr", currOpr);
localStorage.SetItemAsync("idSessione", inveSessionId);
await MsgService.setCurrOperDtoAsync(sessionOpr);
#endif
NavManager.NavigateTo($"Acquisizione?idSess={sessionId}&idOpr={idOpr}&codMag={magazzinoId}");
}
}
}
}
}