-
@if (selMacchina != "*")
{
+ }
+
+
@if (showEditPar)
{
-
}
diff --git a/MP.SPEC/Components/ParamsFilter.razor.cs b/MP.SPEC/Components/ParamsFilter.razor.cs
index 9fbb67ff..454b7827 100644
--- a/MP.SPEC/Components/ParamsFilter.razor.cs
+++ b/MP.SPEC/Components/ParamsFilter.razor.cs
@@ -1,9 +1,10 @@
using Microsoft.AspNetCore.Components;
using MP.SPEC.Data;
+using System.Runtime.CompilerServices;
namespace MP.SPEC.Components
{
- public partial class ParamsFilter
+ public partial class ParamsFilter : IDisposable
{
#region Public Properties
@@ -15,6 +16,44 @@ namespace MP.SPEC.Components
#endregion Public Properties
+ #region Public Methods
+
+ ///
+ /// Inizializzazione con periodo e arrotondamento
+ ///
+ ///
+ ///
+ public static DateTime RoundDatetime(int minRound)
+ {
+ TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
+ int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound;
+ DateTime endRounded = DateTime.Today.AddMinutes(minDay);
+ return endRounded;
+ }
+
+ public void Dispose()
+ {
+ aTimer.Elapsed -= ElapsedTimer;
+ aTimer.Stop();
+ aTimer.Dispose();
+ }
+
+ public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
+ {
+ snapshotDone = false;
+ aTimer.Stop();
+ aTimer.Enabled = false;
+ //reportChange();
+ var pUpd = Task.Run(async () =>
+ {
+ await Task.Delay(1);
+ await InvokeAsync(() => StateHasChanged());
+ });
+ pUpd.Wait();
+ }
+
+ #endregion Public Methods
+
#region Protected Properties
protected string lastUpdate
@@ -64,10 +103,7 @@ namespace MP.SPEC.Components
protected string selMacchina
{
- get
- {
- return SelFilter.IdxMacchina;
- }
+ get => SelFilter.IdxMacchina;
set
{
if (!SelFilter.IdxMacchina.Equals(value))
@@ -122,6 +158,13 @@ namespace MP.SPEC.Components
#region Protected Methods
+ protected async Task navDossier()
+ {
+ await Task.Delay(1);
+ // rimando alla home
+ NavManager.NavigateTo("DOSS", true);
+ }
+
protected override async Task OnInitializedAsync()
{
SelFilter = new SelectFluxParams();
@@ -130,12 +173,39 @@ namespace MP.SPEC.Components
await FilterChanged.InvokeAsync(SelFilter);
}
+ protected void setDtMax()
+ {
+ // copio il filtro
+ var currFilt = SelFilter;
+ // fermo update
+ currFilt.LiveUpdate = false;
+ currFilt.CurrPage = 0;
+ currFilt.lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}";
+ currFilt.dtMax = RoundDatetime(5);
+ SelFilter = currFilt;
+ }
+
+ protected void startTimer()
+ {
+ aTimer = new System.Timers.Timer(5000);
+ aTimer.Elapsed += ElapsedTimer;
+ aTimer.Enabled = true;
+ aTimer.Start();
+ }
+
protected async Task takeSnapshot()
{
+ // indico snapshot fatto
+ snapshotDone = true;
+ startTimer();
// fermo udpate
liveUpdate = false;
- await MDService.DossiersTakeParamsSnapshot(selMacchina, 10);
- lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
+ // se non ho data rif uso adesso...
+ DateTime dtRif = SelFilter.dtRif == null ? DateTime.Now : (DateTime)SelFilter.dtRif;
+ // aggiungo 2 sec
+ dtRif = dtRif.AddSeconds(1);
+ await MDService.DossiersTakeParamsSnapshot(selMacchina, 10, dtRif);
+ lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}";
}
protected void toggleParams()
@@ -149,7 +219,11 @@ namespace MP.SPEC.Components
await Task.Delay(1);
if (!liveUpdate)
{
- lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
+ lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}";
+ }
+ else
+ {
+ dtMax = null;
}
}
@@ -157,15 +231,47 @@ namespace MP.SPEC.Components
#region Private Fields
+ private static System.Timers.Timer aTimer = new System.Timers.Timer();
private List
? ListFlux = null;
+
private List? ListMacchine = null;
+ private bool snapshotDone = false;
+
#endregion Private Fields
#region Private Properties
+ private DateTime? dtMax
+ {
+ get => SelFilter.dtMax;
+ set
+ {
+ if (SelFilter.dtMax != value)
+ {
+ // copio il filtro
+ var currFilt = SelFilter;
+ // fermo update
+ currFilt.LiveUpdate = false;
+ currFilt.CurrPage = 0;
+ currFilt.lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}";
+ currFilt.dtMax = value;
+ SelFilter = currFilt;
+ reportChange();
+ }
+ }
+ }
+
+ [Inject]
+ private NavigationManager NavManager { get; set; } = null!;
+
private bool showEditPar { get; set; } = false;
+ private string snapMode
+ {
+ get => SelFilter.dtRif == null ? "Realtime Rec" : $"Rec {SelFilter.dtRif:yyyy/MM/dd HH:mm:ss}";
+ }
+
#endregion Private Properties
#region Private Methods
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index 64e95ba8..7210a2a1 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -289,6 +289,26 @@ namespace MP.SPEC.Data
redisConn.Dispose();
}
+ ///
+ /// Eliminazione di un dossier
+ ///
+ /// record dossier da eliminare
+ ///
+ public async Task DossiersDeleteRecord(Dossiers selRecord)
+ {
+ bool result = false;
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ result = await dbController.DossiersDeleteRecord(selRecord);
+ // elimino cache redis...
+ RedisValue pattern = new RedisValue($"{redisDossByMac}:*");
+ bool answ = await ExecFlushRedisPattern(pattern);
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"DossiersDeleteRecord | IdxMacchina {selRecord.IdxMacchina} | DtRif {selRecord.DtRif} | IdxODL {selRecord.IdxODL} | {ts.TotalMilliseconds}ms");
+ return result;
+ }
+
///
/// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato
/// macchina (ordinato x data registrazione)
@@ -332,14 +352,15 @@ namespace MP.SPEC.Data
/// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
///
/// macchina
- /// NUm massimo secondi per recuperare dati correnti
+ /// NUm massimo secondi per recuperare dati correnti
+ /// DataOra riferimento x cui prendere valori antecedenti
///
- public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec)
+ public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec, DateTime DtRif)
{
bool answ = false;
await Task.Delay(1);
// chiamo stored x salvare parametri
- dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec);
+ dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec, DtRif);
// svuoto cache redis x macchina
string currKey = $"{redisDossByMac}:{IdxMacchina}";
redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1));
@@ -374,36 +395,53 @@ namespace MP.SPEC.Data
public async Task FlushRedisCache()
{
await Task.Delay(1);
+ RedisValue pattern = new RedisValue($"{redisBaseAddr}*");
+ bool answ = await ExecFlushRedisPattern(pattern);
+ return answ;
+ }
+
+ ///
+ /// Esegue flush memoria redis dato pattern
+ ///
+ ///
+ ///
+ private async Task ExecFlushRedisPattern(RedisValue pattern)
+ {
bool answ = false;
var listEndpoints = redisConnAdmin.GetEndPoints();
- var server = redisConnAdmin.GetServer(listEndpoints[0]);
- RedisValue pattern = new RedisValue($"{redisBaseAddr}*");
- if (server != null)
+ foreach (var endPoint in listEndpoints)
{
- var keyList = server.Keys(redisDb.Database, pattern);
- foreach (var item in keyList)
+ //var server = redisConnAdmin.GetServer(listEndpoints[0]);
+ var server = redisConnAdmin.GetServer(endPoint);
+ if (server != null)
{
- await redisDb.KeyDeleteAsync(item);
+ var keyList = server.Keys(redisDb.Database, pattern);
+ foreach (var item in keyList)
+ {
+ await redisDb.KeyDeleteAsync(item);
+ }
+ // brutalmente rimuovo intero contenuto DB... DANGER
+ //await server.FlushDatabaseAsync();
+ answ = true;
}
- // brutalmente rimuovo intero contenuto DB... DANGER
- //await server.FlushDatabaseAsync();
- answ = true;
}
+
return answ;
}
///
/// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione)
///
+ /// Data massima (recupera eventi antecedenti)
/// * = tutte, altrimenti solo x una data macchina
/// *=tutti, altrimenti solo selezionato
/// numero massimo record da restituire
///
- public async Task> FluxLogGetLastFilt(string IdxMacchina, string CodFlux, int MaxRec)
+ public async Task> FluxLogGetLastFilt(DateTime DtMax, string IdxMacchina, string CodFlux, int MaxRec)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
- var results = await Task.FromResult(dbController.FluxLogGetLastFilt(IdxMacchina, CodFlux, MaxRec));
+ var results = await Task.FromResult(dbController.FluxLogGetLastFilt(DtMax, IdxMacchina, CodFlux, MaxRec));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"FluxLogGetLastFilt | Read from DB: {ts.TotalMilliseconds}ms");
diff --git a/MP.SPEC/Data/SelectDossierParams.cs b/MP.SPEC/Data/SelectDossierParams.cs
index 9d55bb87..0c962273 100644
--- a/MP.SPEC/Data/SelectDossierParams.cs
+++ b/MP.SPEC/Data/SelectDossierParams.cs
@@ -13,7 +13,7 @@
public int CurrPage { get; set; } = 1;
- public DateTime DtRef { get; set; } = Init(5);
+ public DateTime DtRef { get; set; } = InitDatetime(5);
public string IdxMacchina { get; set; } = "*";
@@ -24,12 +24,11 @@
#region Public Methods
///
- /// Inizializzazione con periodo e arrotondamento
- ///
- ///
- ///
- ///
- public static DateTime Init(int minRound)
+ /// Inizializzazione con periodo e arrotondamento
+ ///
+ ///
+ ///
+ public static DateTime InitDatetime(int minRound)
{
TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound;
diff --git a/MP.SPEC/Data/SelectFluxParams.cs b/MP.SPEC/Data/SelectFluxParams.cs
index 39660b9f..4f416c7a 100644
--- a/MP.SPEC/Data/SelectFluxParams.cs
+++ b/MP.SPEC/Data/SelectFluxParams.cs
@@ -13,12 +13,14 @@
public string CodFlux { get; set; } = "*";
public int CurrPage { get; set; } = 1;
+ public DateTime? dtRif { get; set; } = null;
+ public DateTime? dtMax { get; set; } = null;
public string IdxMacchina { get; set; } = "*";
public string lastUpdate { get; set; } = "-";
public bool LiveUpdate { get; set; } = true;
public int MaxRecord { get; set; } = 100;
- public int TempoAgg { get; set; } = 2000;
+ public int TempoAgg { get; set; } = 10000;
#endregion Public Properties
diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj
index cb5eac54..84219a2b 100644
--- a/MP.SPEC/MP.SPEC.csproj
+++ b/MP.SPEC/MP.SPEC.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.SPEC
- 6.16.2209.2118
+ 6.16.2209.2711
diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor
index d6e4522f..8e161a2b 100644
--- a/MP.SPEC/Pages/Articoli.razor
+++ b/MP.SPEC/Pages/Articoli.razor
@@ -3,7 +3,7 @@
@using MP.SPEC.Components
@using MP.SPEC.Data
-