Trasformazione async metodi SaveSendMessages

This commit is contained in:
Samuele Locatelli
2026-06-01 08:25:28 +02:00
parent 4e632ff9f4
commit b19f21fdff
43 changed files with 70 additions and 65 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>8.16.2606.107</Version>
<Version>8.16.2606.108</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.2606.107</h4>
<h4>Versione: 8.16.2606.108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.107
8.16.2606.108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.107</version>
<version>8.16.2606.108</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>
+7 -7
View File
@@ -3,7 +3,7 @@ using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace MP.Data
{
@@ -44,17 +44,17 @@ namespace MP.Data
/// </summary>
/// <param name="memKey">Chiave REDIS x salvare valore</param>
/// <param name="message">Messaggio serializzato da inviare</param>
public bool saveAndSendMessage(string memKey, string message)
public async Task<bool> SaveAndSendMessageAsync(string memKey, string message)
{
bool answ = false;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
// invio notifica tramite il canale richiesto
answ = sendMessage(message);
answ = await SendMessageAsync(message);
if (redisDb != null)
{
redisDb.StringSetAsync(memKey, message);
await redisDb.StringSetAsync(memKey, message);
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
@@ -68,7 +68,7 @@ namespace MP.Data
}
if (enableLog || numSent[memKey] > 30)
{
Log.Info($"saveAndSendMessage| mKey {memKey} x {numSent[memKey]} | {message.Length} size | {ts.TotalMilliseconds} ms");
Log.Info($"SaveAndSendMessageAsync| mKey {memKey} x {numSent[memKey]} | {message.Length} size | {ts.TotalMilliseconds} ms");
numSent[memKey] = 0;
}
@@ -80,7 +80,7 @@ namespace MP.Data
/// </summary>
/// <param name="newMess"></param>
/// <returns></returns>
public bool sendMessage(string newMess)
public async Task<bool> SendMessageAsync(string newMess)
{
bool answ = false;
if (!string.IsNullOrEmpty(_channel))
@@ -89,7 +89,7 @@ namespace MP.Data
ISubscriber sub = redis.GetSubscriber();
sub.Publish(_channel, newMess);
#endif
var numCli = redisSub.Publish(rChannel, newMess);
var numCli = await redisSub.PublishAsync(rChannel, newMess);
answ = numCli > 0;
}
return answ;
+3 -3
View File
@@ -113,17 +113,17 @@ namespace MP.Data.Services
if (resto == 0)
{
// invio in channel blink il segnale
blinkPipe.sendMessage("true");
blinkPipe.SendMessageAsync("true");
Log.Debug("Elapsed Fast Timer Blink");
}
else
{
// invio in channel blink segnale false
blinkPipe.sendMessage("false");
blinkPipe.SendMessageAsync("false");
// rileggo dati...
var newData = await MseGetAll();
// invio tramite la pipe...
dataPipe.sendMessage(JsonConvert.SerializeObject(newData));
dataPipe.SendMessageAsync(JsonConvert.SerializeObject(newData));
Log.Debug("Elapsed Fast Timer reload");
}
});
+3 -3
View File
@@ -133,17 +133,17 @@ namespace MP.Data.Services
if (resto == 0)
{
// invio in channel blink il segnale
blinkPipe.sendMessage("true");
blinkPipe.SendMessageAsync("true");
Log.Trace("Elapsed Fast Timer Blink");
}
else
{
// invio in channel blink segnale false
blinkPipe.sendMessage("false");
blinkPipe.SendMessageAsync("false");
// rileggo dati...
var newData = await MseGetAll();
// invio tramite la pipe...
dataPipe.sendMessage(JsonConvert.SerializeObject(newData));
dataPipe.SendMessageAsync(JsonConvert.SerializeObject(newData));
Log.Trace("Elapsed Fast Timer reload");
}
});
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.INVE</RootNamespace>
<Version>8.16.2606.107</Version>
<Version>8.16.2606.108</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOINVE </i>
<h4>Versione: 8.16.2606.107</h4>
<h4>Versione: 8.16.2606.108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.107
8.16.2606.108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.107</version>
<version>8.16.2606.108</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
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>8.16.2606.107</Version>
<Version>8.16.2606.108</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-IOC </i>
<h4>Versione: 8.16.2606.107</h4>
<h4>Versione: 8.16.2606.108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.107
8.16.2606.108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.107</version>
<version>8.16.2606.108</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.2606.0107</Version>
<Version>8.16.2606.0108</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.2606.0107</h4>
<h4>Versione: 8.16.2606.0108</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.0107
8.16.2606.0108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.0107</version>
<version>8.16.2606.0108</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.2606.107</Version>
<Version>8.16.2606.108</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 8.16.2606.107</h4>
<h4>Versione: 8.16.2606.108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.107
8.16.2606.108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.107</version>
<version>8.16.2606.108</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.2606.0107</Version>
<Version>8.16.2606.0108</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 8.16.2606.0107</h4>
<h4>Versione: 8.16.2606.0108</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.0107
8.16.2606.0108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.0107</version>
<version>8.16.2606.0108</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.2606.107</Version>
<Version>8.16.2606.108</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-RIOC </i>
<h4>Versione: 8.16.2606.107</h4>
<h4>Versione: 8.16.2606.108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.107
8.16.2606.108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.107</version>
<version>8.16.2606.108</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>
+2 -2
View File
@@ -55,7 +55,7 @@ namespace MP.SPEC.Components
}
// eseguo chiusura finale
CurrAction.IsActive = false;
MDService.ActionSetReq(CurrAction);
MDService.ActionSetReqAsync(CurrAction);
await Task.Delay(1);
}
@@ -103,7 +103,7 @@ namespace MP.SPEC.Components
}
}
MDService.ActionSetReq(CurrAction);
MDService.ActionSetReqAsync(CurrAction);
await Task.Delay(1);
// se fatto --> ricarico!
if (fatto)
+7 -5
View File
@@ -129,18 +129,18 @@ namespace MP.SPEC.Data
/// </summary>
/// <param name="act2save"></param>
/// <returns></returns>
public bool ActionSetReq(DisplayAction? act2save)
public async Task<bool> ActionSetReqAsync(DisplayAction? act2save)
{
using var activity = ActivitySource.StartActivity("ActionSetReq");
using var activity = ActivitySource.StartActivity("ActionSetReqAsync");
string source = "REDIS";
bool fatto = false;
// cerco in redis...
string rawData = JsonConvert.SerializeObject(act2save);
// invio broadcast + salvo in redis
BroadastMsgPipe.saveAndSendMessage(Utils.redisActionReq, rawData);
await BroadastMsgPipe.SaveAndSendMessageAsync(Utils.redisActionReq, rawData);
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"ActionSetReq {source} send to broadcast + Write cache: {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"ActionSetReqAsync {source} send to broadcast + Write cache: {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2307,7 +2307,9 @@ namespace MP.SPEC.Data
}
/// <summary>
/// Implementa gestione recupero cache da memoria o da obj esterno + cache memoria + tracking attività
/// Implementa gestione FusionCache+ tracking attività
/// - recupero cache da memoria o da obj esterno + cache memoria
/// - recupero da fetchFunc se mancasse + store in cache L1/L2
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>8.16.2606.107</Version>
<Version>8.16.2606.108</Version>
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
+2 -2
View File
@@ -38,7 +38,7 @@ namespace MP.SPEC.Pages
CurrAction.IsActive = false;
CurrAction.Topic = "Chiusura ODL";
CurrAction.Message = "Rilevato possibile fine operazioni, Vuoi chiudere la commessa?";
MMDataService.ActionSetReq(CurrAction);
MMDataService.ActionSetReqAsync(CurrAction);
await Task.Delay(1);
}
@@ -72,7 +72,7 @@ namespace MP.SPEC.Pages
{
CurrAction.DtReq = DateTime.Now;
CurrAction.IsActive = true;
MMDataService.ActionSetReq(CurrAction);
MMDataService.ActionSetReqAsync(CurrAction);
}
#endregion Protected Methods
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 8.16.2606.107</h4>
<h4>Versione: 8.16.2606.108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.107
8.16.2606.108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.107</version>
<version>8.16.2606.108</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+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.2606.0107</Version>
<Version>8.16.2606.0108</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.2606.0107</h4>
<h4>Versione: 8.16.2606.0108</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.0107
8.16.2606.0108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.0107</version>
<version>8.16.2606.0108</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>
+10 -7
View File
@@ -72,19 +72,20 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
- `DossiersInsert` (Migrato con tag invalidazione)
- `DossiersUpdateValoreAsync` (Migrato con tag invalidazione)
- `ElencoRepartiDTO` (Migrato)
- `PodlIstKitDeleteAsync` (Migrato con tag invalidazione)
- `POdlUpdateRecipe` (Migrato con tag invalidazione)
- `POdlUpdateRecord` (Migrato con tag invalidazione)
- `POdlGetByKey` (Migrato con FusionCache)
- `POdlListByKitParentAsync` (Migrato con FusionCache)
#### 🛠️ 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 `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`).
- [ ] Migrazione di `POdlUpdateRecipe` (linea 1814: usa `POdlFlushCache` con pattern).
- [ ] Migrazione di `POdlUpdateRecord` (linea 1836: usa `POdlFlushCache` con pattern).
- [ ] Migrazione di `DbDedupStatsAsync` (linea 516: gestione persistente su Redis, valutare se mantenere o cambiare pattern).
- [ ] Migrazione di `ProcFLStats` (linea 1853: usa `redisDb.StringGet`).
- [ ] Migrazione di `RecDbMaintStat` (linea 2451: usa `redisDb.StringSet`).
- [ ] Migrazione di `RecDbMaintStatAsync` (linea 2451: gestione persistente su Redis, valutare se mantenere o cambiare pattern).
*(Nota: I metodi `DbDedupStatsAsync` e `RecDbMaintStatAsync` sono gestiti direttamente su Redis in modo persistente e non sono target della migrazione a FusionCache).*
*(Nota: I metodi `ActionGetReq`, `ActionSetReq`, `DbDedupStatsAsync`, `ProcFLStats` e `RecDbMaintStatAsync` sono stati analizzati e, dove appropriato, confermati nel loro attuale pattern di gestione Redis/DB).*
### Fase 4: Verifica
- [ ] Verificare la compilazione della soluzione tramite script PowerShell.
@@ -102,3 +103,5 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa