diff --git a/MP-TAB-SERV/Components/CmpTop.razor.cs b/MP-TAB-SERV/Components/CmpTop.razor.cs index 176342e7..a3443ff4 100644 --- a/MP-TAB-SERV/Components/CmpTop.razor.cs +++ b/MP-TAB-SERV/Components/CmpTop.razor.cs @@ -1,6 +1,9 @@ +using EgwCoreLib.Utils; using Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; +using MP.Data.DTO; using MP.Data.Services; +using Newtonsoft.Json; using NLog; using System.Diagnostics; @@ -71,20 +74,59 @@ namespace MP_TAB_SERV.Components NavMan.NavigateTo("/", true); } - private string UserName + protected async Task logIn(string decodValue) { - get => MsgServ.CognomeNome; - } - private int MatrOpr - { - get => MsgServ.MatrOpr; + // decifro i valori.. + var decrVal = MsgServ.DecryptData(decodValue); + var opData = JsonConvert.DeserializeObject(decrVal); + if (opData != null) + { + var rigaOpr = await TDService.OperatoreSearch(opData.currOpr.MatrOpr, opData.currOpr.authKey); +#if false + if (rigaOpr == null) + { + var deHash = TDService.DecryptData(authKey); + rigaOpr = await TDService.OperatoreSearch(matrOpr, deHash); + } + if (rigaOpr != null) + { + userTknDTO newUserTkn = new userTknDTO() + { + currOpr = rigaOpr, + expTime = expDT + }; + + var jsonTkn = JsonConvert.SerializeObject(newUserTkn); + string hash = TDService.EncryptData(jsonTkn); + MsgServ.RigaOper = rigaOpr; + await MsgServ.setCurrOperDtoAsync(hash); + await TDService.OperatoreSetRedis(matrOpr, hash); + NavMan.NavigateTo("status-map"); + } +#endif + } } + protected DateTime expDT { get; set; } = DateTime.Now; + [Inject] + protected SharedMemService SMServ { get; set; } = null!; protected override async Task OnInitializedAsync() { await Task.Delay(1); + int expDays= SMServ.GetConfInt("cookieDayExpire"); + expDT = DateTime.Now.AddDays(expDays); + CurrOprTknLS = await MsgServ.getCurrOperDtoAsync(); var decodedUrl = Uri.UnescapeDataString(CurrOprTknLS); + + // verifico se non avessi dati operatore + if(MsgServ.RigaOper==null) + { + await logIn(decodedUrl); + } + + + CurrOprTknRedis = await TDService.OperatoreGetRedis(MatrOpr); if (CurrOprTknRedis == "") { @@ -146,5 +188,19 @@ namespace MP_TAB_SERV.Components private static Logger Log = LogManager.GetCurrentClassLogger(); #endregion Private Fields + + #region Private Properties + + private int MatrOpr + { + get => MsgServ.MatrOpr; + } + + private string UserName + { + get => MsgServ.CognomeNome; + } + + #endregion Private Properties } } \ No newline at end of file diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 899a778f..ea5554a0 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2311.1412 + 6.16.2311.1414 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Pages/RegNewDevice.razor.cs b/MP-TAB-SERV/Pages/RegNewDevice.razor.cs index 60740dd8..16149e86 100644 --- a/MP-TAB-SERV/Pages/RegNewDevice.razor.cs +++ b/MP-TAB-SERV/Pages/RegNewDevice.razor.cs @@ -61,8 +61,12 @@ namespace MP_TAB_SERV.Pages protected DateTime expDT { get; set; } = DateTime.Now; protected async Task logIn() { - await Task.Delay(1); rigaOpr = await TDService.OperatoreSearch(matrOpr, authKey); + if (rigaOpr == null) + { + var deHash = TDService.DecryptData(authKey); + rigaOpr = await TDService.OperatoreSearch(matrOpr, deHash); + } if (rigaOpr != null) { userTknDTO newUserTkn = new userTknDTO() @@ -115,29 +119,7 @@ namespace MP_TAB_SERV.Pages authKey = _authKey; } } - - - rigaOpr = await TDService.OperatoreSearch(matrOpr, authKey); - if (rigaOpr == null) - { - var deHash = TDService.DecryptData(authKey); - rigaOpr = await TDService.OperatoreSearch(matrOpr, deHash); - } - if (rigaOpr != null) - { - userTknDTO newUserTkn = new userTknDTO() - { - currOpr = rigaOpr, - expTime = expDT - }; - - var jsonTkn = JsonConvert.SerializeObject(newUserTkn); - string hash = TDService.EncryptData(jsonTkn); - MsgServ.RigaOper = rigaOpr; - await MsgServ.setCurrOperDtoAsync(hash); - await TDService.OperatoreSetRedis(matrOpr, hash); - NavMan.NavigateTo("status-map"); - } + await logIn(); } } } diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index 0b60a31d..94db3b42 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2311.1412

+

Versione: 6.16.2311.1414


Note di rilascio: