diff --git a/MP.SPEC/Pages/RepStop.razor b/MP.SPEC/Pages/RepStop.razor new file mode 100644 index 00000000..4cef2ed8 --- /dev/null +++ b/MP.SPEC/Pages/RepStop.razor @@ -0,0 +1,85 @@ +@page "/repa-stop" + +
+
+
+
+
+
+ Fermi Reparto +
+
+
+
+ Edit Massivo Fermi +
+
+
+
+ @if (isLoading) + { + + } + else + { +
+
+ @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 new file mode 100644 index 00000000..c7ec77f5 --- /dev/null +++ b/MP.SPEC/Pages/RepStop.razor.cs @@ -0,0 +1,140 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DbModels; +using MP.SPEC.Components.Reparti; +using MP.SPEC.Data; +using NLog.LayoutRenderers; +using static MP.Core.Objects.Enums; +using static MP.Data.Services.ExecStatsCollector; + +namespace MP.SPEC.Pages +{ + public partial class RepStop + { + #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 68c34e0d..0543f89b 100644 --- a/MP.SPEC/Program.cs +++ b/MP.SPEC/Program.cs @@ -1,4 +1,4 @@ -using Blazored.LocalStorage; +using Blazored.LocalStorage; using Blazored.SessionStorage; using Microsoft.AspNetCore.Authentication.Negotiate; using Microsoft.AspNetCore.Components; @@ -12,9 +12,14 @@ using MP.SPEC.Components; using MP.SPEC.Data; using MP.SPEC.Services; using NLog; +using NLog.Targets; +using NLog.Targets.OpenTelemetryProtocol; using NLog.Web; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; using StackExchange.Redis; + var builder = WebApplication.CreateBuilder(args); /*-------------------- @@ -25,18 +30,55 @@ var builder = WebApplication.CreateBuilder(args); * * */ +ConfigurationManager configuration = builder.Configuration; 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"); -ConfigurationManager configuration = builder.Configuration; // REDIS setup logger.Info("Setup REDIS"); -string connStringRedis = configuration.GetConnectionString("Redis"); +string connStringRedis = configuration.GetConnectionString("Redis") ?? "localhost:6379"; //string connStringRedis = ConfMan.GetConnectionString("RedisAdmin"); string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")); // avvio oggetto shared x redis... @@ -54,9 +96,54 @@ builder.Services.AddAuthorization(options => options.FallbackPolicy = options.DefaultPolicy; }); +// 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(redisMultiplexer); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -69,6 +156,7 @@ builder.Services.AddHttpClient(); logger.Info("Aggiunti services"); + var app = builder.Build(); logger.Info("Build App"); diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index a0c72812..e2a1447d 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2509.1211

+

Versione: 6.16.2602.2412


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index fe790325..04185a95 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2509.1211 +6.16.2602.2412 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 729537ed..e46a72cc 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2509.1211 + 6.16.2602.2412 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.SPEC/appsettings.Development.json b/MP.SPEC/appsettings.Development.json index ad871614..875ee554 100644 --- a/MP.SPEC/appsettings.Development.json +++ b/MP.SPEC/appsettings.Development.json @@ -6,6 +6,12 @@ "Microsoft.AspNetCore": "Warning" } }, + "UptraceDev": { + "Endpoint": "https://uptrace.egalware.com:14317", + "Dsn": "https://DC_iX71mEzg7KA7atQEBdQ@uptrace.egalware.com?grpc=14317" + //"Endpoint": "http://upt.ovh:14317", + //"Dsn": "http://DC_iX71mEzg7KA7atQEBdQ@upt.ovh?grpc=14317" + }, "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": 2, diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index b4ceb714..cbaf21a5 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,8 +4,7 @@ net6.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 6.16.2510.1508 - 6.16.2510.1508 + 6.16.2601.1310 true $(NoWarn);1591 en diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html index 51b3e118..d7d90128 100644 --- a/MP.Stats/Resources/ChangeLog.html +++ b/MP.Stats/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

    Versione: 6.16.2510.1508

    +

    Versione: 6.16.2601.1310


    Note di rilascio:
      diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt index 32e8c4f7..93295548 100644 --- a/MP.Stats/Resources/VersNum.txt +++ b/MP.Stats/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2510.1508 +6.16.2601.1310 diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml index b589822b..0c54652f 100644 --- a/MP.Stats/Resources/manifest.xml +++ b/MP.Stats/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2510.1508 + 6.16.2601.1310 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