diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj
index e6037d2d..f13534b2 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.708
+ 6.16.2311.709
enable
MP_TAB_SERV
diff --git a/MP-TAB-SERV/Pages/ODL.razor b/MP-TAB-SERV/Pages/ODL.razor
index d3b5fa95..8fdeb1fa 100644
--- a/MP-TAB-SERV/Pages/ODL.razor
+++ b/MP-TAB-SERV/Pages/ODL.razor
@@ -1,6 +1,6 @@
@page "/odl"
-
+
@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null)
{
diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html
index 72fa0cea..23b7c068 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.708
+ Versione: 6.16.2311.709
Note di rilascio:
-
diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt
index d337feb6..51da60c0 100644
--- a/MP-TAB-SERV/Resources/VersNum.txt
+++ b/MP-TAB-SERV/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2311.708
+6.16.2311.709
diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml
index bface0b0..bd7451d8 100644
--- a/MP-TAB-SERV/Resources/manifest.xml
+++ b/MP-TAB-SERV/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2311.708
+ 6.16.2311.709
https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip
https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html
false
diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs
index f510d0ef..b1b6fb55 100644
--- a/MP.Data/Services/MessageService.cs
+++ b/MP.Data/Services/MessageService.cs
@@ -1,10 +1,13 @@
using Blazored.LocalStorage;
using Blazored.SessionStorage;
+using Microsoft.Extensions.Configuration;
using MP.Data.DatabaseModels;
using Newtonsoft.Json;
using NLog;
+using StackExchange.Redis;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
namespace MP.Data.Services
@@ -13,16 +16,25 @@ namespace MP.Data.Services
{
#region Public Fields
+ public const string KeyCommDtRif = "DtRifComm";
+ public const string KeyCommText = "ValComm";
public int orarioDip = 0;
#endregion Public Fields
#region Public Constructors
- public MessageService(ILocalStorageService genLocalStorage, ISessionStorageService sessStore)
+ public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore)
{
+ _configuration = configuration;
+
+ // gestione sessioni in browser
localStorage = genLocalStorage;
sessionStore = sessStore;
+
+ // setup compoenti REDIS
+ redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
+ redisDb = redisConn.GetDatabase();
}
#endregion Public Constructors
@@ -35,32 +47,21 @@ namespace MP.Data.Services
#endregion Public Events
-#if false
- public event Action EA_DateChanged = null!;
- public event Action EA_CalModeChanged = null!;
+ #region Public Properties
- public event Action EA_TimbUpd = null!;
-#endif
-
-#if false
- public RegAttivitaModel? clonedRA { get; set; } = null;
-
- ///
- /// Calcola HASH del codice impiego = payload utente
- ///
- ///
- public string HashDip
+ public string CognomeNome
{
get
{
- DataValidator cDV = new DataValidator(_rigaOper);
- string hash = cDV.HashDip;
- return hash;
+ string answ = "";
+ //int answ = -1;
+ if (_rigaOper != null)
+ {
+ answ = $"{_rigaOper.Cognome} {_rigaOper.Nome}";
+ }
+ return answ;
}
}
-#endif
-
- #region Public Properties
///
/// Dizionario macchine
@@ -100,19 +101,6 @@ namespace MP.Data.Services
return answ;
}
}
- public string CognomeNome
- {
- get
- {
- string answ = "";
- //int answ = -1;
- if (_rigaOper != null)
- {
- answ = $"{_rigaOper.Cognome} {_rigaOper.Nome}";
- }
- return answ;
- }
- }
public AnagOperatoriModel? RigaOper
{
@@ -141,6 +129,15 @@ namespace MP.Data.Services
}
}
+ ///
+ /// Dizionario totale preferenze utente
+ ///
+ public Dictionary UsersPrefDict
+ {
+ get => redisHashDictGet((RedisKey)$"{redisBaseKey}:{MatrOpr}");
+ set => redisHashDictSet((RedisKey)$"{redisBaseKey}:{MatrOpr}", value);
+ }
+
#endregion Public Properties
#region Public Methods
@@ -184,18 +181,6 @@ namespace MP.Data.Services
await sessionStore.SetItemAsync(KeyCommDtRif, DtRif);
}
-
- ///
- /// Verifico esistenza chiave in session store
- ///
- ///
- ///
- public async Task SessHasVal(string keyName)
- {
- bool hasKey = await sessionStore.ContainKeyAsync(keyName);
- return hasKey;
- }
-
///
/// Commento fermata x recupero in editing
///
@@ -303,6 +288,17 @@ namespace MP.Data.Services
}
}
+ ///
+ /// Verifico esistenza chiave in session store
+ ///
+ ///
+ ///
+ public async Task SessHasVal(string keyName)
+ {
+ bool hasKey = await sessionStore.ContainKeyAsync(keyName);
+ return hasKey;
+ }
+
///
/// Scrive il valore di IPV4 del device nel localstoragee
///
@@ -343,6 +339,44 @@ namespace MP.Data.Services
return answ;
}
+ ///
+ /// Recupero singola preferenza utente
+ ///
+ ///
+ ///
+ public string UserPrefGet(string chiave)
+ {
+ string answ = "";
+ var currDict = UsersPrefDict;
+ if (currDict.ContainsKey(chiave))
+ {
+ answ = currDict[chiave];
+ }
+ return answ;
+ }
+
+ ///
+ /// Salvo singola rpeferenza utente
+ ///
+ ///
+ ///
+ ///
+ public bool UserPrefSave(string chiave, string valore)
+ {
+ bool done = false;
+ var currDict = UsersPrefDict;
+ if (currDict.ContainsKey(chiave))
+ {
+ currDict[chiave] = valore;
+ }
+ else
+ {
+ currDict.Add(chiave, valore);
+ UsersPrefDict = currDict;
+ }
+ return done;
+ }
+
#endregion Public Methods
#region Protected Fields
@@ -350,20 +384,130 @@ namespace MP.Data.Services
protected const string KeyDevIp4 = "DevIpv4";
protected const string KeyDevSec = "DevSec";
protected const string KeyMacDict = "MachineDict";
+ protected static IConfiguration _configuration = null!;
+
+ ///
+ /// Oggetto per connessione a REDIS
+ ///
+ protected ConnectionMultiplexer redisConn = null!;
+
+ ///
+ /// Oggetto DB redis da impiegare x chiamate R/W
+ ///
+ protected IDatabase redisDb = null!;
#endregion Protected Fields
#region Protected Properties
protected ILocalStorageService localStorage { get; set; } = null!;
+
protected ISessionStorageService sessionStore { get; set; } = null!;
#endregion Protected Properties
#region Private Fields
- public const string KeyCommDtRif = "DtRifComm";
- public const string KeyCommText = "ValComm";
+ private AnagOperatoriModel? _rigaOper;
+
+ ///
+ /// Durata cache lunga IN SECONDI
+ ///
+ private int cacheTtlLong = 60 * 5;
+
+ ///
+ /// Durata cache breve IN SECONDI
+ ///
+ private int cacheTtlShort = 60 * 1;
+
+ private Logger Log = LogManager.GetCurrentClassLogger();
+ private string redisBaseKey = "MP:TAB:User";
+ private Random rnd = new Random();
+
+ #endregion Private Fields
+
+ #region Private Methods
+
+ private string machineMse(string idxMacc)
+ {
+ return $"MSE_{idxMacc}";
+ }
+
+ ///
+ /// Recupero HashSet redis come Dictionary
+ ///
+ ///
+ ///
+ private Dictionary redisHashDictGet(RedisKey currKey)
+ {
+ Dictionary answ = new Dictionary();
+ try
+ {
+ answ = redisDb
+ .HashGetAll(currKey)
+ .ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore redisHashDictGet | currKey: {currKey}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Salvataggio Dictionary come HashSet Redis
+ ///
+ ///
+ ///
+ private bool redisHashDictSet(RedisKey currKey, Dictionary dict)
+ {
+ bool fatto = false;
+ try
+ {
+ HashEntry[] data2ins = new HashEntry[dict.Count];
+ int i = 0;
+ foreach (KeyValuePair kvp in dict)
+ {
+ data2ins[i] = new HashEntry(kvp.Key, kvp.Value);
+ i++;
+ }
+ // salvo!
+ redisDb.HashSet(currKey, data2ins);
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in redisHashDictSet | currKey: {currKey}{Environment.NewLine}{exc}");
+ }
+ return fatto;
+ }
+
+ #endregion Private Methods
+
+#if false
+ public event Action EA_DateChanged = null!;
+ public event Action EA_CalModeChanged = null!;
+
+ public event Action EA_TimbUpd = null!;
+#endif
+
+#if false
+ public RegAttivitaModel? clonedRA { get; set; } = null;
+
+ ///
+ /// Calcola HASH del codice impiego = payload utente
+ ///
+ ///
+ public string HashDip
+ {
+ get
+ {
+ DataValidator cDV = new DataValidator(_rigaOper);
+ string hash = cDV.HashDip;
+ return hash;
+ }
+ }
+#endif
#if false
public bool IsActive
{
@@ -546,21 +690,6 @@ namespace MP.Data.Services
}
}
#endif
- private AnagOperatoriModel? _rigaOper;
-
- private Logger Log = LogManager.GetCurrentClassLogger();
-
- #endregion Private Fields
-
- #region Private Methods
-
- private string machineMse(string idxMacc)
- {
- return $"MSE_{idxMacc}";
- }
-
- #endregion Private Methods
-
#if false
private string _pageIcon = "";
private string _pageName = "";