diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 6d66bdb..d896239 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -919,31 +919,44 @@ namespace GWMS.UI.Data public async Task> PlantDtoGetAll() { List dbResult = new List(); - string cacheVetoKey = "DATA:PLANTS:CalcListDTO"; + string cacheVetoKey = "DATA:PLANTS:VetoReadDto"; + string rawData; + var rand = new Random(); // controllo se ci sia semaforo lettura var redVeto = await distributedCache.GetAsync(cacheVetoKey); // attendo sino a che non ho scadenza blocco richiesta... - var rand = new Random(); while (redVeto != null) { - await Task.Delay(1000 * rand.Next(1, 5)); - // controllo se ci sia semaforo lettura - redVeto = await distributedCache.GetAsync(cacheVetoKey); - Log.Info($"Veto attivo per PlantDtoGetAll: salto!"); + rawData = Encoding.UTF8.GetString(redVeto); + var vetoDt = JsonConvert.DeserializeObject(rawData); + if (vetoDt < DateTime.Now) + { + Log.Info("Fine veto attesa"); + redVeto = null; + } + else + { + Log.Trace($"Veto attivo per PlantDtoGetAll: salto!"); + // controllo se ci sia semaforo lettura + redVeto = await distributedCache.GetAsync(cacheVetoKey); + // se scaduto da oltre 10 sec --> tolgo + //attendo + await Task.Delay(1000 * rand.Next(1, 5)); + } } // inserisco veto x bloccare! - var vetoData = JsonConvert.SerializeObject("1"); + var vetoData = JsonConvert.SerializeObject(DateTime.Now.AddSeconds(5)); var serVetoData = Encoding.UTF8.GetBytes(vetoData); await distributedCache.SetAsync(cacheVetoKey, serVetoData, cacheOptFast(true)); // proseguo con la vera lettura e serializzazione string cacheKey = "DATA:PLANTS:ListDTO"; - string rawData; var redisDataList = await distributedCache.GetAsync(cacheKey); if (redisDataList != null) { rawData = Encoding.UTF8.GetString(redisDataList); dbResult = JsonConvert.DeserializeObject>(rawData); + Log.Trace($"PlantDtoGetAll: lettura da cache REDIS"); } else { @@ -958,8 +971,13 @@ namespace GWMS.UI.Data await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per PlantDtoGetAll: {ts.TotalMilliseconds} ms"); + Log.Info($"Effettuata lettura da DB + caching per PlantDtoGetAll: {ts.TotalMilliseconds} ms"); } + // metto veto lettura scaduto... + vetoData = JsonConvert.SerializeObject(DateTime.Now.AddSeconds(-1)); + serVetoData = Encoding.UTF8.GetBytes(vetoData); + await distributedCache.SetAsync(cacheVetoKey, serVetoData, cacheOptFast(true)); + return await Task.FromResult(dbResult); } @@ -1770,8 +1788,8 @@ namespace GWMS.UI.Data /// private DistributedCacheEntryOptions cacheOptFast(bool fastCache) { - var numSecAbsExp = fastCache ? 1 : chAbsExp * 10; - var numSecSliExp = fastCache ? 10 : chSliExp * 10; + var numSecAbsExp = fastCache ? 5 : chAbsExp * 10; + var numSecSliExp = fastCache ? 15 : chSliExp * 10; return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp)); } diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 1fa4661..510a98d 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.0.2406.0318 + 1.0.2406.0319 95c9f021-52d1-4390-a670-5810b7b777b0 true true diff --git a/GWMS.UI/Startup.cs b/GWMS.UI/Startup.cs index ddd4f5c..ae2c537 100644 --- a/GWMS.UI/Startup.cs +++ b/GWMS.UI/Startup.cs @@ -127,7 +127,11 @@ namespace GWMS.UI // altri parametri per check vari string connStringDB = DbConfig.CONNECTION_STRING; string connStringRedis = Configuration.GetConnectionString("Redis"); - string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")); + string redisSrvAddr = "localhost"; + if (connStringRedis.Contains(":")) + { + redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")); + } // healthchecks services.AddHealthChecks() @@ -150,7 +154,7 @@ namespace GWMS.UI s.SetMinimumSecondsBetweenFailureNotifications(120); s.SetApiMaxActiveRequests(5); s.SetHeaderText("GWMS Health Check Status"); - }) + }) .AddInMemoryStorage(); // abilitazione x email management con MailKit diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 556fe68..2b35c04 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

Versione: 1.0.2406.0318

+

Versione: 1.0.2406.0319


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 4247f1f..c86a490 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.0.2406.0318 +1.0.2406.0319 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 52712fd..c954ba8 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.0.2406.0318 + 1.0.2406.0319 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false