From 3ea3193ba413474bc46ae9199654d7a8a985d8d7 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 24 Feb 2026 15:07:31 +0100 Subject: [PATCH] Refresh con check setup Staging --- MP.SPEC/Components/ListFerm.razor | 5 + MP.SPEC/Components/ListMacc.razor | 76 +++++++++++++ MP.SPEC/Components/ListMacc.razor.cs | 137 +++++++++++++++++++++++ MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Pages/RepStop.razor | 56 +--------- MP.SPEC/Pages/RepStop.razor.cs | 101 ----------------- MP.SPEC/Program.cs | 159 +++++++++++++-------------- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 10 files changed, 303 insertions(+), 239 deletions(-) create mode 100644 MP.SPEC/Components/ListFerm.razor create mode 100644 MP.SPEC/Components/ListMacc.razor create mode 100644 MP.SPEC/Components/ListMacc.razor.cs diff --git a/MP.SPEC/Components/ListFerm.razor b/MP.SPEC/Components/ListFerm.razor new file mode 100644 index 00000000..902a959b --- /dev/null +++ b/MP.SPEC/Components/ListFerm.razor @@ -0,0 +1,5 @@ +

Elenco Fermate

+ +@code { + +} diff --git a/MP.SPEC/Components/ListMacc.razor b/MP.SPEC/Components/ListMacc.razor new file mode 100644 index 00000000..1f8ebf18 --- /dev/null +++ b/MP.SPEC/Components/ListMacc.razor @@ -0,0 +1,76 @@ + + +
+
+
+
+
+
+ Stato Impianti Corrente +
+
+
+ @*
+ Edit Massivo Fermi +
*@ +
+
+
+ @if (ListRecords != null) + { + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + } + + + + + + +
+ @if (AllSelected) + { + + } + else + { + + } + @if (numSel > 0) + { + (@numSel) + } + Cod MacchinaStato
+ @if (CurrList.Contains(record.CodMacchina)) + { + + } + else + { + + } + @record.CodMacchina@record.Descrizione + Stato: TBD +
+ +
+ } + +
+
\ No newline at end of file diff --git a/MP.SPEC/Components/ListMacc.razor.cs b/MP.SPEC/Components/ListMacc.razor.cs new file mode 100644 index 00000000..8d61a911 --- /dev/null +++ b/MP.SPEC/Components/ListMacc.razor.cs @@ -0,0 +1,137 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DbModels; + +namespace MP.SPEC.Components +{ + public partial class ListMacc + { + #region Public Properties + + [Parameter] + public List ListMSE { get; set; } = null!; + + #endregion Public Properties + + #region Protected Properties + + /// + /// Elenco selezione corrente + /// + protected List CurrList { get; set; } = new List(); + + /// + /// Conteggio elementi selezionati + /// + protected int numSel + { + get => CurrList.Count(); + } + + #endregion Protected Properties + + #region Protected Methods + + protected string CheckSelect(MacchineModel currRec) + { + string answ = ""; + if (CurrList.Contains(currRec.CodMacchina)) + { + answ = "table-info"; + } + return answ; + } + + protected override async Task OnParametersSetAsync() + { + totalCount = ListMSE.Count(); + await ReloadData(); + } + + protected async Task SetNumRec(int newNum) + { + numRecord = newNum; + currPage = 1; + await ReloadData(); + } + + protected async Task SetPage(int newNum) + { + currPage = newNum; + await ReloadData(); + } + + /// + /// Esegue toggle selezione fino a numMax in aggiunta e rimuovendo tutti se era true + /// + protected async Task ToggleAllSel() + { + AllSelected = !AllSelected; + if (AllSelected) + { + if (ListRecords != null) + { + foreach (var record in ListRecords) + { + if (!CurrList.Contains(record.CodMacchina)) + { + CurrList.Add(record.CodMacchina); + } + } + } + } + else + { + CurrList.Clear(); + } + await Task.Delay(1); +#if false + await EC_ListUpdated.InvokeAsync(CurrList); +#endif + } + + protected void ToggleSel(string newVal) + { + if (!CurrList.Contains(newVal)) + { + CurrList.Add(newVal); + } + else + { + CurrList.Remove(newVal); + } + // riordino + CurrList = CurrList.OrderBy(x => x).ToList(); + } + + #endregion Protected Methods + + #region Private Fields + + private bool AllSelected = false; + private int currPage = 1; + private bool isLoading = false; + + private List ListRecords = new(); + private int numRecord = 10; + private int totalCount = 0; + + #endregion Private Fields + + #region Private Methods + + private async Task ReloadData() + { + if (ListMSE != null) + { + // filtro x display + ListRecords = ListMSE + .Skip(numRecord * (currPage - 1)) + .Take(numRecord) + .ToList(); + } + await Task.Delay(1); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 264eac14..84e8c92a 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2602.2412 + 6.16.2602.2415 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Pages/RepStop.razor b/MP.SPEC/Pages/RepStop.razor index 4cef2ed8..2a8b9b42 100644 --- a/MP.SPEC/Pages/RepStop.razor +++ b/MP.SPEC/Pages/RepStop.razor @@ -24,59 +24,11 @@ {
- @if (ListRecords != null) - { - - - - - - - - - - @foreach (var record in ListRecords) - { - - - - - - } - - - - - - -
- @if (AllSelected) - { - - } - else - { - - } - @if (numSel > 0) - { - (@numSel) - } - Cod Macchina
- @if (CurrList.Contains(record.CodMacchina)) - { - - } - else - { - - } - @record.CodMacchina@record.Descrizione
- -
- } + +
+
+
-
Elenco Fermate
} diff --git a/MP.SPEC/Pages/RepStop.razor.cs b/MP.SPEC/Pages/RepStop.razor.cs index c7ec77f5..c99cdb84 100644 --- a/MP.SPEC/Pages/RepStop.razor.cs +++ b/MP.SPEC/Pages/RepStop.razor.cs @@ -12,129 +12,28 @@ namespace MP.SPEC.Pages { #region Protected Properties - protected List CurrList { get; set; } = new List(); - [Inject] protected MpDataService MDService { get; set; } = null!; - protected int numSel - { - get => CurrList.Count(); - } - #endregion Protected Properties #region Protected Methods - protected string CheckSelect(MacchineModel currRec) - { - string answ = ""; - if (CurrList.Contains(currRec.CodMacchina)) - { - answ = "table-info"; - } - return answ; - } - protected override void OnInitialized() { var rawList = MDService.MacchineGetFilt("*"); // prendo solo macchine VALIDE SearchRecords = rawList.Where(x => !string.IsNullOrEmpty(x.locazione)).ToList(); - totalCount = SearchRecords.Count; - } - - protected override async Task OnParametersSetAsync() - { - await ReloadData(); - } - - protected async Task SetNumRec(int newNum) - { - numRecord = newNum; - currPage = 1; - await ReloadData(); - } - - protected async Task SetPage(int newNum) - { - currPage = newNum; - await ReloadData(); - } - - /// - /// Esegue toggle selezione fino a numMax in aggiunta e rimuovendo tutti se era true - /// - protected async Task ToggleAllSel() - { - AllSelected = !AllSelected; - if (AllSelected) - { - if (ListRecords != null) - { - foreach (var record in ListRecords) - { - if (!CurrList.Contains(record.CodMacchina)) - { - CurrList.Add(record.CodMacchina); - } - } - } - } - else - { - CurrList.Clear(); - } - await Task.Delay(1); -#if false - await EC_ListUpdated.InvokeAsync(CurrList); -#endif - } - - protected void ToggleSel(string newVal) - { - if (!CurrList.Contains(newVal)) - { - CurrList.Add(newVal); - } - else - { - CurrList.Remove(newVal); - } - // riordino - CurrList = CurrList.OrderBy(x => x).ToList(); } #endregion Protected Methods #region Private Fields - private bool AllSelected = false; - private int currPage = 1; private bool isLoading = false; - private List ListRecords = new(); - private int numRecord = 10; private List SearchRecords = new(); - private int totalCount = 0; #endregion Private Fields - - #region Private Methods - - private async Task ReloadData() - { - if (SearchRecords != null) - { - // filtro x display - ListRecords = SearchRecords - .Skip(numRecord * (currPage - 1)) - .Take(numRecord) - .ToList(); - } - await Task.Delay(1); - } - - #endregion Private Methods } } \ No newline at end of file diff --git a/MP.SPEC/Program.cs b/MP.SPEC/Program.cs index 0543f89b..4ce8412d 100644 --- a/MP.SPEC/Program.cs +++ b/MP.SPEC/Program.cs @@ -36,46 +36,8 @@ var logger = LogManager.Setup() .LoadConfigurationFromAppSettings() .GetCurrentClassLogger(); - -string uptraceEndpoint = configuration["UptraceDev:Endpoint"] ?? ""; -string uptraceDsn = configuration["UptraceDev:Dsn"] ?? ""; -// NLog Uptrace setup -if (builder.Environment.IsDevelopment()) -{ - // Recupera i parametri dal file appsettings.Development.json - - if (!string.IsNullOrEmpty(uptraceEndpoint) && !string.IsNullOrEmpty(uptraceDsn)) - { - // Crea il target OTLP di NLog - var otlpTarget = new OtlpTarget - { - Name = "UptraceRealtime", - Endpoint = uptraceEndpoint, - // Impostiamo il layout per far capire a Uptrace il nome del servizio - ServiceName = "MP.DATA.Tracer", - Headers = $"uptrace-dsn={uptraceDsn}" - }; - - // Recupera la configurazione attuale di NLog (quella caricata da nlog.config) - var config = LogManager.Configuration ?? new NLog.Config.LoggingConfiguration(); - - // Aggiunge il nuovo target - config.AddTarget(otlpTarget); - - // Crea una regola per inviare tutto (da Info in su) al target OTLP - config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, otlpTarget); - - // Applica le modifiche a NLog - LogManager.Configuration = config; - LogManager.ReconfigExistingLoggers(); - - Console.WriteLine("🚀 NLog OTLP Target attivato per Uptrace in Development!"); - } -} logger.Info("Program.cs: startup"); - - // REDIS setup logger.Info("Setup REDIS"); string connStringRedis = configuration.GetConnectionString("Redis") ?? "localhost:6379"; @@ -84,6 +46,83 @@ string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")) // avvio oggetto shared x redis... var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis); +// Check develop e conseguente Uptrace setup +// CONTROLLO GLOBALE: Tutto questo gira SOLO in Development +if (builder.Environment.IsDevelopment()) +{ + var uptraceEndpoint = builder.Configuration["UptraceDev:Endpoint"]; + var uptraceDsn = builder.Configuration["UptraceDev:Dsn"]; + + // Se le variabili di configurazione esistono nel json locale, attiviamo la magia + if (!string.IsNullOrEmpty(uptraceEndpoint) && !string.IsNullOrEmpty(uptraceDsn)) + { + // ==================================================================== + // 1. SETUP NLOG (Per i log in tempo reale) + // ==================================================================== + var otlpTarget = new OtlpTarget + { + Name = "UptraceRealtime", + Endpoint = uptraceEndpoint, + ServiceName = "MP.DATA.Tracer", + Headers = $"uptrace-dsn={uptraceDsn}" + }; + + var config = LogManager.Configuration ?? new NLog.Config.LoggingConfiguration(); + config.AddTarget(otlpTarget); + config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, otlpTarget); + LogManager.Configuration = config; + LogManager.ReconfigExistingLoggers(); + + Console.WriteLine("🚀 NLog OTLP Target attivato per Uptrace in Development!"); + + // ==================================================================== + // 2. SETUP OPENTELEMETRY (Per gli Span, HTTP, DB e Redis in tempo reale) + // ==================================================================== + var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.0.0"; + + builder.Services.AddOpenTelemetry() + .WithTracing(tracerProviderBuilder => + { + tracerProviderBuilder + // Definiamo il nome e versione del servizio CORRENTE su Uptrace + .SetResourceBuilder(ResourceBuilder.CreateDefault() + .AddService(serviceName: "MAPO.SPEC", serviceVersion: appVersion)) + + // Diciamo a OTel di ascoltare gli Span manuali generati + .AddSource("MP.DATA.Tracer") + + // Strumentazione Automatica + .AddAspNetCoreInstrumentation(options => + { + options.Filter = (httpContext) => !httpContext.Request.Path.StartsWithSegments("/health"); + }) + .AddSqlClientInstrumentation(options => + { + options.RecordException = true; + }) + // Assicurati che redisMultiplexer sia inizializzato PRIMA di questo blocco + .AddRedisInstrumentation(redisMultiplexer) + + // Esporta i dati verso Uptrace + .AddOtlpExporter(options => + { + options.Endpoint = new Uri(uptraceEndpoint); + options.Headers = $"uptrace-dsn={uptraceDsn}"; + options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc; + }); + + // Scommenta per testare in console + // .AddConsoleExporter(); + }); + + Console.WriteLine("🚀 OpenTelemetry Tracing attivato per Uptrace in Development!"); + } + else + { + Console.WriteLine("⚠️ Variabili UptraceDev mancanti nel json. Telemetria realtime disabilitata."); + } +} + // Add services to the container. logger.Info("Setup Auth"); @@ -98,50 +137,6 @@ builder.Services.AddAuthorization(options => // redis replliminare builder.Services.AddSingleton(redisMultiplexer); - -// Estrae la versione compilata (es. 1.0.0.0) dell'applicazione corrente -var appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.0.0"; - -//opentelemetry services -builder.Services.AddOpenTelemetry() - .WithTracing(tracerProviderBuilder => - { - tracerProviderBuilder - // Definiamo il nome del servizio CORRENTE su Uptrace - //.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName: "MAPO.SPEC")) - .SetResourceBuilder(ResourceBuilder.CreateDefault() - .AddService(serviceName: "MAPO.SPEC", serviceVersion: appVersion)) - // Diciamo a OTel di ascoltare gli Span generati dalla tua classe - .AddSource("MP.DATA.Tracer") - // aggiunta altre instrumentation - // 1. Strumentazione ASP.NET Core - .AddAspNetCoreInstrumentation(options => - { - // Opzionale: puoi evitare di tracciare le rotte "noiose" come gli health check o i file statici - options.Filter = (httpContext) => !httpContext.Request.Path.StartsWithSegments("/health"); - }) - - // 2. Strumentazione SQL Client - .AddSqlClientInstrumentation(options => - { - options.RecordException = true; - }) - // 3. Strumentazione Redis - // ATTENZIONE: A differenza degli altri, a Redis devi passare l'oggetto di connessione (IConnectionMultiplexer) - .AddRedisInstrumentation(redisMultiplexer) - //.AddRedisInstrumentation(sp => sp.GetRequiredService()) - - // Esporta i dati verso Uptrace - .AddOtlpExporter(options => - { - options.Endpoint = new Uri(uptraceEndpoint); - options.Headers = $"uptrace-dsn={uptraceDsn}"; - options.Protocol = OpenTelemetry.Exporter.OtlpExportProtocol.Grpc; - }); - // da abilitare per verificare SE genera davvero le activity traces - //.AddConsoleExporter(); - }); - builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index e2a1447d..850b6fc7 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2602.2412

+

Versione: 6.16.2602.2415


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 04185a95..1862b72d 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2602.2412 +6.16.2602.2415 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index e46a72cc..3d5f9683 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2602.2412 + 6.16.2602.2415 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