handleBodyClick()">
+
HandleBodyClick()">
-
+
@if (userIsOk || NavMan.Uri.Contains("reg-new-device"))
{
@@ -24,5 +24,5 @@
-
+
diff --git a/MP-TAB3/Shared/MainLayout.razor.cs b/MP-TAB3/Shared/MainLayout.razor.cs
index 672d10ec..4b8e7e55 100644
--- a/MP-TAB3/Shared/MainLayout.razor.cs
+++ b/MP-TAB3/Shared/MainLayout.razor.cs
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Components.Routing;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.Services;
-using MP_TAB3.Components;
using NLog;
namespace MP_TAB3.Shared
@@ -94,23 +93,25 @@ namespace MP_TAB3.Shared
protected async Task checkDtDiff2Logout()
{
- TimeSpan tsDeltaAct = DateTime.Now.Subtract(MsgServ.dtLastAction);
- TimeSpan tsDeltaSave = DateTime.Now.Subtract(MsgServ.dtLastSave);
+ DateTime adesso = DateTime.Now;
+ TimeSpan tsDeltaAct = adesso.Subtract(MsgServ.dtLastAction);
+ TimeSpan tsDeltaSave = adesso.Subtract(MsgServ.dtLastSave);
+ string userTkn = "";
switch (typeScadLogin)
{
case 1:
if (tsDeltaAct.TotalMinutes >= dtScadLogin)
{
- var userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
- if (!string.IsNullOrEmpty(userTkn))
+ userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
+ if (string.IsNullOrEmpty(userTkn))
{
- await MsgServ.DoLogIn(userTkn, true);
- MsgServ.dtLastAction = DateTime.Now;
- MsgServ.dtLastSave = DateTime.Now;
+ NavMan.NavigateTo("logout");
}
else
{
- NavMan.NavigateTo("logout");
+ await MsgServ.DoLogIn(userTkn, true);
+ MsgServ.dtLastAction = adesso;
+ MsgServ.dtLastSave = adesso;
}
}
else
@@ -118,21 +119,35 @@ namespace MP_TAB3.Shared
// se fosse oltre 1 minuto da ultimo save --> salvo!
if (tsDeltaSave.TotalMinutes > 1)
{
- var userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
+ userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
if (!string.IsNullOrEmpty(userTkn))
{
await MsgServ.DoLogIn(userTkn, true);
- MsgServ.dtLastAction = DateTime.Now;
- MsgServ.dtLastSave = DateTime.Now;
+ MsgServ.dtLastAction = adesso;
+ MsgServ.dtLastSave = adesso;
}
}
}
break;
case 2:
- if (tsDeltaAct.TotalMinutes >= dtScadLogin)
+ // se fosse oltre 1 minuto da ultimo save --> salvo!
+ if (tsDeltaSave.TotalMinutes > 1)
{
- NavMan.NavigateTo("logout");
+ // mitigazione controlli: solo ogni 1 minuto...
+ if (tsDeltaSave.TotalMinutes > 1)
+ {
+ MsgServ.dtLastSave = adesso;
+ userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
+ if (string.IsNullOrEmpty(userTkn))
+ {
+ NavMan.NavigateTo("logout");
+ }
+ if (tsDeltaAct.TotalMinutes >= dtScadLogin)
+ {
+ NavMan.NavigateTo("logout");
+ }
+ }
}
break;
@@ -145,13 +160,12 @@ namespace MP_TAB3.Shared
}
}
- protected async Task checkIfUserOk(bool isOk)
+ protected async Task ForceReloadMStor(bool isOk)
{
- await Task.Delay(1);
- userIsOk = isOk;
+ await ReloadMemStor();
}
- protected async Task handleBodyClick()
+ protected async Task HandleBodyClick()
{
await Task.Delay(1);
if (!pageOk)
@@ -160,6 +174,11 @@ namespace MP_TAB3.Shared
}
}
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ currDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
+ }
+
///
/// Init struttura dati
///
@@ -184,11 +203,6 @@ namespace MP_TAB3.Shared
}
}
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- currDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
- }
-
protected async Task ReloadMemStor()
{
// in primis svuoto...
@@ -223,6 +237,12 @@ namespace MP_TAB3.Shared
TDataService.SetupConfig();
}
+ protected async Task SetUserOk(bool isOk)
+ {
+ await Task.Delay(1);
+ userIsOk = isOk;
+ }
+
#endregion Protected Methods
#region Private Fields
diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs
index 6d818038..0466f32f 100644
--- a/MP.Data/Services/MessageService.cs
+++ b/MP.Data/Services/MessageService.cs
@@ -53,30 +53,6 @@ namespace MP.Data.Services
#endregion Public Events
-#if false
- protected bool _tReset { get; set; } = false;
- protected bool tReset
- {
- get => _tReset;
- set
- {
- if (_tReset != value)
- {
- _tReset = value;
- resetTimer();
- }
- }
- }
-
- protected void resetTimer()
- {
- if (EA_ResetFooterTimer != null)
- {
- EA_ResetFooterTimer?.Invoke();
- }
- }
-#endif
-
#region Public Properties
public string CognomeNome
@@ -251,8 +227,6 @@ namespace MP.Data.Services
public async Task
DoLogIn(string decodValue, bool saveOpr)
{
bool answ = false;
- //expDays = SMService.GetConfInt("cookieDayExpire");
- //var expDT = DateTime.Now.AddDays(expDays);
var devGuid = await GetCurrDevGuidLSAsync();
// decifro i valori..
var decrVal = DecryptData(decodValue);
@@ -306,6 +280,7 @@ namespace MP.Data.Services
}
return answ;
}
+
///
/// Restituisce il record OperatoreDTO da localstorage
///
@@ -351,6 +326,20 @@ namespace MP.Data.Services
return answ;
}
+ public TimeSpan GetKeyTTL(string redKey)
+ {
+ TimeSpan answ = new TimeSpan();
+ try
+ {
+ answ = redisDb.KeyTimeToLive(redKey) ?? new TimeSpan();
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore GetKeyTTL | currKey: {redKey}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
///
/// Restituisce ultima matrOpr registrata da localstorage
///
@@ -440,17 +429,6 @@ namespace MP.Data.Services
return hasKey;
}
- ///
- /// scrive il record OperatoreDTO nel localstorage
- ///
- ///
- public async Task SetCurrOperDtoLSAsync(string currTkn)
- {
- bool answ = false;
- await localStorage.SetItemAsync("currTkn", currTkn);
- answ = true;
- return answ;
- }
///
/// scrive il record Device GUID nel localstorage
///
@@ -463,6 +441,18 @@ namespace MP.Data.Services
return answ;
}
+ ///
+ /// scrive il record OperatoreDTO nel localstorage
+ ///
+ ///
+ public async Task SetCurrOperDtoLSAsync(string currTkn)
+ {
+ bool answ = false;
+ await localStorage.SetItemAsync("currTkn", currTkn);
+ answ = true;
+ return answ;
+ }
+
///
/// Scrive il valore di IPV4 del device nel localstoragee
///
@@ -515,7 +505,6 @@ namespace MP.Data.Services
return answ;
}
-
///
/// Recupero singola preferenza utente
///
diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs
index 67f96f8d..cb4db236 100644
--- a/MP.Data/Services/TabDataService.cs
+++ b/MP.Data/Services/TabDataService.cs
@@ -1617,6 +1617,36 @@ namespace MP.Data.Services
return answ;
}
+ public TimeSpan GetKeyTTL(string redKey)
+ {
+ TimeSpan answ = TimeSpan.FromMinutes(-1);
+ try
+ {
+ answ = redisDb.KeyTimeToLive(redKey) ?? new TimeSpan();
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore GetKeyTTL | currKey: {redKey}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+
+ ///
+ /// Legge l'oggetto operatore+device loggato e restituisce la sua TTL
+ ///
+ ///
+ ///
+ ///
+ public TimeSpan OperatoreGetGuidTTL(int matrOpr, Guid currDevGuid)
+ {
+ TimeSpan answ = new TimeSpan();
+ // cerco in redis...
+ string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}";
+ answ = GetKeyTTL(currKey);
+ return answ;
+ }
+
///
/// Legge l'oggetto operatore loggato
///
@@ -1633,8 +1663,6 @@ namespace MP.Data.Services
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
- //var encrData = SteamCrypto.DecryptString(rawData, passPhrase);
- //answ = JsonConvert.DeserializeObject(rawData);
answ = rawData;
}
if (answ == null)