Correzione compilazione progetti x spostamento altre classi in SPEC service method

This commit is contained in:
Samuele Locatelli
2026-06-01 07:59:10 +02:00
parent 8e7d08e4c9
commit 4e632ff9f4
35 changed files with 315 additions and 315 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.107</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB3</RootNamespace>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.107</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.INVE</RootNamespace>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.107</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOINVE </i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.107</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -1645,7 +1645,7 @@ namespace MP.IOC.Data
}
else
{
result = await SpecDbController.PODL_getByKey(idxPODL);
result = await SpecDbController.PODL_getByKeyAsync(idxPODL);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.107</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-IOC </i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.107</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.0107</Version>
<Configurations>Debug;Release;Debug_LiManDebug</Configurations>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<RunAnalyzersDuringBuild>True</RunAnalyzersDuringBuild>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo Tablet MAPO - DotNet6</i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.0107</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.0107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.0107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.MON</RootNamespace>
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.107</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.107</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.MON.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MP.Prog</RootNamespace>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.0107</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.0107</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.0107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.0107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.RIOC</RootNamespace>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.107</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-RIOC </i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.107</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+269 -273
View File
@@ -1,6 +1,5 @@
using EgwCoreLib.Utils;
using Microsoft.EntityFrameworkCore;
using MP.Core.Conf;
using MP.Core.DTO;
using MP.Core.Objects;
using MP.Data;
@@ -85,10 +84,7 @@ namespace MP.SPEC.Data
#region Public Properties
public static MpSpecController dbController { get; set; } = null!;
public static MpMongoController mongoController { get; set; } = null!;
public MessagePipe BroadastMsgPipe { get; set; } = null!;
public Dictionary<string, List<TagData>> currTagConf { get; set; } = new Dictionary<string, List<TagData>>();
/// <summary>
/// Expiry DateTime x refresh pagina parametri
@@ -173,7 +169,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "AnagEventiGeneralAsync",
cacheKey: $"{Utils.redisEventList}:VSEB:GENERAL",
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
{
return await dbController.AnagEventiGeneralAsync() ?? new List<vSelEventiBCodeModel>();
@@ -224,7 +220,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "AnagStatiCommAsync",
cacheKey: Utils.redisStatoCom,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.AnagStatiCommAsync() ?? new List<ListValuesModel>(),
tagList: [Utils.redisStatoCom]
@@ -240,7 +236,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "AnagTipoArtLvAsync",
cacheKey: Utils.redisTipoArt,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.AnagTipoArtLvAsync() ?? new List<ListValuesModel>(),
tagList: [Utils.redisTipoArt]
);
@@ -255,25 +251,19 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ArticleWithDossierAsync",
cacheKey: Utils.redisArtByDossier,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await Task.FromResult(dbController.ArticleWithDossier()) ?? new List<string>(),
tagList: [Utils.redisArtByDossier]
);
}
public async Task<int> ArticoliCountAsync()
{
string redisKey = $"{Utils.redisArtList}:Count";
return await GetOrFetchAsync(
operationName: "ArticoliCountAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.ArticoliCountAsync(),
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:CountAll"]
);
}
/// <summary>
/// Conteggio articoli data ricerca
/// </summary>
/// <param name="tipo"></param>
/// <param name="azienda"></param>
/// <param name="searchVal"></param>
/// <returns></returns>
public async Task<int> ArticoliCountSearchAsync(string tipo = "*", string azienda = "*", string searchVal = "")
{
string sKey = string.IsNullOrWhiteSpace(tipo) ? "ALL" : tipo.Trim();
@@ -281,7 +271,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ArticoliCountSearchAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.ArticoliCountSearchAsync(tipo, azienda, searchVal),
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:CountSearch"]
@@ -298,7 +288,7 @@ namespace MP.SPEC.Data
using var activity = ActivitySource.StartActivity("ArticoliDeleteRecord");
string source = "DB";
bool fatto = await dbController.ArticoliDeleteRecord(currRec);
await FlushCacheArticoli();
await FlushFusionCacheArticoli();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ArticoliDeleteRecord | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -318,7 +308,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ArticoliGetByTipoAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.ArticoliGetByTipoAsync(tipo, azienda) ?? new List<AnagArticoliModel>(),
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:Tipo"]
@@ -340,7 +330,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ArticoliGetSearchAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.ArticoliGetSearchAsync(numRecord, tipoArt, azienda, searchVal) ?? new List<AnagArticoliModel>(),
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:Search"]
@@ -357,7 +347,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ArticoliInKitAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.ArticoliInKitAsync() ?? new List<AnagArticoliModel>(),
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:InKit"]
@@ -374,7 +364,7 @@ namespace MP.SPEC.Data
using var activity = ActivitySource.StartActivity("ArticoliUpdateRecord");
string source = "DB";
bool fatto = await dbController.ArticoliUpdateRecord(currRec);
await FlushCacheArticoli();
await FlushFusionCacheArticoli();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ArticoliUpdateRecord | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -450,7 +440,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ConfigGetAllAsync",
cacheKey: Utils.redisConfAll,
expiration: getRandTOut(redisLongTimeCache * 2),
expiration: GetRandTOut(redisLongTimeCache * 2),
fetchFunc: async () => await dbController.ConfigGetAllAsync() ?? new List<ConfigModel>(),
tagList: [Utils.redisConfAll]
);
@@ -464,7 +454,7 @@ namespace MP.SPEC.Data
{
using var activity = ActivitySource.StartActivity("ConfigResetCacheAsync");
string source = "REDIS";
await FlushCacheConfig();
await FlushFusionCacheConfig();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ConfigResetCacheAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -502,7 +492,7 @@ namespace MP.SPEC.Data
using var activity = ActivitySource.StartActivity("ConfigUpdateAsync");
string source = "DB";
var updRes = await dbController.ConfigUpdateAsync(updRec);
await FlushCacheConfig();
await FlushFusionCacheConfig();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ConfigUpdateAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -578,7 +568,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "DossiersGetLastFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache * 5),
expiration: GetRandTOut(redisLongTimeCache * 5),
fetchFunc: async () => await dbController.DossiersGetLastFiltAsync(IdxMacchina, CodArticolo, DtStart, DtEnd, MaxRec) ?? new List<DossierModel>(),
tagList: [Utils.redisDossByMac]
);
@@ -652,7 +642,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ElencoAziendeAsync",
cacheKey: $"{Utils.redisAnagGruppi}:Aziende",
expiration: getRandTOut(redisLongTimeCache * 2),
expiration: GetRandTOut(redisLongTimeCache * 2),
fetchFunc: async () =>
await dbController.AnagGruppiAziendeAsync() ?? new List<AnagGruppiModel>(),
tagList: [Utils.redisAnagGruppi, $"{Utils.redisAnagGruppi}:Aziende"]
@@ -668,7 +658,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ElencoGruppiFaseAsync",
cacheKey: $"{Utils.redisAnagGruppi}:FASE",
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.AnagGruppiFaseAsync() ?? new List<AnagGruppiModel>(),
tagList: [Utils.redisAnagGruppi]
);
@@ -683,7 +673,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ElencoLinkAsync",
cacheKey: Utils.redisLinkMenu,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.ElencoLinkAsync() ?? new List<LinkMenuModel>(),
tagList: [Utils.redisLinkMenu]
);
@@ -698,7 +688,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ElencoRepartiDtoAsync",
cacheKey: $"{Utils.redisAnagGruppi}:REPARTO",
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.AnagGruppiRepartoDtoAsync() ?? new(),
tagList: [Utils.redisAnagGruppi]
);
@@ -759,52 +749,6 @@ namespace MP.SPEC.Data
return result;
}
/// <summary>
/// Esegue flush memoria redis dato keyVal, async
/// </summary>
/// <param name="pat2Flush"></param>
/// <returns></returns>
public async Task<bool> ExecFlushRedisPatternAsync(RedisValue pat2Flush)
{
bool answ = false;
using var activity = ActivitySource.StartActivity("ExecFlushRedisPatternAsync");
string source = "REDIS";
var masterEndpoint = redisConn.GetEndPoints()
.Where(ep => redisConn.GetServer(ep).IsConnected && !redisConn.GetServer(ep).IsReplica)
.FirstOrDefault();
// sepattern è "*" elimino intero DB...
if (masterEndpoint != null && (pat2Flush.Equals(new RedisValue("*")) || pat2Flush == RedisValue.Null))
{
redisConn.GetServer(masterEndpoint).FlushDatabase(database: redisDb.Database);
}
else
{
var server = redisConn.GetServer(masterEndpoint);
var keys = server.Keys(database: redisDb.Database, pattern: pat2Flush, pageSize: 1000);
var deleteTasks = new List<Task>();
foreach (var key in keys)
{
deleteTasks.Add(redisDb.KeyDeleteAsync(key));
if (deleteTasks.Count >= 1000)
{
await Task.WhenAll(deleteTasks);
deleteTasks.Clear();
}
}
if (deleteTasks.Count > 0)
{
await Task.WhenAll(deleteTasks);
}
}
answ = true;
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ExecFlushRedisPatternAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Flush cache relativa a MP-IO x dati ODL
/// </summary>
@@ -842,7 +786,7 @@ namespace MP.SPEC.Data
// effettuo merge statistiche...
await ProcDedupStatMergeAsync(procStats);
// svuoto cache
await FlushCacheFluxLog();
await FlushFusionCacheFluxLog();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FluxLogDataReduxAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -908,7 +852,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "FluxLogParetoAsync",
cacheKey: redKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.FluxLogParetoAsync(idxMacchina, dtFrom, dtTo) ?? new List<ParetoFluxLogDTO>(),
tagList: [Utils.redisParetoFLKey]
);
@@ -930,7 +874,7 @@ namespace MP.SPEC.Data
string source = "DB";
await dbController.ForceDbMaint(doExec, doUpdStat, doSave, minPgCnt, minAvgFrag, maxAvgFragReb);
// svuoto cache
await FlushCacheFluxLog();
await FlushFusionCacheFluxLog();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ForceDbMaint | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -947,6 +891,10 @@ namespace MP.SPEC.Data
return FlushFusionCacheAsync();
}
/// <summary>
/// Cancellazione RedisCache forzata
/// </summary>
/// <returns></returns>
public async Task<bool> ForceFlushRedisCache()
{
using var activity = ActivitySource.StartActivity("ForceFlushRedisCache");
@@ -972,7 +920,7 @@ namespace MP.SPEC.Data
bool result = false;
result = await dbController.Grp2MaccDeleteAsync(rec2del);
// elimino cache redis...
await FlushCacheMacGrp();
await FlushFusionCacheMacGrp();
activity?.SetTag("data.source", "DB");
activity?.Stop();
LogTrace($"Grp2MaccDeleteAsync | CodGruppo {rec2del.CodGruppo} | IdxMacc {rec2del.IdxMacchina} | {activity?.Duration.TotalMilliseconds}ms");
@@ -990,7 +938,7 @@ namespace MP.SPEC.Data
bool result = false;
result = await dbController.Grp2MaccInsertAsync(upsRec);
// elimino cache redis...
await FlushCacheMacGrp();
await FlushFusionCacheMacGrp();
activity?.SetTag("data.source", "DB");
activity?.Stop();
LogTrace($"Grp2MaccInsertAsync | CodGruppo {upsRec.CodGruppo} | IdxMacc {upsRec.IdxMacchina} | {activity?.Duration.TotalMilliseconds}ms");
@@ -1008,7 +956,7 @@ namespace MP.SPEC.Data
bool result = false;
result = await dbController.Grp2OperDeleteAsync(rec2del);
// elimino cache redis...
await FlushCacheOprGrp();
await FlushFusionCacheOprGrp();
activity?.SetTag("data.source", "DB");
activity?.Stop();
LogTrace($"Grp2OperDeleteAsync | CodGruppo {rec2del.CodGruppo} | MatrOpr {rec2del.MatrOpr} | {activity?.Duration.TotalMilliseconds}ms");
@@ -1026,7 +974,7 @@ namespace MP.SPEC.Data
bool result = false;
result = await dbController.Grp2OperInsertAsync(upsRec);
// elimino cache redis...
await FlushCacheOprGrp();
await FlushFusionCacheOprGrp();
activity?.SetTag("data.source", "DB");
activity?.Stop();
LogTrace($"Grp2OperInsertAsync | CodGruppo {upsRec.CodGruppo} | MatrOpr {upsRec.MatrOpr} | {activity?.Duration.TotalMilliseconds}ms");
@@ -1056,7 +1004,7 @@ namespace MP.SPEC.Data
// salvo
bool fatto = await dbController.IstKitDeleteAsync(currRecord);
// svuoto cache
await FlushKitCache();
await FlushFusionCacheKit();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"IstKitDeleteAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -1075,7 +1023,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "IstKitFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.IstKitFiltAsync(keyKit, keyExtOrd) ?? new List<IstanzeKitModel>(),
tagList: [Utils.redisKitInst]
);
@@ -1093,7 +1041,7 @@ namespace MP.SPEC.Data
// salvo
bool fatto = await dbController.IstKitInsertByWKSAsync(CodArtParent, KeyFilt);
// svuoto cache
await FlushKitCache();
await FlushFusionCacheKit();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"IstKitInsertByWKSAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -1111,7 +1059,7 @@ namespace MP.SPEC.Data
// salvo
bool fatto = await dbController.IstKitUpsertAsync(currRecord);
// svuoto cache
await FlushKitCache();
await FlushFusionCacheKit();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"IstKitUpsertAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -1129,7 +1077,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ListGiacenzeAsync",
cacheKey: currKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () => await dbController.ListGiacenzeAsync(IdxOdl) ?? new List<AnagGiacenzeModel>(),
tagList: [Utils.redisGiacenzaList]
);
@@ -1148,7 +1096,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ListPODL_ByCodArtAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.ListPODL_ByCodArtAsync(CodArticolo, OnlyAvail) ?? new(),
tagList: [Utils.redisPOdlByCodArt]
);
@@ -1167,7 +1115,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "MacchineGetFiltAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
await dbController.MacchineGetFiltAsync(codGruppo)
?? new List<MacchineModel>(),
@@ -1186,7 +1134,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "MacchineRecipeArchiveAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
{
var machineList = await MacchineGetFiltAsync("*");
@@ -1208,7 +1156,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "MacchineRecipeConfAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () =>
{
var machineList = await MacchineGetFiltAsync("*");
@@ -1231,7 +1179,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "MacchineWithFluxAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.MacchineWithFluxAsync(dtStart, dtEnd) ?? new List<string>(),
tagList: [Utils.redisMacByFlux]
);
@@ -1244,7 +1192,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "MachineWithOdlAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () =>
{
var rawData = await dbController.OdlGetCurrentAsync();
@@ -1270,12 +1218,12 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "MachIobConfAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () =>
{
Dictionary<string, string> result = new Dictionary<string, string>();
// cerco in redis...
string currKey = redHashMpIO($"IOB:{IdxMacchina}:MachIobConfAsync");
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:MachIobConfAsync");
if (await redisDb.KeyExistsAsync(currKey))
{
result = (await redisDb.HashGetAllAsync(currKey))
@@ -1332,7 +1280,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "OdlByBatchAsync",
cacheKey: Utils.redisOdlByBatch,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.OdlByBatchAsync(BatchSel),
tagList: [Utils.redisOdlByBatch]
);
@@ -1349,7 +1297,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "OdlByKeyAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.OdlByKeyAsync(IdxOdl),
tagList: [Utils.redisOdlByKey]
);
@@ -1409,7 +1357,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "OdlListGetFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () => await dbController.ListODLFiltAsync(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate) ?? new(),
tagList: [Utils.redisOdlList]
);
@@ -1426,7 +1374,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "OdlStatsAsync",
cacheKey: currKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () => await dbController.OdlGetStatAsync(IdxOdl) ?? new(),
tagList: [Utils.redisOdlStats]
);
@@ -1445,7 +1393,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "OperatoriGetFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.OperatoriGetFiltAsync(codGruppo) ?? new List<AnagOperatoriModel>(),
tagList: [Utils.redisOprList]
);
@@ -1462,7 +1410,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "ParametriGetFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () => await dbController.ParametriGetFiltAsync(IdxMacchina) ?? new(),
tagList: [Utils.redisFluxByMac]
);
@@ -1548,7 +1496,7 @@ namespace MP.SPEC.Data
string source = "DB+REDIS";
var dbResult = await dbController.PODLDeleteRecord(currRec);
// elimino cache redis...
await FlushCachePOdl();
await FlushFusionCachePOdl();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"POdlDeleteRecord | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -1566,7 +1514,7 @@ namespace MP.SPEC.Data
string source = "DB+REDIS";
var dbResult = await dbController.PODL_startSetup(currRec, 0, 1, 1, "", DateTime.Now);
// elimino cache redis...
await FlushCachePOdl();
await FlushFusionCachePOdl();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"POdlDoSetup | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -1618,7 +1566,7 @@ namespace MP.SPEC.Data
// salvo
fatto = await dbController.PodlIstKitDeleteAsync(IdxPODL);
// svuoto cache
await FlushCachePOdl();
await FlushFusionCachePOdl();
activity?.SetTag("data.source", "DB");
return fatto;
}
@@ -1634,7 +1582,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "POdlListByKitParentAsync",
cacheKey: currKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () => await dbController.ListPODL_ByKitParentAsync(IdxPodlParent) ?? new(),
tagList: [Utils.redisPOdlList]
);
@@ -1656,7 +1604,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "POdlListGetFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisShortTimeCache),
expiration: GetRandTOut(redisShortTimeCache),
fetchFunc: async () => await dbController.ListPODLFiltAsync(lanciato, keyRichPart, idxMacchina, codGruppo, startDate, endDate) ?? new List<PODLExpModel>(),
tagList: [Utils.redisPOdlList]
);
@@ -1679,7 +1627,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "POdlToKitListGetFiltAsync",
cacheKey: redisKey,
expiration: getRandTOut(redisShortTimeCache * 5),
expiration: GetRandTOut(redisShortTimeCache * 5),
fetchFunc: async () =>
await dbController.ListPODL_KitFiltAsync(
lanciato,
@@ -1706,7 +1654,7 @@ namespace MP.SPEC.Data
bool answ = false;
answ = await dbController.PODL_updateRecipe(idxPODL, recipeName);
// reset redis...
await FlushCachePOdl();
await FlushFusionCachePOdl();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"POdlUpdateRecipe | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -1724,7 +1672,7 @@ namespace MP.SPEC.Data
string source = "DB";
var dbResult = await dbController.PODLUpdateRecordAsync(currRec);
// elimino cache redis...
await FlushCachePOdl();
await FlushFusionCachePOdl();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"POdlUpdateRecord | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -1785,7 +1733,7 @@ namespace MP.SPEC.Data
string source = "MONGO";
bool answ = false;
answ = await mongoController.RecipeSetByPODL(currRecord);
await FlushCachePOdl();
await FlushFusionCachePOdl();
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"RecipeSetByPODL | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -1885,7 +1833,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "StatoMacchinaAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.StatoMacchinaAsync(idxMacchina) ?? new(),
tagList: [Utils.redisStatoMacch]
);
@@ -1922,7 +1870,7 @@ namespace MP.SPEC.Data
return await GetOrFetchAsync(
operationName: "TemplateKitFiltAsync",
cacheKey: currKey,
expiration: getRandTOut(redisLongTimeCache),
expiration: GetRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.TemplateKitFiltAsync(codParent, codChild) ?? new List<TemplateKitModel>(),
tagList: [Utils.redisKitTempl]
);
@@ -2087,154 +2035,6 @@ namespace MP.SPEC.Data
#endregion Public Methods
#region Protected Methods
protected async Task<bool> FlushCacheArticoli()
{
using var activity = ActivitySource.StartActivity("FlushCacheArticoli");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisArtList, Utils.redisArtByDossier });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushCacheArticoli | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
protected async Task<bool> FlushCacheConfig()
{
using var activity = ActivitySource.StartActivity("FlushCacheConfig");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisConfKey });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushCacheConfig | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Reset macchine e gruppi
/// </summary>
protected async Task<bool> FlushCacheMacGrp()
{
using var activity = ActivitySource.StartActivity("FlushCacheMacGrp");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string> { Utils.redisAnagGruppi, Utils.redisMacList });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushCacheMacGrp | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Reset cache operatori e gruppi
/// </summary>
protected async Task<bool> FlushCacheOprGrp()
{
using var activity = ActivitySource.StartActivity("FlushCacheOprGrp");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string> { Utils.redisAnagGruppi, Utils.redisOprList });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushCacheOprGrp | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
protected async Task<bool> FlushCachePOdl()
{
using var activity = ActivitySource.StartActivity("FlushCachePOdl");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisXdlData, Utils.redisPOdlByOdl, Utils.redisPOdlByPOdl, Utils.redisPOdlList });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushCachePOdl | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Cancellazione FusionCache (totale)
/// </summary>
/// <returns></returns>
protected async Task<bool> FlushFusionCacheAsync()
{
await _cache.ClearAsync(allowFailSafe: false);
_configData.Clear();
_artCacheExpiry = DateTime.Now.AddHours(-1);
return true;
}
/// <summary>
/// Cancellazione FusionCache dato singolo tag
/// </summary>
/// <returns></returns>
protected async Task<bool> FlushFusionCacheAsync(string tag)
{
if (string.IsNullOrWhiteSpace(tag)) return false;
await _cache.RemoveByTagAsync(tag);
_configData.Clear();
return true;
}
/// <summary>
/// Cancellazione FusionCache dato elenco tags
/// </summary>
/// <returns></returns>
protected async Task<bool> FlushFusionCacheAsync(List<string> listTags)
{
if (listTags == null || listTags.Count == 0) return false;
// Generiamo i Task di rimozione ed eseguiamoli in parallelo su Redis/L1
var tasks = listTags
.Where(tag => !string.IsNullOrWhiteSpace(tag))
.Select(tag => _cache.RemoveByTagAsync(tag).AsTask());
await Task.WhenAll(tasks);
_configData.Clear();
return true;
}
protected async Task<bool> FlushKitCache()
{
using var activity = ActivitySource.StartActivity("FlushKitCache");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisPOdlList, Utils.redisKitInst, Utils.redisKitWip, Utils.redisKitScore, Utils.redisPOdlByCodArt });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushKitCache | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Restituisce un timeout dal valore secondi richiesti + tempo random +/-3%
/// </summary>
/// <param name="durationSec"></param>
/// <returns></returns>
protected TimeSpan getRandTOut(double durationSec)
{
double noise = (rand.NextDouble() * 0.06) - 0.03;
double rValue = durationSec * (1 + noise);
return TimeSpan.FromSeconds(rValue);
}
/// <summary>
/// Merge statistiche DB Maintenance
/// </summary>
/// <param name="procStats"></param>
/// <returns></returns>
protected async Task<bool> RecDbMaintStatAsync(TimeSpan duration)
{
Dictionary<DateTime, double> actStats = await DbDedupStatsAsync();
// aggiungo record!
actStats.Add(DateTime.Now, duration.TotalSeconds);
// salvo NUOVO record statistiche
string currKey = $"{Utils.redisStatsDbMaint}";
var rawData = JsonConvert.SerializeObject(actStats);
return await redisDb.StringSetAsync(currKey, rawData);
}
#endregion Protected Methods
#region Private Fields
/// <summary>
@@ -2269,8 +2069,6 @@ namespace MP.SPEC.Data
/// </summary>
private HashSet<string> _listCodArtUsed = new();
private string canCacheParametri = "";
private string MpIoNS = "";
private Random rand = new Random();
@@ -2309,6 +2107,14 @@ namespace MP.SPEC.Data
#endregion Private Fields
#region Private Properties
private static MpSpecController dbController { get; set; } = null!;
private static MpMongoController mongoController { get; set; } = null!;
#endregion Private Properties
#region Private Methods
/// <summary>
@@ -2327,14 +2133,176 @@ namespace MP.SPEC.Data
}
}
private async Task<bool> FlushCacheFluxLog()
/// <summary>
/// Esegue flush memoria redis dato keyVal, async
/// </summary>
/// <param name="pat2Flush"></param>
/// <returns></returns>
private async Task<bool> ExecFlushRedisPatternAsync(RedisValue pat2Flush)
{
using var activity = ActivitySource.StartActivity("FlushCacheFluxLog");
bool answ = false;
using var activity = ActivitySource.StartActivity("ExecFlushRedisPatternAsync");
string source = "REDIS";
var masterEndpoint = redisConn.GetEndPoints()
.Where(ep => redisConn.GetServer(ep).IsConnected && !redisConn.GetServer(ep).IsReplica)
.FirstOrDefault();
// sepattern è "*" elimino intero DB...
if (masterEndpoint != null && (pat2Flush.Equals(new RedisValue("*")) || pat2Flush == RedisValue.Null))
{
redisConn.GetServer(masterEndpoint).FlushDatabase(database: redisDb.Database);
}
else
{
var server = redisConn.GetServer(masterEndpoint);
var keys = server.Keys(database: redisDb.Database, pattern: pat2Flush, pageSize: 1000);
var deleteTasks = new List<Task>();
foreach (var key in keys)
{
deleteTasks.Add(redisDb.KeyDeleteAsync(key));
if (deleteTasks.Count >= 1000)
{
await Task.WhenAll(deleteTasks);
deleteTasks.Clear();
}
}
if (deleteTasks.Count > 0)
{
await Task.WhenAll(deleteTasks);
}
}
answ = true;
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ExecFlushRedisPatternAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
private async Task<bool> FlushFusionCacheArticoli()
{
using var activity = ActivitySource.StartActivity("FlushFusionCacheArticoli");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisArtList, Utils.redisArtByDossier });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushFusionCacheArticoli | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Cancellazione FusionCache (totale)
/// </summary>
/// <returns></returns>
private async Task<bool> FlushFusionCacheAsync()
{
await _cache.ClearAsync(allowFailSafe: false);
_configData.Clear();
_artCacheExpiry = DateTime.Now.AddHours(-1);
return true;
}
/// <summary>
/// Cancellazione FusionCache dato singolo tag
/// </summary>
/// <returns></returns>
private async Task<bool> FlushFusionCacheAsync(string tag)
{
if (string.IsNullOrWhiteSpace(tag)) return false;
await _cache.RemoveByTagAsync(tag);
_configData.Clear();
return true;
}
/// <summary>
/// Cancellazione FusionCache dato elenco tags
/// </summary>
/// <returns></returns>
private async Task<bool> FlushFusionCacheAsync(List<string> listTags)
{
if (listTags == null || listTags.Count == 0) return false;
// Generiamo i Task di rimozione ed eseguiamoli in parallelo su Redis/L1
var tasks = listTags
.Where(tag => !string.IsNullOrWhiteSpace(tag))
.Select(tag => _cache.RemoveByTagAsync(tag).AsTask());
await Task.WhenAll(tasks);
_configData.Clear();
return true;
}
private async Task<bool> FlushFusionCacheConfig()
{
using var activity = ActivitySource.StartActivity("FlushFusionCacheConfig");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisConfKey });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushFusionCacheConfig | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
private async Task<bool> FlushFusionCacheFluxLog()
{
using var activity = ActivitySource.StartActivity("FlushFusionCacheFluxLog");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisFluxLogFilt, Utils.redisParetoFLKey });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushCacheFluxLog | {source} | {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"FlushFusionCacheFluxLog | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
private async Task<bool> FlushFusionCacheKit()
{
using var activity = ActivitySource.StartActivity("FlushFusionCacheKit");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisPOdlList, Utils.redisKitInst, Utils.redisKitWip, Utils.redisKitScore, Utils.redisPOdlByCodArt });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushFusionCacheKit | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Reset macchine e gruppi
/// </summary>
private async Task<bool> FlushFusionCacheMacGrp()
{
using var activity = ActivitySource.StartActivity("FlushFusionCacheMacGrp");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string> { Utils.redisAnagGruppi, Utils.redisMacList });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushFusionCacheMacGrp | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
/// <summary>
/// Reset cache operatori e gruppi
/// </summary>
private async Task<bool> FlushFusionCacheOprGrp()
{
using var activity = ActivitySource.StartActivity("FlushFusionCacheOprGrp");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string> { Utils.redisAnagGruppi, Utils.redisOprList });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushFusionCacheOprGrp | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
private async Task<bool> FlushFusionCachePOdl()
{
using var activity = ActivitySource.StartActivity("FlushFusionCachePOdl");
string source = "FUSION";
bool answ = await FlushFusionCacheAsync(new List<string>() { Utils.redisXdlData, Utils.redisPOdlByOdl, Utils.redisPOdlByPOdl, Utils.redisPOdlList });
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"FlushFusionCachePOdl | {source} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2405,6 +2373,18 @@ namespace MP.SPEC.Data
return final!;
}
/// <summary>
/// Restituisce un timeout dal valore secondi richiesti + tempo random +/-3%
/// </summary>
/// <param name="durationSec"></param>
/// <returns></returns>
private TimeSpan GetRandTOut(double durationSec)
{
double noise = (rand.NextDouble() * 0.06) - 0.03;
double rValue = durationSec * (1 + noise);
return TimeSpan.FromSeconds(rValue);
}
/// <summary>
/// Helper trace messaggio log (SE abilitato)
/// </summary>
@@ -2462,7 +2442,23 @@ namespace MP.SPEC.Data
return await redisDb.StringSetAsync(currKey, rawData);
}
private string redHashMpIO(string keyName)
/// <summary>
/// Merge statistiche DB Maintenance
/// </summary>
/// <param name="procStats"></param>
/// <returns></returns>
private async Task<bool> RecDbMaintStatAsync(TimeSpan duration)
{
Dictionary<DateTime, double> actStats = await DbDedupStatsAsync();
// aggiungo record!
actStats.Add(DateTime.Now, duration.TotalSeconds);
// salvo NUOVO record statistiche
string currKey = $"{Utils.redisStatsDbMaint}";
var rawData = JsonConvert.SerializeObject(actStats);
return await redisDb.StringSetAsync(currKey, rawData);
}
private string RedHashMpIO(string keyName)
{
string result = keyName;
try
@@ -2471,7 +2467,7 @@ namespace MP.SPEC.Data
}
catch (Exception exc)
{
Log.Error($"Errore in redHashMpIO{Environment.NewLine}{exc}");
Log.Error($"Errore in RedHashMpIO{Environment.NewLine}{exc}");
}
return result;
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>8.16.2605.2912</Version>
<Version>8.16.2606.0107</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 8.16.2605.2912</h4>
<h4>Versione: 8.16.2606.0107</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2912
8.16.2606.0107
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2912</version>
<version>8.16.2606.0107</version>
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+13 -9
View File
@@ -9,7 +9,7 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
## Strategia di Migrazione
- **Metodo Standard**: `GetOrFetchAsync<T>(string operationName, string cacheKey, Func<Task<T>> fetchFunc, TimeSpan expiration, params string[] tagList)`.
- **Invalidazione**: Utilizzare i tag tramite `FlushCacheByTagAsync`.
- **Invalidazione**: Utilizzare i tag tramite `FlushFusionCacheByTagAsync`.
## Stato Avanzamento
@@ -19,7 +19,7 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
### Fase 2: Refactoring Metodi di Lettura (Cache-aside) (In corso)
#### ✅ Metodi Migrati (Usano già `GetOrFetchAsync`, `FusionCache.GetOrSet` o `FlushCacheByTagAsync`)
#### ✅ Metodi Migrati (Usano già `GetOrFetchAsync`, `FusionCache.GetOrSet` o `FlushFusionCacheByTagAsync`)
- `AnagEventiGeneralAsync`
- `AnagStatiCommAsync`
- `AnagTipoArtLvAsync`
@@ -65,15 +65,17 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
- `Grp2MaccInsertAsync` (Migrato con tag invalidazione)
- `Grp2OperDeleteAsync` (Migrato con tag invalidazione)
- `Grp2OperInsertAsync` (Migrato con tag invalidazione)
- `ArticoliDeleteRecord` (Migrato con `FlushCacheArticoli`)
- `ArticoliUpdateRecord` (Migrato con `FlushCacheArticoli`)
- `DossiersDeleteRecordAsync` (Migrato con tag invalidazione)
- `DossiersTakeParamsSnapshotLast` (Migrato con tag invalidazione)
- `DossiersInsert` (Migrato con tag invalidazione)
- `DossiersUpdateValoreAsync` (Migrato con tag invalidazione)
- `ElencoRepartiDTO` (Migrato)
#### 🛠️ Metodi da Migrare (Usano ancora Redis/DB manuale)
#### 🛠️ Metodi da Migrare (Usano ancora Redis/DB manuale o pattern non standard per Fusion)
- [ ] Migrazione di `ActionGetReq` (linea 110: usa `redisDb.StringGetAsync`).
- [ ] Migrazione di `ActionSetReq` (linea 136: usa `BroadastMsgPipe.saveAndSendMessage`).
- [ ] Migrazione di `ArticoliDeleteRecord`/`UpdateRecord` (linea 296/372: usa `resetCacheArticoli`).
- [ ] Migrazione di `DbDedupStats` (linea 516: usa `redisDb.StringGet`).
- [ ] Migrazione di `DossiersDeleteRecord` (linea 551: usa `ExecFlushRedisPatternAsync`).
- [ ] Migrazione di `DossiersTakeParamsSnapshotLast` (linea 610: usa `ExecFlushRedisPatternAsync`).
- [ ] Migrazione di `ElencoRepartiDTO` (linea 697: usa `redisDb.StringGet` e `StringSet`).
- [ ] Migrazione di `PodlIstKitDelete` (linea 1760: usa `ExecFlushRedisPattern` sincrono).
- [ ] Migrazione di `POdlListByKitParent` (linea 1781: usa `redisDb.StringGet` e `StringSet`).
- [ ] Migrazione di `POdlGetByKey` (linea 1662: usa `redisDb.StringGet` e `StringSet`).
@@ -82,7 +84,7 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
- [ ] Migrazione di `ProcFLStats` (linea 1853: usa `redisDb.StringGet`).
- [ ] Migrazione di `RecDbMaintStat` (linea 2451: usa `redisDb.StringSet`).
*(Nota: Il vecchio metodo `VocabolarioGetAll` e la gestione manuale del dizionario sono stati rimossi in favore di `Traduci` con FusionCache).*
*(Nota: I metodi `DbDedupStatsAsync` e `RecDbMaintStatAsync` sono gestiti direttamente su Redis in modo persistente e non sono target della migrazione a FusionCache).*
### Fase 4: Verifica
- [ ] Verificare la compilazione della soluzione tramite script PowerShell.
@@ -98,3 +100,5 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa