From 5f7d2ab1aeffe61e4bbf4640e53b4e58f0042173 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Thu, 29 Sep 2022 11:06:01 +0200 Subject: [PATCH] aggiunta componente alarmDur + cleanUp --- MP.MONO.UI/Components/ListDurAlarms.razor | 56 ++++++ MP.MONO.UI/Components/ListDurAlarms.razor.cs | 169 +++++++++++++++++++ MP.MONO.UI/Components/ListFreqAlarms.razor | 2 +- MP.MONO.UI/Conf/lic.file | 2 +- MP.MONO.UI/MP.MONO.UI.csproj | 2 +- MP.MONO.UI/Pages/AlarmsAnalysis.razor | 58 +------ MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs | 157 +---------------- MP.MONO.UI/Resources/ChangeLog.html | 2 +- MP.MONO.UI/Resources/VersNum.txt | 2 +- MP.MONO.UI/Resources/manifest.xml | 2 +- MP.MONO.UI/temp/InfoData.json | 66 ++++---- 11 files changed, 268 insertions(+), 250 deletions(-) create mode 100644 MP.MONO.UI/Components/ListDurAlarms.razor create mode 100644 MP.MONO.UI/Components/ListDurAlarms.razor.cs diff --git a/MP.MONO.UI/Components/ListDurAlarms.razor b/MP.MONO.UI/Components/ListDurAlarms.razor new file mode 100644 index 0000000..7a4edaa --- /dev/null +++ b/MP.MONO.UI/Components/ListDurAlarms.razor @@ -0,0 +1,56 @@ +
+
+ @if (ListRecordsDur == null) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { +
+
+ + + + + + + + + + + @foreach (var item in ListRecordsDur) + { + + + + + + + + } + +
Alarm DescriptionAlarm DurationEvent DurationEvent Duration Chart
+
@item.AlarmDescription
+
+
@Math.Round(item.Duration,2)
+
+
+ @if (totalVar != 0) + { + @calcPercDur((double)item.Duration) + } +
+
+
+
@Math.Round(item.Duration,2)
+
+
+
+
+ } +
+
diff --git a/MP.MONO.UI/Components/ListDurAlarms.razor.cs b/MP.MONO.UI/Components/ListDurAlarms.razor.cs new file mode 100644 index 0000000..3a7084e --- /dev/null +++ b/MP.MONO.UI/Components/ListDurAlarms.razor.cs @@ -0,0 +1,169 @@ +using Microsoft.AspNetCore.Components; +using MP.MONO.Data.DTO; +using MP.MONO.UI.Data; + +namespace MP.MONO.UI.Components +{ + public partial class ListDurAlarms + { + #region Public Properties + + [Parameter] + public selectChartParams selFilter { get; set; } = null!; + + [Parameter] + public EventCallback TotRecordChanged { get; set; } + + #endregion Public Properties + + #region Protected Properties + + protected int currPage + { + get => selFilter.CurrPage; + } + + protected DateTime dtEnd + { + get => selFilter.dtMax; + } + + protected DateTime dtStart + { + get => selFilter.dtMin; + } + + protected List? ListRecordsDur { get; set; } = null; + protected List? SearchRecordsDur { get; set; } = null; + protected double totalVar { get; set; } = 0; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + } + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + #endregion Protected Methods + + #region Private Fields + + private double sogliaGreen = 0; + + private double sogliaRed = 1; + + #endregion Private Fields + + #region Private Properties + + private int _totalCount { get; set; } = 0; + + private int numRecord + { + get => selFilter.NumRecord; + } + + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + TotRecordChanged.InvokeAsync(value); + } + } + } + + #endregion Private Properties + + #region Private Methods + + private void calcolaSoglieDur() + { + int numRecord = totalCount; + if (SearchRecordsDur != null) + { + + var firstRecord = SearchRecordsDur.Skip((int)(numRecord * 0.2)).FirstOrDefault(); + var lastRecord = SearchRecordsDur.Skip((int)(numRecord * 0.8)).FirstOrDefault(); + if (firstRecord != null) + { + sogliaGreen = (double)firstRecord.Duration / totalVar; + } + if (lastRecord != null) + { + sogliaRed = (double)lastRecord.Duration / totalVar; + } + } + } + + protected string calcPercDur(double duration) + { + string ans = $"{duration / totalVar:P2}"; + + return ans; + } + + private async Task ReloadData() + { + SearchRecordsDur = CurrentDataService.dbController.AlarmRecGetParetoDur(1, dtStart, dtEnd); + ListRecordsDur = SearchRecordsDur.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + totalCount = SearchRecordsDur.Count; + totalVar = SearchRecordsDur.Sum(x => x.Duration); + //calcolaSoglieDur(); + await Task.Delay(1); + } + + protected string styleColourPBarDur(double duration) + { + string ans = ""; + //var source = ListRecordsDur; + + calcolaSoglieDur(); + + if (duration >= sogliaGreen) + { + ans = "bg-danger"; + } + else if (duration <= sogliaRed) + { + ans = "bg-success"; + } + else + { + ans = "bg-warning"; + } + + return ans; + } + + protected string valDur(double duration) + { + string ans = ""; + if (SearchRecordsDur != null) + { + + double max = SearchRecordsDur.Max(a => a.Duration); + + double divisione = duration / max; + + int percentage = (int)(divisione * 100); + + ans = $"width: {percentage}%"; + } + + return ans; + } + + #endregion Private Methods + } +} diff --git a/MP.MONO.UI/Components/ListFreqAlarms.razor b/MP.MONO.UI/Components/ListFreqAlarms.razor index add001d..41f2d3a 100644 --- a/MP.MONO.UI/Components/ListFreqAlarms.razor +++ b/MP.MONO.UI/Components/ListFreqAlarms.razor @@ -49,4 +49,4 @@ } - + \ No newline at end of file diff --git a/MP.MONO.UI/Conf/lic.file b/MP.MONO.UI/Conf/lic.file index 9540e9d..69f59a3 100644 --- a/MP.MONO.UI/Conf/lic.file +++ b/MP.MONO.UI/Conf/lic.file @@ -1 +1 @@ -31e9cc1c2e8f30a1b4098cb157d712f11f3f2e60fb74169a354c3fa646d6d0e28518b4e3139f844b25824fbcc4340051fc507d22c1c2d2786d3786c777c31cc3 \ No newline at end of file +467e4b24bc3fe9d237169aa274ae589b64f072fb1cd91f4d79aaee76c64afbfced7fb51536b62cf612dedfb304202a1e653778b7cc8c758f83bb058984460301 \ No newline at end of file diff --git a/MP.MONO.UI/MP.MONO.UI.csproj b/MP.MONO.UI/MP.MONO.UI.csproj index daf2497..0c9560c 100644 --- a/MP.MONO.UI/MP.MONO.UI.csproj +++ b/MP.MONO.UI/MP.MONO.UI.csproj @@ -5,7 +5,7 @@ enable enable AnyCPU;x86;x64 - 1.2.2209.2910 + 1.2.2209.2911 diff --git a/MP.MONO.UI/Pages/AlarmsAnalysis.razor b/MP.MONO.UI/Pages/AlarmsAnalysis.razor index 6ffba6a..bb68366 100644 --- a/MP.MONO.UI/Pages/AlarmsAnalysis.razor +++ b/MP.MONO.UI/Pages/AlarmsAnalysis.razor @@ -13,65 +13,13 @@
- - @if ((ListRecordsFreq == null && setFreqDur) || (ListRecordsDur == null && !setFreqDur)) + @if (setFreqDur) { - - } - else if (totalCount == 0) - { -
Nessun record trovato
+ } else { - @if (setFreqDur) - { - - } - else - { -
-
- - - - - - - - - - - @foreach (var item in ListRecordsDur) - { - - - - - - - - } - -
Alarm DescriptionAlarm DurationEvent DurationEvent Duration Chart
-
@item.AlarmDescription
-
-
@Math.Round(item.Duration,2)
-
-
- @if (totalVar != 0) - { - @calcPercDur((double)item.Duration) - } -
-
-
-
@Math.Round(item.Duration,2)
-
-
-
-
- } + }