201 lines
4.9 KiB
C#
201 lines
4.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.SPEC.Components;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Pages
|
|
{
|
|
public partial class PARAMS : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
//aTimer.Elapsed -= ElapsedTimer;
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
|
|
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
if (!isLoading && liveUpdate)
|
|
{
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => reloadData());
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
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.AutoReset = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected string _selFlux = "*";
|
|
protected string _selMacchina = "*";
|
|
protected string lastUpdate = "-";
|
|
protected bool liveUpdate = false;
|
|
protected DataPager pagerODL;
|
|
protected bool reqNew = false;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; }
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; }
|
|
|
|
[Inject]
|
|
protected MessageService MsgService { get; set; }
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
// abilito ricerca...
|
|
MsgService.ShowSearch = false;
|
|
// resetto search
|
|
MsgService.SearchVal = "";
|
|
|
|
ListMacchine = await MDService.MacchineGetAll();
|
|
StartTimer();
|
|
// carico dati
|
|
lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
|
|
await reloadFilters();
|
|
await reloadData();
|
|
}
|
|
|
|
protected async Task pgResetReq(bool doReset)
|
|
{
|
|
if (doReset)
|
|
{
|
|
await pagerODL.resetCurrPage();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Crea nuovo record e va in editing...
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task reqNewPODL()
|
|
{
|
|
reqNew = !reqNew;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task toggleUpdate()
|
|
{
|
|
liveUpdate = !liveUpdate;
|
|
await reloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static System.Timers.Timer aTimer = null!;
|
|
|
|
private List<string>? ListFlux;
|
|
|
|
private List<MP.Data.DatabaseModels.Macchine>? ListMacchine;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private string currAziend { get; set; } = "*";
|
|
|
|
private int currPage
|
|
{
|
|
get => MsgService.currPage;
|
|
set => MsgService.currPage = value;
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private int numRecord
|
|
{
|
|
get => MsgService.numRecord;
|
|
set => MsgService.numRecord = value;
|
|
}
|
|
|
|
private string selFlux
|
|
{
|
|
get => _selFlux;
|
|
set => _selFlux = value;
|
|
}
|
|
|
|
|
|
private string selMacchina
|
|
{
|
|
get => _selMacchina;
|
|
set => _selMacchina = value;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => MsgService.totalCount;
|
|
set => MsgService.totalCount = value;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async void MsgService_EA_MacchUpdated()
|
|
{
|
|
await reloadFilters();
|
|
}
|
|
|
|
private async Task reloadData()
|
|
{
|
|
isLoading = true;
|
|
await Task.Delay(1);
|
|
if (!liveUpdate)
|
|
{
|
|
lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
|
|
}
|
|
isLoading = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async Task reloadFilters()
|
|
{
|
|
await Task.Delay(1);
|
|
ListFlux = await MDService.ParametriGetFilt(selMacchina);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |