Ancora update x gestione filtro/stop live...
This commit is contained in:
@@ -15,7 +15,17 @@ namespace MP.SPEC.Components
|
||||
public EventCallback<int> TotRecordChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool LiveUpdate { get; set; }
|
||||
public bool LiveUpdate
|
||||
{
|
||||
get => _liveUpdate;
|
||||
set
|
||||
{
|
||||
_liveUpdate = value;
|
||||
// var pUpd = Task.Run(async () => await reloadData(false));
|
||||
// pUpd.Wait();
|
||||
}
|
||||
}
|
||||
private bool _liveUpdate { get; set; }
|
||||
|
||||
|
||||
[Parameter]
|
||||
@@ -225,14 +235,9 @@ namespace MP.SPEC.Components
|
||||
if (_totalCount != value)
|
||||
{
|
||||
_totalCount = value;
|
||||
|
||||
//var pUpd = Task.Run(async () => await TotRecordChanged.InvokeAsync(value));
|
||||
//pUpd.Wait();
|
||||
TotRecordChanged.InvokeAsync(value);
|
||||
}
|
||||
}
|
||||
//get => MessageService.totalCount;
|
||||
//set => MessageService.totalCount = value;
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -283,6 +283,7 @@ namespace MP.SPEC.Data
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
redisConn.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -442,14 +443,20 @@ namespace MP.SPEC.Data
|
||||
public async Task<List<string>> ParametriGetFilt(string IdxMacchina)
|
||||
{
|
||||
List<string>? result = new List<string>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string readType = "DB";
|
||||
|
||||
result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina));
|
||||
|
||||
|
||||
#if false
|
||||
// 2 minuti valore cache
|
||||
int maxAgeMin = 5;
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
string currKey = $"{redisFluxByMac}:{IdxMacchina}";
|
||||
|
||||
// cerco in redis dato valore sel macchina...
|
||||
RedisValue rawData = await redisDb.StringGetAsync($"{redisFluxByMac}:{IdxMacchina}");
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<string>>($"{rawData}");
|
||||
@@ -462,16 +469,16 @@ namespace MP.SPEC.Data
|
||||
result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync($"{redisFluxByMac}:{IdxMacchina}", rawData, TimeSpan.FromMinutes(maxAgeMin));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ParametriGetFilt | Read from DB: {ts.TotalMilliseconds}ms");
|
||||
await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromMinutes(maxAgeMin));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<string>();
|
||||
}
|
||||
#endif
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ParametriGetFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,12 +49,13 @@ namespace MP.SPEC.Pages
|
||||
|
||||
protected void ForceReloadPage(int newNum)
|
||||
{
|
||||
liveUpdate = newNum == 1;
|
||||
//liveUpdate = newNum == 1;
|
||||
currPage = newNum;
|
||||
}
|
||||
|
||||
protected void updateTotal(int newTotCount)
|
||||
{
|
||||
//await Task.Delay(1);
|
||||
totalCount = newTotCount;
|
||||
}
|
||||
|
||||
@@ -137,6 +138,7 @@ namespace MP.SPEC.Pages
|
||||
_selFlux = value;
|
||||
ForceReloadPage(1);
|
||||
isLoading = false;
|
||||
liveUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,6 +165,7 @@ namespace MP.SPEC.Pages
|
||||
|
||||
ForceReloadPage(1);
|
||||
isLoading = false;
|
||||
liveUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user