Refresh commenti

This commit is contained in:
Samuele Locatelli
2025-09-24 18:27:43 +02:00
parent 14657f100b
commit fd21093ee4
8 changed files with 57 additions and 61 deletions
+39 -44
View File
@@ -14,19 +14,24 @@ using System.Threading.Tasks;
namespace EgwCoreLib.Lux.Data.Services
{
/// <summary>
/// BaseServ class serves as a foundational service for handling Redis operations and message piping.
/// It provides common configurations, caching strategies, and message delivery mechanisms for derived services.
/// The class initializes Redis connections, sets up message channels, and manages JSON serialization with loop handling.
/// 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.
/// </summary>
public class BaseServ
{
#region Public Constructors
/// <summary>
/// Initializes a new instance of the BaseServ class.
/// Inizializza una nuova istanza della classe BaseServ.
/// Configura la connessione Redis, carica le impostazioni di configurazione e inizializza il serializzatore JSON.
/// </summary>
/// <param name="Configuration">Configuration object to retrieve application settings.</param>
/// <param name="RedisConn">Redis connection multiplexer for database operations.</param>
/// <param name="Configuration">Oggetto di configurazione per recuperare le impostazioni dell'applicazione.</param>
/// <param name="RedisConn">Multiplexer di connessione Redis per operazioni sul database.</param>
public BaseServ(IConfiguration Configuration, IConnectionMultiplexer RedisConn)
{
_config = Configuration;
@@ -51,18 +56,14 @@ namespace EgwCoreLib.Lux.Data.Services
updateChannel += ":*";
}
// JSON serializer settings to prevent circular reference errors during serialization
// ReferenceLoopHandling.Ignore ensures that circular references in objects are ignored instead of throwing exceptions
// Configurazione serializzatore JSON per risolvere errore di loop circolare
JSSettings = new JsonSerializerSettings()
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
// Initializes a message pipe for communication between calculation services and UI components
// Messages are sent via the specified Redis channel (svgChannel)
// Configurazione pipe dei messaggi
CalcDonePipe = new MessagePipe(redisConn, svgChannel);
// init others channel
BomPipe = new MessagePipe(RedisConn, bomChannel);
UpdatePipe = new MessagePipe(RedisConn, updateChannel);
}
@@ -72,19 +73,18 @@ namespace EgwCoreLib.Lux.Data.Services
#region Public Properties
/// <summary>
/// Message pipe for BOM calculation update
/// Pipe dei messaggi per la comunicazione riguardo update calcolo BOM
/// </summary>
public MessagePipe BomPipe { get; set; } = null!;
/// <summary>
/// Message pipe for delivering completion messages from calculation services to the UI.
/// Uses Redis to publish messages on the svgChannel for real-time updates.
/// Pipe dei messaggi per la comunicazione tra servizi di calcolo e interfaccia utente.
/// I messaggi vengono inviati sul canale Redis definito da svgChannel.
/// </summary>
public MessagePipe CalcDonePipe { get; set; } = null!;
/// <summary>
/// Message pipe for delivering generico update to the UI.
/// Uses Redis to publish messages on the updateChannel for real-time updates.
/// Pipe dei messaggi per la comunicazione riguardo update generico UI
/// </summary>
public MessagePipe UpdatePipe { get; set; } = null!;
@@ -93,26 +93,25 @@ namespace EgwCoreLib.Lux.Data.Services
#region Protected Fields
/// <summary>
/// Configuration object for accessing application settings (e.g., connection strings, service parameters).
/// This is a static instance shared across all instances of BaseServ.
/// Oggetto di configurazione statico per accedere alle impostazioni dell'applicazione (es. stringhe di connessione).
/// Condiviso tra tutte le istanze di BaseServ.
/// </summary>
protected static IConfiguration _config = null!;
/// <summary>
/// JSON serialization settings to handle circular references (e.g., object references to themselves).
/// Prevents exceptions during serialization by ignoring loops.
/// Impostazioni del serializzatore JSON utilizzato per gestire oggetti con riferimenti circolari
/// (es. oggetti che si fanno riferimento reciprocamente).
/// </summary>
protected JsonSerializerSettings? JSSettings;
/// <summary>
/// Redis connection multiplexer that provides access to Redis database operations.
/// Used for reading and writing data in Redis.
/// Oggetto per la connessione a Redis utilizzato per operazioni di lettura/scrittura.
/// </summary>
protected IConnectionMultiplexer redisConn = null!;
/// <summary>
/// Redis database instance used for performing read/write operations.
/// This database is accessed via the redisConn.GetDatabase() method.
/// Database Redis utilizzato per le operazioni di lettura/scrittura
/// nb: ottenuto tramite redisConn.GetDatabase()
/// </summary>
protected IDatabase redisDb = null!;
@@ -121,8 +120,7 @@ namespace EgwCoreLib.Lux.Data.Services
#region Protected Properties
/// <summary>
/// Cache duration for short-term operations (approximately 1 minute with ±10% variation).
/// The actual duration is calculated dynamically with a random factor to avoid fixed TTLs.
/// Durata della cache breve (circa 1 minuto + variazione del +/-10%)
/// </summary>
protected TimeSpan FastCache
{
@@ -130,8 +128,7 @@ namespace EgwCoreLib.Lux.Data.Services
}
/// <summary>
/// Cache duration for long-term operations (5 minutes with ±10% variation).
/// Used for data that should be cached for longer periods but still allow some flexibility.
/// Durata della cache lunga (+ variazione del +/-10%)
/// </summary>
protected TimeSpan LongCache
{
@@ -139,8 +136,7 @@ namespace EgwCoreLib.Lux.Data.Services
}
/// <summary>
/// Cache duration for very short-term operations (approximately 10 seconds with ±10% variation).
/// Used for transient data that needs to be refreshed frequently.
/// Durata della cache molto breve (circa 10 secondi + variazione del +/-10%)
/// </summary>
protected TimeSpan UltraFastCache
{
@@ -148,8 +144,7 @@ namespace EgwCoreLib.Lux.Data.Services
}
/// <summary>
/// Cache duration for very long-term operations (up to 50 minutes with ±10% variation).
/// Designed for data that changes infrequently and requires long-term persistence.
/// Durata della cache molto lunga (+ variazione del +/-10%)
/// </summary>
protected TimeSpan UltraLongCache
{
@@ -161,8 +156,8 @@ namespace EgwCoreLib.Lux.Data.Services
#region Private Fields
/// <summary>
/// Logger instance for logging events and errors at the class level.
/// Used to track application behavior and diagnose issues.
/// 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.
/// </summary>
private static Logger Log = LogManager.GetCurrentClassLogger();
@@ -172,31 +167,31 @@ namespace EgwCoreLib.Lux.Data.Services
private string bomChannel = "";
/// <summary>
/// Duration of long-term cache in seconds (default: 5 minutes).
/// Used in the LongCache property to define how long data should be cached.
/// 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.
/// </summary>
private int cacheTtlLong = 60 * 5;
/// <summary>
/// Duration of short-term cache in seconds (default: 1 minute).
/// Used in the FastCache and UltraFastCache properties to define short-term cache durations.
/// Durata della cache breve in secondi (predefinito: 1 minuto)
/// Utilizzato nelle proprietà FastCache e UltraFastCache per definire la durata della cache breve.
/// </summary>
private int cacheTtlShort = 60 * 1;
/// <summary>
/// Random number generator for introducing dynamic variability in cache durations.
/// Used to simulate real-world variations in data freshness and TTL.
/// 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).
/// </summary>
private Random rnd = new Random();
/// <summary>
/// The Redis channel name used for subscribing to and publishing messages.
/// Default is "svg:img", with a wildcard suffix ":*" to enable dynamic message matching.
/// Nome del canale Redis utilizzato per l'invio/ricezione di messaggi relativi a img svg.
/// Predefinito a "svg:img" con suffisso ":*".
/// </summary>
private string svgChannel = "";
/// <summary>
/// Redis channel for generic update info
/// Nome del canale Redis utilizzato per l'invio/ricezione di messaggi di update
/// </summary>
private string updateChannel = "";
@@ -621,7 +621,7 @@ namespace EgwCoreLib.Lux.Data.Services
var bomList = JsonConvert.DeserializeObject<List<BomItemDTO>>(bomContent);
if (bomList != null)
{
// verifico 1:1 gli item ricevuti dalla BOM sul DB con eventuale insert in anagrafica
// verifico 1:1 gli item ricevuti dalla BOM sul DB con eventuale insert in anagrafica dei nuovi
dbController.ItemUpsertFromBom(bomList);
// salvo la BOM nel record del DB relativo all'oggetto richiesto
dbController.OfferUpsertFromBom(uID, bomList);
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2509.2417</Version>
<Version>0.9.2509.2418</Version>
</PropertyGroup>
<ItemGroup>
+12 -11
View File
@@ -197,17 +197,6 @@ namespace Lux.UI.Components.Compo
await EC_Updated.InvokeAsync(true);
}
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadData()
{
if (OfferID > 0)
{
AllRecords = await DLService.OfferRowGetByOffer(OfferID);
totalCount = AllRecords.Count();
}
}
/// <summary>
/// Svuota cache corrente + rilegge dati
/// </summary>
@@ -222,6 +211,18 @@ namespace Lux.UI.Components.Compo
isLoading = false;
}
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadData()
{
if (OfferID > 0)
{
AllRecords = await DLService.OfferRowGetByOffer(OfferID);
totalCount = AllRecords.Count();
}
}
/// <summary>
/// salva nel record corrente la BOM aggiornata e poi ricalcola importo...
/// </summary>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2509.2417</Version>
<Version>0.9.2509.2418</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2509.2417</h4>
<h4>Versione: 0.9.2509.2418</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2509.2417
0.9.2509.2418
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2509.2417</version>
<version>0.9.2509.2418</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>