Merge branch 'release/StartFixRecalcDto03'
This commit is contained in:
@@ -919,31 +919,44 @@ namespace GWMS.UI.Data
|
||||
public async Task<List<PlantDTO>> PlantDtoGetAll()
|
||||
{
|
||||
List<PlantDTO> dbResult = new List<PlantDTO>();
|
||||
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<DateTime>(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<List<PlantDTO>>(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
|
||||
/// <returns></returns>
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.0.2406.0318</Version>
|
||||
<Version>1.0.2406.0319</Version>
|
||||
<UserSecretsId>95c9f021-52d1-4390-a670-5810b7b777b0</UserSecretsId>
|
||||
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
|
||||
|
||||
+6
-2
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>GWMS - Gas Warehouse Management System</i>
|
||||
<h4>Versione: 1.0.2406.0318</h4>
|
||||
<h4>Versione: 1.0.2406.0319</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.2406.0318
|
||||
1.0.2406.0319
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>1.0.2406.0318</version>
|
||||
<version>1.0.2406.0319</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user