diff --git a/MP-TAB3/MP-TAB3.csproj b/MP-TAB3/MP-TAB3.csproj
index 6bdd5336..a9d0c0cd 100644
--- a/MP-TAB3/MP-TAB3.csproj
+++ b/MP-TAB3/MP-TAB3.csproj
@@ -3,7 +3,7 @@
net8.0
enable
- 8.16.2606.2013
+ 8.16.2606.2208
enable
MP_TAB3
diff --git a/MP-TAB3/Resources/ChangeLog.html b/MP-TAB3/Resources/ChangeLog.html
index f7877962..5711f4d3 100644
--- a/MP-TAB3/Resources/ChangeLog.html
+++ b/MP-TAB3/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOSPEC
- Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
-
diff --git a/MP-TAB3/Resources/VersNum.txt b/MP-TAB3/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP-TAB3/Resources/VersNum.txt
+++ b/MP-TAB3/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP-TAB3/Resources/manifest.xml b/MP-TAB3/Resources/manifest.xml
index e51c280e..674d8a6c 100644
--- a/MP-TAB3/Resources/manifest.xml
+++ b/MP-TAB3/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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.RIOC/Services/IWeightProvider.cs b/MP.Data/Services/RouteWeight/IWeightProvider.cs
similarity index 88%
rename from MP.RIOC/Services/IWeightProvider.cs
rename to MP.Data/Services/RouteWeight/IWeightProvider.cs
index b18e4fcb..aa28bda4 100644
--- a/MP.RIOC/Services/IWeightProvider.cs
+++ b/MP.Data/Services/RouteWeight/IWeightProvider.cs
@@ -1,6 +1,8 @@
using MP.Core.DTO;
+using System.Collections.Generic;
+using System.Threading.Tasks;
-namespace MP.RIOC.Services
+namespace MP.Data.Services.RouteWeight
{
public interface IWeightProvider
{
@@ -26,4 +28,4 @@ namespace MP.RIOC.Services
#endregion Public Methods
}
-}
+}
\ No newline at end of file
diff --git a/MP.RIOC/Services/InMemoryWeightProvider.cs b/MP.Data/Services/RouteWeight/InMemoryWeightProvider.cs
similarity index 82%
rename from MP.RIOC/Services/InMemoryWeightProvider.cs
rename to MP.Data/Services/RouteWeight/InMemoryWeightProvider.cs
index f4baf415..16f022b6 100644
--- a/MP.RIOC/Services/InMemoryWeightProvider.cs
+++ b/MP.Data/Services/RouteWeight/InMemoryWeightProvider.cs
@@ -1,13 +1,15 @@
-using MP.Core.DTO;
+using Microsoft.Extensions.Configuration;
+using MP.Core.DTO;
+using System;
using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Threading.Tasks;
-namespace MP.RIOC.Services
+namespace MP.Data.Services.RouteWeight
{
public class InMemoryWeightProvider : IWeightProvider
{
- private readonly ConcurrentDictionary _map = new();
- private readonly int _defaultOld;
- private readonly int _defaultNew;
+ #region Public Constructors
public InMemoryWeightProvider(IConfiguration config)
{
@@ -15,16 +17,9 @@ namespace MP.RIOC.Services
_defaultNew = config.GetValue("RouteMan:DefaultWeightNew", 0);
}
- public (int oldWeight, int newWeight) GetWeightsFor(string method)
- {
- if (string.IsNullOrEmpty(method)) method = "unknown";
- return _map.GetOrAdd(method, _ => (_defaultOld, _defaultNew));
- }
+ #endregion Public Constructors
- public void SetWeights(string method, int oldWeight, int newWeight)
- {
- _map[method] = (Math.Clamp(oldWeight, 0, 100), Math.Clamp(newWeight, 0, 100));
- }
+ #region Public Methods
public async Task
> GetAllWeightsAsync()
{
@@ -43,6 +38,17 @@ namespace MP.RIOC.Services
return result;
}
+ public (int oldWeight, int newWeight) GetWeightsFor(string method)
+ {
+ if (string.IsNullOrEmpty(method)) method = "unknown";
+ return _map.GetOrAdd(method, _ => (_defaultOld, _defaultNew));
+ }
+
+ public void SetWeights(string method, int oldWeight, int newWeight)
+ {
+ _map[method] = (Math.Clamp(oldWeight, 0, 100), Math.Clamp(newWeight, 0, 100));
+ }
+
public bool UpsertWeight(WeightDTO updRecord)
{
if (updRecord == null || string.IsNullOrEmpty(updRecord.Method))
@@ -52,5 +58,15 @@ namespace MP.RIOC.Services
return true;
}
+
+ #endregion Public Methods
+
+ #region Private Fields
+
+ private readonly int _defaultNew;
+ private readonly int _defaultOld;
+ private readonly ConcurrentDictionary _map = new();
+
+ #endregion Private Fields
}
-}
+}
\ No newline at end of file
diff --git a/MP.RIOC/Services/RedisWeightProvider.cs b/MP.Data/Services/RouteWeight/RedisWeightProvider.cs
similarity index 96%
rename from MP.RIOC/Services/RedisWeightProvider.cs
rename to MP.Data/Services/RouteWeight/RedisWeightProvider.cs
index 4b313397..91caa478 100644
--- a/MP.RIOC/Services/RedisWeightProvider.cs
+++ b/MP.Data/Services/RouteWeight/RedisWeightProvider.cs
@@ -1,8 +1,13 @@
-using MP.Core.DTO;
+using Microsoft.Extensions.Configuration;
+using MP.Core.DTO;
using StackExchange.Redis;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
using ZiggyCreatures.Caching.Fusion;
-namespace MP.RIOC.Services
+namespace MP.Data.Services.RouteWeight
{
public class RedisWeightProvider : IWeightProvider
{
@@ -36,7 +41,6 @@ namespace MP.RIOC.Services
if (string.IsNullOrEmpty(method)) return;
var cacheKey = $"weights:{method}";
-
// Rimuove la chiave dalla RAM (L1) dell'istanza corrente del Gateway
_cache.Remove(cacheKey);
}
@@ -174,7 +178,7 @@ namespace MP.RIOC.Services
new HashEntry("new", Math.Clamp(newWeight,0,100))
});
- // 2. 🚀 COORDINAZIONE: Rimuovi la chiave da FusionCache.
+ // 2. Rimozione della chiave da FusionCache.
// Grazie al Backplane Pub/Sub, la RAM verrà azzerata istantaneamente su TUTTI i server.
var cacheKey = $"weights:{method}";
_cache.Remove(cacheKey);
@@ -192,7 +196,7 @@ namespace MP.RIOC.Services
new HashEntry("new", Math.Clamp(updRecord.NewWeight, 0, 100))
});
- // 2. 🚀 COORDINAZIONE: Rimuovi la chiave da FusionCache.
+ // 2. Rimozione della chiave da FusionCache.
// Grazie al Backplane Pub/Sub, la RAM verrà azzerata istantaneamente su TUTTI i server.
var cacheKey = $"weights:{updRecord.Method}";
_cache.Remove(cacheKey);
diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj
index 7b13a96d..ab3c2e4a 100644
--- a/MP.INVE/MP.INVE.csproj
+++ b/MP.INVE/MP.INVE.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.INVE
- 8.16.2606.2013
+ 8.16.2606.2208
diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html
index c5a58374..60dd4771 100644
--- a/MP.INVE/Resources/ChangeLog.html
+++ b/MP.INVE/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOINVE
- Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
-
diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.INVE/Resources/VersNum.txt
+++ b/MP.INVE/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml
index bacbd8ca..c735c0e1 100644
--- a/MP.INVE/Resources/manifest.xml
+++ b/MP.INVE/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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/Components/Pages/RouteConf.razor.cs b/MP.IOC/Components/Pages/RouteConf.razor.cs
index 35822888..d3547469 100644
--- a/MP.IOC/Components/Pages/RouteConf.razor.cs
+++ b/MP.IOC/Components/Pages/RouteConf.razor.cs
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Core.DTO;
-using MP.IOC.Services;
+using MP.Data.Services.RouteWeight;
namespace MP.IOC.Components.Pages
{
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index 08ae3f75..a0c478a1 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,9 +4,16 @@
net8.0
enable
enable
- 8.16.2606.2013
+ 8.16.2606.2208
+
+
+
+
+
+
+
@@ -57,6 +64,7 @@
+
diff --git a/MP.IOC/Program.cs b/MP.IOC/Program.cs
index 248374be..bba091a0 100644
--- a/MP.IOC/Program.cs
+++ b/MP.IOC/Program.cs
@@ -4,10 +4,10 @@ using Microsoft.Extensions.Caching.Distributed;
using Microsoft.OpenApi.Models;
using MP.Core.Conf;
using MP.Data;
+using MP.Data.Services.RouteWeight;
using MP.IOC.Components;
using MP.IOC.Data;
using MP.IOC.Endpoints;
-using MP.IOC.Services;
using NLog;
using NLog.Web;
using StackExchange.Redis;
@@ -124,9 +124,6 @@ builder.Services.AddFusionCache()
// Jitter: variazione casuale alla scadenza per evitare scadenze in blocco
options.JitterMaxDuration = TimeSpan.FromSeconds(5);
});
-//// 3. LA RIGA MAGICA: Estrae l'istanza nominata e la mappa come IFusionCache standard
-//builder.Services.AddSingleton(sp =>
-// sp.GetRequiredService().GetCache("MAPO_MES_FusionCache"));
// aggiunta http client x chiamare REST esterne (reset cache su RIOC, in attesa fix fusionCache)
builder.Services.AddHttpClient();
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index d0fe27de..2c7ed97b 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
-
Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index f159aea0..040331cc 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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/Services/BaseServ.cs b/MP.IOC/Services/BaseServ.cs
deleted file mode 100644
index a5420f14..00000000
--- a/MP.IOC/Services/BaseServ.cs
+++ /dev/null
@@ -1,372 +0,0 @@
-using MP.Data;
-using Newtonsoft.Json;
-using NLog;
-using StackExchange.Redis;
-using System.Collections.Concurrent;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-
-namespace MP.IOC.Services
-{
-
- ///
- /// Classe base per i servizi che fornisce funzionalità comuni come
- /// - connessione a Redis
- /// - configurazione
- /// - gestione dei messaggi
- /// - strategie di caching.
- ///
- /// Questa classe agisce come modello per altri servizi derivati.
- ///
- public class BaseServ
- {
- #region Public Constructors
-
- ///
- /// Inizializza una nuova istanza della classe BaseServ.
- /// Configura la connessione Redis, carica le impostazioni di configurazione e inizializza il serializzatore JSON.
- ///
- /// Oggetto di configurazione per recuperare le impostazioni dell'applicazione.
- /// Multiplexer di connessione Redis per operazioni sul database.
- public BaseServ(IConfiguration Configuration, IConnectionMultiplexer RedisConn)
- {
- _config = Configuration;
- _redisConn = RedisConn;
- _redisDb = _redisConn.GetDatabase();
- // configuro la base key x la cache Redis, con verifica contenga Cache finale
- _redisBaseKey = _config.GetValue("ServerConf:RedisBaseKey") ?? "Lux:Cache";
- // aggiungo cache se non finisse per ":cache"
- if (!_redisBaseKey.EndsWith(":Cache"))
- {
- _redisBaseKey += ":Cache";
- }
-
- // Configurazione serializzatore JSON per risolvere errore di loop circolare
- JSSettings = new JsonSerializerSettings()
- {
- ReferenceLoopHandling = ReferenceLoopHandling.Ignore
- };
- }
-
- #endregion Public Constructors
-
- #region Public Properties
-
- ///
- /// Pipe dei messaggi per la comunicazione riguardo update calcolo BOM
- ///
- public MessagePipe PipeBom { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno HwList da Engine di calcolo verso interfaccia utente.
- /// I messaggi vengono inviati sul canale Redis definito da ChannelHwList.
- ///
- public MessagePipe PipeHwList { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno HwOptions calcolate da Engine di calcolo verso interfaccia utente.
- /// I messaggi vengono inviati sul canale Redis definito da ChannelHwOpt.
- ///
- public MessagePipe PipeHwOpt { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno PNG calcolati da Engine di calcolo verso interfaccia utente.
- /// I messaggi vengono inviati sul canale Redis definito da ChannelPng.
- ///
- public MessagePipe PipePng { get; set; } = null!;
-
- ///
- /// Canale informazioni relativo ad attività relative alla gesitone PROD:
- /// - carico macchine
- /// - scheduling
- ///
- public MessagePipe PipeProd { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno info elementi del profile
- ///
- public MessagePipe PipeProfElement { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno ProfileListAsync calcolate da Engine di calcolo verso interfaccia utente.
- /// I messaggi vengono inviati sul canale Redis definito da ChannelProfList.
- ///
- public MessagePipe PipeProfList { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno Shape calcolate da Engine di calcolo verso interfaccia utente.
- /// I messaggi vengono inviati sul canale Redis definito da ChannelShape.
- ///
- public MessagePipe PipeShape { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per ritorno SVG calcolati da Engine di calcolo verso interfaccia utente.
- /// I messaggi vengono inviati sul canale Redis definito da ChannelSvg.
- ///
- public MessagePipe PipeSvg { get; set; } = null!;
-
- ///
- /// Pipe dei messaggi per la comunicazione riguardo update generico UI
- ///
- public MessagePipe PipeUpdate { get; set; } = null!;
-
- #endregion Public Properties
-
- #region Protected Fields
-
- ///
- /// Oggetto per collezione dati Activity (span in Uptrace)
- ///
- protected static readonly ActivitySource ActivitySource = new ActivitySource("Lux.DATA");
-
- ///
- /// Oggetto logger utilizzato per registrare eventi e errori a livello di classe.
- /// Utile per il monitoraggio del comportamento dell'applicazione e la risoluzione di problemi.
- ///
- protected static Logger Log = LogManager.GetCurrentClassLogger();
-
- ///
- /// Oggetto di configurazione statico per accedere alle impostazioni dell'applicazione (es. stringhe di connessione).
- /// Condiviso tra tutte le istanze di BaseServ.
- ///
- protected readonly IConfiguration _config = null!;
-
- ///
- /// Path base chiavi REDIS
- ///
- protected readonly string _redisBaseKey = "Lux:Cache";
-
- ///
- /// Oggetto per la connessione a Redis utilizzato per operazioni di lettura/scrittura.
- ///
- protected readonly IConnectionMultiplexer _redisConn = null!;
-
- ///
- /// Database Redis utilizzato per le operazioni di lettura/scrittura
- /// nb: ottenuto tramite _redisConn.GetDatabase()
- ///
- protected readonly IDatabase _redisDb = null!;
-
- ///
- /// Abilitazione operazioni tracing generiche
- ///
- protected readonly bool _traceEnabled = false;
-
- ///
- /// Impostazioni del serializzatore JSON utilizzato per gestire oggetti con riferimenti circolari
- /// (es. oggetti che si fanno riferimento reciprocamente).
- ///
- protected JsonSerializerSettings? JSSettings;
-
- #endregion Protected Fields
-
- #region Protected Properties
-
- ///
- /// Durata della cache breve (circa 1 minuto + variazione del +/-10%)
- ///
- protected TimeSpan FastCache
- {
- get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000);
- }
-
- ///
- /// Durata della cache lunga (+ variazione del +/-10%)
- ///
- protected TimeSpan LongCache
- {
- get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000);
- }
-
- ///
- /// Durata della cache molto breve (circa 10 secondi + variazione del +/-10%)
- ///
- protected TimeSpan UltraFastCache
- {
- get => TimeSpan.FromSeconds(cacheTtlShort / 6 * rnd.Next(900, 1100) / 1000);
- }
-
- ///
- /// Durata della cache molto lunga (+ variazione del +/-10%)
- ///
- protected TimeSpan UltraLongCache
- {
- get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000);
- }
-
- #endregion Protected Properties
-
- #region Protected Methods
-
- ///
- /// Helper avvio attività per la funzione tracciata
- ///
- ///
- ///
- protected static Activity? StartActivity([CallerMemberName] string? methodName = null)
- {
- var activity = ActivitySource.StartActivity(methodName ?? "UNDEF");
- activity?.SetTag("host.name", Environment.MachineName);
- return activity;
- }
-
- ///
- /// Invalida una o più chiavi/pattern in Redis
- ///
- protected async Task ClearCacheAsync(params string[] patterns)
- {
- foreach (var pattern in patterns)
- {
- // Chiamata al tuo metodo esistente
- await ExecFlushRedisPatternAsync((RedisValue)pattern);
- }
- }
-
- ///
- /// Metodo di flush dati cache Redis
- ///
- ///
- ///
- protected async Task ExecFlushRedisPatternAsync(RedisValue pattern)
- {
- // Qui inserisci la tua logica attuale (es. via Lua script o Keys/Scan)
- // Esempio rapido via server scan:
- var endpoints = _redisConn.GetEndPoints();
- foreach (var endpoint in endpoints)
- {
- var server = _redisConn.GetServer(endpoint);
- await foreach (var key in server.KeysAsync(_redisDb.Database, pattern))
- {
- await _redisDb.KeyDeleteAsync(key);
- }
- }
- }
-
- ///
- /// Helper generale di lettura da cache o da funzione (DB) con caching successivo
- ///
- ///
- ///
- ///
- ///
- ///
- protected async Task GetOrSetCacheAsync(string key, Func> factory, TimeSpan? expiration = null, [CallerMemberName] string? caller = null)
- {
- using var activity = StartActivity();
- string source = "DB";
-
- // 1. Provo Redis
- var cached = await _redisDb.StringGetAsync(key);
- if (cached.HasValue)
- {
- source = "REDIS";
- var cachedResult = JsonConvert.DeserializeObject(cached!)!;
-
- activity?.SetTag("data.source", source);
- LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms", NLog.LogLevel.Trace, caller);
-
- return cachedResult;
- }
-
- // 2. Chiamo il factory (DB)
- T result = await factory();
-
- if (result != null)
- {
- // 3. Salva in Redis per la prossima volta
- var serialized = JsonConvert.SerializeObject(result, JSSettings);
- await _redisDb.StringSetAsync(key, serialized, expiration ?? LongCache);
- }
-
- // sistemo activity tracking data
- activity?.SetTag("data.source", source);
- activity?.Stop();
-
- // log in console
- LogTrace($"GetOrSetCacheAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds:N3}ms", NLog.LogLevel.Trace, caller);
-
- return result!;
- }
-
- ///
- /// Helper trace messaggio log (SE abilitato)
- ///
- ///
- ///
- ///
- protected void LogTrace(string traceMsg, NLog.LogLevel? reqLevel = null, [CallerMemberName] string? methodName = null)
- {
- if (!_traceEnabled)
- return;
-
- reqLevel ??= NLog.LogLevel.Debug;
-
- // Loggo!
- Log.Log(reqLevel, $"{methodName} | {traceMsg}");
- }
-
- ///
- /// Helper generale per la telemetria e gestione eccezioni
- ///
- ///
- ///
- ///
- ///
- ///
- protected async Task TraceAsync(string name, Func> body, object? parameters = null)
- {
- using var activity = ActivitySource.StartActivity(name);
- try
- {
- if (parameters != null)
- {
- activity?.SetTag("params", JsonConvert.SerializeObject(parameters));
- }
- var result = await body(activity);
- activity?.SetStatus(ActivityStatusCode.Ok);
- activity?.Stop();
- LogTrace($"TraceAsync | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms", methodName: name);
- return result;
- }
- catch (Exception ex)
- {
- activity?.SetStatus(ActivityStatusCode.Error, ex.Message);
- //Log.Error(ex, "Errore in {MethodName}", name);
- LogTrace($"Errore in {name}", NLog.LogLevel.Error, name);
- throw; // Riesponi l'eccezione per il tracking globale
- }
- }
-
- #endregion Protected Methods
-
- #region Private Fields
-
- private static readonly ConcurrentDictionary _locks = new();
-
- ///
- /// Durata della cache lunga in secondi (predefinito: 5 minuti)
- /// Utilizzato nella proprietà LongCache per definire quanto a lungo i dati devono essere memorizzati in cache.
- ///
- private int cacheTtlLong = 60 * 5;
-
- ///
- /// Durata della cache breve in secondi (predefinito: 1 minuto)
- /// Utilizzato nelle proprietà FastCache e UltraFastCache per definire la durata della cache breve.
- ///
- private int cacheTtlShort = 60 * 1;
-
-
- ///
- /// Generatore di numeri casuali utilizzato per introdurre variabilità dinamica nelle durate della cache
- /// (simula variazioni reali nella freschezza dei dati e nei tempi di scadenza).
- ///
- private Random rnd = new Random();
-
- #endregion Private Fields
-
- #region Private Methods
-
-
- #endregion Private Methods
- }
-}
diff --git a/MP.IOC/Services/IWeightProvider.cs b/MP.IOC/Services/IWeightProvider.cs
deleted file mode 100644
index a2fc5a6c..00000000
--- a/MP.IOC/Services/IWeightProvider.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using MP.Core.DTO;
-
-namespace MP.IOC.Services
-{
- public interface IWeightProvider
- {
- #region Public Methods
-
- ///
- /// Ritorna l'intero elenco dei weight attivi nel formato WeightDTO
- ///
- ///
- Task
> GetAllWeightsAsync();
-
-#if false
- ///
- /// Ritorna la coppia (oldWeight, newWeight) per scegliere dove instradare il metodo tra i 2 sistemi API.
- ///
- (int oldWeight, int newWeight) GetWeightsFor(string method);
-#endif
-
- ///
- /// Aggiorna/Aggiuinge il valore del weight richiesto
- ///
- ///
- ///
- bool UpsertWeight(WeightDTO updRecord);
-
- #endregion Public Methods
- }
-}
\ No newline at end of file
diff --git a/MP.IOC/Services/InMemoryWeightProvider.cs b/MP.IOC/Services/InMemoryWeightProvider.cs
deleted file mode 100644
index 30ebd212..00000000
--- a/MP.IOC/Services/InMemoryWeightProvider.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using MP.Core.DTO;
-using System.Collections.Concurrent;
-
-namespace MP.IOC.Services
-{
-
- public class InMemoryWeightProvider : IWeightProvider
- {
- private readonly ConcurrentDictionary _map = new();
- private readonly int _defaultOld;
- private readonly int _defaultNew;
-
- public InMemoryWeightProvider(IConfiguration config)
- {
- _defaultOld = config.GetValue("RouteMan:DefaultWeightOld", 100);
- _defaultNew = config.GetValue("RouteMan:DefaultWeightNew", 0);
- }
-
-#if false
- public (int oldWeight, int newWeight) GetWeightsFor(string method)
- {
- if (string.IsNullOrEmpty(method)) method = "unknown";
- return _map.GetOrAdd(method, _ => (_defaultOld, _defaultNew));
- }
-#endif
-
- public void SetWeights(string method, int oldWeight, int newWeight)
- {
- _map[method] = (Math.Clamp(oldWeight, 0, 100), Math.Clamp(newWeight, 0, 100));
- }
-
- public async Task> GetAllWeightsAsync()
- {
- var result = new List();
- await Task.Delay(1);
-
- foreach (var kvp in _map)
- {
- result.Add(new WeightDTO
- {
- Method = kvp.Key,
- OldWeight = Math.Clamp(kvp.Value.oldW, 0, 100),
- NewWeight = Math.Clamp(kvp.Value.newW, 0, 100)
- });
- }
- return result;
- }
-
- public bool UpsertWeight(WeightDTO updRecord)
- {
- if (updRecord == null || string.IsNullOrEmpty(updRecord.Method))
- return false;
-
- _map[updRecord.Method] = (Math.Clamp(updRecord.OldWeight, 0, 100), Math.Clamp(updRecord.NewWeight, 0, 100));
-
- return true;
- }
- }
-
-
-}
diff --git a/MP.IOC/Services/RedisWeightProvider.cs b/MP.IOC/Services/RedisWeightProvider.cs
deleted file mode 100644
index 1a4f8f5e..00000000
--- a/MP.IOC/Services/RedisWeightProvider.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-using MP.Core.DTO;
-using NLog;
-using StackExchange.Redis;
-using ZiggyCreatures.Caching.Fusion;
-
-namespace MP.IOC.Services
-{
- public class RedisWeightProvider : IWeightProvider
- {
- #region Public Constructors
-
- public RedisWeightProvider(
- IConnectionMultiplexer mux,
- IFusionCache cache,
- IHttpClientFactory httpClientFactory,
- IConfiguration config)
- {
- _cache = cache;
- _config = config;
- _httpClientFactory = httpClientFactory;
- _db = mux.GetDatabase();
- _mux = mux;
- _defaultOld = config.GetValue("RouteMan:DefaultWeightOld", 100);
- _defaultNew = config.GetValue("RouteMan:DefaultWeightNew", 0);
- _redisBaseKey = config.GetValue("ServerConf:RedisBaseKey") ?? "MP_IOC";
- // Leggiamo l'URL base del gateway dal file di configurazione dell'Admin
- // es. "https://10.74.83.100:5290/MP/RIOC/api/admin/cache/purge-route/"
- _gatewayPurgeUrl = config.GetValue("ServerConf:GatewayPurgeUrl") ?? "https://localhost:7120/MP/RIOC/api/admin/cache/purge-route/";
- _keyPrefix = $"{_redisBaseKey}:route_weight:";
- }
-
- #endregion Public Constructors
-
- #region Public Methods
-
- public async Task> GetAllWeightsAsync()
- {
- var result = new List();
- var server = _mux.GetServer(_mux.GetEndPoints().First());
-
- if (server.IsReplica)
- {
- return result;
- }
-
- await foreach (var key in server.KeysAsync(pattern: $"{_keyPrefix}*"))
- {
- var methodName = KeyToString(key.ToString());
- if (string.IsNullOrEmpty(methodName)) continue;
-
- var oldVal = _db.HashGet(key, "old");
- var newVal = _db.HashGet(key, "new");
-
- int oldW = 100;
- int newW = 0;
-
- if (!oldVal.IsNull && int.TryParse(oldVal.ToString(), out var parsedOld))
- oldW = Math.Clamp(parsedOld, 0, 100);
-
- if (!newVal.IsNull && int.TryParse(newVal.ToString(), out var parsedNew))
- newW = Math.Clamp(parsedNew, 0, 100);
-
- result.Add(new WeightDTO { Method = methodName, OldWeight = oldW, NewWeight = newW });
- }
-
- // riordino desc x NEW poi alfabetico...
- result = result
- .OrderByDescending(x => x.NewWeight)
- .ThenBy(x => x.Method)
- .ToList();
-
- return result;
- }
-
- // API per aggiornare i pesi a runtime (opzionale)
- public void SetWeights(string method, int oldWeight, int newWeight)
- {
- var key = _keyPrefix + (string.IsNullOrEmpty(method) ? "unknown" : method);
- _db.HashSet(key, new HashEntry[] {
- new HashEntry("old", Math.Clamp(oldWeight,0,100)),
- new HashEntry("new", Math.Clamp(newWeight,0,100))
- });
-
- ResetFusionCache(method);
- }
-
- public bool UpsertWeight(WeightDTO updRecord)
- {
- if (updRecord == null || string.IsNullOrEmpty(updRecord.Method))
- return false;
-
- // 1. Scrivi su Redis (Sorgente dati reale)
- var key = _keyPrefix + updRecord.Method;
- _db.HashSet(key, new HashEntry[] {
- new HashEntry("old", Math.Clamp(updRecord.OldWeight, 0, 100)),
- new HashEntry("new", Math.Clamp(updRecord.NewWeight, 0, 100))
- });
-
- ResetFusionCache(updRecord.Method);
-
- return true;
- }
-
- #endregion Public Methods
-
- #region Private Fields
-
- private static string _keyPrefix = "route_weight:";
- private static string _redisBaseKey = "";
- private static Logger Log = LogManager.GetCurrentClassLogger();
- private readonly IFusionCache _cache;
- private readonly IConfiguration _config;
- private readonly IDatabase _db;
- private readonly int _defaultNew;
- private readonly int _defaultOld;
- private readonly string _gatewayPurgeUrl;
- private readonly IHttpClientFactory _httpClientFactory;
- private readonly IConnectionMultiplexer _mux;
-
- #endregion Private Fields
-
- #region Private Methods
-
- private string KeyToString(string key)
- {
- if (string.IsNullOrEmpty(key)) return "";
- var prefix = _keyPrefix ?? "";
- if (key.StartsWith(prefix))
- return key.Substring(prefix.Length);
- return key;
- }
-
- private void ResetFusionCache(string method)
- {
- //try
- //{
- // // Sfrutta la factory per prendere un client ottimizzato e pulito
- // using var client = _httpClientFactory.CreateClient();
-
- // // Componiamo l'URL finale pulito (es. .../purge-route/SIMUL_01)
- // var finalUrl = $"{_gatewayPurgeUrl.TrimEnd('/')}/{updRecord.Method}";
-
- // // Inviamo la POST (passiamo null come HttpContent perché non serve un Body)
- // var response = client.PostAsync(finalUrl, null);
-
- // if (response.IsSuccessStatusCode)
- // {
- // Log.Info($"[CACHE] Sfratto RAM notificato con successo al Gateway per il metodo: {updRecord.Method}");
- // }
- // else
- // {
- // Log.Warn($"[CACHE] Il gateway ha risposto con codice {response.StatusCode} alla purga di {updRecord.Method}");
- // }
- //}
- //catch (Exception ex)
- //{
- // // Usiamo un log di errore ma non blocchiamo l'applicazione Admin
- // // se il gateway in quel momento fosse offline o irraggiungibile
- // Log.Error(ex, $"[CACHE] Impossibile raggiungere il gateway per spurgare la rotta: {updRecord.Method}");
- //}
-
- // Grazie al Backplane Pub/Sub, la RAM verrà azzerata istantaneamente su TUTTI i server.
- var cacheKey = $"weights:{method}";
- _cache.Remove(cacheKey);
- }
-
- #endregion Private Methods
-
-#if false
- ///
- /// Ritorna (oldWeight, newWeight) per il metodo. Se non esiste, crea la chiave con i default.
- ///
- public (int oldWeight, int newWeight) GetWeightsFor(string method)
- {
- if (string.IsNullOrEmpty(method)) method = "unknown";
- var key = _keyPrefix + method;
-
- // Leggi entrambi i campi
- var oldVal = _db.HashGet(key, "old");
- var newVal = _db.HashGet(key, "new");
-
- // Se entrambi mancanti, inizializza con default (usando HSet con When.NotExists per evitare overwrite)
- if (oldVal.IsNull && newVal.IsNull)
- {
- // Imposta i campi singolarmente con When.NotExists per evitare overwrite
- _db.HashSet(key, "old", _defaultOld, When.NotExists);
- _db.HashSet(key, "new", _defaultNew, When.NotExists);
-
- // Rileggi per essere sicuri
- oldVal = _db.HashGet(key, "old");
- newVal = _db.HashGet(key, "new");
- }
-
- // Se uno dei due manca, impostalo al default (non sovrascrive l'altro)
- if (oldVal.IsNull)
- {
- _db.HashSet(key, "old", _defaultOld, When.NotExists);
- oldVal = _defaultOld;
- }
- if (newVal.IsNull)
- {
- _db.HashSet(key, "new", _defaultNew, When.NotExists);
- newVal = _defaultNew;
- }
-
- if (!int.TryParse(oldVal.ToString(), out var oldW)) oldW = _defaultOld;
- if (!int.TryParse(newVal.ToString(), out var newW)) newW = _defaultNew;
-
- // clamp 0..100
- oldW = Math.Clamp(oldW, 0, 100);
- newW = Math.Clamp(newW, 0, 100);
-
- return (oldW, newW);
- }
-#endif
- }
-}
\ No newline at end of file
diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj
index 639f2aaa..99a04ebc 100644
--- a/MP.Land/MP.Land.csproj
+++ b/MP.Land/MP.Land.csproj
@@ -3,7 +3,7 @@
net8.0
MP.Land
- 8.16.2606.2013
+ 8.16.2606.2208
Debug;Release;Debug_LiManDebug
en
True
diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html
index 573b323d..fdd5899b 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.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.Land/Resources/VersNum.txt
+++ b/MP.Land/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml
index a8e3de47..dd962edb 100644
--- a/MP.Land/Resources/manifest.xml
+++ b/MP.Land/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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 8420b81a..91fac835 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.2013
+ 8.16.2606.2208
diff --git a/MP.MON/Resources/ChangeLog.html b/MP.MON/Resources/ChangeLog.html
index f7877962..5711f4d3 100644
--- a/MP.MON/Resources/ChangeLog.html
+++ b/MP.MON/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOSPEC
- Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
-
diff --git a/MP.MON/Resources/VersNum.txt b/MP.MON/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.MON/Resources/VersNum.txt
+++ b/MP.MON/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.MON/Resources/manifest.xml b/MP.MON/Resources/manifest.xml
index 37567214..21eacd6e 100644
--- a/MP.MON/Resources/manifest.xml
+++ b/MP.MON/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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 38fd7223..52e2d9f7 100644
--- a/MP.Prog/MP.Prog.csproj
+++ b/MP.Prog/MP.Prog.csproj
@@ -3,7 +3,7 @@
net8.0
MP.Prog
- 8.16.2606.2013
+ 8.16.2606.2208
True
diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html
index 56458639..5002c1d2 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.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.Prog/Resources/VersNum.txt
+++ b/MP.Prog/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml
index cd364ae0..a46afa88 100644
--- a/MP.Prog/Resources/manifest.xml
+++ b/MP.Prog/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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 1d28b455..d8d563a5 100644
--- a/MP.RIOC/MP.RIOC.csproj
+++ b/MP.RIOC/MP.RIOC.csproj
@@ -5,10 +5,16 @@
enable
enable
MP.RIOC
- 8.16.2606.2013
+ 8.16.2606.2208
InProcess
+
+
+
+
+
+
diff --git a/MP.RIOC/Program.cs b/MP.RIOC/Program.cs
index c47c8b8f..eac850df 100644
--- a/MP.RIOC/Program.cs
+++ b/MP.RIOC/Program.cs
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
using MP.Core.Conf;
using MP.Data;
+using MP.Data.Services.RouteWeight;
using MP.RIOC.Services;
using NLog;
using NLog.Web;
@@ -118,9 +119,6 @@ builder.Services.AddFusionCache()
// Jitter: variazione casuale alla scadenza per evitare scadenze in blocco
options.JitterMaxDuration = TimeSpan.FromSeconds(5);
});
-//// 3. LA RIGA MAGICA: Estrae l'istanza nominata e la mappa come IFusionCache standard
-//builder.Services.AddSingleton(sp =>
-// sp.GetRequiredService().GetCache("MAPO_MES_FusionCache"));
// Registrazione dei servizi custom
builder.Services.AddSingleton();
diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html
index dde49877..73dbdef8 100644
--- a/MP.RIOC/Resources/ChangeLog.html
+++ b/MP.RIOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-RIOC
-
Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
-
diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.RIOC/Resources/VersNum.txt
+++ b/MP.RIOC/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml
index 82e3f4dd..b6f74dac 100644
--- a/MP.RIOC/Resources/manifest.xml
+++ b/MP.RIOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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 ce661fd0..fb1f2865 100644
--- a/MP.RIOC/Services/RouteManager.cs
+++ b/MP.RIOC/Services/RouteManager.cs
@@ -1,4 +1,5 @@
-using NLog;
+using MP.Data.Services.RouteWeight;
+using NLog;
using System.Diagnostics;
using Yarp.ReverseProxy.Forwarder;
diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj
index 67b982b1..628337bc 100644
--- a/MP.SPEC/MP.SPEC.csproj
+++ b/MP.SPEC/MP.SPEC.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.SPEC
- 8.16.2606.2013
+ 8.16.2606.2208
1800a78a-6ff1-40f9-b490-87fb8bfc1394
en
diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html
index f7877962..5711f4d3 100644
--- a/MP.SPEC/Resources/ChangeLog.html
+++ b/MP.SPEC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOSPEC
-
Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
-
diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.SPEC/Resources/VersNum.txt
+++ b/MP.SPEC/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml
index 0def9f44..1b142fab 100644
--- a/MP.SPEC/Resources/manifest.xml
+++ b/MP.SPEC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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 063e03b2..1614299a 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.2013
+ 8.16.2606.2208
true
en
diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html
index 02cffd56..947d141b 100644
--- a/MP.Stats/Resources/ChangeLog.html
+++ b/MP.Stats/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo statistiche MAPO
-
Versione: 8.16.2606.2013
+ Versione: 8.16.2606.2208
Note di rilascio:
diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt
index e8c8b0bf..60d2cec2 100644
--- a/MP.Stats/Resources/VersNum.txt
+++ b/MP.Stats/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.2013
+8.16.2606.2208
diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml
index 809d61f8..9e65b1b9 100644
--- a/MP.Stats/Resources/manifest.xml
+++ b/MP.Stats/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.2013
+ 8.16.2606.2208
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