Fix live + filtri x parameters
This commit is contained in:
@@ -5,10 +5,28 @@ using MP.SPEC.Data;
|
||||
|
||||
namespace MP.SPEC.Components
|
||||
{
|
||||
public partial class ListPARAMS
|
||||
public partial class ListPARAMS : IDisposable
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public bool LiveUpdate { get; set; }
|
||||
//{
|
||||
// get => _liveUpdate;
|
||||
// set
|
||||
// {
|
||||
// if (_liveUpdate != value)
|
||||
// {
|
||||
// _liveUpdate = value;
|
||||
// var pUpd = Task.Run(async () => await reloadData(true));
|
||||
// pUpd.Wait();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
private bool _liveUpdate { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int MaxRecord
|
||||
{
|
||||
@@ -76,6 +94,26 @@ namespace MP.SPEC.Components
|
||||
return answ;
|
||||
}
|
||||
|
||||
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(true));
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task reloadData(bool setChanged)
|
||||
{
|
||||
isLoading = true;
|
||||
@@ -90,6 +128,17 @@ namespace MP.SPEC.Components
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
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 Properties
|
||||
@@ -111,6 +160,7 @@ namespace MP.SPEC.Components
|
||||
{
|
||||
MessageService.EA_PageUpdated += MessageService_EA_PageUpdated;
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
StartTimer();
|
||||
|
||||
await reloadData(true);
|
||||
}
|
||||
@@ -136,6 +186,7 @@ namespace MP.SPEC.Components
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static System.Timers.Timer aTimer = null!;
|
||||
private int _maxRecord = 300;
|
||||
private string _selFlux = "*";
|
||||
private string _selMacchina = "*";
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<ListPARAMS SelMacchina="@selMacchina" SelFlux="@selFlux"></ListPARAMS>
|
||||
<ListPARAMS SelMacchina="@selMacchina" SelFlux="@selFlux" LiveUpdate="@liveUpdate"></ListPARAMS>
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager @ref="pagerODL" PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
|
||||
@@ -5,40 +5,11 @@ using MP.SPEC.Data;
|
||||
|
||||
namespace MP.SPEC.Pages
|
||||
{
|
||||
public partial class PARAMS : IDisposable
|
||||
public partial class PARAMS
|
||||
{
|
||||
#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
|
||||
|
||||
@@ -89,9 +60,8 @@ namespace MP.SPEC.Pages
|
||||
MsgService.SearchVal = "";
|
||||
|
||||
ListMacchine = await MDService.MacchineGetAll();
|
||||
StartTimer();
|
||||
// carico dati
|
||||
lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
|
||||
lastUpdate = $"Updated: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
|
||||
await reloadFilters();
|
||||
await reloadData();
|
||||
}
|
||||
@@ -124,7 +94,6 @@ namespace MP.SPEC.Pages
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static System.Timers.Timer aTimer = null!;
|
||||
|
||||
private List<string>? ListFlux;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user