diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 8c27cd57..4172154b 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -1,12 +1,10 @@ using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using MP.Data.DatabaseModels; using NLog; using System; using System.Collections.Generic; using System.Linq; -using System.Text.Json; using System.Threading.Tasks; namespace MP.Data.Controllers @@ -303,6 +301,22 @@ namespace MP.Data.Controllers return dbResult; } + public bool DossiersTakeParamsSnapshot(string idxMacchina, int maxSec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + var pMaxSec = new SqlParameter("@MaxSec", maxSec); + + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_FL_TakeSnapshot @IdxMacchina,@MaxSec", pIdxMacchina, pMaxSec); + answ = true; + } + return answ; + } + /// /// Elenco valori link (x home e navMenu laterale) /// diff --git a/MP.SPEC/Components/CmpTop.razor b/MP.SPEC/Components/CmpTop.razor index 994fd8da..8061e546 100644 --- a/MP.SPEC/Components/CmpTop.razor +++ b/MP.SPEC/Components/CmpTop.razor @@ -43,7 +43,6 @@ } private async void MService_EA_ShowSearch() { - //await forceReload(); await Task.Delay(1); await InvokeAsync(() => StateHasChanged()); } @@ -54,7 +53,7 @@ var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); var user = authState.User; - if (user.Identity.IsAuthenticated) + if (user.Identity != null&& user.Identity.IsAuthenticated) { userName = $"{user.Identity.Name}"; } diff --git a/MP.SPEC/Components/ListDossiers.razor.cs b/MP.SPEC/Components/ListDossiers.razor.cs index aa60446a..e89fe063 100644 --- a/MP.SPEC/Components/ListDossiers.razor.cs +++ b/MP.SPEC/Components/ListDossiers.razor.cs @@ -1,22 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; using Microsoft.JSInterop; -using MP.SPEC; -using MP.SPEC.Shared; -using MP.SPEC.Components; using MP.Data.DatabaseModels; using MP.SPEC.Data; -using System.Diagnostics; namespace MP.SPEC.Components { @@ -24,13 +9,14 @@ namespace MP.SPEC.Components { #region Public Properties + [Parameter] + public EventCallback RecordSel { get; set; } + [Parameter] public SelectDossierParams SelFilter { get; set; } = null!; [Parameter] public EventCallback TotRecordChanged { get; set; } - [Parameter] - public EventCallback RecordSel { get; set; } #endregion Public Properties @@ -51,40 +37,6 @@ namespace MP.SPEC.Components return answ; } -#if false - public void Dispose() - { - aTimer.Elapsed -= ElapsedTimer; - MessageService.EA_PageUpdated -= MessageService_EA_PageUpdated; - MessageService.EA_SearchUpdated -= OnSeachUpdated; - aTimer.Stop(); - aTimer.Dispose(); - } -#endif - - //public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) - //{ - // if (!isLoading && LiveUpdate) - // { - // aTimer.Stop(); - // // inizio misura esecuzione - // Stopwatch stopWatch = new Stopwatch(); - // stopWatch.Start(); - // var pUpd = Task.Run(async () => - // { - // await Task.Delay(1); - // await InvokeAsync(() => reloadData(true)); - // }); - // pUpd.Wait(); - // // misuro tempo esecuzione - // stopWatch.Stop(); - // TimeSpan ts = stopWatch.Elapsed; - // int deltaTime = RefreshPeriod - (int)ts.TotalMilliseconds; - // aTimer.Interval = deltaTime > 100 ? deltaTime : 100; - // aTimer.Start(); - // } - //} - public async Task reloadData(bool setChanged) { isLoading = true; @@ -99,16 +51,6 @@ namespace MP.SPEC.Components isLoading = false; } - //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(); - //} - #endregion Public Methods #region Protected Properties @@ -122,12 +64,6 @@ namespace MP.SPEC.Components [Inject] protected MessageService MessageService { get; set; } = null!; - //protected int RefreshPeriod - //{ - // get => SelFilter.TempoAgg; - //} - //protected int RefreshPeriod { get; set; } = 5000; - #endregion Protected Properties #region Protected Methods @@ -141,23 +77,24 @@ namespace MP.SPEC.Components await reloadData(); } - protected async Task selRecord(Dossiers selRec) - { - currRecord = selRec; - await RecordSel.InvokeAsync(selRec); - listaFlux = MDService.convertToFluxLog(selRec.Valore); - toggleTableFlux(); - } protected async void OnSeachUpdated() { await InvokeAsync(() => { - //currPage = 1; + currPage = 1; StateHasChanged(); }); } + protected async Task selRecord(Dossiers selRec) + { + currRecord = selRec; + await RecordSel.InvokeAsync(selRec); + listaFlux = MDService.convertToFluxLog(selRec.Valore); + await toggleTableFlux(); + } + protected async Task UpdateData() { currRecord = null; @@ -168,13 +105,10 @@ namespace MP.SPEC.Components #region Private Fields - //private static System.Timers.Timer aTimer = null!; - private int _totalCount = 0; private Dossiers? currRecord = null; private List? ListRecords; private List? SearchRecords; - private List? listaFlux { get; set; } = null; #endregion Private Fields @@ -186,9 +120,8 @@ namespace MP.SPEC.Components set => MessageService.currPage = value; } - private bool visualizzaFlux { get; set; } = true; - private bool isLoading { get; set; } = false; + private List? listaFlux { get; set; } = null; private int MaxRecord { @@ -201,15 +134,16 @@ namespace MP.SPEC.Components set => MessageService.numRecord = value; } - private string SelMacchina - { - get => SelFilter.IdxMacchina; - } private DateTime SelDtRef { get => SelFilter.DtRef; } + private string SelMacchina + { + get => SelFilter.IdxMacchina; + } + private int totalCount { get => _totalCount; @@ -223,6 +157,8 @@ namespace MP.SPEC.Components } } + private bool visualizzaFlux { get; set; } = true; + #endregion Private Properties #region Private Methods @@ -231,6 +167,7 @@ namespace MP.SPEC.Components { await reloadData(); } + private async Task reloadData() { isLoading = true; @@ -244,10 +181,10 @@ namespace MP.SPEC.Components private async Task toggleTableFlux() { - visualizzaFlux = false; await Task.Delay(1); } + private async Task unToggleTableFlux() { currRecord = null; diff --git a/MP.SPEC/Components/ParamsFilter.razor b/MP.SPEC/Components/ParamsFilter.razor index 91590d3c..41e13353 100644 --- a/MP.SPEC/Components/ParamsFilter.razor +++ b/MP.SPEC/Components/ParamsFilter.razor @@ -1,19 +1,34 @@ - @if (!liveUpdate) - { - toggleUpdate()"> - @lastUpdate - - } - else - { - toggleUpdate()"> - - Valori live - - } + + + + @if (!liveUpdate) + { + toggleUpdate()"> + @lastUpdate + + } + else + { + toggleUpdate()"> + + Valori live + + } + + + + @if (selMacchina != "*") + { + takeSnapshot()"> + + Registra + + } + + @@ -21,9 +36,9 @@ @if (showEditPar) { - toggleParams()"> + toggleParams()"> - + 2 3 4 diff --git a/MP.SPEC/Components/ParamsFilter.razor.cs b/MP.SPEC/Components/ParamsFilter.razor.cs index 101cb520..a715db76 100644 --- a/MP.SPEC/Components/ParamsFilter.razor.cs +++ b/MP.SPEC/Components/ParamsFilter.razor.cs @@ -149,6 +149,14 @@ namespace MP.SPEC.Components } } + protected async Task takeSnapshot() + { + // fermo udpate + liveUpdate = false; + await MDService.DossiersTakeParamsSnapshot(selMacchina, 10); + lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}"; + } + #endregion Protected Methods #region Private Fields diff --git a/MP.SPEC/Data/MessageService.cs b/MP.SPEC/Data/MessageService.cs index 79ca19ff..02a690b2 100644 --- a/MP.SPEC/Data/MessageService.cs +++ b/MP.SPEC/Data/MessageService.cs @@ -150,7 +150,7 @@ private string searchVal = ""; private bool showSearch; private string stateSel = "*"; - private string tipoSearch = "*"; + private string tipoSearch = ""; #endregion Private Fields diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index af2ec5aa..64e95ba8 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -274,6 +274,14 @@ namespace MP.SPEC.Data return await Task.FromResult(dbController.ConfigUpdate(updRec)); } + public List convertToFluxLog(string Valore) + { + //string valStriped = Valore.Substring(7, Valore.Length - 8); + //var result = JsonConvert.DeserializeObject>(valStriped); + var result = JsonConvert.DeserializeObject(Valore); + return result.ODL; + } + public void Dispose() { // Clear database controller @@ -286,7 +294,7 @@ namespace MP.SPEC.Data /// macchina (ordinato x data registrazione) /// /// * = tutte, altrimenti solo x una data macchina - /// Data di riferimento (Massima) per estrazioen records + /// Data di riferimento (Massima) per estrazione records /// numero massimo record da restituire /// public async Task> DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec) @@ -318,15 +326,26 @@ namespace MP.SPEC.Data TimeSpan ts = stopWatch.Elapsed; Log.Debug($"DossiersGetLastFilt | Read from {readType}: {ts.TotalMilliseconds}ms"); return result; - - //return await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, DtRef, MaxRec)); } - public List convertToFluxLog(string Valore) + + /// + /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis + /// + /// macchina + /// NUm massimo secondi per recuperare dati correnti + /// + public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec) { - //string valStriped = Valore.Substring(7, Valore.Length - 8); - //var result = JsonConvert.DeserializeObject>(valStriped); - var result = JsonConvert.DeserializeObject(Valore); - return result.ODL; + bool answ = false; + await Task.Delay(1); + // chiamo stored x salvare parametri + dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec); + // svuoto cache redis x macchina + string currKey = $"{redisDossByMac}:{IdxMacchina}"; + redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1)); + currKey = $"{redisDossByMac}:*"; + redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1)); + return answ; } /// @@ -593,8 +612,8 @@ namespace MP.SPEC.Data private const string redisBaseAddr = "MP:"; private const string redisConfKey = redisBaseAddr + "SPEC:Cache:Config"; - private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac"; private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac"; + private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac"; private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux"; private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList"; private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom"; diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 318b2f36..55d5b54d 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.15.2209.2109 + 6.16.2209.2110 diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 81749999..59ec5ae7 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC - Versione: 6.15.2209.2109 + Versione: 6.16.2209.2110 Note di rilascio: diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 0ff92fea..86a8516f 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2209.2109 +6.16.2209.2110 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 05c0aa52..0cdb93c2 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2209.2109 + 6.16.2209.2110 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