diff --git a/MP.MONO.UI/Pages/AlarmsAnalysis.razor b/MP.MONO.UI/Pages/AlarmsAnalysis.razor index 7391138..5de1536 100644 --- a/MP.MONO.UI/Pages/AlarmsAnalysis.razor +++ b/MP.MONO.UI/Pages/AlarmsAnalysis.razor @@ -33,7 +33,7 @@ { }*@ - @if (ListRecordsFreq == null && setFreqDur || ListRecordsDur == null && !setFreqDur) + @if ((ListRecordsFreq == null && setFreqDur) || (ListRecordsDur == null && !setFreqDur)) { } @@ -71,7 +71,7 @@
- @if (totalEvents != 0) + @if (totalVar != 0) { @calcPerc((double)record.EventCount) } @@ -79,7 +79,7 @@
-
@record.EventCount
+
@record.EventCount
diff --git a/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs b/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs index 10699cc..95cafb6 100644 --- a/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs +++ b/MP.MONO.UI/Pages/AlarmsAnalysis.razor.cs @@ -28,13 +28,13 @@ namespace MP.MONO.UI.Pages { #region Private Fields - private AlarmFreqDTO currRecord = null; + private AlarmFreqDTO? currRecord = null; - private List ListRecordsFreq = null!; - private List ListRecordsDur = null!; + private List? ListRecordsFreq = null; + private List? ListRecordsDur = null; - private List SearchRecordsFreq = null!; - private List SearchRecordsDur = null!; + private List? SearchRecordsFreq = null; + private List? SearchRecordsDur = null; #endregion Private Fields @@ -43,7 +43,7 @@ namespace MP.MONO.UI.Pages private int _currPage { get; set; } = 1; private int _numRecord { get; set; } = 10; - protected int totalEvents = 0; + protected double totalVar = 0; protected string percEvents = ""; private int currPage @@ -135,22 +135,22 @@ namespace MP.MONO.UI.Pages #region Protected Properties - protected int totalCount - { - get - { - int answ = 0; - if (SearchRecordsFreq != null && setFreqDur) - { - answ = SearchRecordsFreq.Count; - } - else - { - //answ = SearchRecordsDur.Count; - } - return answ; - } - } + protected int totalCount { get; set; } = 0; + //{ + // get + // { + // int answ = 0; + // if (SearchRecordsFreq != null && setFreqDur) + // { + // answ = SearchRecordsFreq.Count; + // } + // else + // { + // //answ = SearchRecordsDur.Count; + // } + // return answ; + // } + //} #endregion Protected Properties @@ -166,7 +166,8 @@ namespace MP.MONO.UI.Pages { SearchRecordsFreq = CurrentDataService.dbController.AlarmRecGetParetoFreq(1, dtStart, dtEnd); ListRecordsFreq = SearchRecordsFreq.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - totalEvents = SearchRecordsFreq.Sum(x => x.EventCount); + totalCount = SearchRecordsFreq.Count; + totalVar = SearchRecordsFreq.Sum(x => x.EventCount); calcolaSoglie(); await Task.Delay(1); } @@ -174,6 +175,8 @@ namespace MP.MONO.UI.Pages { 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); await Task.Delay(1); } await Task.Delay(1); @@ -219,11 +222,11 @@ namespace MP.MONO.UI.Pages var lastRecord = SearchRecordsFreq.Skip((int)(numRecord * 0.8)).FirstOrDefault(); if (firstRecord != null) { - sogliaGreen = (double)firstRecord.EventCount / totalEvents; + sogliaGreen = (double)firstRecord.EventCount / totalVar; } if (lastRecord != null) { - sogliaRed = (double)lastRecord.EventCount / totalEvents; + sogliaRed = (double)lastRecord.EventCount / totalVar; } } @@ -233,7 +236,7 @@ namespace MP.MONO.UI.Pages } protected string calcPerc(double numEvent) { - string ans = $"{numEvent / totalEvents:P2}"; + string ans = $"{numEvent / totalVar:P2}"; return ans; }