Refresh con check setup Staging

This commit is contained in:
Samuele Locatelli
2026-02-24 15:07:31 +01:00
parent e0cd9baf37
commit 3ea3193ba4
10 changed files with 303 additions and 239 deletions
+5
View File
@@ -0,0 +1,5 @@
<h3>Elenco Fermate</h3>
@code {
}
+76
View File
@@ -0,0 +1,76 @@
<div class="card mb-5 shadow">
<div class="card-header table-primary">
<div class="d-flex justify-content-between">
<div class="px-0">
<div class="d-flex justify-content-between">
<div class="px-2">
<span class="fs-5 mb-0">Stato Impianti Corrente</span>
</div>
</div>
</div>
@* <div class="px-0 align-content-center d-flex justify-content-end">
<small class="fs-5">Edit Massivo Fermi</small>
</div> *@
</div>
</div>
<div class="card-body">
@if (ListRecords != null)
{
<table class="table table-sm table-striped small">
<thead>
<tr>
<th>
@if (AllSelected)
{
<button class="btn btn-outline-dark border-0 py-0" @onclick="() => ToggleAllSel()"><i class="fa-solid fa-toggle-on"></i></button>
}
else
{
<button class="btn btn-outline-secondary border-0 py-0" @onclick="() => ToggleAllSel()"><i class="fa-solid fa-toggle-off"></i></button>
}
@if (numSel > 0)
{
<span class="fw-bold">(@numSel)</span>
}
</th>
<th><i class="fa-solid fa-thumbtack"></i> Cod</th>
<th><i class="fa-solid fa-industry"></i> Macchina</th>
<th>Stato</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@CheckSelect(record)">
<td>
@if (CurrList.Contains(record.CodMacchina))
{
<button class="btn btn-outline-primary border-0 py-0" @onclick="() => ToggleSel(record.CodMacchina)"><i class="fa-solid fa-toggle-on"></i></button>
}
else
{
<button class="btn btn-outline-dark border-0 py-0" @onclick="() => ToggleSel(record.CodMacchina)"><i class="fa-solid fa-toggle-off"></i></button>
}
</td>
<td>@record.CodMacchina</td>
<td>@record.Descrizione</td>
<td>
<span class="badge text-bg-info bg-opacity-50">Stato: TBD</span>
</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<td colspan="3">
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading" />
</td>
</tr>
</tfoot>
</table>
}
</div>
</div>
+137
View File
@@ -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<MacchineModel> ListMSE { get; set; } = null!;
#endregion Public Properties
#region Protected Properties
/// <summary>
/// Elenco selezione corrente
/// </summary>
protected List<string> CurrList { get; set; } = new List<string>();
/// <summary>
/// Conteggio elementi selezionati
/// </summary>
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();
}
/// <summary>
/// Esegue toggle selezione fino a numMax in aggiunta e rimuovendo tutti se era true
/// </summary>
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<MacchineModel> 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
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2602.2412</Version>
<Version>6.16.2602.2415</Version>
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
+4 -52
View File
@@ -24,59 +24,11 @@
{
<div class="row">
<div class="col-6">
@if (ListRecords != null)
{
<table class="table table-sm table-striped small">
<thead>
<tr>
<th>
@if (AllSelected)
{
<button class="btn btn-outline-dark border-0 py-0" @onclick="() => ToggleAllSel()"><i class="fa-solid fa-toggle-on"></i></button>
}
else
{
<button class="btn btn-outline-secondary border-0 py-0" @onclick="() => ToggleAllSel()"><i class="fa-solid fa-toggle-off"></i></button>
}
@if (numSel > 0)
{
<span class="fw-bold">(@numSel)</span>
}
</th>
<th><i class="fa-solid fa-thumbtack"></i> Cod</th>
<th><i class="fa-solid fa-industry"></i> Macchina</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@CheckSelect(record)">
<td>
@if (CurrList.Contains(record.CodMacchina))
{
<button class="btn btn-outline-primary border-0 py-0" @onclick="() => ToggleSel(record.CodMacchina)"><i class="fa-solid fa-toggle-on"></i></button>
}
else
{
<button class="btn btn-outline-dark border-0 py-0" @onclick="() => ToggleSel(record.CodMacchina)"><i class="fa-solid fa-toggle-off"></i></button>
}
</td>
<td>@record.CodMacchina</td>
<td>@record.Descrizione</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<td colspan="3">
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading" />
</td>
</tr>
</tfoot>
</table>
}
<ListMacc ListMSE="@SearchRecords"></ListMacc>
</div>
<div class="col-6">
<ListFerm></ListFerm>
</div>
<div class="col-6">Elenco Fermate</div>
</div>
}
</div>
-101
View File
@@ -12,129 +12,28 @@ namespace MP.SPEC.Pages
{
#region Protected Properties
protected List<string> CurrList { get; set; } = new List<string>();
[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();
}
/// <summary>
/// Esegue toggle selezione fino a numMax in aggiunta e rimuovendo tutti se era true
/// </summary>
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<MacchineModel> ListRecords = new();
private int numRecord = 10;
private List<MacchineModel> 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
}
}
+77 -82
View File
@@ -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<IConnectionMultiplexer>(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<IConnectionMultiplexer>())
// 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<MpDataService>();
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2602.2412</h4>
<h4>Versione: 6.16.2602.2415</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2602.2412
6.16.2602.2415
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2602.2412</version>
<version>6.16.2602.2415</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>