Rrefresh automatico stati Feeder

This commit is contained in:
Samuele Locatelli
2026-02-25 11:27:59 +01:00
parent 7802babd0e
commit 93c2f8ea0c
16 changed files with 79 additions and 364 deletions
-18
View File
@@ -692,24 +692,6 @@ namespace MP.AppAuth.Services
}
}
answ = true;
#if false
var listEndpoints = redisConn.GetEndPoints();
foreach (var endPoint in listEndpoints)
{
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
var server = redisConn.GetServer(endPoint);
if (server != null)
{
var keyList = server.Keys(redisDb.Database, pattern);
foreach (var item in keyList)
{
await redisDb.KeyDeleteAsync(item);
}
answ = true;
}
}
#endif
return answ;
}
+5 -4
View File
@@ -6,6 +6,7 @@ using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Data.Controllers
{
@@ -136,18 +137,18 @@ namespace MP.Data.Controllers
/// Elenco da tabella MappaStatoExplModel
/// </summary>
/// <returns></returns>
public List<DbModels.MappaStatoExplModel> MseGetAll(int maxAge = 2000)
public async Task<List<MappaStatoExplModel>> MseGetAllAsync(int maxAge = 2000)
{
List<DbModels.MappaStatoExplModel> dbResult = new List<DbModels.MappaStatoExplModel>();
List<MappaStatoExplModel> dbResult = new List<DbModels.MappaStatoExplModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge);
dbResult = dbCtx
dbResult = await dbCtx
.DbSetMSE
.FromSqlRaw("EXEC stp_MSE_getData @maxAgeSec", maxAgeSec)
.AsNoTracking()
.ToList();
.ToListAsync();
}
return dbResult;
}
+9 -3
View File
@@ -30,9 +30,15 @@ namespace MP.Data.Services
// conf DB
string connStr = _configuration.GetConnectionString("MP.Mon");
// se non trovo cerco con MP.All...
if (string.IsNullOrEmpty(connStr))
{
Log.Error("ConnString empty!");
connStr = _configuration.GetConnectionString("MP.All");
}
if (string.IsNullOrEmpty(connStr))
{
Log.Error("ConnString empty! [MP.Mon / MP.All]");
}
else
{
@@ -329,7 +335,7 @@ namespace MP.Data.Services
}
else
{
result = await Task.FromResult(dbController.MseGetAll(maxAge));
result = await dbController.MseGetAllAsync(maxAge);
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(Constants.redisMseKey, rawData, UltraFastCache);
@@ -339,7 +345,7 @@ namespace MP.Data.Services
result = new List<MappaStatoExplModel>();
}
sw.Stop();
Log.Debug($"MseGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
Log.Debug($"MseGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
+7 -9
View File
@@ -12,20 +12,17 @@ namespace MP.SPEC.Components.Fermate
{
public partial class ListFerm
{
[Parameter]
public List<vSelEventiBCodeModel> ListaFermate { get; set; } = new List<vSelEventiBCodeModel>();
#region Public Properties
[Parameter]
public EventCallback<SelEventDTO> EC_EventSelected { get; set; }
private bool isProcessing = false;
[Parameter]
public List<vSelEventiBCodeModel> ListaFermate { get; set; } = new List<vSelEventiBCodeModel>();
//[Inject]
//protected SharedMemService SMServ { get; set; } = null!;
#endregion Public Properties
//[Inject]
//protected TabDataService TabDServ { get; set; } = null!;
#region Protected Methods
/// <summary>
/// Sollevo evento click
@@ -34,9 +31,10 @@ namespace MP.SPEC.Components.Fermate
/// <returns></returns>
protected async Task ReportEvent(SelEventDTO selEv)
{
isProcessing = true;
// solleva evento selezione...
await EC_EventSelected.InvokeAsync(selEv);
}
#endregion Protected Methods
}
}
+2 -2
View File
@@ -11,7 +11,7 @@
</div>
</div>
<div class="px-0 align-content-center d-flex justify-content-end">
<button class="btn btn-primary" @onclick="RaiseRefresh"><i class="fa-solid fa-arrow-rotate-right"></i></button>
@* <button class="btn btn-primary" @onclick="RaiseRefresh"><i class="fa-solid fa-arrow-rotate-right"></i></button> *@
</div>
</div>
</div>
@@ -68,7 +68,7 @@
</tbody>
<tfoot>
<tr>
<td colspan="3">
<td colspan="4">
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading" />
</td>
</tr>
-4
View File
@@ -368,10 +368,6 @@ namespace MP.SPEC.Components
SearchRecords = await MDService.OdlListGetFilt(currFilter.IsActive, currFilter.SearchVal, currFilter.CodFase, currFilter.CodReparto, currFilter.IdxMacchina, currFilter.DtStart, currFilter.DtEnd);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
#if false
await InvokeAsync(StateHasChanged);
#endif
isLoading = false;
}
@@ -182,11 +182,6 @@ namespace MP.SPEC.Components.ProdKit
#region Private Fields
/// <summary>
/// Boolear controllo visualizzazione ricerca articoli
/// </summary>
private bool doSearchArt = false;
/// <summary>
/// Elenco singoli podl esplosi
/// </summary>
+1 -225
View File
@@ -84,7 +84,6 @@ namespace MP.SPEC.Components
return answ;
}
/// <summary>
/// Verifica eliminabilità del record: se è avviato il PODL non è liminabile...
/// </summary>
@@ -126,8 +125,6 @@ namespace MP.SPEC.Components
await Task.Delay(1);
}
private bool OptAdmKitEnabled = false;
protected override void OnInitialized()
{
numRecord = 10;
@@ -150,22 +147,6 @@ namespace MP.SPEC.Components
}
}
#if false
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
if (OptAdmKitEnabled)
{
doReset();
}
}
//base.OnAfterRender(firstRender);
}
#endif
protected override void OnParametersSet()
{
ReloadData();
@@ -219,10 +200,9 @@ namespace MP.SPEC.Components
private bool doSearchArt = false;
private IstanzeKitModel? EditRecord = null;
private List<IstanzeKitModel>? ListRecords;
private int minChar = 2;
private bool OptAdmKitEnabled = false;
/// <summary>
/// RegExp x SAVE KIT
@@ -326,209 +306,5 @@ namespace MP.SPEC.Components
}
#endregion Private Methods
#if false
public string codKitTemp
{
get
{
return memLayer.ML.StringSessionObj(string.Format("codKitTemp_{0}", uid));
}
set
{
memLayer.ML.setSessionVal(string.Format("codKitTemp_{0}", uid), value);
hlCodKitTemp.Value = value;
grViewWSK.DataBind();
}
}
/// <summary>
/// Ultimo Codice KIT creato
/// </summary>
public string lastKitMade
{
get
{
return memLayer.ML.StringSessionObj("lastKitMade");
}
set
{
memLayer.ML.setSessionVal("lastKitMade", value);
}
}
/// <summary>
/// Aggiunge (in obj OrdineKit) l'ordine coi parametri indicati
/// </summary>
/// <param name="codOrd"></param>
/// <param name="codArt"></param>
/// <param name="descArt"></param>
/// <param name="qta"></param>
/// <returns></returns>
public bool addOrdArt(string codOrd, string codArt, string descArt, int qta)
{
bool answ = false;
// verifico di avere un codiceKIT
checkCodKit();
// salvo info x il cod temporaneo...
DataLayerObj.taWKS.insertQuery(codKitTemp, codOrd, codArt, descArt, qta);
// verifico SE HO un KIT riconosciuto e quindi un CodArt di KIT valido...
string currCodArtKit = "###";
var TksTab = DataLayerObj.taTKS.GetData(codKitTemp, 1);
bool showPODL = false;
if (TksTab.Rows.Count > 0)
{
// verifico se ho aderenza 100%...
if (TksTab[0].TotalScore == 1)
{
currCodArtKit = TksTab[0].CodArtParent;
showPODL = true;
}
}
hfCodArtKit.Value = currCodArtKit;
divPODL.Visible = showPODL;
answ = true;
grViewWSK.DataBind();
grViewKitSel.DataBind();
grViewPODL.DataBind();
grViewIstanzeKIT.DataBind();
return answ;
}
private void doReset()
{
// elimino eventuali record ODL
DataLayerObj.taWKS.deleteQuery(codKitTemp);
codKitTemp = "";
divPODL.Visible = false;
checkCodKit();
}
/// <summary>
/// Ultimo input registrato
/// </summary>
public string lastInput
{
get
{
return hlLastInput.Value;
}
set
{
hlLastInput.Value = value;
}
}
/// <summary>
/// Aggiorno controllo secondo ULTIMO input
/// </summary>
public void doUpdate()
{
// aggiorno label...
messOut = "";
// controllo input (reset/inizio o salva...)
if (lastInput == regExp_KO)
{
// resetto dati
doReset();
messOut = "Effettuato reset!";
}
else if (lastInput == regExp_KitStart)
{
// resetto dati
doReset();
messOut = "Inizio configurazione KIT";
}
else if (lastInput == regExp_KitSave)
{
// controllo SE HO un kit selezionato...
string currCodArtKit = "###";
var TksTab = DataLayerObj.taTKS.GetData(codKitTemp, 1);
bool showPODL = false;
if (TksTab.Rows.Count > 0)
{
// verifico se ho aderenza 100%...
if (TksTab[0].TotalScore == 1)
{
currCodArtKit = TksTab[0].CodArtParent;
showPODL = true;
}
}
if (showPODL)
{
// in questo caso creo istanza!
creazioneIstanzaKit(currCodArtKit);
}
}
else if (lastInput == regExp_OK)
{
}
// ennesimo check cod TEMP
checkCodKit();
}
/// <summary>
/// Verifico SE HO un codKit Temporaneo sennò lo creo...
/// </summary>
private void checkCodKit()
{
if (codKitTemp == "")
{
// genero un NUOVO cod temp kit...
codKitTemp = string.Format("KIT_{0:yyMMdd_HHmmss}", DateTime.Now);
}
}
public string messOut
{
set
{
lblOut.Text = value;
}
get
{
return lblOut.Text;
}
}
protected void grViewKitSel_SelectedIndexChanged(object sender, EventArgs e)
{
// se ho selezionato recupero CHIAVE = CodArticolo del KIT
string CodArtParent = grViewKitSel.SelectedValue.ToString();
// crea KIT x quel CodArtParent...
creazioneIstanzaKit(CodArtParent);
}
/// <summary>
/// Crea una NUOVA istanza KIT
/// </summary>
/// <param name="CodArtParent">CodArt dell'Assieme/KIT</param>
private void creazioneIstanzaKit(string CodArtParent)
{
// calcolo NUOVO codice kit...
var tabKey = DataLayerObj.taIstK.getNewKey();
if (tabKey.Rows.Count == 1)
{
// stacco un NUOVO codice KIT
lastKitMade = tabKey[0].KeyKit;
// inserisco ISTANZA KIT!
DataLayerObj.taIstK.insertByWKS(lastKitMade, CodArtParent, codKitTemp);
// faccio reset valori WKS...
doReset();
// ora resetto ordine caricato...
messOut = string.Format("Creato NUOVA P.ODL cod {0} per il KIT {1}", lastKitMade, CodArtParent);
// sollevo evento x impostare lettura KIT a BARCODE (x conferma successiva...)
// sollevo evento nuovo valore...
if (eh_selKit != null)
{
eh_selKit(this, new EventArgs());
}
}
}
#endif
}
}
+2 -2
View File
@@ -1898,7 +1898,7 @@ namespace MP.SPEC.Data
/// <returns></returns>
public async Task<List<MappaStatoExplModel>> MseGetAll(bool forceDb = false)
{
using var activity = ActivitySource.StartActivity("MseGetAll");
using var activity = ActivitySource.StartActivity("MseGetAllAsync");
string source = "DB";
List<MappaStatoExplModel>? result = new List<MappaStatoExplModel>();
// cerco in redisConn...
@@ -1922,7 +1922,7 @@ namespace MP.SPEC.Data
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
activity?.Stop();
LogTrace($"MseGetAll | {source} | {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"MseGetAllAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2602.2510</Version>
<Version>6.16.2602.2511</Version>
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
+48 -1
View File
@@ -6,13 +6,14 @@ using MP.Data.DbModels;
using MP.Data.Services;
using MP.SPEC.Components.Reparti;
using MP.SPEC.Data;
using Newtonsoft.Json;
using NLog.LayoutRenderers;
using static MP.Core.Objects.Enums;
using static MP.Data.Services.ExecStatsCollector;
namespace MP.SPEC.Pages
{
public partial class RepStop
public partial class RepStop: IDisposable
{
#region Protected Properties
@@ -35,6 +36,49 @@ namespace MP.SPEC.Pages
protected override async Task OnInitializedAsync()
{
await ReloadData();
TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage;
}
[Inject]
protected TabDataFeeder TDFeeder { get; set; } = null!;
public void Dispose()
{
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
}
/// <summary>
/// Ricevuto nuovi dati da mostrare!
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DataPipe_EA_NewMessage(object? sender, EventArgs e)
{
PubSubEventArgs currArgs = (PubSubEventArgs)e;
// conversione on-the-fly List<string> --> allarmi
if (!string.IsNullOrEmpty(currArgs.newMessage))
{
try
{
List<MappaStatoExplModel>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExplModel>>(currArgs.newMessage);
if (dataList != null)
{
InvokeAsync(() => SaveData(dataList));
}
}
catch
{ }
}
InvokeAsync(() =>
{
StateHasChanged();
});
}
protected async Task SaveData(List<MappaStatoExplModel> newList)
{
// salvo valori ricevuti
CurrMSE = newList;
}
#endregion Protected Methods
@@ -64,7 +108,10 @@ namespace MP.SPEC.Pages
private async Task DoReload(bool forceReload)
{
isLoading = true;
await Task.Delay(100);
CurrMSE = await MDService.MseGetAll(true);
isLoading = false;
}
/// <summary>
+1 -78
View File
@@ -131,84 +131,6 @@ else
logger.Info("⏸️ Telemetria e Tracing completamente disabilitati.");
}
//// 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");
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
@@ -231,6 +153,7 @@ builder.Services.AddSingleton<AppAuthService>();
builder.Services.AddScoped<MsgServiceSpec>();
builder.Services.AddSingleton<SharedMemService>();
builder.Services.AddSingleton<TabDataService>();
builder.Services.AddSingleton<TabDataFeeder>();
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddBlazoredSessionStorage();
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2602.2510</h4>
<h4>Versione: 6.16.2602.2511</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2602.2510
6.16.2602.2511
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2602.2510</version>
<version>6.16.2602.2511</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>
-9
View File
@@ -43,18 +43,9 @@ namespace MP.SPEC.Shared
protected override void OnInitialized()
{
//base.OnInitialized();
ElencoLink = MDService.ElencoLink();
}
#if false
protected override async Task OnInitializedAsync()
{
// recupero elenco JQM
await Task.Delay(1);
}
#endif
protected void ToggleCompress()
{
showText = !showText;