From 2594166efc32b75ed5ed1ada52126eec527d404e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 18:17:24 +0200 Subject: [PATCH 01/28] Fix spec x gestione giacenze (si apre) + cleanup program.cs --- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Pages/Giacenze.razor | 2 -- MP.SPEC/Pages/Giacenze.razor.cs | 51 ++++++++++++++------------------ MP.SPEC/Program.cs | 15 ---------- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 7 files changed, 27 insertions(+), 49 deletions(-) diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 49f371ab..739c9afd 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2606.1117 + 8.16.2606.1118 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/Giacenze.razor b/MP.SPEC/Pages/Giacenze.razor index 7970bc22..70400660 100644 --- a/MP.SPEC/Pages/Giacenze.razor +++ b/MP.SPEC/Pages/Giacenze.razor @@ -68,8 +68,6 @@ else } - @**@ } diff --git a/MP.SPEC/Pages/Giacenze.razor.cs b/MP.SPEC/Pages/Giacenze.razor.cs index 06cf32da..a109da04 100644 --- a/MP.SPEC/Pages/Giacenze.razor.cs +++ b/MP.SPEC/Pages/Giacenze.razor.cs @@ -1,27 +1,13 @@ -using Blazored.SessionStorage; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; using MP.Data.DbModels; +using MP.Data.Services; using MP.SPEC.Data; namespace MP.SPEC.Pages { public partial class Giacenze { - #region Protected Fields - - protected List? elencoOdl; - - #endregion Protected Fields - - #region Protected Properties - - protected int IdxOdl { get; set; } = 0; - - protected ODLExpModel? odlExp { get; set; } = null!; - - #endregion Protected Properties - #region Protected Methods protected override async Task OnInitializedAsync() @@ -41,34 +27,43 @@ namespace MP.SPEC.Pages odlExp = await MDService.OdlByKeyAsync(IdxOdl); } + protected void saveBatch(string newBatch) + { + BatchSel = newBatch; + } + #endregion Protected Methods + #region Private Fields + + private List? elencoOdl; + + private string giacenzeConf = "false"; + + #endregion Private Fields + #region Private Properties + private string BatchSel { get; set; } = ""; + private int IdxOdl { get; set; } = 0; + + private string mainTabCss + { + get => !string.IsNullOrEmpty(BatchSel) ? "col-10" : "col-12"; + } + [Inject] private MpDataService MDService { get; set; } = null!; [Inject] private NavigationManager NavManager { get; set; } = null!; + private ODLExpModel? odlExp { get; set; } = null!; private string padCodXdl { get; set; } = "00000"; - private string giacenzeConf = "false"; [Inject] private ISessionStorageService sessionStorage { get; set; } = null!; - private string BatchSel { get; set; } = ""; - - private string mainTabCss - { - get => !string.IsNullOrEmpty(BatchSel) ? "col-10" : "col-12"; - } - - protected void saveBatch(string newBatch) - { - BatchSel = newBatch; - } - #endregion Private Properties } } \ No newline at end of file diff --git a/MP.SPEC/Program.cs b/MP.SPEC/Program.cs index a90fc99b..84d72109 100644 --- a/MP.SPEC/Program.cs +++ b/MP.SPEC/Program.cs @@ -192,21 +192,6 @@ builder.Services.TryAddScoped(); builder.Services.TryAddSingleton(); builder.Services.TryAddScoped(); -#if false -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -#endif - -#if false -// aggiunta helper local/session storage service -builder.Services.AddScoped(); -builder.Services.AddScoped(); -#endif - - builder.Services.AddHttpClient(); logger.Info("Aggiunti services"); diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index a7abc269..648a902c 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 8.16.2606.1117

+

Versione: 8.16.2606.1118


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index cb037420..edaf8e76 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1118 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index ecd13772..dfc5e362 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1118 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false From 1e7572a098125058f96373a56ade93affe113b52 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 18:28:43 +0200 Subject: [PATCH 02/28] Bozza dopia scadenza giorno/ora per le statistiche --- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/MetricsDbFlushService.cs | 5 ++--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 5ce68600..7b168969 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1117 + 8.16.2606.1118 diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index f680de55..6cde41a6 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

    Versione: 8.16.2606.1117

    +

    Versione: 8.16.2606.1118


    Note di rilascio:
    • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index cb037420..edaf8e76 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1118 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index d25782e0..26b82416 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1118 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index c268e6d0..8a4c2a33 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -299,9 +299,9 @@ namespace MP.RIOC.Services var sKey = (RedisKey)$"{statKey}"; if (!TryParseKeyMetadata(sKey, out var meta) || !meta.IsHourType) continue; - // Verifica se la chiave è "orfana" (nessun TTL o TTL troppo lungo >30gg) + // Verifica se la chiave è "orfana" (nessun TTL o TTL troppo lungo >15gg) var keyTtl = GetKeyTtl(sKey); - bool isOrphanKey = keyTtl?.TotalSeconds < 0 || keyTtl?.TotalHours > 30.25 * 24; + bool isOrphanKey = keyTtl?.TotalSeconds < 0 || keyTtl?.TotalHours > 15.25 * 24; // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione if ((meta.Timestamp < currentHourStart || isOrphanKey) && deleteConfirmed) @@ -326,7 +326,6 @@ namespace MP.RIOC.Services dict.TryGetValue("totalMs", out var totalMsStr)) { long count = long.Parse(countStr); - count = long.Parse(countStr); double totalMs = double.Parse(totalMsStr, CultureInfo.InvariantCulture); double maxMs = dict.ContainsKey("maxMs") ? double.Parse(dict["maxMs"], CultureInfo.InvariantCulture) : 0; From 9f6e012b51b65a1ece276b6894cc43e9c3df624e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 18:53:35 +0200 Subject: [PATCH 03/28] Fix RIOC x scadenza chiavi hour --- MP.Data/Services/BaseServ.cs | 4 +- MP.Data/Services/IOC/IocService.cs | 74 ++++++++++++----------- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/MetricsDbFlushService.cs | 28 +++++++-- 7 files changed, 70 insertions(+), 44 deletions(-) diff --git a/MP.Data/Services/BaseServ.cs b/MP.Data/Services/BaseServ.cs index df5344c6..2ca02528 100644 --- a/MP.Data/Services/BaseServ.cs +++ b/MP.Data/Services/BaseServ.cs @@ -368,8 +368,8 @@ namespace MP.Data.Services var cacheOptions = new FusionCacheEntryOptions() .SetDuration(expiration) .SetFailSafe(true); - // cache in RAM per 1/3 del tempo x risparmiare risorse - cacheOptions.MemoryCacheDuration = expiration / 3; + // cache in RAM per 1/2 del tempo x risparmiare risorse + cacheOptions.MemoryCacheDuration = expiration / 2; var final = await _cache.GetOrSetAsync( cacheKey, diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index f4901fb0..2595f6cf 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -91,6 +91,19 @@ namespace MP.Data.Services.IOC /// public async Task GetCurrOdlAsync(string idxMacchina) { + string cKey = $"{MP.Data.Utils.redisOdlCurrByMac}:{idxMacchina}"; + return await GetOrFetchAsync( + operationName: "GetCurrOdlAsync", + cacheKey: cKey, + fetchFunc: async () => + { + return await GetCurrOdlByProdAsync(idxMacchina); + }, + expiration: GetRandTOut(redisShortTimeCache), + tagList: ["IOC_CurrOdl", cKey, idxMacchina] + ); + +#if false string result = ""; string currKey = $"{MP.Data.Utils.redisOdlCurrByMac}:{idxMacchina}"; // cerco in redis dato valOut sel macchina... @@ -104,7 +117,8 @@ namespace MP.Data.Services.IOC result = await GetCurrOdlByProdAsync(idxMacchina); _redisDb.StringSet(currKey, result, GetRandTOut(redisShortTimeCache)); } - return result; + return result; +#endif } /// @@ -117,39 +131,27 @@ namespace MP.Data.Services.IOC /// public async Task IobInsEnabAsync(string idxMacchina) { -#if false - string cacheKey = $"IOC_IobInsEnab_{idxMacchina}"; - return await GetOrFetchAsync(cacheKey, async () => - { - var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS); - - string? val = await _redisDb.HashGetAsync(rKey, "insEnabled"); - - if (val == null) + string cKey = $"IOC_IobInsEnab_{idxMacchina}"; + return await GetOrFetchAsync( + operationName: "StatoProdMacchinaAsync", + cacheKey: cKey, + fetchFunc: async () => { - var data = await ResetDatiMacchinaAsync(idxMacchina); - data.TryGetValue("insEnabled", out val); - } + var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS); - return val != null && (val == "1" || val.ToLower() == "true"); - }, TimeSpan.FromSeconds(5)); -#endif + string? val = await _redisDb.HashGetAsync(rKey, "insEnabled"); - bool answ = false; - // ORA recupero da memoria redis... - var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS); - RedisValue rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"insEnabled"); - // se è vuoto... leggo da DB e popolo! - if (!rawData.HasValue) - { - await ResetDatiMacchinaAsync(idxMacchina); - // riprovo - rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"insEnabled"); - } + if (val == null) + { + var data = await ResetDatiMacchinaAsync(idxMacchina); + data.TryGetValue("insEnabled", out val); + } - // provo conversione - bool.TryParse($"{rawData}", out answ); - return answ; + return val != null && (val == "1" || val.ToLower() == "true"); + }, + expiration: GetRandTOut(30), + tagList: ["IOC_IobInsEnab", cKey, idxMacchina] + ); } /// @@ -886,6 +888,8 @@ namespace MP.Data.Services.IOC // Eseguiamo tutto in un unico viaggio verso Redis bool success = await transaction.ExecuteAsync(); + await ForceFlushFusionCacheAsync(idxMacc); + return result; } @@ -1040,13 +1044,13 @@ namespace MP.Data.Services.IOC /// private async Task StatoProdMacchinaAsync(string idxMacchina, DateTime dtReq, bool forceDb = false) { - string cKey = $"IOC_StatoProd_{idxMacchina}"; - var stdTTL = TimeSpan.FromSeconds(30); + string cKey = $"{MP.Data.Utils.redisStatoProd}:{idxMacchina}:{dtReq:HHmm}"; return await GetOrFetchAsync( operationName: "StatoProdMacchinaAsync", cacheKey: cKey, fetchFunc: async () => { +#if false StatoProdModel? result = new StatoProdModel(); // cerco in _redisConn... string currKey = $"{MP.Data.Utils.redisStatoProd}:{idxMacchina}:{dtReq:HHmm}"; @@ -1066,9 +1070,11 @@ namespace MP.Data.Services.IOC { result = new StatoProdModel(); } - return result; + return result; +#endif + return await _repo.StatoProdMacchinaAsync(idxMacchina, dtReq); }, - expiration: stdTTL, + expiration: GetRandTOut(30), tagList: ["IOC_StatoProd", cKey, idxMacchina] ); } diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 46403a15..fc29050c 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1117 + 8.16.2606.1118 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 6e78a542..399acdde 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

      Versione: 8.16.2606.1117

      +

      Versione: 8.16.2606.1118


      Note di rilascio:
      • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index cb037420..edaf8e76 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1118 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 02fc9a9e..25228fab 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1118 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index 8a4c2a33..3d89e907 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -165,9 +165,19 @@ namespace MP.RIOC.Services var sKey = (RedisKey)$"{statKey}"; if (!TryParseKeyMetadata(sKey, out var meta) || meta.IsHourType) continue; - // Verifica se la chiave è "orfana" (nessun TTL o TTL troppo lungo >30gg) + // Verifica se la chiave è "orfana" + bool isOrphanKey = false; var keyTtl = GetKeyTtl(sKey); - bool isOrphanKey = keyTtl?.TotalSeconds < 0 || keyTtl?.TotalHours > 30.25 * 24; + if (keyTtl == null) + { + // Nessun TTL recuperato = chiave senza scadenza = orfana se > 30 gg + DateTime cutoffDay = DateTime.Today.AddDays(-30); + isOrphanKey = meta.Timestamp < cutoffDay; + } + else + { + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 30.25 * 24; + } // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione if ((meta.Timestamp < currentDayStart || isOrphanKey) && deleteConfirmed) @@ -299,9 +309,19 @@ namespace MP.RIOC.Services var sKey = (RedisKey)$"{statKey}"; if (!TryParseKeyMetadata(sKey, out var meta) || !meta.IsHourType) continue; - // Verifica se la chiave è "orfana" (nessun TTL o TTL troppo lungo >15gg) + // Verifica se la chiave è "orfana" + bool isOrphanKey = false; var keyTtl = GetKeyTtl(sKey); - bool isOrphanKey = keyTtl?.TotalSeconds < 0 || keyTtl?.TotalHours > 15.25 * 24; + if (keyTtl == null) + { + // Nessun TTL recuperato = chiave senza scadenza = orfana se > 7 gg + DateTime cutoffHour = DateTime.Now.AddDays(-7); + isOrphanKey = meta.Timestamp < cutoffHour; + } + else + { + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 15.25 * 24; + } // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione if ((meta.Timestamp < currentHourStart || isOrphanKey) && deleteConfirmed) From 850c549b1bd4c654cb2eefaf8f8fedfd499d0319 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 19:41:45 +0200 Subject: [PATCH 04/28] Fix flush dati RIOC --- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/MetricsDbFlushService.cs | 59 ++++++++++++++++------- 5 files changed, 45 insertions(+), 22 deletions(-) diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 7b168969..49b7811e 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1118 + 8.16.2606.1119 diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index 6cde41a6..7e230697 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

        Versione: 8.16.2606.1118

        +

        Versione: 8.16.2606.1119


        Note di rilascio:
        • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index edaf8e76..7907c963 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1118 +8.16.2606.1119 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index 26b82416..d39cf2ef 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1118 + 8.16.2606.1119 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index 3d89e907..53f4d415 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -69,20 +69,27 @@ namespace MP.RIOC.Services /// /// Cancellazione ricorsiva chiavi ausiliarie (:status, :errors) e rimozione dall'indice /// - private async Task DeleteAuxKeysAndIndexAsync(RedisKey sKey, RedisKey indexKey, IBatch batch) + private async Task DeleteAuxKeysAndIndexAsync(RedisKey sKey, RedisKey indexKey, IBatch batch, List pendingOps) { string sKeyStr = sKey.ToString(); string keyDir = sKeyStr.Substring(0, sKeyStr.LastIndexOf(':')); // Cancella :status dal sorted set e dalla hash string statusKey = keyDir + ":status"; - await batch.SortedSetRemoveAsync(indexKey, statusKey); - await batch.KeyDeleteAsync(statusKey); - + try + { + pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, statusKey)); + pendingOps.Add(batch.KeyDeleteAsync(statusKey)); + } + catch { } // Cancella :errors dal sorted set e dalla hash string errorKey = keyDir + ":errors"; - await batch.SortedSetRemoveAsync(indexKey, errorKey); - await batch.KeyDeleteAsync(errorKey); + try + { + pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, errorKey)); + pendingOps.Add(batch.KeyDeleteAsync(errorKey)); + } + catch { } // Cancella chiave ausiliaria :status anche da un eventuale indice days se presente if (statusKey.Contains(":stats:hours:")) @@ -90,7 +97,7 @@ namespace MP.RIOC.Services string daysIndex = statusKey.Replace(":stats:hours:", ":stats:days:"); try { - await batch.SortedSetRemoveAsync(daysIndex, statusKey); + pendingOps.Add(batch.SortedSetRemoveAsync(daysIndex, statusKey)); } catch { } } @@ -101,7 +108,7 @@ namespace MP.RIOC.Services string daysIndex = errorKey.Replace(":stats:hours:", ":stats:days:"); try { - await batch.SortedSetRemoveAsync(daysIndex, errorKey); + pendingOps.Add(batch.SortedSetRemoveAsync(daysIndex, errorKey)); } catch { } } @@ -150,6 +157,7 @@ namespace MP.RIOC.Services }; var batch = _db.CreateBatch(); + var pendingOps = new List(); foreach (var pattern in patternsToScan) { // Nota: KeyScanAsync/KeysAsync e' disponibile su IServer @@ -179,17 +187,19 @@ namespace MP.RIOC.Services isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 30.25 * 24; } - // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione - if ((meta.Timestamp < currentDayStart || isOrphanKey) && deleteConfirmed) + // Se è orfana e abbiamo il permesso, segnamola per la cancellazione + // NOTA: non usiamo il confronto con currentDayStart perché taglierebbe fuori + // i dati delle ore/giorni precedenti che devono essere ancora processati dal DB + if (isOrphanKey && deleteConfirmed) { // 1. Segna la chiave Hash (Dati) per l'eliminazione keysToDelete.Add(sKey); // 2. Rimuovi il riferimento dal Sorted Set (Indice) - await batch.SortedSetRemoveAsync(indexKey, statKey); + pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, statKey)); // 3. Cancellazione ricorsiva delle chiavi ausiliarie (:status, :errors, :days) - await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch); + await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch, pendingOps); } // Recupero dati dalla Hash @@ -236,6 +246,8 @@ namespace MP.RIOC.Services } } batch.Execute(); + // attendo conclusione + await Task.WhenAll(pendingOps); } // --- FASE UPSERT DB --- @@ -251,13 +263,16 @@ namespace MP.RIOC.Services if (deleteConfirmed && keysToDelete.Any()) { var batch = _db.CreateBatch(); + var pendingOps = new List(); int deletedCount = 0; foreach (var key in keysToDelete) { - await batch.KeyDeleteAsync(key); + pendingOps.Add(batch.KeyDeleteAsync(key)); deletedCount++; } batch.Execute(); + // attendo conclusione + await Task.WhenAll(pendingOps); Log.Info($"[CLEANUP DAY] Deleted {deletedCount} expired metric keys from Redis"); } } @@ -294,6 +309,7 @@ namespace MP.RIOC.Services }; var batch = _db.CreateBatch(); + var pendingOps = new List(); foreach (var pattern in patternsToScan) { // Nota: KeyScanAsync/KeysAsync e' disponibile su IServer @@ -323,17 +339,19 @@ namespace MP.RIOC.Services isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 15.25 * 24; } - // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione - if ((meta.Timestamp < currentHourStart || isOrphanKey) && deleteConfirmed) + // Se è orfana e abbiamo il permesso, segnamola per la cancellazione + // NOTA: non usiamo il confronto con currentHourStart perché taglierebbe fuori + // i dati delle ore precedenti che devono essere ancora processati dal DB + if (isOrphanKey && deleteConfirmed) { // 1. Segna la chiave Hash (Dati) per l'eliminazione keysToDelete.Add(sKey); // 2. Rimuovi il riferimento dal Sorted Set (Indice) - await batch.SortedSetRemoveAsync(indexKey, statKey); + pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, statKey)); // 3. Cancellazione ricorsiva chiavi ausiliarie - await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch); + await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch, pendingOps); } // Recupero dati dalla Hash @@ -379,6 +397,8 @@ namespace MP.RIOC.Services } } batch.Execute(); + // attendo conclusione + await Task.WhenAll(pendingOps); } // --- FASE UPSERT DB --- @@ -394,13 +414,16 @@ namespace MP.RIOC.Services if (deleteConfirmed && keysToDelete.Count > 0) { var batch = _db.CreateBatch(); + var pendingOps = new List(); int deletedCount = 0; foreach (var key in keysToDelete) { - await batch.KeyDeleteAsync(key); + pendingOps.Add(batch.KeyDeleteAsync(key)); deletedCount++; } batch.Execute(); + // attendo conclusione + await Task.WhenAll(pendingOps); Log.Info($"[CLEANUP HOUR] Deleted {deletedCount} expired metric keys from Redis"); } } From 1d1a71e95ff305e1020cb81d1fb2d50f2b037381 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 19:54:05 +0200 Subject: [PATCH 05/28] Provo modifica durata info statoProd in redis... --- MP.Data/Services/IOC/IocService.cs | 4 ++-- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/MetricsDbFlushService.cs | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index 2595f6cf..d3ad3c82 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -1044,7 +1044,7 @@ namespace MP.Data.Services.IOC /// private async Task StatoProdMacchinaAsync(string idxMacchina, DateTime dtReq, bool forceDb = false) { - string cKey = $"{MP.Data.Utils.redisStatoProd}:{idxMacchina}:{dtReq:HHmm}"; + string cKey = $"{MP.Data.Utils.redisStatoProd}:{idxMacchina}"; return await GetOrFetchAsync( operationName: "StatoProdMacchinaAsync", cacheKey: cKey, @@ -1074,7 +1074,7 @@ namespace MP.Data.Services.IOC #endif return await _repo.StatoProdMacchinaAsync(idxMacchina, dtReq); }, - expiration: GetRandTOut(30), + expiration: GetRandTOut(redisShortTimeCache), tagList: ["IOC_StatoProd", cKey, idxMacchina] ); } diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index fc29050c..5b48ca5e 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1118 + 8.16.2606.1119 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 399acdde..d86571ba 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

          Versione: 8.16.2606.1118

          +

          Versione: 8.16.2606.1119


          Note di rilascio:
          • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index edaf8e76..7907c963 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1118 +8.16.2606.1119 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 25228fab..05f35334 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1118 + 8.16.2606.1119 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index 53f4d415..a95fce6f 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -184,7 +184,7 @@ namespace MP.RIOC.Services } else { - isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 30.25 * 24; + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays > 30.25; } // Se è orfana e abbiamo il permesso, segnamola per la cancellazione @@ -336,7 +336,7 @@ namespace MP.RIOC.Services } else { - isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 15.25 * 24; + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays > 15.25; } // Se è orfana e abbiamo il permesso, segnamola per la cancellazione @@ -438,7 +438,7 @@ namespace MP.RIOC.Services var p = relativeKey.Split(':'); if (p.Length < 4) return false; - meta.IsHourType = p[1].Equals("hour", StringComparison.InvariantCultureIgnoreCase); + meta.IsHourType = p[1].Contains("hour", StringComparison.InvariantCultureIgnoreCase); meta.Dest = p[2]; if (meta.IsHourType) { From db44a8ca878e5ae3f2b22f59f006d94e34c0325c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 20:10:47 +0200 Subject: [PATCH 06/28] Spostato controller alive in map controller, sotto 1ms... (HOPE) --- MP.IOC/Controllers/IOBController.cs | 18 +++++++++--------- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Program.cs | 4 ++++ MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index 834d64bd..1cb8570f 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -75,15 +75,15 @@ namespace MP.IOC.Controllers return Ok(answ); } - /// - /// GET: IOB/ - /// - /// - [HttpGet] - public IActionResult Alive() - { - return Ok("OK"); // Restituisce Status 200 - } + ///// + ///// GET: IOB/ + ///// + ///// + //[HttpGet] + //public string Alive() + //{ + // return "OK"; // Restituisce Status 200 + //} /// /// GET: IOB/enabled/SIMUL_03 diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 5b48ca5e..b6338f70 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1119 + 8.16.2606.1120 diff --git a/MP.IOC/Program.cs b/MP.IOC/Program.cs index fb334554..e8b04c59 100644 --- a/MP.IOC/Program.cs +++ b/MP.IOC/Program.cs @@ -173,6 +173,10 @@ app.UseAntiforgery(); // Mappatura delle API app.MapControllers(); +// mappa del base url check +app.MapGet("api/IOB/", () => Results.Ok("OK")); +app.MapGet("api/IOB/alive", () => Results.Ok("OK")); + // Mappatura della Dashboard Blazor app.MapRazorComponents() .AddInteractiveServerRenderMode(); diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index d86571ba..62ff9fcb 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

            Versione: 8.16.2606.1119

            +

            Versione: 8.16.2606.1120


            Note di rilascio:
            • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 7907c963..a0507993 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1119 +8.16.2606.1120 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 05f35334..35c9bdcd 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1119 + 8.16.2606.1120 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false From 1361aab3b984c9ba29dac7f05a94ef271802cd81 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 20:27:06 +0200 Subject: [PATCH 07/28] Ancora ottimizzazioni minori IOC x metodi + frequenti --- MP.Data/Services/IOC/IocService.cs | 81 ++++++++++++++++++++--------- MP.IOC/Controllers/IOBController.cs | 35 +++++++------ MP.IOC/appsettings.json | 3 +- 3 files changed, 76 insertions(+), 43 deletions(-) diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index d3ad3c82..5acbe23a 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -117,7 +117,7 @@ namespace MP.Data.Services.IOC result = await GetCurrOdlByProdAsync(idxMacchina); _redisDb.StringSet(currKey, result, GetRandTOut(redisShortTimeCache)); } - return result; + return result; #endif } @@ -138,16 +138,37 @@ namespace MP.Data.Services.IOC fetchFunc: async () => { var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS); + var val = await _redisDb.HashGetAsync(rKey, "insEnabled"); - string? val = await _redisDb.HashGetAsync(rKey, "insEnabled"); - - if (val == null) + if (!val.HasValue) { var data = await ResetDatiMacchinaAsync(idxMacchina); - data.TryGetValue("insEnabled", out val); + // 2. Uso del pattern matching per evitare allocazioni e passaggi intermedi + return data != null + && data.TryGetValue("insEnabled", out string? sVal) + && IsStringTrue(sVal); } - return val != null && (val == "1" || val.ToLower() == "true"); + // 3. Conversione efficiente da RedisValue a string (evita l'interpolazione $"{val}") + string? sRedisVal = val; + return IsStringTrue(sRedisVal); + +#if false + var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS); + var val = await _redisDb.HashGetAsync(rKey, "insEnabled"); + string sVal = ""; + if (!val.HasValue) + { + var data = await ResetDatiMacchinaAsync(idxMacchina); + data.TryGetValue("insEnabled", out sVal); + } + else + { + sVal = $"{val}"; + } + + return !string.IsNullOrEmpty(sVal) && (sVal == "1" || sVal.ToLower() == "true"); +#endif }, expiration: GetRandTOut(30), tagList: ["IOC_IobInsEnab", cKey, idxMacchina] @@ -303,30 +324,14 @@ namespace MP.Data.Services.IOC #endregion Protected Fields -#if false - /// - /// Restituisce un timeout dai minuti richiesti + tempo random 1..60 sec - /// - /// - /// - protected TimeSpan GetRandTOut(double stdMinutes) - { - double rndValue = stdMinutes + (double)rand.Next(1, 60) / 60; - return TimeSpan.FromMinutes(rndValue); - } -#endif - #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); -#if false - private readonly IFusionCache _cache; -#endif - private readonly string _className; private readonly IIocRepository _repo; + private readonly IServiceScopeFactory _scopeFactory; /// @@ -341,14 +346,38 @@ namespace MP.Data.Services.IOC #endregion Private Fields + #region Private Methods + + private static bool IsStringTrue(string? value) + { + if (string.IsNullOrEmpty(value)) return false; + + // Evita ToLower() che alloca una nuova stringa in memoria ad ogni chiamata + return value == "1" + || value.Equals("true", StringComparison.OrdinalIgnoreCase); + } + +#if false + /// + /// Restituisce un timeout dai minuti richiesti + tempo random 1..60 sec + /// + /// + /// + protected TimeSpan GetRandTOut(double stdMinutes) + { + double rndValue = stdMinutes + (double)rand.Next(1, 60) / 60; + return TimeSpan.FromMinutes(rndValue); + } +#endif +#if false + private readonly IFusionCache _cache; +#endif #if false private int redisLongTimeCache = 5; private int redisShortTimeCache = 2; #endif - #region Private Methods - /// /// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE /// @@ -1070,7 +1099,7 @@ namespace MP.Data.Services.IOC { result = new StatoProdModel(); } - return result; + return result; #endif return await _repo.StatoProdMacchinaAsync(idxMacchina, dtReq); }, diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index 1cb8570f..a7e29794 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -75,39 +75,42 @@ namespace MP.IOC.Controllers return Ok(answ); } - ///// - ///// GET: IOB/ - ///// - ///// - //[HttpGet] - //public string Alive() - //{ - // return "OK"; // Restituisce Status 200 - //} - /// /// GET: IOB/enabled/SIMUL_03 /// /// /// [HttpGet("enabled/{id}")] - public async Task Enabled(string id) + public async Task Enabled(string id) { - if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + if (string.IsNullOrWhiteSpace(id)) + { + Response.StatusCode = StatusCodes.Status400BadRequest; + return "Missing ID"; + //return BadRequest("Missing ID"); + } try { // Il metodo ora restituisce direttamente il booleano logico bool isEnabled = await IOCService.IobInsEnabAsync(id); - return isEnabled - ? Ok("OK") - : UnprocessableEntity("NO"); + // Eliminazione delle allocazioni di stringhe e oggetti inutili + if (!isEnabled) + { + Response.StatusCode = StatusCodes.Status422UnprocessableEntity; + return "NO"; + } + + // Status 200 di default, scrive direttamente sul body della response + return "OK"; } catch (Exception ex) { Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); - return StatusCode(500, "Errore interno del server"); + Response.StatusCode = StatusCodes.Status500InternalServerError; + return "Errore interno del server"; + //return StatusCode(500, "Errore interno del server"); } } diff --git a/MP.IOC/appsettings.json b/MP.IOC/appsettings.json index e947a8ce..c70d3442 100644 --- a/MP.IOC/appsettings.json +++ b/MP.IOC/appsettings.json @@ -6,7 +6,8 @@ "Microsoft.EntityFrameworkCore.Database.Command": "Warning", "Microsoft.EntityFrameworkCore.Infrastructure": "Warning", "Microsoft.WebTools.BrowserLink.Net.BrowserLinkMiddleware": "None", - "Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware": "None" + "Microsoft.AspNetCore.Watch.BrowserRefresh.BrowserRefreshMiddleware": "None", + "ZiggyCreatures.Caching.Fusion": "Warning" } }, "NLog": { From e9c4049824a2a5b373b3694b08c9ae7ea9ed99a0 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 20:55:06 +0200 Subject: [PATCH 08/28] =?UTF-8?q?Cambio=20modalit=C3=A0=20di=20calcolo=20c?= =?UTF-8?q?hiavi=20orphaned=20x=20gestire=20statistiche=20in=20modo=20+=20?= =?UTF-8?q?corretto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/MetricsDbFlushService.cs | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 49b7811e..9adb0f4b 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1119 + 8.16.2606.1120 diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index 7e230697..2f4766a9 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

              Versione: 8.16.2606.1119

              +

              Versione: 8.16.2606.1120


              Note di rilascio:
              • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index 7907c963..a0507993 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1119 +8.16.2606.1120 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index d39cf2ef..56ff116c 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1119 + 8.16.2606.1120 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index a95fce6f..841b5e7b 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -184,7 +184,7 @@ namespace MP.RIOC.Services } else { - isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays > 30.25; + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 1 >; } // Se è orfana e abbiamo il permesso, segnamola per la cancellazione @@ -336,7 +336,7 @@ namespace MP.RIOC.Services } else { - isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays > 15.25; + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 15; } // Se è orfana e abbiamo il permesso, segnamola per la cancellazione From 3c0eb3fb4649014407ccfbca3aaa7ba9b6e73db4 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 11 Jun 2026 20:58:02 +0200 Subject: [PATCH 09/28] Fix controllo scadenza dati DAY --- MP.RIOC/Services/MetricsDbFlushService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index 841b5e7b..d90a1dd9 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -184,7 +184,7 @@ namespace MP.RIOC.Services } else { - isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 1 >; + isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 1; } // Se è orfana e abbiamo il permesso, segnamola per la cancellazione From 6105e769178dc1051a451007882a81bc4d49297d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 07:14:59 +0200 Subject: [PATCH 10/28] Review pulizia key redis --- MP.RIOC/Services/MetricsDbFlushService.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index d90a1dd9..56510506 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -114,6 +114,7 @@ namespace MP.RIOC.Services } } +#if false /// /// Recupera il TTL residuo di una chiave Redis (-1 = nessun TTL, -2 = chiave non esiste) /// @@ -124,7 +125,8 @@ namespace MP.RIOC.Services return _db.KeyTimeToLive(key); } catch { return null; } - } + } +#endif /// /// Processing dati giornalieri (da Redis a DB) @@ -174,18 +176,19 @@ namespace MP.RIOC.Services if (!TryParseKeyMetadata(sKey, out var meta) || meta.IsHourType) continue; // Verifica se la chiave è "orfana" + bool isOrphanKey = meta.Timestamp < currentDayStart; +#if false bool isOrphanKey = false; var keyTtl = GetKeyTtl(sKey); if (keyTtl == null) { - // Nessun TTL recuperato = chiave senza scadenza = orfana se > 30 gg - DateTime cutoffDay = DateTime.Today.AddDays(-30); - isOrphanKey = meta.Timestamp < cutoffDay; + isOrphanKey = meta.Timestamp < currentDayStart; } else { isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 1; - } + } +#endif // Se è orfana e abbiamo il permesso, segnamola per la cancellazione // NOTA: non usiamo il confronto con currentDayStart perché taglierebbe fuori @@ -326,6 +329,8 @@ namespace MP.RIOC.Services if (!TryParseKeyMetadata(sKey, out var meta) || !meta.IsHourType) continue; // Verifica se la chiave è "orfana" + bool isOrphanKey = meta.Timestamp < currentHourStart; +#if false bool isOrphanKey = false; var keyTtl = GetKeyTtl(sKey); if (keyTtl == null) @@ -337,7 +342,8 @@ namespace MP.RIOC.Services else { isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalDays < 15; - } + } +#endif // Se è orfana e abbiamo il permesso, segnamola per la cancellazione // NOTA: non usiamo il confronto con currentHourStart perché taglierebbe fuori From f192c354540d16b0b5da766a24131ce256b45e16 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 07:27:18 +0200 Subject: [PATCH 11/28] update conf RIOC da testare --- MP.IOC/Controllers/IOBController.cs | 19 +++++++++++++++++++ MP.RIOC/MP.RIOC.csproj | 1 + 2 files changed, 20 insertions(+) diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index a7e29794..d4c0b7ae 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -112,6 +112,25 @@ namespace MP.IOC.Controllers return "Errore interno del server"; //return StatusCode(500, "Errore interno del server"); } + +#if false + if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + + try + { + // Il metodo ora restituisce direttamente il booleano logico + bool isEnabled = await IOCService.IobInsEnabAsync(id); + + return isEnabled + ? Ok("OK") + : UnprocessableEntity("NO"); + } + catch (Exception ex) + { + Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); + return StatusCode(500, "Errore interno del server"); + } +#endif } /// diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 9adb0f4b..87280c4b 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -6,6 +6,7 @@ enable MP.RIOC 8.16.2606.1120 + InProcess From 56392e0dcf19c3971e266e59af09d8f34e127683 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 09:47:42 +0200 Subject: [PATCH 12/28] Aggiunta metodi con MinimalApi --- MP.IOC/Controllers/IOBController.cs | 44 +++---- MP.IOC/Endpoints/IobEndpoints.cs | 112 ++++++++++++++++++ MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Program.cs | 9 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- MP.IOC/appsettings.json | 2 +- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Program.cs | 4 + .../Properties/PublishProfiles/IIS01.pubxml | 59 ++++----- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- 14 files changed, 183 insertions(+), 63 deletions(-) create mode 100644 MP.IOC/Endpoints/IobEndpoints.cs diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index d4c0b7ae..0555f619 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -75,6 +75,7 @@ namespace MP.IOC.Controllers return Ok(answ); } +#if false /// /// GET: IOB/enabled/SIMUL_03 /// @@ -83,11 +84,10 @@ namespace MP.IOC.Controllers [HttpGet("enabled/{id}")] public async Task Enabled(string id) { - if (string.IsNullOrWhiteSpace(id)) + if (string.IsNullOrEmpty(id)) { Response.StatusCode = StatusCodes.Status400BadRequest; return "Missing ID"; - //return BadRequest("Missing ID"); } try @@ -110,28 +110,26 @@ namespace MP.IOC.Controllers Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); Response.StatusCode = StatusCodes.Status500InternalServerError; return "Errore interno del server"; - //return StatusCode(500, "Errore interno del server"); } -#if false - if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + //if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); - try - { - // Il metodo ora restituisce direttamente il booleano logico - bool isEnabled = await IOCService.IobInsEnabAsync(id); + //try + //{ + // // Il metodo ora restituisce direttamente il booleano logico + // bool isEnabled = await IOCService.IobInsEnabAsync(id); - return isEnabled - ? Ok("OK") - : UnprocessableEntity("NO"); - } - catch (Exception ex) - { - Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); - return StatusCode(500, "Errore interno del server"); - } + // return isEnabled + // ? Ok("OK") + // : UnprocessableEntity("NO"); + //} + //catch (Exception ex) + //{ + // Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); + // return StatusCode(500, "Errore interno del server"); + //} + } #endif - } /// /// Processa una chiamata POST per l'invio di un array Json di oggetti input (EVENTI) @@ -485,6 +483,7 @@ namespace MP.IOC.Controllers return Ok(actValues); } +#if false /// /// Recupera ODL corrente x macchina: /// GET: IOB/getCurrODL/SIMUL_03 @@ -508,7 +507,8 @@ namespace MP.IOC.Controllers Log.Error(exc, "Errore GetCurrODL | macchina {MachineId}", id); return StatusCode(StatusCodes.Status500InternalServerError, "NO"); } - } + } +#endif /// /// Restituisce la quantità pezzi dell'odl correntemente in lavorazione sulla macchina... @@ -1227,6 +1227,7 @@ namespace MP.IOC.Controllers return Ok(answ); } +#if false /// /// SALVA Counter x macchina restituendo il valore appena inviato o, se mancasse chiave /// redis, valore da DB /// @@ -1257,7 +1258,8 @@ namespace MP.IOC.Controllers return StatusCode(StatusCodes.Status500InternalServerError, "NO"); } return Ok(answ); - } + } +#endif /// /// Salva associazione tra macchina, device IOB chiamante e sue info diff --git a/MP.IOC/Endpoints/IobEndpoints.cs b/MP.IOC/Endpoints/IobEndpoints.cs new file mode 100644 index 00000000..f998de18 --- /dev/null +++ b/MP.IOC/Endpoints/IobEndpoints.cs @@ -0,0 +1,112 @@ +using MP.Data.Services.IOC; +using NLog; + +namespace MP.IOC.Endpoints +{ + public static class IobEndpoints + { + public static void MapIobHighPerformanceEndpoints(this IEndpointRouteBuilder app) + { + // 1. Root di test base: api/IOB e api/IOB/alive + app.MapGet("api/IOB", () => "OK"); + app.MapGet("api/IOB/alive", () => "OK"); + + // 2. Il metodo Enabled ad alto traffico: api/IOB/enabled/{id} + app.MapGet("api/IOB/enabled/{id}", async (string id, IIocService iocService, HttpContext context) => + { + if (string.IsNullOrEmpty(id)) + { + context.Response.StatusCode = StatusCodes.Status400BadRequest; + return "Missing ID"; + } + + try + { + bool isEnabled = await iocService.IobInsEnabAsync(id); + + if (!isEnabled) + { + context.Response.StatusCode = StatusCodes.Status422UnprocessableEntity; + return "NO"; + } + + return "OK"; + } + catch (Exception ex) + { + Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); + context.Response.StatusCode = StatusCodes.Status500InternalServerError; + return "Errore interno del server"; + } + }); + + // 3. Metodo: SetCounter (api/IOB/setCounter/{id}?counter=10) + // Nota: 'counter' viene letto automaticamente dalla Query String grazie al Model Binding automatico + app.MapGet("api/IOB/setCounter/{id}", async (string id, string counter, IIocService iocService, HttpContext context) => + { + if (string.IsNullOrEmpty(id)) + { + context.Response.StatusCode = StatusCodes.Status400BadRequest; + return "Missing ID"; + } + + // Ottimizzazione: esegui il Replace solo se il carattere è effettivamente presente + if (id.Contains('|')) + { + id = id.Replace('|', '#'); + } + + // Se il log di Debug è disattivato in produzione, eviti l'allocazione della stringa interpolata + if (Log.IsDebugEnabled) + { + Log.Debug($"Salvataggio counter | id: {id} | pzCount: {counter}"); + } + + try + { + string answ = await iocService.SaveCounterAsync(id, counter); + return answ; // Ritorna direttamente la stringa (Status 200 di default, zero allocazioni di ObjectResult) + } + catch (Exception exc) + { + // Usiamo la stringa formattata standard di NLog per evitare Environment.NewLine manuale + Log.Error(exc, "Errore in SetCounter per macchina {MachineId}", id); + context.Response.StatusCode = StatusCodes.Status500InternalServerError; + return "NO"; + } + }); + + // 4. Metodo: GetCurrODL (api/IOB/getCurrODL/{id}) + app.MapGet("api/IOB/getCurrODL/{id}", async (string id, IIocService iocService, HttpContext context) => + { + if (string.IsNullOrEmpty(id)) + { + context.Response.StatusCode = StatusCodes.Status400BadRequest; + return "Missing ID"; + } + + if (id.Contains('|')) + { + id = id.Replace('|', '#'); + } + + try + { + var odl = await iocService.GetCurrOdlAsync(id); + + // Ottimizzazione: Se 'odl' è già una stringa, ritornala direttamente. + // Se è un oggetto o un numero, il C# gestirà l'estrazione. Evitiamo $"{odl}" che alloca memoria inutilmente. + return odl?.ToString() ?? string.Empty; + } + catch (Exception exc) + { + Log.Error(exc, "Errore GetCurrODL | macchina {MachineId}", id); + context.Response.StatusCode = StatusCodes.Status500InternalServerError; + return "NO"; + } + }); + + } + private static Logger Log = LogManager.GetCurrentClassLogger(); + } +} \ No newline at end of file diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index b6338f70..a51454d0 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1120 + 8.16.2606.1208 diff --git a/MP.IOC/Program.cs b/MP.IOC/Program.cs index e8b04c59..376940a2 100644 --- a/MP.IOC/Program.cs +++ b/MP.IOC/Program.cs @@ -6,6 +6,7 @@ using MP.Core.Conf; using MP.Data; using MP.IOC.Components; using MP.IOC.Data; +using MP.IOC.Endpoints; using MP.IOC.Services; using NLog; using NLog.Web; @@ -170,12 +171,12 @@ app.UseDefaultFiles(); app.UseStaticFiles(); app.UseAntiforgery(); -// Mappatura delle API +// Mappatura MinimalApi da file ext x metodi high perf +app.MapIobHighPerformanceEndpoints(); + +// Mappatura delle API "standard" app.MapControllers(); -// mappa del base url check -app.MapGet("api/IOB/", () => Results.Ok("OK")); -app.MapGet("api/IOB/alive", () => Results.Ok("OK")); // Mappatura della Dashboard Blazor app.MapRazorComponents() diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 62ff9fcb..19d81522 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                Versione: 8.16.2606.1120

                +

                Versione: 8.16.2606.1208


                Note di rilascio:
                • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index a0507993..fe6ac8c4 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1120 +8.16.2606.1208 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 35c9bdcd..0f90abd3 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1120 + 8.16.2606.1208 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.IOC/appsettings.json b/MP.IOC/appsettings.json index c70d3442..4bd6bf3c 100644 --- a/MP.IOC/appsettings.json +++ b/MP.IOC/appsettings.json @@ -25,7 +25,7 @@ "logfile": { "type": "File", "fileName": "${basedir}/logs/${shortdate}.log", - "keepFileOpen": false, + "keepFileOpen": true, "archiveEvery": "Day", "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", "archiveNumbering": "DateAndSequence", diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 87280c4b..9d41d7d1 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1120 + 8.16.2606.1208 InProcess diff --git a/MP.RIOC/Program.cs b/MP.RIOC/Program.cs index 489b29dd..fbf3066d 100644 --- a/MP.RIOC/Program.cs +++ b/MP.RIOC/Program.cs @@ -161,6 +161,10 @@ app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments(routePath, StringComparis }); }); +// test per ambiente di esecuzione InProcess... +app.MapGet("api/alive", () => + $"OK - Girando in: {System.Diagnostics.Process.GetCurrentProcess().ProcessName}"); + // 6. Definizione degli Endpoints locali app.MapRazorPages(); diff --git a/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml b/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml index 6c359c50..ca4fed85 100644 --- a/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml +++ b/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml @@ -1,33 +1,34 @@  - - MSDeploy - true - Release - Any CPU - https://iis01.egalware.com/MP/RIOC/ - false - b9188473-f4ae-4f9f-be2d-70edaace0db9 - false - https://iis01.egalware.com:8172/MsDeploy.axd - Default Web Site/MP/RIOC - - true - WMSVC - true - true - jenkins - <_SavePWD>true - <_TargetId>IISWebDeploy - net8.0 - win-x64 - true - - - - filePath - logs\\.*\.log$ - - + + MSDeploy + true + Release + Any CPU + https://iis01.egalware.com/MP/RIOC/ + false + b9188473-f4ae-4f9f-be2d-70edaace0db9 + false + https://iis01.egalware.com:8172/MsDeploy.axd + Default Web Site/MP/RIOC + + true + WMSVC + true + true + jenkins + <_SavePWD>true + <_TargetId>IISWebDeploy + net8.0 + win-x64 + true + True + + + + filePath + logs\\.*\.log$ + + \ No newline at end of file diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index 2f4766a9..fd556bd8 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

                  Versione: 8.16.2606.1120

                  +

                  Versione: 8.16.2606.1208


                  Note di rilascio:
                  • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index a0507993..fe6ac8c4 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1120 +8.16.2606.1208 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index 56ff116c..af3135c8 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1120 + 8.16.2606.1208 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false From 6c400332ff87b977ab6e505e8f55f4ce44c9f86b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 09:58:24 +0200 Subject: [PATCH 13/28] Modifica logica scadenza produzione ed ODL --- MP.Data/Services/IOC/IocService.cs | 7 ++++--- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index 5acbe23a..6b5f94f1 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -99,7 +99,7 @@ namespace MP.Data.Services.IOC { return await GetCurrOdlByProdAsync(idxMacchina); }, - expiration: GetRandTOut(redisShortTimeCache), + expiration: GetRandTOut(redisLongTimeCache), tagList: ["IOC_CurrOdl", cKey, idxMacchina] ); @@ -292,7 +292,8 @@ namespace MP.Data.Services.IOC answ = currCount.ToString(); // salvo per meno tempo... await _redisDb.StringSetAsync(currKey, answ); - await ClearFusionCache(idxMacchina); + await ClearFusionCache("IOC_CurrOdl"); + //await ClearFusionCache(idxMacchina); } } } @@ -1103,7 +1104,7 @@ namespace MP.Data.Services.IOC #endif return await _repo.StatoProdMacchinaAsync(idxMacchina, dtReq); }, - expiration: GetRandTOut(redisShortTimeCache), + expiration: GetRandTOut(redisLongTimeCache), tagList: ["IOC_StatoProd", cKey, idxMacchina] ); } diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index a51454d0..db8ad9c7 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1208 + 8.16.2606.1209 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 19d81522..06d421bc 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                    Versione: 8.16.2606.1208

                    +

                    Versione: 8.16.2606.1209


                    Note di rilascio:
                    • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index fe6ac8c4..e09f03d4 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1208 +8.16.2606.1209 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 0f90abd3..238b0931 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1208 + 8.16.2606.1209 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false From c03a8a7827da321b16585279a158990b46a15550 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 10:37:24 +0200 Subject: [PATCH 14/28] Update scadenza cache IOC x salvataggio contapezzi --- MP.Data/Services/IOC/IocService.cs | 16 ++++++++-------- MP.IOC/Controllers/IOBController.cs | 2 +- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index 6b5f94f1..a9f21244 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -224,7 +224,6 @@ namespace MP.Data.Services.IOC // gestisce i casi DB/REDIS secondo necessità await CheckMicroStatoAsync(idxMacchina, valore, dataOraEvento, contatore, datiMacc); } - await ClearFusionCache(idxMacchina); // forzo RESET dati macchina... await ResetDatiMacchinaAsync(idxMacchina); // registro in risposta che è andato tutto bene... @@ -566,14 +565,15 @@ namespace MP.Data.Services.IOC // se è vuoto... leggo da DB e popolo! if (!rawData.HasValue) { - await ResetDatiMacchinaAsync(idxMacchina); - // riprovo - rawData = await _redisDb.HashGetAsync(rKey, (RedisValue)"sLogEnabled"); - } + var data = await ResetDatiMacchinaAsync(idxMacchina); - // provo conversione - bool.TryParse($"{rawData}", out answ); - return answ; + // 2. Uso del pattern matching per evitare allocazioni e passaggi intermedi + return data != null + && data.TryGetValue("sLogEnabled", out string? sVal) + && IsStringTrue(sVal); + } + string? sRedisVal = rawData; + return IsStringTrue(sRedisVal); } /// diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index 0555f619..a90e82b4 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -1108,7 +1108,7 @@ namespace MP.IOC.Controllers try { answ = await DService.saveCaricoPezzi(id, qty); - await IOCService.ClearFusionCache(); + await IOCService.ClearFusionCache(id); return Ok(answ); } catch (Exception exc) diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index db8ad9c7..7049ec52 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1209 + 8.16.2606.1210 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 06d421bc..330938ad 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                      Versione: 8.16.2606.1209

                      +

                      Versione: 8.16.2606.1210


                      Note di rilascio:
                      • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index e09f03d4..96ea4ac5 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1209 +8.16.2606.1210 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 238b0931..36f70f91 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1209 + 8.16.2606.1210 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false From 650d88a2765e2b43f50122b8c0fe3141366ff55c Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 11:02:48 +0200 Subject: [PATCH 15/28] SPEC: fix visualizzazione KIT Child --- MP.Data/Repository/Production/ProductionRepository.cs | 3 ++- MP.Data/Services/IOC/IocService.cs | 3 +-- MP.SPEC/Components/ProdKit/Manager.razor.cs | 2 +- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Pages/PODL.razor | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/MP.Data/Repository/Production/ProductionRepository.cs b/MP.Data/Repository/Production/ProductionRepository.cs index 9ac67318..cad3c21d 100644 --- a/MP.Data/Repository/Production/ProductionRepository.cs +++ b/MP.Data/Repository/Production/ProductionRepository.cs @@ -197,11 +197,12 @@ namespace MP.Data.Repository.Production var DateFrom = new SqlParameter("@DtInizio", startDate); var DateTo = new SqlParameter("@DtFine", endDate); var pFlagAtt = new SqlParameter("@flgAttive", flagAttive); + var pFlagKit = new SqlParameter("@flgPodlKit", true); var pFlagKChild = new SqlParameter("@flgPodChild", flagKitChild); return await dbCtx .DbSetPODLExp - .FromSqlRaw("EXEC stp_PODL_getByFiltSpecKit @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine, @flgAttive, @flgPodChild", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo, pFlagAtt, pFlagKChild) + .FromSqlRaw("EXEC stp_PODL_getByFiltSpecKit @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DtInizio, @DtFine, @flgAttive, @flgPodlKit, @flgPodChild", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo, pFlagAtt, pFlagKit, pFlagKChild) .AsNoTracking() .ToListAsync(); } diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index a9f21244..27cf07d5 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -291,8 +291,7 @@ namespace MP.Data.Services.IOC answ = currCount.ToString(); // salvo per meno tempo... await _redisDb.StringSetAsync(currKey, answ); - await ClearFusionCache("IOC_CurrOdl"); - //await ClearFusionCache(idxMacchina); + await ClearFusionCache(idxMacchina); } } } diff --git a/MP.SPEC/Components/ProdKit/Manager.razor.cs b/MP.SPEC/Components/ProdKit/Manager.razor.cs index afaa0533..00310ca2 100644 --- a/MP.SPEC/Components/ProdKit/Manager.razor.cs +++ b/MP.SPEC/Components/ProdKit/Manager.razor.cs @@ -188,7 +188,7 @@ namespace MP.SPEC.Components.ProdKit { listPOdlCheck = new List(); listPOdlAct = await MDService.POdlListGetFiltAsync(ActFilt.HasOdl, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd); - listPOdl2Kit = await MDService.POdlToKitListGetFiltAsync(ActFilt.HasOdl, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd, true, true); + listPOdl2Kit = await MDService.POdlToKitListGetFiltAsync(ActFilt.HasOdl, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd, true, false); listWSM = await MDService.WipKitFiltAsync(keyFilt); listTSM = await MDService.TksScoreAsync(keyFilt, 1000, true); listIKP = await MDService.IstKitFiltAsync("", ""); diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 739c9afd..7829be22 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2606.1118 + 8.16.2606.1210 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/PODL.razor b/MP.SPEC/Pages/PODL.razor index 0b88ee99..a122e1a9 100644 --- a/MP.SPEC/Pages/PODL.razor +++ b/MP.SPEC/Pages/PODL.razor @@ -33,7 +33,7 @@
                        - Kit + Kit C
                        diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 648a902c..2b2553ba 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                        Versione: 8.16.2606.1118

                        +

                        Versione: 8.16.2606.1210


                        Note di rilascio:
                        • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index edaf8e76..96ea4ac5 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1118 +8.16.2606.1210 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index dfc5e362..c252a143 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1118 + 8.16.2606.1210 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false From 1231731c8f1b5f3b83a2ccb7175472bd0f9d18fd Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 15:10:06 +0200 Subject: [PATCH 16/28] SPEC: fix filtro sel PODL disponibili in creazione KIT --- MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs | 6 ------ MP.SPEC/Components/ProdKit/KitVerify.razor | 4 ++-- MP.SPEC/Components/ProdKit/Manager.razor.cs | 2 +- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 7 files changed, 7 insertions(+), 13 deletions(-) diff --git a/MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs b/MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs index 0bb9c05f..bde8feb5 100644 --- a/MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs +++ b/MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs @@ -220,12 +220,6 @@ namespace MP.SPEC.Components.ProdKit set => ActFilter.CurrPage = value; } - private bool hasOdl - { - get => ActFilter.HasOdl; - set => ActFilter.HasOdl = value; - } - private bool isLoading { get; set; } = false; private SelectXdlParams lastFilter { get; set; } = new SelectXdlParams() { CurrPage = -1 }; diff --git a/MP.SPEC/Components/ProdKit/KitVerify.razor b/MP.SPEC/Components/ProdKit/KitVerify.razor index 6ead57b4..c64b9677 100644 --- a/MP.SPEC/Components/ProdKit/KitVerify.razor +++ b/MP.SPEC/Components/ProdKit/KitVerify.razor @@ -54,10 +54,10 @@ }
                          - Elenco promesse per KIT (100%) + Elenco promesse KIT (100%) da produrre @if (ListRecPODL == null || ListRecPODL.Count == 0) { -
                          Nessuna PODL compatibile presente
                          +
                          Nessuna PODL KIT presente
                          } else { diff --git a/MP.SPEC/Components/ProdKit/Manager.razor.cs b/MP.SPEC/Components/ProdKit/Manager.razor.cs index 00310ca2..3dbc1355 100644 --- a/MP.SPEC/Components/ProdKit/Manager.razor.cs +++ b/MP.SPEC/Components/ProdKit/Manager.razor.cs @@ -188,7 +188,7 @@ namespace MP.SPEC.Components.ProdKit { listPOdlCheck = new List(); listPOdlAct = await MDService.POdlListGetFiltAsync(ActFilt.HasOdl, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd); - listPOdl2Kit = await MDService.POdlToKitListGetFiltAsync(ActFilt.HasOdl, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd, true, false); + listPOdl2Kit = await MDService.POdlToKitListGetFiltAsync(false, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd, true, false); listWSM = await MDService.WipKitFiltAsync(keyFilt); listTSM = await MDService.TksScoreAsync(keyFilt, 1000, true); listIKP = await MDService.IstKitFiltAsync("", ""); diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 7829be22..1acb3e2e 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2606.1210 + 8.16.2606.1215 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 2b2553ba..1c6099d6 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                          Versione: 8.16.2606.1210

                          +

                          Versione: 8.16.2606.1215


                          Note di rilascio:
                          • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 96ea4ac5..40249781 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1210 +8.16.2606.1215 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index c252a143..a7d04d9c 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1210 + 8.16.2606.1215 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false From c8632f00d570140ff9145438cebc3cf2a1b8258f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 15:13:26 +0200 Subject: [PATCH 17/28] Fix visualizzazione filtro data ricerche PODL --- MP.SPEC/Components/SelFilterXDL.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MP.SPEC/Components/SelFilterXDL.razor b/MP.SPEC/Components/SelFilterXDL.razor index fd67cd66..0ee83b92 100644 --- a/MP.SPEC/Components/SelFilterXDL.razor +++ b/MP.SPEC/Components/SelFilterXDL.razor @@ -87,7 +87,7 @@
                        } - @if (!isActive || hasOdl) + @if (true || !isActive || hasOdl) {
                        From 295dab2fd9b1c70af6b277bd74b5beed6a0f74fa Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 15:14:16 +0200 Subject: [PATCH 18/28] Rimozione differente cache FusionCache dati --- MP.Data/Services/IOC/IocService.cs | 2 +- MP.IOC/Data/MpDataService.cs | 2 +- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Program.cs | 3 +++ MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/appsettings.json | 24 ++++++++++++++++++++---- 12 files changed, 33 insertions(+), 14 deletions(-) diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index 27cf07d5..5db8d93a 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -100,7 +100,7 @@ namespace MP.Data.Services.IOC return await GetCurrOdlByProdAsync(idxMacchina); }, expiration: GetRandTOut(redisLongTimeCache), - tagList: ["IOC_CurrOdl", cKey, idxMacchina] + tagList: [idxMacchina] ); #if false diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs index 59802944..1d73bb38 100644 --- a/MP.IOC/Data/MpDataService.cs +++ b/MP.IOC/Data/MpDataService.cs @@ -1224,7 +1224,7 @@ namespace MP.IOC.Data cacheKey: $"{Utils.redisOdlList}:Current:{IdxMacchina}", expiration: TimeSpan.FromSeconds(redisShortTimeCache), fetchFunc: async () => (await IocDbController.OdlCurrByMaccAsync(IdxMacchina)) ?? new ODLExpModel(), - tagList: [Utils.redisOdlList] + tagList: [Utils.redisOdlList, IdxMacchina] ); } diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 7049ec52..5f92b4c7 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1210 + 8.16.2606.1212 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 330938ad..d6a97867 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                        Versione: 8.16.2606.1210

                        +

                        Versione: 8.16.2606.1212


                        Note di rilascio:
                        • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 96ea4ac5..c0099cc4 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1210 +8.16.2606.1212 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 36f70f91..978aa6f8 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1210 + 8.16.2606.1212 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 9d41d7d1..d025b198 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1208 + 8.16.2606.1212 InProcess diff --git a/MP.RIOC/Program.cs b/MP.RIOC/Program.cs index fbf3066d..f2fd466a 100644 --- a/MP.RIOC/Program.cs +++ b/MP.RIOC/Program.cs @@ -18,6 +18,9 @@ var logger = LogManager.Setup() .LoadConfigurationFromAppSettings() .GetCurrentClassLogger(); +builder.Logging.ClearProviders(); +builder.Host.UseNLog(); + var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); logger.Info($"MP.RIOC | Program.cs: startup | v.{assemblyVersion}"); logger.Info($"Current ASPNETCORE_ENVIRONMENT: {env.EnvironmentName}"); diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index fd556bd8..192b2593 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

                          Versione: 8.16.2606.1208

                          +

                          Versione: 8.16.2606.1212


                          Note di rilascio:
                          • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index fe6ac8c4..c0099cc4 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1208 +8.16.2606.1212 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index af3135c8..1c07d5fc 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1208 + 8.16.2606.1212 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/appsettings.json b/MP.RIOC/appsettings.json index 958cb8ba..334c3b27 100644 --- a/MP.RIOC/appsettings.json +++ b/MP.RIOC/appsettings.json @@ -3,9 +3,10 @@ "LogLevel": { "Default": "Information", "Yarp": "Debug", - "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Information", + "Microsoft.EntityFrameworkCore.Database.Command": "Warning", "Microsoft.EntityFrameworkCore": "Warning", - "Microsoft.EntityFrameworkCore.Database.Command": "Warning" + "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", @@ -24,7 +25,7 @@ "logfile": { "type": "File", "fileName": "${basedir}/logs/${shortdate}.log", - "keepFileOpen": false, + "keepFileOpen": true, "archiveEvery": "Day", "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", "archiveNumbering": "DateAndSequence", @@ -39,9 +40,24 @@ } }, "rules": [ + { + "logger": "Microsoft.EntityFrameworkCore.*", + "maxLevel": "Info", + "final": true + }, + { + "logger": "Microsoft.AspNetCore.Hosting.*", + "minLevel": "Info", + "finalMinLevel": "Info" + }, + { + "logger": "Microsoft.AspNetCore.*", + "maxLevel": "Info", + "finalMinLevel": "Info" + }, { "logger": "*", - "minLevel": "Trace", + "minLevel": "Info", "writeTo": "logconsole" }, { From 3c42f0ab833a972ff5d08e25b387048b927590b8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 15:23:22 +0200 Subject: [PATCH 19/28] Fix scadenza PODL in compoisizione KIT --- MP.SPEC/Data/MpDataService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 65cee36d..19ead2ec 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1926,7 +1926,7 @@ namespace MP.SPEC.Data return await GetOrFetchAsync( operationName: "TksScoreAsync", cacheKey: currKey, - expiration: TimeSpan.FromMinutes(redisLongTimeCache), + expiration: GetRandTOut(redisLongTimeCache), fetchFunc: async () => await _productionRepository.TksScoreAsync(KeyFilt, MaxResult) ?? new List(), tagList: [Utils.redisKitScore] ); @@ -2016,7 +2016,7 @@ namespace MP.SPEC.Data return await GetOrFetchAsync( operationName: "WipKitFiltAsync", cacheKey: currKey, - expiration: TimeSpan.FromMinutes(redisLongTimeCache), + expiration: GetRandTOut(redisLongTimeCache), fetchFunc: async () => await _productionRepository.WipKitFiltAsync(KeyFilt) ?? new List(), tagList: [Utils.redisKitWip] ); @@ -2035,6 +2035,7 @@ namespace MP.SPEC.Data fatto = await _productionRepository.WipKitUpsertAsync(currRecord); // svuoto cache KitWip await FlushFusionCacheAsync(Utils.redisKitWip); + await FlushFusionCacheAsync(Utils.redisKitScore); activity?.SetTag("data.source", source); activity?.Stop(); LogTrace($"WipKitUpsertAsync | {source} | {activity?.Duration.TotalMilliseconds}ms"); From 1ff5b10a8f8719afee43a6c4e1fdd70a626848a2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 16:58:15 +0200 Subject: [PATCH 20/28] Aggiunto reset forzato x SPEC --- MP.SPEC/Components/CmpTop.razor.cs | 9 +++++++++ MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Pages/ForceReset.razor | 8 ++++++++ MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 6 files changed, 21 insertions(+), 4 deletions(-) diff --git a/MP.SPEC/Components/CmpTop.razor.cs b/MP.SPEC/Components/CmpTop.razor.cs index 2889baca..e7075b5c 100644 --- a/MP.SPEC/Components/CmpTop.razor.cs +++ b/MP.SPEC/Components/CmpTop.razor.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.JSInterop; using MP.AppAuth.Services; +using MP.Data.DbModels; using MP.SPEC.Data; using MP.SPEC.Extensions; @@ -52,6 +53,14 @@ namespace MP.SPEC.Components protected async Task FlushCache() { + + // svuoto cache redis... + ConfigModel updRec = new ConfigModel() + { + Chiave = "AZIENDA", + Valore = "*" + }; + await MDService.ConfigUpdateAsync(updRec); await MDService.ForceFlushRedisCache(); await MDService.ForceFlushFusionCacheAsync(); await ForceReload(); diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 1acb3e2e..ba8925e4 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2606.1215 + 8.16.2606.1216 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/ForceReset.razor b/MP.SPEC/Pages/ForceReset.razor index 3d209938..073e56e3 100644 --- a/MP.SPEC/Pages/ForceReset.razor +++ b/MP.SPEC/Pages/ForceReset.razor @@ -1,4 +1,5 @@ @page "/force-reset" +@page "/ForceReset" @using MP.AppAuth.Services @using MP.SPEC.Data @@ -47,6 +48,13 @@ nextVal = 10; await InvokeAsync(StateHasChanged); await Task.Delay(bDelay); + // svuoto cache redis... + ConfigModel updRec = new ConfigModel() + { + Chiave = "AZIENDA", + Valore = "*" + }; + await MDService.ConfigUpdateAsync(updRec); title = "UserDataReload..."; currVal = 50; nextVal = 80; diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 1c6099d6..c77d7379 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                            Versione: 8.16.2606.1215

                            +

                            Versione: 8.16.2606.1216


                            Note di rilascio:
                            • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 40249781..90643774 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1215 +8.16.2606.1216 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index a7d04d9c..dd7203ef 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1215 + 8.16.2606.1216 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false From 12994c5c7a421f81675b59c55610f9a190c0a06e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 16:58:23 +0200 Subject: [PATCH 21/28] =?UTF-8?q?RIOC:=20update=20verbosit=C3=A0=20x=20tes?= =?UTF-8?q?t=20staging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/RouteManager.cs | 1 - MP.RIOC/appsettings.Development.json | 1 + MP.RIOC/appsettings.Production.json | 1 + MP.RIOC/appsettings.Staging-silent.json | 30 ++++++++++++++++++++++++ MP.RIOC/appsettings.Staging-verbose.json | 24 +++++++++++++++++++ MP.RIOC/appsettings.Staging.json | 30 ++++++++++++++++++++++++ MP.RIOC/appsettings.json | 2 +- 11 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 MP.RIOC/appsettings.Staging-silent.json create mode 100644 MP.RIOC/appsettings.Staging-verbose.json create mode 100644 MP.RIOC/appsettings.Staging.json diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index d025b198..12a3a6a1 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1212 + 8.16.2606.1216 InProcess diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index 192b2593..b0206033 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

                              Versione: 8.16.2606.1212

                              +

                              Versione: 8.16.2606.1216


                              Note di rilascio:
                              • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index c0099cc4..90643774 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1212 +8.16.2606.1216 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index 1c07d5fc..53089d5c 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1212 + 8.16.2606.1216 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/RouteManager.cs b/MP.RIOC/Services/RouteManager.cs index e6961d85..23d45c90 100644 --- a/MP.RIOC/Services/RouteManager.cs +++ b/MP.RIOC/Services/RouteManager.cs @@ -101,7 +101,6 @@ namespace MP.RIOC.Services // commento transformer custom //var error = await _forwarder.SendAsync(context, destBase, _httpClientInvoker, _forwarderConfig, _transformer, context.RequestAborted); - sw.Stop(); _stats.RecordDuration(sKey, sw.Elapsed); diff --git a/MP.RIOC/appsettings.Development.json b/MP.RIOC/appsettings.Development.json index 0c208ae9..d7f9ed43 100644 --- a/MP.RIOC/appsettings.Development.json +++ b/MP.RIOC/appsettings.Development.json @@ -2,6 +2,7 @@ "Logging": { "LogLevel": { "Default": "Information", + "Yarp": "Warning", "Microsoft.AspNetCore": "Warning" } } diff --git a/MP.RIOC/appsettings.Production.json b/MP.RIOC/appsettings.Production.json index 7a752d3d..7910e3ea 100644 --- a/MP.RIOC/appsettings.Production.json +++ b/MP.RIOC/appsettings.Production.json @@ -2,6 +2,7 @@ "Logging": { "LogLevel": { "Default": "Information", + "Yarp": "Warning", "Microsoft.AspNetCore": "Warning" } }, diff --git a/MP.RIOC/appsettings.Staging-silent.json b/MP.RIOC/appsettings.Staging-silent.json new file mode 100644 index 00000000..4bb192f6 --- /dev/null +++ b/MP.RIOC/appsettings.Staging-silent.json @@ -0,0 +1,30 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Yarp": "Warning", + "Microsoft": "Warning", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Warning" + } + }, + "NLog": { + "rules": [ + { + "logger": "Microsoft.*", + "maxLevel": "Fatal", + "final": true + }, + { + "logger": "Yarp.*", + "maxLevel": "Fatal", + "final": true + }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logfile" + } + ] + } +} \ No newline at end of file diff --git a/MP.RIOC/appsettings.Staging-verbose.json b/MP.RIOC/appsettings.Staging-verbose.json new file mode 100644 index 00000000..cdb99149 --- /dev/null +++ b/MP.RIOC/appsettings.Staging-verbose.json @@ -0,0 +1,24 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Yarp": "Warning", + "Microsoft.EntityFrameworkCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Information" + } + }, + "NLog": { + "rules": [ + { + "logger": "Microsoft.AspNetCore.Hosting.Diagnostics", + "maxLevel": "Info", + "finalMinLevel": "Info" + }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logfile" + } + ] + } +} \ No newline at end of file diff --git a/MP.RIOC/appsettings.Staging.json b/MP.RIOC/appsettings.Staging.json new file mode 100644 index 00000000..4bb192f6 --- /dev/null +++ b/MP.RIOC/appsettings.Staging.json @@ -0,0 +1,30 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Yarp": "Warning", + "Microsoft": "Warning", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Hosting.Diagnostics": "Warning" + } + }, + "NLog": { + "rules": [ + { + "logger": "Microsoft.*", + "maxLevel": "Fatal", + "final": true + }, + { + "logger": "Yarp.*", + "maxLevel": "Fatal", + "final": true + }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logfile" + } + ] + } +} \ No newline at end of file diff --git a/MP.RIOC/appsettings.json b/MP.RIOC/appsettings.json index 334c3b27..809c089c 100644 --- a/MP.RIOC/appsettings.json +++ b/MP.RIOC/appsettings.json @@ -2,7 +2,7 @@ "Logging": { "LogLevel": { "Default": "Information", - "Yarp": "Debug", + "Yarp": "Information", "Microsoft.AspNetCore.Hosting.Diagnostics": "Information", "Microsoft.EntityFrameworkCore.Database.Command": "Warning", "Microsoft.EntityFrameworkCore": "Warning", From 5e7016629ac80ad2b2170e21d6b9175b06f1ca62 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 17:58:10 +0200 Subject: [PATCH 22/28] Update POOL di RIOC x testing specifico sotto carico --- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Program.cs | 27 ++++++++++++++++++++++--- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/appsettings.Staging-silent.json | 5 +++++ MP.RIOC/appsettings.Staging.json | 5 +++++ 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 12a3a6a1..2b28390d 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1216 + 8.16.2606.1217 InProcess diff --git a/MP.RIOC/Program.cs b/MP.RIOC/Program.cs index f2fd466a..b122a104 100644 --- a/MP.RIOC/Program.cs +++ b/MP.RIOC/Program.cs @@ -12,8 +12,17 @@ using System.Reflection; var builder = WebApplication.CreateBuilder(args); -// recupero env corrente +// RECUPERO L'AMBIENTE REALE (Che ora IIS passa correttamente come 'Staging') var env = builder.Environment; + +// FORZA IL CARICAMENTO CORRETTO DEI JSON CON LA GERARCHIA DI AMBIENTE +builder.Configuration + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); + +// recupero env corrente var logger = LogManager.Setup() .LoadConfigurationFromAppSettings() .GetCurrentClassLogger(); @@ -60,23 +69,35 @@ builder.Services.AddDbContextFactory(options => builder.Services.AddIocDataLayer(); // 1. Configurazione dell'invoker personalizzato (Risolve i tuoi errori) +// 1. Configurazione dell'invoker personalizzato (Potenziato con il Pooling) var httpClientInvoker = new HttpMessageInvoker(new SocketsHttpHandler { UseProxy = false, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.None, UseCookies = false, - // Correzione per il tracing: usa il propagatore corrente di sistema ActivityHeadersPropagator = DistributedContextPropagator.Current, ConnectTimeout = TimeSpan.FromSeconds(60), - // Gestione certificato (ignora errori per localhost/test) + // ================================================================== + // 🚀 LE TRE RIGHE PER ABBATTERE IL MURO DEI 2 SECONDI SOTTO STRESS + // ================================================================== + // Permette a YARP di aprire fino a 5000 canali paralleli contemporanei verso IIS + MaxConnectionsPerServer = 5000, + + // Tiene caldi i socket ed evita di rifare l'handshake TCP/TLS a ogni richiesta + PooledConnectionLifetime = TimeSpan.FromMinutes(15), + PooledConnectionIdleTimeout = TimeSpan.FromMinutes(2), + // ================================================================== + + // Gestione certificato (Invariata) SslOptions = new System.Net.Security.SslClientAuthenticationOptions { RemoteCertificateValidationCallback = (sender, cert, chain, sslPolicyErrors) => true } }); +// Registrazione nella Dependency Injection (Invariata) builder.Services.AddSingleton(httpClientInvoker); builder.Services.AddHttpForwarder(); diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index b0206033..aa4396fe 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

                                Versione: 8.16.2606.1216

                                +

                                Versione: 8.16.2606.1217


                                Note di rilascio:
                                • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index 90643774..d947c970 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1216 +8.16.2606.1217 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index 53089d5c..9512a461 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1216 + 8.16.2606.1217 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/appsettings.Staging-silent.json b/MP.RIOC/appsettings.Staging-silent.json index 4bb192f6..b68fbaa1 100644 --- a/MP.RIOC/appsettings.Staging-silent.json +++ b/MP.RIOC/appsettings.Staging-silent.json @@ -20,6 +20,11 @@ "maxLevel": "Fatal", "final": true }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logconsole" + }, { "logger": "*", "minLevel": "Info", diff --git a/MP.RIOC/appsettings.Staging.json b/MP.RIOC/appsettings.Staging.json index 4bb192f6..b68fbaa1 100644 --- a/MP.RIOC/appsettings.Staging.json +++ b/MP.RIOC/appsettings.Staging.json @@ -20,6 +20,11 @@ "maxLevel": "Fatal", "final": true }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logconsole" + }, { "logger": "*", "minLevel": "Info", From f738c0a6905be6ca0b6161ea8e2a8a240259f364 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 18:34:57 +0200 Subject: [PATCH 23/28] Fix spec: rimanda su pagina 1 al cambio filtro su PODL KIT, fix vari RIOC --- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Program.cs | 4 ++++ MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- MP.RIOC/Services/MetricsDbFlushService.cs | 19 +++++++++++++++++-- MP.RIOC/Services/RouteManager.cs | 12 ++++++++++-- .../Components/ProdKit/GestKitPodl.razor.cs | 1 + MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 12 files changed, 40 insertions(+), 12 deletions(-) diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 2b28390d..3dfd370b 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1217 + 8.16.2606.1218 InProcess diff --git a/MP.RIOC/Program.cs b/MP.RIOC/Program.cs index b122a104..a1f35daf 100644 --- a/MP.RIOC/Program.cs +++ b/MP.RIOC/Program.cs @@ -10,6 +10,10 @@ using System.Diagnostics; using System.Net; using System.Reflection; + +// Forza il ThreadPool a tenere pronti almeno 500 thread per i calcoli e 500 per l'I/O di rete +ThreadPool.SetMinThreads(500, 500); + var builder = WebApplication.CreateBuilder(args); // RECUPERO L'AMBIENTE REALE (Che ora IIS passa correttamente come 'Staging') diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index aa4396fe..5e1d7f8b 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

                                  Versione: 8.16.2606.1217

                                  +

                                  Versione: 8.16.2606.1218


                                  Note di rilascio:
                                  • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index d947c970..d19c598e 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1217 +8.16.2606.1218 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index 9512a461..3ec9a26b 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1217 + 8.16.2606.1218 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs index 56510506..0fde0e93 100644 --- a/MP.RIOC/Services/MetricsDbFlushService.cs +++ b/MP.RIOC/Services/MetricsDbFlushService.cs @@ -33,8 +33,23 @@ namespace MP.RIOC.Services { try { - await ProcessDayLiveMetricsAsync(); - await ProcessHourLiveMetricsAsync(); + //await ProcessDayLiveMetricsAsync(); + //await ProcessHourLiveMetricsAsync(); + + // 2. 🚀 COSTRINGIAMO IL FLUSH A GIRARE IN BACKGROUND + // Task.Run prende l'intera esecuzione e la sposta su un thread separato. + // In questo modo, anche se l'Upsert fa calcoli pesanti o blocca momentaneamente, + // i thread principali di YARP rimangono liberi al 100% di rispondere a wrk in 2ms. + await Task.Run(async () => + { + // Cede immediatamente il controllo per evitare di monopolizzare il thread corrente + await Task.Yield(); + + // Esegue i tuoi due metodi (che manterranno i loro scope interni asincroni) + await ProcessDayLiveMetricsAsync(); + await ProcessHourLiveMetricsAsync(); + }, stoppingToken); + // poi attendo... await Task.Delay(TimeSpan.FromSeconds(interval), stoppingToken); } catch (TaskCanceledException) { break; } diff --git a/MP.RIOC/Services/RouteManager.cs b/MP.RIOC/Services/RouteManager.cs index 23d45c90..26e9994f 100644 --- a/MP.RIOC/Services/RouteManager.cs +++ b/MP.RIOC/Services/RouteManager.cs @@ -98,8 +98,16 @@ namespace MP.RIOC.Services // ESECUZIONE FORWARDING var error = await _forwarder.SendAsync(context, destBase, _httpClientInvoker, _forwarderConfig, HttpTransformer.Default, context.RequestAborted); - // commento transformer custom - //var error = await _forwarder.SendAsync(context, destBase, _httpClientInvoker, _forwarderConfig, _transformer, context.RequestAborted); + // Se YARP fallisce per un problema di connessione interrotta (come l'errore 995) + // e NON è un problema di sintassi della richiesta o di autorizzazione + if (error != ForwarderError.None && + error != ForwarderError.RequestBodyClient && + error != ForwarderError.NoAvailableDestinations) + { + // Fai un secondo e ultimo tentativo immediato prima di dare errore al client + Log.Warn($"Micro-reset di rete rilevato ({error}). Tento il secondo invio immediato..."); + error = await _forwarder.SendAsync(context, destBase, _httpClientInvoker, _forwarderConfig, HttpTransformer.Default, context.RequestAborted); + } sw.Stop(); _stats.RecordDuration(sKey, sw.Elapsed); diff --git a/MP.SPEC/Components/ProdKit/GestKitPodl.razor.cs b/MP.SPEC/Components/ProdKit/GestKitPodl.razor.cs index e15fd13e..4492444f 100644 --- a/MP.SPEC/Components/ProdKit/GestKitPodl.razor.cs +++ b/MP.SPEC/Components/ProdKit/GestKitPodl.razor.cs @@ -169,6 +169,7 @@ namespace MP.SPEC.Components.ProdKit protected async Task toggleClosed() { hasOdl = !hasOdl; + currPage = 1; await EC_HasOdl.InvokeAsync(hasOdl); } diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index ba8925e4..bfdfb22e 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2606.1216 + 8.16.2606.1218 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index c77d7379..d8370644 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                                    Versione: 8.16.2606.1216

                                    +

                                    Versione: 8.16.2606.1218


                                    Note di rilascio:
                                    • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 90643774..d19c598e 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1216 +8.16.2606.1218 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index dd7203ef..924c3e2c 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1216 + 8.16.2606.1218 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false From 826fb75ccda883702e194fbc4d6e480e98625b4d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 Jun 2026 19:24:16 +0200 Subject: [PATCH 24/28] Altro update route... --- MP.RIOC/Services/RouteManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MP.RIOC/Services/RouteManager.cs b/MP.RIOC/Services/RouteManager.cs index 26e9994f..ce661fd0 100644 --- a/MP.RIOC/Services/RouteManager.cs +++ b/MP.RIOC/Services/RouteManager.cs @@ -102,6 +102,7 @@ namespace MP.RIOC.Services // e NON è un problema di sintassi della richiesta o di autorizzazione if (error != ForwarderError.None && error != ForwarderError.RequestBodyClient && + error != ForwarderError.RequestCanceled && error != ForwarderError.NoAvailableDestinations) { // Fai un secondo e ultimo tentativo immediato prima di dare errore al client From a16282ff786e43d827781c39c8ec684138a3f88e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 13 Jun 2026 12:00:56 +0200 Subject: [PATCH 25/28] Update launch settings x test locale IOC da wrs su WSL... 65/70k/sec!!! --- MP.IOC/Controllers/IOBController.cs | 2 +- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Properties/launchSettings.json | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index a90e82b4..6c294a13 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -128,7 +128,7 @@ namespace MP.IOC.Controllers // Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); // return StatusCode(500, "Errore interno del server"); //} - } + } #endif /// diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 5f92b4c7..e7cbe37e 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1212 + 8.16.2606.1311 diff --git a/MP.IOC/Properties/launchSettings.json b/MP.IOC/Properties/launchSettings.json index 3785cec7..fa6dd204 100644 --- a/MP.IOC/Properties/launchSettings.json +++ b/MP.IOC/Properties/launchSettings.json @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7050;http://localhost:5264", + "applicationUrl": "https://*:7050;http://*:5264", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index d6a97867..c7bf384a 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                                      Versione: 8.16.2606.1212

                                      +

                                      Versione: 8.16.2606.1311


                                      Note di rilascio:
                                      • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index c0099cc4..319c82a7 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1212 +8.16.2606.1311 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 978aa6f8..67bdbbc3 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1212 + 8.16.2606.1311 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false From f9a20b2ee94115d967d8765558bfbcd4d0f93f35 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 13 Jun 2026 12:22:47 +0200 Subject: [PATCH 26/28] Rimesso da minimal api a controller metodi --- MP.INVE/MP.INVE.csproj | 2 +- MP.INVE/Resources/ChangeLog.html | 2 +- MP.INVE/Resources/VersNum.txt | 2 +- MP.INVE/Resources/manifest.xml | 2 +- MP.IOC/Controllers/IOBController.cs | 11 ++++------ MP.IOC/Endpoints/IobEndpoints.cs | 32 +++++++++++++++-------------- MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- MP.Land/MP.Land.csproj | 2 +- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- MP.MON/MP.MON.csproj | 2 +- MP.MON/Resources/ChangeLog.html | 2 +- MP.MON/Resources/VersNum.txt | 2 +- MP.MON/Resources/manifest.xml | 2 +- MP.Prog/MP.Prog.csproj | 2 +- MP.Prog/Resources/ChangeLog.html | 2 +- MP.Prog/Resources/VersNum.txt | 2 +- MP.Prog/Resources/manifest.xml | 2 +- MP.RIOC/MP.RIOC.csproj | 2 +- MP.RIOC/Resources/ChangeLog.html | 2 +- MP.RIOC/Resources/VersNum.txt | 2 +- MP.RIOC/Resources/manifest.xml | 2 +- 26 files changed, 45 insertions(+), 46 deletions(-) diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index 37b17e7a..6a3e6044 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 8.16.2606.1117 + 8.16.2606.1312 diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index e2bcff20..4a399a9e 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

                                        Versione: 8.16.2606.1117

                                        +

                                        Versione: 8.16.2606.1312


                                        Note di rilascio:
                                        • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index cb037420..84233792 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1312 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index 57ec3dc9..d7fa5553 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html false diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index 6c294a13..a0276ab4 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -127,7 +127,7 @@ namespace MP.IOC.Controllers //{ // Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); // return StatusCode(500, "Errore interno del server"); - //} + //} } #endif @@ -483,7 +483,6 @@ namespace MP.IOC.Controllers return Ok(actValues); } -#if false /// /// Recupera ODL corrente x macchina: /// GET: IOB/getCurrODL/SIMUL_03 @@ -507,8 +506,7 @@ namespace MP.IOC.Controllers Log.Error(exc, "Errore GetCurrODL | macchina {MachineId}", id); return StatusCode(StatusCodes.Status500InternalServerError, "NO"); } - } -#endif + } /// /// Restituisce la quantità pezzi dell'odl correntemente in lavorazione sulla macchina... @@ -1227,7 +1225,6 @@ namespace MP.IOC.Controllers return Ok(answ); } -#if false /// /// SALVA Counter x macchina restituendo il valore appena inviato o, se mancasse chiave /// redis, valore da DB /// @@ -1258,8 +1255,7 @@ namespace MP.IOC.Controllers return StatusCode(StatusCodes.Status500InternalServerError, "NO"); } return Ok(answ); - } -#endif + } /// /// Salva associazione tra macchina, device IOB chiamante e sue info @@ -1473,6 +1469,7 @@ namespace MP.IOC.Controllers #endregion Public Methods #region Private Fields + private static Logger Log = LogManager.GetCurrentClassLogger(); private IIocService IOCService; diff --git a/MP.IOC/Endpoints/IobEndpoints.cs b/MP.IOC/Endpoints/IobEndpoints.cs index f998de18..b977d971 100644 --- a/MP.IOC/Endpoints/IobEndpoints.cs +++ b/MP.IOC/Endpoints/IobEndpoints.cs @@ -5,6 +5,8 @@ namespace MP.IOC.Endpoints { public static class IobEndpoints { + #region Public Methods + public static void MapIobHighPerformanceEndpoints(this IEndpointRouteBuilder app) { // 1. Root di test base: api/IOB e api/IOB/alive @@ -15,31 +17,24 @@ namespace MP.IOC.Endpoints app.MapGet("api/IOB/enabled/{id}", async (string id, IIocService iocService, HttpContext context) => { if (string.IsNullOrEmpty(id)) - { - context.Response.StatusCode = StatusCodes.Status400BadRequest; - return "Missing ID"; - } + return Results.BadRequest("Missing ID"); try { bool isEnabled = await iocService.IobInsEnabAsync(id); - if (!isEnabled) - { - context.Response.StatusCode = StatusCodes.Status422UnprocessableEntity; - return "NO"; - } - - return "OK"; + return isEnabled + ? Results.Ok("OK") + : Results.UnprocessableEntity("NO"); } catch (Exception ex) { Log.Error(ex, "Errore durante la verifica abilitazione per {Id}", id); - context.Response.StatusCode = StatusCodes.Status500InternalServerError; - return "Errore interno del server"; + return Results.StatusCode(500); } }); +#if false // 3. Metodo: SetCounter (api/IOB/setCounter/{id}?counter=10) // Nota: 'counter' viene letto automaticamente dalla Query String grazie al Model Binding automatico app.MapGet("api/IOB/setCounter/{id}", async (string id, string counter, IIocService iocService, HttpContext context) => @@ -94,7 +89,7 @@ namespace MP.IOC.Endpoints { var odl = await iocService.GetCurrOdlAsync(id); - // Ottimizzazione: Se 'odl' è già una stringa, ritornala direttamente. + // Ottimizzazione: Se 'odl' è già una stringa, ritornala direttamente. // Se è un oggetto o un numero, il C# gestirà l'estrazione. Evitiamo $"{odl}" che alloca memoria inutilmente. return odl?.ToString() ?? string.Empty; } @@ -105,8 +100,15 @@ namespace MP.IOC.Endpoints return "NO"; } }); - +#endif } + + #endregion Public Methods + + #region Private Fields + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } } \ No newline at end of file diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index e7cbe37e..25647da6 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1311 + 8.16.2606.1312 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index c7bf384a..7ed31778 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                                          Versione: 8.16.2606.1311

                                          +

                                          Versione: 8.16.2606.1312


                                          Note di rilascio:
                                          • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 319c82a7..84233792 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1311 +8.16.2606.1312 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 67bdbbc3..6c9ebef2 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1311 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 221e706b..f8824d6e 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net8.0 MP.Land - 8.16.2606.1117 + 8.16.2606.1312 Debug;Release;Debug_LiManDebug en True diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index 7a619745..7e4dedb9 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo Tablet MAPO - DotNet6 -

                                            Versione: 8.16.2606.1117

                                            +

                                            Versione: 8.16.2606.1312


                                            Note di rilascio:
                                              diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index cb037420..84233792 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1312 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index f267ad6d..ed12ccf8 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false diff --git a/MP.MON/MP.MON.csproj b/MP.MON/MP.MON.csproj index 6fd567dd..ba22459c 100644 --- a/MP.MON/MP.MON.csproj +++ b/MP.MON/MP.MON.csproj @@ -6,7 +6,7 @@ enable MP.MON $(AssemblyName.Replace(' ', '_')) - 8.16.2606.1117 + 8.16.2606.1312 diff --git a/MP.MON/Resources/ChangeLog.html b/MP.MON/Resources/ChangeLog.html index a7abc269..b09252cc 100644 --- a/MP.MON/Resources/ChangeLog.html +++ b/MP.MON/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                                              Versione: 8.16.2606.1117

                                              +

                                              Versione: 8.16.2606.1312


                                              Note di rilascio:
                                              • diff --git a/MP.MON/Resources/VersNum.txt b/MP.MON/Resources/VersNum.txt index cb037420..84233792 100644 --- a/MP.MON/Resources/VersNum.txt +++ b/MP.MON/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1312 diff --git a/MP.MON/Resources/manifest.xml b/MP.MON/Resources/manifest.xml index d5837e14..07216334 100644 --- a/MP.MON/Resources/manifest.xml +++ b/MP.MON/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.MON.zip https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html false diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj index 01dcebc8..50d58df9 100644 --- a/MP.Prog/MP.Prog.csproj +++ b/MP.Prog/MP.Prog.csproj @@ -3,7 +3,7 @@ net8.0 MP.Prog - 8.16.2606.1117 + 8.16.2606.1312 True diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html index 75515685..589576a7 100644 --- a/MP.Prog/Resources/ChangeLog.html +++ b/MP.Prog/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

                                                Versione: 8.16.2606.1117

                                                +

                                                Versione: 8.16.2606.1312


                                                Note di rilascio:
                                                  diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt index cb037420..84233792 100644 --- a/MP.Prog/Resources/VersNum.txt +++ b/MP.Prog/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1312 diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml index 114f199e..2faec268 100644 --- a/MP.Prog/Resources/manifest.xml +++ b/MP.Prog/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj index 3dfd370b..d43f29e2 100644 --- a/MP.RIOC/MP.RIOC.csproj +++ b/MP.RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2606.1218 + 8.16.2606.1312 InProcess diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html index 5e1d7f8b..ca5bc7eb 100644 --- a/MP.RIOC/Resources/ChangeLog.html +++ b/MP.RIOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-RIOC -

                                                  Versione: 8.16.2606.1218

                                                  +

                                                  Versione: 8.16.2606.1312


                                                  Note di rilascio:
                                                  • diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt index d19c598e..84233792 100644 --- a/MP.RIOC/Resources/VersNum.txt +++ b/MP.RIOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1218 +8.16.2606.1312 diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml index 3ec9a26b..fd40f4f9 100644 --- a/MP.RIOC/Resources/manifest.xml +++ b/MP.RIOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1218 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html false From 3dfb9171233a8fc1a2b2fe7d01c25cc27c3dc1c9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 13 Jun 2026 12:23:06 +0200 Subject: [PATCH 27/28] Refresh --- MP-TAB3/MP-TAB3.csproj | 2 +- MP-TAB3/Resources/ChangeLog.html | 2 +- MP-TAB3/Resources/VersNum.txt | 2 +- MP-TAB3/Resources/manifest.xml | 2 +- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- MP.Stats/MP.Stats.csproj | 2 +- MP.Stats/Resources/ChangeLog.html | 2 +- MP.Stats/Resources/VersNum.txt | 2 +- MP.Stats/Resources/manifest.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/MP-TAB3/MP-TAB3.csproj b/MP-TAB3/MP-TAB3.csproj index 9bdd0469..65364cf6 100644 --- a/MP-TAB3/MP-TAB3.csproj +++ b/MP-TAB3/MP-TAB3.csproj @@ -3,7 +3,7 @@ net8.0 enable - 8.16.2606.1117 + 8.16.2606.1312 enable MP_TAB3 diff --git a/MP-TAB3/Resources/ChangeLog.html b/MP-TAB3/Resources/ChangeLog.html index a7abc269..b09252cc 100644 --- a/MP-TAB3/Resources/ChangeLog.html +++ b/MP-TAB3/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                                                    Versione: 8.16.2606.1117

                                                    +

                                                    Versione: 8.16.2606.1312


                                                    Note di rilascio:
                                                    • diff --git a/MP-TAB3/Resources/VersNum.txt b/MP-TAB3/Resources/VersNum.txt index cb037420..84233792 100644 --- a/MP-TAB3/Resources/VersNum.txt +++ b/MP-TAB3/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1312 diff --git a/MP-TAB3/Resources/manifest.xml b/MP-TAB3/Resources/manifest.xml index bdbc08e1..4896b650 100644 --- a/MP-TAB3/Resources/manifest.xml +++ b/MP-TAB3/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index bfdfb22e..906a6c6d 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2606.1218 + 8.16.2606.1312 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index d8370644..b09252cc 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

                                                      Versione: 8.16.2606.1218

                                                      +

                                                      Versione: 8.16.2606.1312


                                                      Note di rilascio:
                                                      • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index d19c598e..84233792 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1218 +8.16.2606.1312 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 924c3e2c..ed5dece3 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1218 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index eeaa0c38..d203eefb 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,7 +4,7 @@ net8.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 8.16.2606.1117 + 8.16.2606.1312 true en diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html index 657c6a2c..ef9a814f 100644 --- a/MP.Stats/Resources/ChangeLog.html +++ b/MP.Stats/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

                                                        Versione: 8.16.2606.1117

                                                        +

                                                        Versione: 8.16.2606.1312


                                                        Note di rilascio:
                                                          diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt index cb037420..84233792 100644 --- a/MP.Stats/Resources/VersNum.txt +++ b/MP.Stats/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1117 +8.16.2606.1312 diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml index 7326843d..4401e30e 100644 --- a/MP.Stats/Resources/manifest.xml +++ b/MP.Stats/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1117 + 8.16.2606.1312 https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html false From 3ee34c0300a1412616d250f806581438d923bb70 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 15 Jun 2026 11:23:08 +0200 Subject: [PATCH 28/28] Fix reset cache anche di InsEnabled da reload --- MP.Data/Services/IOC/IocService.cs | 4 +- MP.Data/Services/Utils/IStatsDetailService.cs | 7 + MP.Data/Services/Utils/StatsDetailService.cs | 10 +- MP.IOC/Components/Pages/CallStats.razor.cs | 10 + MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- MP.IOC/refactor_migration.md | 377 ++++++++++++++++++ 9 files changed, 409 insertions(+), 7 deletions(-) create mode 100644 MP.IOC/refactor_migration.md diff --git a/MP.Data/Services/IOC/IocService.cs b/MP.Data/Services/IOC/IocService.cs index 5db8d93a..8669e3e1 100644 --- a/MP.Data/Services/IOC/IocService.cs +++ b/MP.Data/Services/IOC/IocService.cs @@ -152,7 +152,6 @@ namespace MP.Data.Services.IOC // 3. Conversione efficiente da RedisValue a string (evita l'interpolazione $"{val}") string? sRedisVal = val; return IsStringTrue(sRedisVal); - #if false var rKey = MP.Data.Utils.RedKeyDatiMacc(idxMacchina, MpIoNS); var val = await _redisDb.HashGetAsync(rKey, "insEnabled"); @@ -170,7 +169,8 @@ namespace MP.Data.Services.IOC return !string.IsNullOrEmpty(sVal) && (sVal == "1" || sVal.ToLower() == "true"); #endif }, - expiration: GetRandTOut(30), + expiration: GetRandTOut(60), + //expiration: GetRandTOut(30), tagList: ["IOC_IobInsEnab", cKey, idxMacchina] ); } diff --git a/MP.Data/Services/Utils/IStatsDetailService.cs b/MP.Data/Services/Utils/IStatsDetailService.cs index 751f003b..6f84b5af 100644 --- a/MP.Data/Services/Utils/IStatsDetailService.cs +++ b/MP.Data/Services/Utils/IStatsDetailService.cs @@ -63,6 +63,13 @@ namespace MP.Data.Services.Utils /// Task ResetCache(); + /// + /// Forza il reset della cache REDIS x il pattern richiesto + /// + /// + /// + Task ResetCache(string pattern); + /// /// Inserisce o aggiorna in batch le statistiche di dettaglio nel database. /// Opzionalmente elimina i record precedenti nel periodo specificato. diff --git a/MP.Data/Services/Utils/StatsDetailService.cs b/MP.Data/Services/Utils/StatsDetailService.cs index b637b33d..3c10ad2b 100644 --- a/MP.Data/Services/Utils/StatsDetailService.cs +++ b/MP.Data/Services/Utils/StatsDetailService.cs @@ -22,7 +22,7 @@ namespace MP.Data.Services.Utils IConnectionMultiplexer redis, IFusionCache cache, IStatsDetailRepository repo - ) : base(config,cache, redis) + ) : base(config, cache, redis) { _className = "StatsDetail"; _repo = repo; @@ -134,6 +134,14 @@ namespace MP.Data.Services.Utils await ClearCacheAsync($"{_redisBaseKey}:*"); } + /// + public async Task ResetCache(string pattern) + { + // tolgo eventuali ":" finali + pattern = pattern.EndsWith(":") ? pattern.Substring(0, pattern.Length - 1) : pattern; + await ClearCacheAsync($"{pattern}:*"); + } + /// public async Task UpsertManyAsync(List listRecords, bool removeOld) { diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index 427f7037..c8cfbc54 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -14,6 +14,7 @@ namespace MP.IOC.Components.Pages protected override async Task OnInitializedAsync() { + MpIoNS = Config.GetValue("ServerConf:MpIoNS") ?? "MP"; await ReloadData(); } @@ -105,6 +106,9 @@ namespace MP.IOC.Components.Pages [Inject] private IIocService IocService { get; set; } = null!; + [Inject] + private IConfiguration Config { get; set; } = null!; + #endregion Private Properties #region Private Methods @@ -114,8 +118,14 @@ namespace MP.IOC.Components.Pages return currStatSel != null && currStatSel.Title == curKey ? "active" : ""; } + private string MpIoNS = ""; + private async Task DoForceReload() { + // svuoto cache dati IoNS... + var dtMaccKey = Utils.RedKeyDatiMacc("", MpIoNS); + await SDetService.ResetCache(dtMaccKey); + // resto delle cache await SDetService.ResetCache(); await IocService.ClearFusionCache(); DoReset(); diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 25647da6..202183d5 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2606.1312 + 8.16.2606.1511 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 7ed31778..8bf6f1c5 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

                                                          Versione: 8.16.2606.1312

                                                          +

                                                          Versione: 8.16.2606.1511


                                                          Note di rilascio:
                                                          • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 84233792..27bab3be 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.1312 +8.16.2606.1511 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 6c9ebef2..f9e64e4d 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.1312 + 8.16.2606.1511 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.IOC/refactor_migration.md b/MP.IOC/refactor_migration.md new file mode 100644 index 00000000..ab91040a --- /dev/null +++ b/MP.IOC/refactor_migration.md @@ -0,0 +1,377 @@ +# Piano Migrazione MpDataService → IIocService + +> **Obiettivo**: Standardizzare l'accesso dati su `IIocService` (con FusionCache) e pensionare `MpDataService` come service layer principale di `MP.IOC`. +> +> **Strategia**: Ogni metodo `MpDataService` usato dal controller viene migrato in `IocService`. La cache FusionCache avvolge le chiamate Redis/DB con le stesse durate e tag esistenti. I controller usano solo `IIocService`. + +--- + +## Architettura Target + +``` +IOBController + └── IIocService (scoped) + ├── FusionCache (L1 Memory + L2 Redis + L3 DB via tags) + ├── StackExchange.Redis (IDatabase) ← sorgente "live" per dati esterni + └── IIocRepository (scoped) ← DB access +``` + +**Regola chiave**: Redis diretto (scritto da IOB-WIN, altri programmi) resta accessibile via `IDatabase _redisDb` in `IocService`. FusionCache ha una durata equivalente per validare/invalidare coerentemente. + +--- + +## Stato Attuale + +### Minimal APIs — OK + +I 3 endpoint in `IobEndpoints.cs` sono stati puliti e ora contengono solo: +- `GET api/IOB` / `api/IOB/alive` — health check +- `GET api/IOB/enabled/{id}` — usa `await iocService.IobInsEnabAsync(id)` + +I metodi `setCounter` e `getCurrODL` sono stati rimossi (troppo semplici, nel controller bastano). + +### Controller — Misto + +| Usa DService | Usa IOCService | +|---|---| +| ~37 metodi | 5 metodi (`getCounterTCRec`, `getCurrODL`, `setCounter`, `input`, `getTask2Exe` in parte) | + +### MpDataService + +- Registrato come **singleton** in `Program.cs:106` +- Contiene ~80 metodi, molti con accesso Redis diretto senza FusionCache +- `IocService` è **scoped** e usa già FusionCache + +### IocService + +- Eredita da `MP.Data.Services.BaseServ` (contiene `GetOrFetchAsync`) +- 12 metodi pubblici nell'interface +- Usa FusionCache per i metodi più critici (`IobInsEnabAsync`, `GetCurrOdlAsync`, `StatoProdMacchinaAsync`) + +--- + +## Piano di Migrazione — Fasi + +### Fase 0: Preparazione (`IocService` base) + +**File**: `IIocService.cs`, `IocService.cs` + +0.1. `IocService` deve ereditare da `MP.Data.Services.BaseServ` (attuale `IocService` non lo fa) — per accedere a `GetOrFetchAsync` condiviso + +0.2. Aggiunta di `IFusionCache _cache` nel constructor (già presente in `BaseServ`) + +0.3. Verifica: `redisLongTimeCache` e `redisShortTimeCache` usati da `IocService` per le durate FusionCache + +--- + +### Fase 1: Metodi KeepAlive + Task Management + +**Priorità**: Alta — usati da quasi tutti gli altri metodi come precursori. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `ScriviKeepAliveAsync` | ✓ già duplicato in `IocService` | Unificare, aggiungere FusionCache per la check key | +| `AddOptPar4Machine` | → `AddOptPar4Machine` | Redis hash, cache per tag machine | +| `AddTask4Machine` | → `AddTask4Machine` | Redis hash + backup, cache per tag machine | +| `mOptParMacchina` | → `GetOptParMacchina` | Redis hash read | +| `mTaskMacchina` / `mTaskMacchinaAsync` | → `GetTaskMacchina` | Redis hash read | +| `RemTask2ExeMacchinaAsync` | → `RemoveTask2ExeAsync` | Redis hash write + delete | +| `mSavedTaskMacchina` | → `GetSavedTasksMacchina` | Redis hash read | +| `AddCheckTask4Machine` | → `AddCheckTask4Machine` | Redis hash read/write | +| `AddTask4MacListAsync` | → `AddTaskListAsync` | Redis hash batch write | + +**Durata cache**: `redisShortTimeCache` (2 min + jitter) per task hash (dati volatile) +**Tag cache**: `Task:{idxMacchina}`, `OptPar:{idxMacchina}`, `SavedTask:{idxMacchina}` + +--- + +### Fase 2: Metodi Process (INPUT, FLOG, ULOG) + +**Priorità**: Altissima — il cuore del sistema, alto traffico. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `ProcessInputAsync` | → `ProcessInputAsync` | GIÀ in `IocService` ✓ | +| `ProcessFluxLogAsync` | → `ProcessFluxLogAsync` | DB insert + Redis write | +| `ProcessUserLogAsync` | → `ProcessUserLogAsync` | DB insert multi-flux | +| `CheckMicroStatoAsync` | → `CheckMicroStatoAsync` | DB upsert + transizione | +| `scriviRigaEventoAsync` | → `WriteEventRecordAsync` | DB insert | +| `saveSigLogAsync` | → `SaveSignalLogAsync` | DB insert | +| `GetSrvDtEvent` | → `GetServerDateTime` | Pure logic — no cache | +| `ParseEventTime` | → `ParseEventTime` | GIÀ in `IocService` ✓ | +| `preProcInput` | → `PreProcessInput` | Pure logic — no cache | +| `ValidateInputParams` / `ValidateinputParams` | → `ValidateInputParams` | Pure logic — no cache | + +**Durata cache**: Nessuna (scrittura). Tag invalidazione per `MachineData:{idxMacchina}` sui dati che influenzano. +**Tag cache**: `Input:{idxMacchina}`, `FluxLog:{idxMacchina}`, `UserLog:{idxMacchina}`, `MicroStato:{idxMacchina}` + +--- + +### Fase 3: Metodi ODL/PODL + +**Priorità**: Alta — letture frequenti durante produzione. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `GetCurrOdlAsync` | → `GetCurrOdlAsync` | GIÀ in `IocService` ✓ | +| `GetLastOdlAsync` | → `GetLastOdlAsync` | Usare `GetOrFetchAsync` | +| `OdlCurrByMaccAsync` | → `GetCurrentOdlAsync` | Usare `GetOrFetchAsync` | +| `AutoStartOdlAsync` | → `AutoStartOdlAsync` | Complesso — Redis + DB + eventi | +| `FixDailyDossierAsync` | → `FixDailyDossierAsync` | Chiamata batch | +| `OdlAutoDayGenAsync` | → `GenerateDailyOdlAsync` | DB stored procedure | +| `OdlAutoDayGenFullAsync` | → `GenerateDailyOdlFullAsync` | DB stored procedure | +| `POdlGetByKey` | → `GetPodlByKeyAsync` | Usare `GetOrFetchAsync` | +| `POdlGetByMaccArtAsync` | → `GetPodlByMachineAsync` | Usare `GetOrFetchAsync` | + +**Durata cache**: `redisLongTimeCache` (5 min) per ODL/PODL +**Tag cache**: `Odl:{idxMacchina}`, `Podl:{idxMacchina}` + +--- + +### Fase 4: Metodi Contapezzi + +**Priorità**: Alta — traffico continuo. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `pzCounter` | → `GetPzCounterAsync` | Redis StringGet (lettura live) | +| `PzCounterTcAsync` | → `PzCounterTcAsync` | GIÀ in `IocService` ✓ | +| `saveCaricoPezzi` | → `SavePezziCaricoAsync` | Redis StringSet + DB insert | +| `SaveCounterAsync` | → `SaveCounterAsync` | GIÀ in `IocService` ✓ | + +**Durata cache**: `redisShortTimeCache` per counter (dati volatile scritti da IOB esterni) +**Tag cache**: `PzCounter:{idxMacchina}` + +--- + +### Fase 5: Metodi Parametri Macchina + +**Priorità**: Alta — metodo più chiamato (ogni richiesta legge i parametri). + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `MachineParamListAsync` | → `GetMachineParamsAsync` | **CRITICO** — Redis read, aggiungere FusionCache | +| `MachineParamListPendingWriteAsync` | → `GetPendingWriteParamsAsync` | Wrapper su GetMachineParamsAsync | +| `MachineParamListSetAsync` | → `SetMachineParamsAsync` | Redis StringSet | +| `MachineParamUpsertAsync` | → `UpsertMachineParamsAsync` | Redis read + write batch | +| `UpsertCurrObjItemsAsync` | → `UpsertMachineParamsAsync` | Duplicate — unificare con UpsertMachineParamsAsync | + +**Durata cache**: `redisShortTimeCache` (2 min) per parametri macchina — dati scritti da IOB esterni ogni pochi secondi +**Tag cache**: `MachineParams:{idxMacchina}` + +--- + +### Fase 6: Metodi Anagrafica e Lookup + +**Priorità**: Media — dati relativamente statici. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `AnagStatiGetAllAsync` | → `GetAllStatiAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `ArticoliGetLastByMaccAsync` | → `GetLastArticlesByMachineAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `DossierLastByMachAsync` | → `GetLastDossiersByMachineAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `ListValuesFilt` | → `GetListValuesFilteredAsync` | Redis read (duplicare logica FusionCache) | +| `DecNumArtGetFiltAsync` | → `GetDecNumArticoliAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `MacchineGetFilt` | → `GetMachinesFilteredAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `Macchine2SlaveGetAllAsync` | → `GetMachineSlaveMapAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `MacchineRecipeArchive` | → `GetMachineRecipeArchivePathAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `ConfigGetAllAsync` | → `GetAllConfigAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `ConfFluxMach` | → `GetConfFluxByMachineAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | +| `GetArtNumAsync` | → `GetArtNumByCodeAsync` | Interno — wrapper a DecNumArtGetFiltAsync | +| `MseGetAllAsync` | → `GetMachineStateExplAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | + +**Durata cache**: `redisLongTimeCache` (5 min + jitter) +**Tag cache**: `AnagStati`, `Articoli:{idxMacchina}`, `Dossier:{idxMacchina}`, `Config`, `MSE`, `Macchine` + +--- + +### Fase 7: Metodi Configurazione IOB + Redis Diretto + +**Priorità**: Bassa — configurazione manuale, basso traffico. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `SetIobMemMap` | → `SetIobMemMapAsync` | Redis StringSet | +| `SetIobConfYamlAsync` | → `SetIobConfYamlAsync` | Redis StringSet | +| `SaveMachineIobConf` | → `SaveMachineIobConfAsync` | Redis HashSet | +| `SaveMachine2Iob` | → `SaveMachine2IobAsync` | Redis StringSet | +| `SaveDataItemsAsync` | → `SaveDataItemsAsync` | Mongo o DB | +| `GetCurrObjItems` | → `GetMachineParamsAsync` | **Duplicate** — usare Fase 5 | + +--- + +### Fase 8: Metodi Logging e Monitoring + +**Priorità**: Bassa — writing-only, nessun cache. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `AlarmInsertAsync` | → `InsertAlarmLogAsync` | DB insert | +| `RemRebootLogAddAsync` | → `AddRebootLogAsync` | DB insert + Redis flush | +| `WriteEventRecordAsync` (scriviRigaEventoAsync) | → `WriteEventRecordAsync` | DB insert | +| `FluxLogSaveSnapshotAsync` | → `SaveFluxSnapshotAsync` | DB stored procedure | +| `DossierLastByMachResetAsync` | → `ResetDossierCacheAsync` | Redis delete | +| `FluxLogFirstByMachAsync` | → `GetFirstFluxLogsAsync` | GIÀ usa `GetOrFetchAsync` in MpDataService | + +--- + +### Fase 9: Metodi Helper e Internal + +**Priorità**: Bassa — usati internamente. + +| MpDataService | → IocService | NOTE | +|---|---|---| +| `mDatiMacchineAsync` | → `GetMachineDataAsync` | Redis HashGetAll + reset | +| `ResetDatiMacchinaAsync` | → `ResetMachineDataAsync` | Redis transaction batch | +| `StateMachInByKeyAsync` | → `GetStateMachineIngressiAsync` | Redis Hash | +| `resetMSMIAsync` | → `ResetMultiSMIAsync` | Redis Hash write | +| `resetSMIAsync` | → `ResetSMIAsync` | Redis Hash write | +| `ValoreSmiAsync` | → `GetSMIValueAsync` | Redis HashField get | +| `isMulti` | → `IsMultiMachine` | Pure logic | +| `ListMasterAsync` / `ListSlaveAsync` | → `GetMasterListAsync` / `GetSlaveListAsync` | Redis cache | +| `getRandTOut` | → `GetRandomTimeout` | Shared in BaseServ | +| `RedisCountKey`, `RedisDelKey`, `RedisFlushPatternAsync` | → `FlushKeysByPatternAsync` | Admin only | +| `RedisGetHashDictAsync`, `RedisSetHashDictAsync` | → `RedisGet/HashDictAsync` | Wrapper utilities | + +--- + +## Fase 10: Pulizia Controller + +### 10.1. Sostituire `DService` con `IOCService` in `IOBController` + +Cambiare constructor e tutte le chiamate: + +```csharp +// PRIMA +public IOBController(IConfiguration configuration, MpDataService DataService, IIocService IService) +{ + DService = DataService; + IOCService = IService; +} + +// DOPO +public IOBController(IIocService service) +{ + _service = service; +} +``` + +Poi sostituire ogni `DService.Xxx(...)` con `_service.Xxx(...)`. + +### 10.2. Rimuovere `MpDataService` dal controller + +- Rimuovere la property `DService` +- Rimuovere il parametro dal constructor +- Unificare le chiamate miste (alcuni metodi fanno `DService.ScriviKeepAliveAsync` + `IOCService.Xxx`) + +### 10.3. Spostare i private method in `IocService` + +I metodi `processEvListJsonAsync`, `processFLogJsonAsync`, `processULogJsonAsync` contengono logica di business: + +- `processEvListJsonAsync` → `ProcessEventListJsonAsync` in `IocService` +- `processFLogJsonAsync` → `ProcessFluxLogJsonAsync` in `IocService` (complesso — usa `MachineParamListAsync` + `UpsertCurrObjItemsAsync`) +- `processULogJsonAsync` → `ProcessUserLogJsonAsync` in `IocService` + +### 10.4. Rimuovere `MpDataService` da `Program.cs` + +```csharp +// RIMUOVERE: +// builder.Services.AddSingleton(); +``` + +--- + +## Riepilogo Metodi da Migrire + +| Categoria | Metodi da aggiungere a IocService | +|---|---| +| KeepAlive + Task | ~9 metodi | +| Process (INPUT/FLOG/ULOG) | ~9 metodi | +| ODL/PODL | ~8 metodi | +| Contapezzi | ~3 metodi | +| Parametri Macchina | ~4 metodi | +| Anagrafica/Lookup | ~11 metodi | +| Config IOB | ~5 metodi | +| Logging | ~6 metodi | +| Helper/Internal | ~10 metodi | +| **TOTALE** | **~65 metodi** | + +Di questi, ~15 sono già in `IocService` o `BaseServ`. Quindi **~50 nuovi metodi** da implementare. + +--- + +## Criteri di Validazione + +1. **Build** — `./build_all_par.ps1 --agent` senza errori +2. **Functional parity** — ogni endpoint del controller restituisce lo stesso output di prima +3. **Cache behavior** — i metodi migrati registrano `data.source` come TRACE/DEBUG +4. **No `MpDataService` references** nel controller +5. **`Program.cs`** — `MpDataService` rimosso dalla DI registration + +--- + +## Sequenza di Sviluppo Consigliata + +``` +Fase 1 → Fase 4: Blocchi "hot" (keepalive, task, counter) +Fase 5: Parametri macchina (blocco più critico per perf) +Fase 2: Process (INPUT/FLOG/ULOG - cuore dell'app) +Fase 3: ODL/PODL +Fase 6: Anagrafica (dati statici, meno rischioso) +Fase 7-9: Config + Logging + Helper +Fase 10: Cleanup finale +``` + +Ogni fase va build-ata e testata prima di procedere alla successiva. + +--- + +## Note Tecniche + +### Caching su Redis diretto + +Per i dati scritti da programmi esterni (IOB-WIN, ecc.), il pattern è: + +``` +1. Lettura: _redisDb.StringGet/HashGet (dati "live") +2. Scrittura: programmi esterni scrivono in Redis direttamente +3. FusionCache: durata pari a redisShortTimeCache o redisLongTimeCache + - Il backplane Redis invalida L1 negli altri worker + - Se un programma esterno scrive, la prossima lettura dal controller fa cache-miss +``` + +Questo è coerente con l'architettura attuale: il controller legge Redis (sorgente di verità) e FusionCache avvolge per ridurre i round-trip. + +### Tagging Strategy + +``` +MachineData:{idxMacchina} — dati macchina generali (ResetDatiMacchina) +MachineParams:{idxMacchina} — parametri macchina (MachineParamListAsync) +Task:{idxMacchina} — task da eseguire +PzCounter:{idxMacchina} — contapezzi +Odl:{idxMacchina} — ODL correnti +Podl:{idxMacchina} — PODL +Input:{idxMacchina} — log input +FluxLog:{idxMacchina} — log flux +UserLog:{idxMacchina} — log user +``` + +### Transizioni di Scope + +`MpDataService` è singleton → `IIocService` è scoped. Questo va bene per le minimal APIs (che iniettano `IIocService` correttamente). Per il controller, dopo la rimozione di `MpDataService`, il controller diventerà scoped di default (già lo è per `[ApiController]`). + +### IocService constructor + +Attuale (da `MP.Data.Services.IOC.IocService`): +```csharp +public IocService(IConfiguration config, IConnectionMultiplexer redis, + IFusionCache cache, IIocRepository repo, + IServiceScopeFactory scopeFactory) +``` + +Da `MP.Data.Services.BaseServ`: +```csharp +public BaseServ(IConfiguration configuration, IFusionCache cache, IConnectionMultiplexer redConn) +``` + +La gerarchia sarà: `IocService` estende `BaseServ` e il constructor chiama `base(configuration, cache, redConn)`.