From b076148e65ddabb48aee142586539c00be16850a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 8 Jul 2022 10:01:03 +0200 Subject: [PATCH] MON: - Update con log esteso - evitato server prerender x raddoppio pagina - test stress (disabilitato) --- MP.Mon/Components/DetailMSE.razor.cs | 196 +++++++++++++-------------- MP.Mon/MP.Mon.csproj | 2 +- MP.Mon/NLog.config | 2 +- MP.Mon/Pages/Index.razor.cs | 20 ++- MP.Mon/Pages/_Host.cshtml | 2 +- MP.Mon/Resources/ChangeLog.html | 2 +- MP.Mon/Resources/VersNum.txt | 2 +- MP.Mon/Resources/manifest.xml | 2 +- 8 files changed, 116 insertions(+), 112 deletions(-) diff --git a/MP.Mon/Components/DetailMSE.razor.cs b/MP.Mon/Components/DetailMSE.razor.cs index c9e91dd1..b67e53cb 100644 --- a/MP.Mon/Components/DetailMSE.razor.cs +++ b/MP.Mon/Components/DetailMSE.razor.cs @@ -1,39 +1,12 @@ -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.Data.Conf; +using MP.Data.DatabaseModels; +using NLog; namespace MP.Mon.Components { public partial class DetailMSE { - #region Protected Fields - - protected string baseCss = "sem"; - protected int kaFactor = 60 / 2; - - #endregion Protected Fields - - #region Private Fields - - private static System.Timers.Timer aTimer = new System.Timers.Timer(60 * 1000); - - #endregion Private Fields - #region Public Properties [Parameter] @@ -56,6 +29,80 @@ namespace MP.Mon.Components #endregion Public Properties + #region Public Methods + + public void Dispose() + { + aTimer.Stop(); + aTimer.Dispose(); + } + + public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) + { + var pUpd = Task.Run(async () => + { + Log.Trace($"Elapsed Timer {CurrRecord?.CodMacchina}"); + await Task.Delay(1); + await InvokeAsync(StateHasChanged); + }); + pUpd.Wait(); + } + + public void StartTimer() + { + int tOutPeriod = 1000; + //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); + aTimer = new System.Timers.Timer(tOutPeriod); + aTimer.Elapsed += ElapsedTimer; + aTimer.Enabled = true; + aTimer.Start(); + } + + #endregion Public Methods + + #region Protected Fields + + protected string baseCss = "sem"; + protected int kaFactor = 60 / 2; + + #endregion Protected Fields + + #region Protected Properties + + protected string codIOB + { + get + { + string answ = ""; + if (CurrRecord != null) + { + answ = CurrRecord.IdxMacchina; + } + return answ; + } + } + + protected bool dataLoaded { get; set; } = false; + + #endregion Protected Properties + + #region Protected Methods + + /// + /// restituisce il valore data la tagLocation + /// + /// + /// + protected string currVal(string tagLocation) + { + string answ = ""; + if (currTagVal.ContainsKey(tagLocation)) + { + answ = currTagVal[tagLocation]; + } + return answ; + } + /// /// Verifica se ci sia un override per la riga indicata /// @@ -75,6 +122,15 @@ namespace MP.Mon.Components return answ; } + protected override async Task OnInitializedAsync() + { + StartTimer(); + Random rnd = new Random(); + await Task.Delay(rnd.Next(5)); + setupConf(); + dataLoaded = true; + } + /// /// Restituisce (se presenti) valori di override per la riga indicata /// @@ -98,83 +154,15 @@ namespace MP.Mon.Components return rowVals; } - /// - /// restituisce il valore data la tagLocation - /// - /// - /// - protected string currVal(string tagLocation) - { - string answ = ""; - if (currTagVal.ContainsKey(tagLocation)) - { - answ = currTagVal[tagLocation]; - } - return answ; - } - - #region Protected Properties - - protected string codIOB - { - get - { - string answ = ""; - if (CurrRecord != null) - { - answ = CurrRecord.IdxMacchina; - } - return answ; - } - } - - protected bool dataLoaded { get; set; } = false; - - #endregion Protected Properties - - #region Public Methods - - public void Dispose() - { - aTimer.Stop(); - aTimer.Dispose(); - } - - public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) - { - var pUpd = Task.Run(async () => - { - await Task.Delay(1); - await InvokeAsync(StateHasChanged); - }); - pUpd.Wait(); - } - - public void StartTimer() - { - int tOutPeriod = 1000; - //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod); - aTimer = new System.Timers.Timer(tOutPeriod); - aTimer.Elapsed += ElapsedTimer; - aTimer.Enabled = true; - aTimer.Start(); - } - - #endregion Public Methods - - #region Protected Methods - - protected override async Task OnInitializedAsync() - { - StartTimer(); - Random rnd = new Random(); - await Task.Delay(rnd.Next(5)); - dataLoaded = true; - setupConf(); - } - #endregion Protected Methods + #region Private Fields + + private static System.Timers.Timer aTimer { get; set; } = null!; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + #region Private Methods private string cssComStatus(string semaforo, DateTime? lastUpdateN) diff --git a/MP.Mon/MP.Mon.csproj b/MP.Mon/MP.Mon.csproj index b9c8a139..a97f1c6d 100644 --- a/MP.Mon/MP.Mon.csproj +++ b/MP.Mon/MP.Mon.csproj @@ -4,7 +4,7 @@ net6.0 enable enable - 6.15.2207.718 + 6.15.2207.810 diff --git a/MP.Mon/NLog.config b/MP.Mon/NLog.config index bd414080..b32ba10a 100644 --- a/MP.Mon/NLog.config +++ b/MP.Mon/NLog.config @@ -29,7 +29,7 @@ layout="${longdate} ${uppercase:${level}} ${message}" /> --> - + diff --git a/MP.Mon/Pages/Index.razor.cs b/MP.Mon/Pages/Index.razor.cs index e612fb93..d028d1b9 100644 --- a/MP.Mon/Pages/Index.razor.cs +++ b/MP.Mon/Pages/Index.razor.cs @@ -64,7 +64,8 @@ namespace MP.Mon.Pages var pUpd = Task.Run(async () => { await ReloadData(); - //await Task.Delay(1); + await Task.Delay(1); + Log.Trace("Elapsed Fast Timer"); await InvokeAsync(StateHasChanged); }); pUpd.Wait(); @@ -74,6 +75,7 @@ namespace MP.Mon.Pages { ListMSE = null; await Task.Delay(1); + Log.Trace("Elapsed Slow Timer"); NavManager.NavigateTo(NavManager.Uri); } @@ -188,7 +190,21 @@ namespace MP.Mon.Pages private async Task ReloadData() { - ListMSE = await MMDataService.MseGetAll(); + // hack: legge 4 volte i dati x stressare sistema + bool stressTest = false; + if (stressTest) + { + var singleData = await MMDataService.MseGetAll(); + ListMSE = singleData.ToList(); + for (int i = 0; i < 3; i++) + { + ListMSE.AddRange(singleData); + } + } + else + { + ListMSE = await MMDataService.MseGetAll(); + } } private async Task setupConf() diff --git a/MP.Mon/Pages/_Host.cshtml b/MP.Mon/Pages/_Host.cshtml index 3417db8d..2787c70d 100644 --- a/MP.Mon/Pages/_Host.cshtml +++ b/MP.Mon/Pages/_Host.cshtml @@ -5,4 +5,4 @@ Layout = "_Layout"; } - \ No newline at end of file + \ No newline at end of file diff --git a/MP.Mon/Resources/ChangeLog.html b/MP.Mon/Resources/ChangeLog.html index 650bbc24..7d69493d 100644 --- a/MP.Mon/Resources/ChangeLog.html +++ b/MP.Mon/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MON MAPO -

Versione: 6.15.2207.718

+

Versione: 6.15.2207.810


Note di rilascio:
  • diff --git a/MP.Mon/Resources/VersNum.txt b/MP.Mon/Resources/VersNum.txt index 7db13b1c..96f0a100 100644 --- a/MP.Mon/Resources/VersNum.txt +++ b/MP.Mon/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2207.718 +6.15.2207.810 diff --git a/MP.Mon/Resources/manifest.xml b/MP.Mon/Resources/manifest.xml index 78d96058..06ffca68 100644 --- a/MP.Mon/Resources/manifest.xml +++ b/MP.Mon/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2207.718 + 6.15.2207.810 https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.Mon.zip https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html false