164 lines
5.4 KiB
C#
164 lines
5.4 KiB
C#
using Blazored.LocalStorage;
|
|
using Blazored.SessionStorage;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.WebUtilities;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.Data.DTO;
|
|
using MP.INVE.Data;
|
|
using Newtonsoft.Json;
|
|
using System.Numerics;
|
|
using System.Web;
|
|
|
|
namespace MP.INVE.Pages
|
|
{
|
|
public partial class Jumper
|
|
{
|
|
#region Protected Properties
|
|
|
|
protected string authKey { get; set; } = "";
|
|
|
|
protected string codMag { get; set; } = "";
|
|
|
|
protected string idOpr { get; set; } = "";
|
|
|
|
protected int inveSessionId { get; set; } = 0;
|
|
protected bool isFullUrl { get; set; } = false;
|
|
|
|
[Inject]
|
|
protected ILocalStorageService localStorage { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MiDataService MIService { get; set; } = null!;
|
|
[Inject]
|
|
protected MessageService MsgService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected ISessionStorageService sessionStorage { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await Task.Delay(1);
|
|
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("MatrOpr", out var _matrOpr))
|
|
{
|
|
if (!string.IsNullOrEmpty(_matrOpr))
|
|
{
|
|
idOpr = _matrOpr;
|
|
}
|
|
}
|
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("UserAuthKey", out var _authKey))
|
|
{
|
|
if (!string.IsNullOrEmpty(_authKey))
|
|
{
|
|
authKey = _authKey;
|
|
}
|
|
}
|
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idSessione", out var _inveSessionId))
|
|
{
|
|
if (_inveSessionId != 0)
|
|
{
|
|
inveSessionId = int.Parse(_inveSessionId);
|
|
}
|
|
}
|
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idMag", out var _codMag))
|
|
{
|
|
if (!string.IsNullOrEmpty(_codMag))
|
|
{
|
|
codMag = _codMag;
|
|
}
|
|
}
|
|
|
|
#if false
|
|
if (!string.IsNullOrEmpty(idOpr) && !string.IsNullOrEmpty(authKey))
|
|
{
|
|
isFullUrl = true;
|
|
string pw = MIService.DeriptData(authKey);
|
|
logged = MIService.loginOperatore(int.Parse(idOpr), pw);
|
|
|
|
if (logged)
|
|
{
|
|
operatore = MIService.ElencoOperatori();
|
|
if (operatore != null)
|
|
{
|
|
AnagOperatoriModel? currOpr = operatore.Where(x => (x.MatrOpr == int.Parse(idOpr)) && (x.authKey == pw)).SingleOrDefault();
|
|
|
|
if (currOpr != null)
|
|
{
|
|
string hash = MIService.EncriptData(currOpr.authKey);
|
|
OperatoreDTO sessionOpr = new OperatoreDTO
|
|
{
|
|
MatrOpr = currOpr.MatrOpr,
|
|
Nome = currOpr.Nome,
|
|
Cognome = currOpr.Cognome,
|
|
hashAuthKey = hash,
|
|
dtExp = DateTime.Now.AddMinutes(1)
|
|
};
|
|
|
|
#if false
|
|
await localStorage.SetItemAsync("MatrOpr", currOpr);
|
|
#endif
|
|
await MsgService.setCurrOperDtoAsync(sessionOpr);
|
|
await sessionStorage.SetItemAsync("idSessione", inveSessionId);
|
|
}
|
|
NavManager.NavigateTo($"Acquisizione?idSess={inveSessionId}&idOpr={idOpr}&codMag={codMag}");
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
string json = "";
|
|
Dictionary<string, string> uriProcDict = new Dictionary<string, string>();
|
|
protected void saveScan(string newScan)
|
|
{
|
|
//uriProcDict.Clear();
|
|
if (!string.IsNullOrEmpty(newScan))
|
|
{
|
|
#if false
|
|
//eseguo split su "?" e divido in due il link
|
|
var uriProc1 = newScan.Split("?");
|
|
//eseguo split su "&" e divido il rimanente del link ottenendo così le variabili singole
|
|
var uriProc2 = uriProc1[1].Split("&");
|
|
string[] uriProc3;
|
|
|
|
for (int i = 0; i < uriProc2.Length; i++)
|
|
{
|
|
uriProc3 = uriProc2[i].Split("=");
|
|
uriProcDict.Add(uriProc3[0], uriProc3[1]);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(idOpr))
|
|
{
|
|
rawScan = uriProcDict["MatrOpr"];
|
|
}
|
|
else
|
|
{
|
|
rawScan = uriProcDict["IdSessione"];
|
|
}
|
|
#endif
|
|
rawScan = newScan;
|
|
}
|
|
}
|
|
protected string rawScan { get; set; } = null!;
|
|
protected AnagOperatoriModel currOpr { get; set; } = null!;
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<AnagOperatoriModel> operatore = new List<AnagOperatoriModel>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private bool logged { get; set; } = false;
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |