From e77c7b3c7f75ce3bd213d60fc9beae17c989f8d8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 11 Jan 2023 07:58:41 +0100 Subject: [PATCH] Continuo fix dati x cambio tipologia cache --- GPW.CORE.WRKLOG/Data/GpwDataService.cs | 67 ++++++++++++++++---------- GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/GPW.CORE.WRKLOG/Data/GpwDataService.cs b/GPW.CORE.WRKLOG/Data/GpwDataService.cs index c55332e..4f1a831 100644 --- a/GPW.CORE.WRKLOG/Data/GpwDataService.cs +++ b/GPW.CORE.WRKLOG/Data/GpwDataService.cs @@ -116,32 +116,39 @@ namespace GPW.CORE.WRKLOG.Data /// public async Task> AnagClientiAll() { + string source = "DB"; List? dbResult = new List(); string currKey = $"{rKeyCliAll}"; - string rawData; - var redisDataList = await distributedCache.GetAsync(currKey); - if (redisDataList != null) + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject>(rawData); + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } } else { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); dbResult = dbController.AnagClientiAll(); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per AnagClientiAll: {ts.TotalMilliseconds} ms"); + await redisDb.StringSetAsync(currKey, rawData, FastCache); } if (dbResult == null) { dbResult = new List(); } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagClientiAll | {source} in: {ts.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -151,32 +158,38 @@ namespace GPW.CORE.WRKLOG.Data /// public async Task> AnagFasiAll() { + string source = "DB"; List? dbResult = new List(); string currKey = $"{rKeyFasiAll}"; - - string rawData; - var redisDataList = await distributedCache.GetAsync(currKey); - if (redisDataList != null) + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject>(rawData); + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } } else { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); dbResult = dbController.AnagFasiAll(false); rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB + caching per AnagFasiAll: {ts.TotalMilliseconds} ms"); + await redisDb.StringSetAsync(currKey, rawData, FastCache); } if (dbResult == null) { dbResult = new List(); } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagFasiAll | {source} in: {ts.TotalMilliseconds} ms"); return await Task.FromResult(dbResult); } @@ -659,6 +672,10 @@ namespace GPW.CORE.WRKLOG.Data rawData = JsonConvert.SerializeObject(dbResult, JSSettings); await redisDb.StringSetAsync(currKey, rawData, FastCache); } + if (dbResult == null) + { + dbResult = new List(); + } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Debug($"DailyDetails | {source} in: {ts.TotalMilliseconds} ms"); diff --git a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj index 212ddd9..cd48f2a 100644 --- a/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj +++ b/GPW.CORE.WRKLOG/GPW.CORE.WRKLOG.csproj @@ -2,7 +2,7 @@ net6.0 - 3.0.2301.1021 + 3.0.2301.1107 enable enable diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index e8b7e52..92dc1df 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GPW - Gestione Presenze Web -

Versione: 3.0.2301.1021

+

Versione: 3.0.2301.1107


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index ccd36c2..0418e8d 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -3.0.2301.1021 +3.0.2301.1107 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 1d90426..37c83fa 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 3.0.2301.1021 + 3.0.2301.1107 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false