diff --git a/MP.SPEC/Components/ListPARAMS.razor.cs b/MP.SPEC/Components/ListPARAMS.razor.cs index 485a1150..41474db0 100644 --- a/MP.SPEC/Components/ListPARAMS.razor.cs +++ b/MP.SPEC/Components/ListPARAMS.razor.cs @@ -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 = "*"; diff --git a/MP.SPEC/Pages/PARAMS.razor b/MP.SPEC/Pages/PARAMS.razor index 20cde666..e4f75732 100644 --- a/MP.SPEC/Pages/PARAMS.razor +++ b/MP.SPEC/Pages/PARAMS.razor @@ -61,7 +61,7 @@
- +