Completato salvataggio snapshot + refresh

This commit is contained in:
Samuele Locatelli
2022-09-21 10:26:09 +02:00
parent a3dc1e1657
commit 5df4195e6c
11 changed files with 110 additions and 118 deletions
+1 -2
View File
@@ -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}";
}
+22 -85
View File
@@ -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<Dossiers> RecordSel { get; set; }
[Parameter]
public SelectDossierParams SelFilter { get; set; } = null!;
[Parameter]
public EventCallback<int> TotRecordChanged { get; set; }
[Parameter]
public EventCallback<Dossiers> 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<Dossiers>? ListRecords;
private List<Dossiers>? SearchRecords;
private List<FluxLog>? 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<FluxLog>? 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;
+30 -15
View File
@@ -1,19 +1,34 @@
<div class="d-flex justify-content-between">
<div class="px-0 py-1">
@if (!liveUpdate)
{
<button class="btn btn-secondary" type="button" @onclick="() => toggleUpdate()">
<small>@lastUpdate</small>
</button>
}
else
{
<button class="btn btn-primary" type="button" @onclick="() => toggleUpdate()">
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Valori live
</button>
}
<div class="d-flex justify-content-between">
<div class="px-2">
@if (!liveUpdate)
{
<button class="btn btn-secondary" type="button" @onclick="() => toggleUpdate()">
<small>@lastUpdate</small>
</button>
}
else
{
<button class="btn btn-primary" type="button" @onclick="() => toggleUpdate()">
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Valori live
</button>
}
</div>
<div class="px-2">
@if (selMacchina != "*")
{
<button class="btn btn-warning" type="button" @onclick="() => takeSnapshot()">
<i class="fa-solid fa-camera"></i>
Registra
</button>
}
</div>
</div>
</div>
<div class="px-0">
@@ -21,9 +36,9 @@
@if (showEditPar)
{
<div class="px-0 input-group py-1" id="basic-addon1">
<button class="btn btn-primary" @onclick="() => toggleParams()"> <i class="fa-solid fa-arrow-right"></i></button>
<button class="btn btn-primary" @onclick="() => toggleParams()"> <i class="fa-solid fa-arrow-right"></i></button>
<label class="input-group-text" for="tempoAgg" title="Selezionare il tempo di aggiornamento dei dati"><i class="fa-solid fa-clock"></i></label>
<select @bind="@selTempoAgg" class="form-select" id="tempoAgg" title="Selezionare il tempo di aggiornamento dei dati">
<select @bind="@selTempoAgg" class="form-select" id="tempoAgg" title="Selezionare il tempo di aggiornamento dei dati" style="width: 3em;">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
+8
View File
@@ -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
+1 -1
View File
@@ -150,7 +150,7 @@
private string searchVal = "";
private bool showSearch;
private string stateSel = "*";
private string tipoSearch = "*";
private string tipoSearch = "";
#endregion Private Fields
+28 -9
View File
@@ -274,6 +274,14 @@ namespace MP.SPEC.Data
return await Task.FromResult(dbController.ConfigUpdate(updRec));
}
public List<FluxLog> convertToFluxLog(string Valore)
{
//string valStriped = Valore.Substring(7, Valore.Length - 8);
//var result = JsonConvert.DeserializeObject<List<FluxLog>>(valStriped);
var result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(Valore);
return result.ODL;
}
public void Dispose()
{
// Clear database controller
@@ -286,7 +294,7 @@ namespace MP.SPEC.Data
/// macchina (ordinato x data registrazione)
/// </summary>
/// <param name="IdxMacchina">* = tutte, altrimenti solo x una data macchina</param>
/// <param name="DtRef">Data di riferimento (Massima) per estrazioen records</param>
/// <param name="DtRef">Data di riferimento (Massima) per estrazione records</param>
/// <param name="MaxRec">numero massimo record da restituire</param>
/// <returns></returns>
public async Task<List<Dossiers>> 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<FluxLog> convertToFluxLog(string Valore)
/// <summary>
/// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
/// </summary>
/// <param name="IdxMacchina">macchina</param>
/// <param name="maxSec">NUm massimo secondi per recuperare dati correnti</param>
/// <returns></returns>
public async Task<bool> DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec)
{
//string valStriped = Valore.Substring(7, Valore.Length - 8);
//var result = JsonConvert.DeserializeObject<List<FluxLog>>(valStriped);
var result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(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;
}
/// <summary>
@@ -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";
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.15.2209.2109</Version>
<Version>6.16.2209.2110</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.15.2209.2109</h4>
<h4>Versione: 6.16.2209.2110</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.15.2209.2109
6.16.2209.2110
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.15.2209.2109</version>
<version>6.16.2209.2110</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>