Reload pagina anche su PlantStatus

This commit is contained in:
Samuele Locatelli
2021-11-03 19:28:35 +01:00
parent 67b6a5e6c2
commit e136c48dd2
3 changed files with 31 additions and 2 deletions
+2
View File
@@ -323,6 +323,8 @@ namespace GWMS.UI.Pages
public void Dispose()
{
aTimer.Stop();
aTimer.Dispose();
AppMService.EA_SearchUpdated -= OnSeachUpdated;
}
+28 -2
View File
@@ -3,12 +3,11 @@ using GWMS.UI.Data;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
@@ -18,6 +17,7 @@ namespace GWMS.UI.Pages
{
#region Private Fields
private static System.Timers.Timer aTimer;
private PlantDTO currRecord = null;
private List<PlantDTO> ListRecords;
@@ -35,6 +35,9 @@ namespace GWMS.UI.Pages
#region Private Properties
[Inject]
private IConfiguration Configuration { get; set; }
private bool isLoading { get; set; } = false;
private bool ShowCharts { get; set; } = false;
@@ -131,6 +134,7 @@ namespace GWMS.UI.Pages
MessageService.PageName = "Impianti";
MessageService.PageIcon = "fas fa-tachometer-alt pr-2";
MessageService.EA_SearchUpdated += OnSeachUpdated;
StartTimer();
await ReloadAllData();
}
@@ -152,15 +156,37 @@ namespace GWMS.UI.Pages
public void Dispose()
{
aTimer.Stop();
aTimer.Dispose();
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public void ElapsedTimer(Object source, System.Timers.ElapsedEventArgs e)
{
var pUpd = Task.Run(async () =>
{
await ReloadAllData();
await InvokeAsync(StateHasChanged);
});
pUpd.Wait();
}
public async void OnSeachUpdated()
{
await UpdateData();
StateHasChanged();
}
public void StartTimer()
{
int tOutPeriod = 3000;
int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod);
aTimer = new System.Timers.Timer(tOutPeriod);
aTimer.Elapsed += ElapsedTimer;
aTimer.Enabled = true;
aTimer.Start();
}
#endregion Public Methods
}
}
+1
View File
@@ -39,6 +39,7 @@
"ChartWaitDelay": 10,
"logo": "img/LogoPizzaferri.jpg",
"ReloadParamTimer": 5000,
"ReloadStatusTimer": 5000,
"ExternalProviders": {
"MailKit": {
"SMTP": {