77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
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.Mon;
|
|
using MP.Mon.Shared;
|
|
using MP.Mon.Components;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.Mon.Components;
|
|
using MP.Mon.Data;
|
|
|
|
namespace MP.Mon.Pages
|
|
{
|
|
public partial class Index : IDisposable
|
|
{
|
|
protected List<MappaStatoExpl>? ListMSE = null;
|
|
|
|
protected int keepAliveMin = 5; // leggere da conf?
|
|
|
|
protected int maxCol = 6; // leggere da conf?
|
|
|
|
protected bool doAnimate = true; // leggere da conf?
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
StartTimer();
|
|
}
|
|
|
|
|
|
[Inject]
|
|
protected MpDataService MMDataService { get; set; } = null!;
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
ListMSE = await MMDataService.MseGetAll();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
|
|
private static System.Timers.Timer aTimer;
|
|
|
|
public void StartTimer()
|
|
{
|
|
int tOutPeriod = 2000;
|
|
//int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod);
|
|
aTimer = new System.Timers.Timer(tOutPeriod);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
public void ElapsedTimer(Object source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await ReloadData();
|
|
//await Task.Delay(1);
|
|
await InvokeAsync(StateHasChanged);
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
} |