diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 4172154b..bd9e5a2d 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -1,6 +1,7 @@ using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using MP.Data.DatabaseModels; using NLog; using System; using System.Collections.Generic; @@ -27,7 +28,7 @@ namespace MP.Data.Controllers /// Elenco Gruppi tipo Azienda /// /// - public List AnagGruppiAziende() + public List AnagGruppiAziende() { return AnagGruppiGetTipo("AZIENDA"); } @@ -36,7 +37,7 @@ namespace MP.Data.Controllers /// Elenco Gruppi tipo Fasi /// /// - public List AnagGruppiFase() + public List AnagGruppiFase() { return AnagGruppiGetTipo("FASE"); } @@ -45,9 +46,9 @@ namespace MP.Data.Controllers /// Elenco Gruppi /// /// - public List AnagGruppiGetAll() + public List AnagGruppiGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -64,9 +65,9 @@ namespace MP.Data.Controllers /// /// /// - public List AnagGruppiGetTipo(string tipoGruppo) + public List AnagGruppiGetTipo(string tipoGruppo) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -83,7 +84,7 @@ namespace MP.Data.Controllers /// Elenco valori ammessi x Stati commessa (es Yacht Baglietto) /// /// - public List AnagStatiComm() + public List AnagStatiComm() { return ListValuesFilt("PODL", "StatoComm"); } @@ -92,7 +93,7 @@ namespace MP.Data.Controllers /// Elenco valori ammessi x Tipo articoli /// /// - public List AnagTipoArtLV() + public List AnagTipoArtLV() { return ListValuesFilt("AnagArticoli", "Tipo"); } @@ -102,7 +103,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task ArticoliDeleteRecord(DatabaseModels.AnagArticoli currRec) + public async Task ArticoliDeleteRecord(AnagArticoli currRec) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) @@ -133,9 +134,9 @@ namespace MP.Data.Controllers /// /// /// - public List ArticoliGetSearch(int numRecord, string searchVal = "") + public List ArticoliGetSearch(int numRecord, string searchVal = "") { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -156,9 +157,9 @@ namespace MP.Data.Controllers /// /// /// - public List ArticoliGetSearch(int numRecord, string azienda = "*", string searchVal = "") + public List ArticoliGetSearch(int numRecord, string azienda = "*", string searchVal = "") { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -176,9 +177,9 @@ namespace MP.Data.Controllers /// Elenco tabella Articoli IMPIEGATI (da stored stp_ART_getUsed) /// /// - public List ArticoliGetUsed() + public List ArticoliGetUsed() { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -195,7 +196,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task ArticoliUpdateRecord(DatabaseModels.AnagArticoli editRec) + public async Task ArticoliUpdateRecord(AnagArticoli editRec) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) @@ -235,9 +236,9 @@ namespace MP.Data.Controllers /// Elenco da tabella Config /// /// - public List ConfigGetAll() + public List ConfigGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -253,10 +254,10 @@ namespace MP.Data.Controllers /// Update record config /// /// - public bool ConfigUpdate(DatabaseModels.ConfigModel updRec) + public bool ConfigUpdate(ConfigModel updRec) { bool fatto = false; - DatabaseModels.ConfigModel dbResult = new DatabaseModels.ConfigModel(); + ConfigModel dbResult = new ConfigModel(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -277,6 +278,36 @@ namespace MP.Data.Controllers { } + /// + /// Eliminazione di un dossier + /// + /// record dossier da eliminare + /// + public async Task DossiersDeleteRecord(Dossiers currRec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + var currVal = dbCtx + .DbSetDossiers + .Where(x => x.IdxDossier == currRec.IdxDossier) + .FirstOrDefault(); + dbCtx + .DbSetDossiers + .Remove(currVal); + await dbCtx.SaveChangesAsync(); + answ = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DossiersDeleteRecord{Environment.NewLine}{exc}"); + } + } + return answ; + } + /// /// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato /// macchina (ordinato x data registrazione) @@ -285,9 +316,9 @@ namespace MP.Data.Controllers /// Data di riferimento (Massima) per estrazioen records /// numero massimo record da restituire /// - public List DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec) + public List DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -301,17 +332,24 @@ namespace MP.Data.Controllers return dbResult; } - public bool DossiersTakeParamsSnapshot(string idxMacchina, int maxSec) + /// + /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis + /// + /// macchina + /// Num massimo secondi per recuperare dati correnti + /// DataOra riferimento x cui prendere valori antecedenti + public bool DossiersTakeParamsSnapshot(string idxMacchina, int maxSec, DateTime dtRif) { bool answ = false; using (var dbCtx = new MoonProContext(_configuration)) { var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); var pMaxSec = new SqlParameter("@MaxSec", maxSec); + var pDtRif = new SqlParameter("@DtRif", dtRif); var dbResult = dbCtx .Database - .ExecuteSqlRaw("EXEC stp_FL_TakeSnapshot @IdxMacchina,@MaxSec", pIdxMacchina, pMaxSec); + .ExecuteSqlRaw("EXEC stp_FL_TakeSnapshot @IdxMacchina,@MaxSec,@DtRif", pIdxMacchina, pMaxSec, pDtRif); answ = true; } return answ; @@ -321,7 +359,7 @@ namespace MP.Data.Controllers /// Elenco valori link (x home e navMenu laterale) /// /// - public List ElencoLink() + public List ElencoLink() { return ListLinkFilt("SpecLink"); } @@ -329,19 +367,20 @@ namespace MP.Data.Controllers /// /// 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 List FluxLogGetLastFilt(string IdxMacchina, string CodFlux, int MaxRec) + public List FluxLogGetLastFilt(DateTime DtMax, string IdxMacchina, string CodFlux, int MaxRec) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx .DbSetFluxLog .AsNoTracking() - .Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux)) + .Where(x => (x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux)) .OrderByDescending(x => x.dtEvento) .Take(MaxRec) .ToList(); @@ -349,9 +388,9 @@ namespace MP.Data.Controllers return dbResult; } - public List ListLinkFilt(string tipoLink) + public List ListLinkFilt(string tipoLink) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -371,9 +410,9 @@ namespace MP.Data.Controllers /// Cod articolo /// KeyRich (parziale) da cercare (es cod stato x yacht) /// - public List ListODLFilt(bool inCorso, string codArt, string keyRichPart) + public List ListODLFilt(bool inCorso, string codArt, string keyRichPart) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -392,9 +431,9 @@ namespace MP.Data.Controllers /// Cod articolo /// KeyRich (parziale) da cercare (es cod stato x yacht) /// - public List ListPODLFilt(string codArt, string keyRichPart) + public List ListPODLFilt(string codArt, string keyRichPart) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -413,9 +452,9 @@ namespace MP.Data.Controllers /// /// /// - public List ListValuesFilt(string tabName, string fieldName) + public List ListValuesFilt(string tabName, string fieldName) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -432,9 +471,9 @@ namespace MP.Data.Controllers /// Elenco da tabella Macchine /// /// - public List MacchineGetAll() + public List MacchineGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { dbResult = dbCtx @@ -469,9 +508,9 @@ namespace MP.Data.Controllers /// Elenco da tabella MappaStatoExpl /// /// - public List MseGetAll(int maxAge = 2000) + public List MseGetAll(int maxAge = 2000) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonProContext(_configuration)) { var maxAgeSec = new SqlParameter("@maxAgeSec", maxAge); @@ -511,7 +550,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task PODLDeleteRecord(DatabaseModels.PODLModel currRec) + public async Task PODLDeleteRecord(PODLModel currRec) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) @@ -541,7 +580,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task PODLUpdateRecord(DatabaseModels.PODLModel editRec) + public async Task PODLUpdateRecord(PODLModel editRec) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) diff --git a/MP.Data/DatabaseModels/Dossiers.cs b/MP.Data/DatabaseModels/Dossiers.cs index a44a47bf..46c294a1 100644 --- a/MP.Data/DatabaseModels/Dossiers.cs +++ b/MP.Data/DatabaseModels/Dossiers.cs @@ -14,6 +14,9 @@ namespace MP.Data.DatabaseModels { #region Public Properties + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxDossier { get; set; } + [MaxLength(50)] public string DataType { get; set; } diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 221d765b..9d62d4f3 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -296,11 +296,6 @@ namespace MP.Data { entity.HasKey(e => new { e.IdxMacchina, e.dtEvento, e.CodFlux }); - }); - modelBuilder.Entity(entity => - { - entity.HasKey(e => new { e.IdxMacchina, e.DtRif }); - }); OnModelCreatingPartial(modelBuilder); diff --git a/MP.SPEC/Components/ListDossiers.razor b/MP.SPEC/Components/ListDossiers.razor index 16e5bcf8..afe8d0a6 100644 --- a/MP.SPEC/Components/ListDossiers.razor +++ b/MP.SPEC/Components/ListDossiers.razor @@ -23,6 +23,7 @@ else Data ODL DATA TYPE + @@ -44,6 +45,8 @@ else @record.DataType + + } @@ -63,7 +66,7 @@ else Macchina Data - ODL + Data Type Valore @@ -89,7 +92,6 @@ else } - } diff --git a/MP.SPEC/Components/ListDossiers.razor.cs b/MP.SPEC/Components/ListDossiers.razor.cs index e89fe063..ed066ead 100644 --- a/MP.SPEC/Components/ListDossiers.razor.cs +++ b/MP.SPEC/Components/ListDossiers.razor.cs @@ -37,6 +37,22 @@ namespace MP.SPEC.Components return answ; } + /// + /// Eliminazione record selezionato (previa conferma) + /// + /// + /// + protected async Task deleteRecord(Dossiers selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", "Eliminazione Dossier: sei sicuro di voler procedere?")) + return; + await Task.Delay(1); + var done = await MDService.DossiersDeleteRecord(selRec); + currRecord = null; + await reloadData(); + await Task.Delay(1); + } + public async Task reloadData(bool setChanged) { isLoading = true; diff --git a/MP.SPEC/Components/ListPARAMS.razor b/MP.SPEC/Components/ListPARAMS.razor index 9efdc64e..7d93b2da 100644 --- a/MP.SPEC/Components/ListPARAMS.razor +++ b/MP.SPEC/Components/ListPARAMS.razor @@ -17,21 +17,20 @@ else - @**@ + Data Macchina Parametro Valore - @foreach (var record in ListRecords) { - + - @**@ + @record.dtEvento @@ -45,12 +44,6 @@ else @record.Valore - - @*@if (ArticoloDelEnabled(record.CodArticolo)) - { - - }*@ - } diff --git a/MP.SPEC/Components/ListPARAMS.razor.cs b/MP.SPEC/Components/ListPARAMS.razor.cs index 6b0b346b..c699b8fe 100644 --- a/MP.SPEC/Components/ListPARAMS.razor.cs +++ b/MP.SPEC/Components/ListPARAMS.razor.cs @@ -13,6 +13,9 @@ namespace MP.SPEC.Components [Parameter] public EventCallback PagerResetReq { get; set; } + [Parameter] + public EventCallback RecordSel { get; set; } + [Parameter] public SelectFluxParams SelFilter { get; set; } = null!; @@ -23,14 +26,14 @@ namespace MP.SPEC.Components #region Public Methods - public string checkSelect(string IdxMacchina) + public string checkSelect(FluxLog selRecord) { string answ = ""; if (currRecord != null) { try { - answ = (currRecord.IdxMacchina == IdxMacchina) ? "table-info" : ""; + answ = (currRecord.IdxMacchina == selRecord.IdxMacchina && currRecord.dtEvento == selRecord.dtEvento && currRecord.CodFlux == selRecord.CodFlux) ? "table-info" : ""; } catch { } @@ -38,6 +41,20 @@ namespace MP.SPEC.Components return answ; } + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + // se sono cambiati --> rileggo... + if (LastFilter==null || !SelFilter.Equals(LastFilter)) + { + await reloadData(false); + LastFilter = SelFilter; + } + } + + + public SelectFluxParams? LastFilter = null; + public void Dispose() { aTimer.Elapsed -= ElapsedTimer; @@ -73,7 +90,12 @@ namespace MP.SPEC.Components public async Task reloadData(bool setChanged) { isLoading = true; - SearchRecords = await MDService.FluxLogGetLastFilt(SelMacchina, SelFlux, MaxRecord); + DateTime limitData = DateTime.Now; + if (SelDtMax != null) + { + limitData = (DateTime)SelDtMax; + } + SearchRecords = await MDService.FluxLogGetLastFilt(limitData, SelMacchina, SelFlux, MaxRecord); totalCount = SearchRecords.Count; ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); @@ -86,11 +108,9 @@ namespace MP.SPEC.Components public void StartTimer() { - //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); aTimer = new System.Timers.Timer(RefreshPeriod); aTimer.Elapsed += ElapsedTimer; aTimer.Enabled = true; - //aTimer.AutoReset = true; aTimer.Start(); } @@ -114,8 +134,6 @@ namespace MP.SPEC.Components #endregion Protected Properties - //protected int RefreshPeriod { get; set; } = 5000; - #region Protected Methods protected override async Task OnInitializedAsync() @@ -123,10 +141,10 @@ namespace MP.SPEC.Components MessageService.EA_PageUpdated += MessageService_EA_PageUpdated; MessageService.EA_SearchUpdated += OnSeachUpdated; StartTimer(); - - await reloadData(true); } + + //protected int RefreshPeriod { get; set; } = 5000; protected async void OnSeachUpdated() { await InvokeAsync(() => @@ -138,6 +156,20 @@ namespace MP.SPEC.Components }); } + protected async Task resetSel() + { + currRecord = null; + await RecordSel.InvokeAsync(null); + } + + protected async Task selRecord(FluxLog selRec) + { + currRecord = selRec; + SelFilter.IdxMacchina = selRec.IdxMacchina; + await reloadData(false); + await RecordSel.InvokeAsync(selRec); + } + protected async Task UpdateData() { currRecord = null; @@ -192,6 +224,10 @@ namespace MP.SPEC.Components { get => SelFilter.IdxMacchina; } + private DateTime? SelDtMax + { + get => SelFilter.dtMax; + } private int totalCount { diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs index 01dd5644..6e3d1422 100644 --- a/MP.SPEC/Components/ListPODL.razor.cs +++ b/MP.SPEC/Components/ListPODL.razor.cs @@ -52,7 +52,7 @@ namespace MP.SPEC.Components #region Protected Methods /// - /// Eliminazione record selezioanto (previa conferma) + /// Eliminazione record selezionato (previa conferma) /// /// /// diff --git a/MP.SPEC/Components/ParamsFilter.razor b/MP.SPEC/Components/ParamsFilter.razor index 41e13353..7642a4c3 100644 --- a/MP.SPEC/Components/ParamsFilter.razor +++ b/MP.SPEC/Components/ParamsFilter.razor @@ -6,7 +6,7 @@ @if (!liveUpdate) { - } @@ -19,12 +19,23 @@ }
- @if (selMacchina != "*") { + } +
+
+ @if (snapshotDone) + { + }
@@ -35,42 +46,25 @@
@if (showEditPar) { -
+
} @@ -81,7 +75,7 @@
}
-
+
+ @if (dtMax == null) + { + + } + else + { + + + }
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 -
+
@@ -35,7 +35,7 @@ {
-
+
Modifica
diff --git a/MP.SPEC/Pages/Articoli.razor.cs b/MP.SPEC/Pages/Articoli.razor.cs index c2f10873..2dabf683 100644 --- a/MP.SPEC/Pages/Articoli.razor.cs +++ b/MP.SPEC/Pages/Articoli.razor.cs @@ -97,7 +97,7 @@ namespace MP.SPEC.Pages } /// - /// Eliminazione record selezioanto (previa conferma) + /// Eliminazione record selezionato (previa conferma) /// /// /// diff --git a/MP.SPEC/Pages/DOSS.razor b/MP.SPEC/Pages/DOSS.razor index ff778773..94278ea8 100644 --- a/MP.SPEC/Pages/DOSS.razor +++ b/MP.SPEC/Pages/DOSS.razor @@ -1,6 +1,6 @@ @page "/DOSS" -
+
diff --git a/MP.SPEC/Pages/Index.razor b/MP.SPEC/Pages/Index.razor index 0616f89b..2fefa35f 100644 --- a/MP.SPEC/Pages/Index.razor +++ b/MP.SPEC/Pages/Index.razor @@ -2,7 +2,7 @@ Index -
+
diff --git a/MP.SPEC/Pages/ODL.razor b/MP.SPEC/Pages/ODL.razor index 10b5550c..4677d2f5 100644 --- a/MP.SPEC/Pages/ODL.razor +++ b/MP.SPEC/Pages/ODL.razor @@ -1,6 +1,6 @@ @page "/ODL" -
+
diff --git a/MP.SPEC/Pages/PARAMS.razor b/MP.SPEC/Pages/PARAMS.razor index 2e62bc74..8b4777f0 100644 --- a/MP.SPEC/Pages/PARAMS.razor +++ b/MP.SPEC/Pages/PARAMS.razor @@ -1,6 +1,6 @@ @page "/PARAMS" -
+
@@ -25,7 +25,7 @@ } else { - + }