diff --git a/MP.Core/DTO/WeightDTO.cs b/MP.Core/DTO/WeightDTO.cs new file mode 100644 index 00000000..1543a7af --- /dev/null +++ b/MP.Core/DTO/WeightDTO.cs @@ -0,0 +1,9 @@ +namespace MP.Core.DTO +{ + public class WeightDTO + { + public string Method { get; set; } = ""; + public int OldWeight { get; set; } = 100; + public int NewWeight { get; set; } = 0; + } +} diff --git a/MP.IOC/Components/Compo/ParetoDetail.razor b/MP.IOC/Components/Compo/ParetoDetail.razor index 1285c8d6..c70979f4 100644 --- a/MP.IOC/Components/Compo/ParetoDetail.razor +++ b/MP.IOC/Components/Compo/ParetoDetail.razor @@ -1,5 +1,5 @@  -
+
@Title
@@ -20,7 +20,7 @@ }
- diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs index 3fd46239..f75cdc68 100644 --- a/MP.IOC/Components/Pages/CallStats.razor.cs +++ b/MP.IOC/Components/Pages/CallStats.razor.cs @@ -6,6 +6,19 @@ namespace MP.IOC.Components.Pages { public partial class CallStats { + #region Protected Properties + + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + protected List bgColors + { + get => semaphColors(currData.Count, "0.3"); + } + + #endregion Protected Properties + #region Protected Methods protected override async Task OnInitializedAsync() @@ -17,13 +30,47 @@ namespace MP.IOC.Components.Pages #region Private Fields + private List currData = new(); + private string currSelect = ""; + private string currTitle = ""; private Dictionary> ParetoDay = new(); + #endregion Private Fields + + #region Private Properties + + private List DatiPareto + { + get => currData.Select(x => x.Value).ToList(); + } + + private List LabelPareto + { + get => currData.Select(x => x.Label).ToList(); + } + + /// + /// Genera colori sfondo 33% rosso / arancione / giallo + /// + /// + private List lineColors + { + get => semaphColors(currData.Count, "1"); + } + + [Inject] + private IStatsDetailService StatsDetService { get; set; } = null!; + + #endregion Private Properties + + #region Private Methods + private void DoReset() { currSelect = ""; currData = new(); } + private void DoSelect(string reqKey) { if (ParetoDay.ContainsKey(reqKey)) @@ -33,19 +80,12 @@ namespace MP.IOC.Components.Pages currData = ParetoDay[reqKey]; } } - private string currSelect = ""; - private string currTitle = ""; - private List currData = new(); - private List LabelPareto + private async Task ReloadData() { - get => currData.Select(x => x.Label).ToList(); + ParetoDay = await StatsDetService.GetParetoStatsDayAsync(); } - private List DatiPareto - { - get => currData.Select(x => x.Value).ToList(); - } /// /// Genera colori sfondo 33% rosso / arancione / giallo /// @@ -72,38 +112,6 @@ namespace MP.IOC.Components.Pages return answ; } - /// - /// Genera colori sfondo 33% rosso / arancione / giallo - /// - /// - protected List bgColors - { - get => semaphColors(currData.Count, "0.3"); - } - /// - /// Genera colori sfondo 33% rosso / arancione / giallo - /// - /// - private List lineColors - { - get => semaphColors(currData.Count, "1"); - } - - #endregion Private Fields - - #region Private Properties - - [Inject] - private IStatsDetailService StatsDetService { get; set; } = null!; - - #endregion Private Properties - - #region Private Methods - - private async Task ReloadData() - { - ParetoDay = await StatsDetService.GetParetoStatsDayAsync(); - } #endregion Private Methods } diff --git a/MP.IOC/Components/Pages/RouteConf.razor b/MP.IOC/Components/Pages/RouteConf.razor index b268f61b..8c5bc43c 100644 --- a/MP.IOC/Components/Pages/RouteConf.razor +++ b/MP.IOC/Components/Pages/RouteConf.razor @@ -1,5 +1,27 @@ @page "/RouteConf" - -

RouteConf

- - +
+
+

Route Configuration (IO/IOC)

+
+
+ + + + + + + + + + @foreach (var record in ListPaged) + { + + + + + + } + +
MetodoIO %IOC %
@record.Method@record.OldWeight@record.NewWeight
+
+
\ No newline at end of file diff --git a/MP.IOC/Components/Pages/RouteConf.razor.cs b/MP.IOC/Components/Pages/RouteConf.razor.cs index 2c925cda..ece23e90 100644 --- a/MP.IOC/Components/Pages/RouteConf.razor.cs +++ b/MP.IOC/Components/Pages/RouteConf.razor.cs @@ -1,7 +1,82 @@ +using Microsoft.AspNetCore.Components; +using MP.Core.DTO; +using MP.IOC.Services; + namespace MP.IOC.Components.Pages { public partial class RouteConf { + #region Protected Methods + protected string CheckSelect(WeightDTO currRec) + { + return SelRecord != null && SelRecord.Method == currRec.Method ? "table-info" : ""; + } + + protected override async Task OnInitializedAsync() + { + //return base.OnInitializedAsync(); + await ReloadData(); + UpdateTable(); + } + + #endregion Protected Methods + + #region Private Fields + + private List ListComplete = new(); + + private List ListPaged = new(); + + private int numRecPage = 10; + + private int pageNum = 1; + + private WeightDTO? SelRecord = null; + private int totalCount = 0; + + #endregion Private Fields + + #region Private Properties + + [Inject] + private IWeightProvider WService { get; set; } = null!; + + #endregion Private Properties + + #region Private Methods + + private async Task ReloadData() + { + ListComplete = await WService.GetAllWeightsAsync(); + totalCount = ListComplete.Count(); + } + + private void SaveNumRec(int newNum) + { + numRecPage = newNum; + UpdateTable(); + } + + private void SavePage(int newNum) + { + pageNum = newNum; + UpdateTable(); + } + + private void UpdateTable() + { + // esegue paginazione + if (totalCount > numRecPage) + { + ListPaged = ListComplete.Skip((pageNum - 1) * numRecPage).Take(numRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.IOC/Services/IWeightProvider.cs b/MP.IOC/Services/IWeightProvider.cs index 0c3a6429..df2c4fa0 100644 --- a/MP.IOC/Services/IWeightProvider.cs +++ b/MP.IOC/Services/IWeightProvider.cs @@ -1,18 +1,10 @@ -namespace MP.IOC.Services -{ - public class WeightDTO - { - public string Method { get; set; } = ""; - public int OldWeight { get; set; } = 100; - public int NewWeight { get; set; } = 0; - } +using MP.Core.DTO; +namespace MP.IOC.Services +{ public interface IWeightProvider { - /// - /// Ritorna la coppia (oldWeight, newWeight) per scegliere dove instradare il metodo tra i 2 sistemi API. - /// - (int oldWeight, int newWeight) GetWeightsFor(string method); + #region Public Methods /// /// Ritorna l'intero elenco dei weight attivi nel formato WeightDTO @@ -20,12 +12,18 @@ /// Task> GetAllWeightsAsync(); + /// + /// Ritorna la coppia (oldWeight, newWeight) per scegliere dove instradare il metodo tra i 2 sistemi API. + /// + (int oldWeight, int newWeight) GetWeightsFor(string method); + /// /// Aggiorna/Aggiuinge il valore del weight richiesto /// /// /// bool UpsertWeight(WeightDTO updRecord); - } -} + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP.IOC/Services/InMemoryWeightProvider.cs b/MP.IOC/Services/InMemoryWeightProvider.cs index c237dcc6..d6885e51 100644 --- a/MP.IOC/Services/InMemoryWeightProvider.cs +++ b/MP.IOC/Services/InMemoryWeightProvider.cs @@ -1,4 +1,5 @@ -using System.Collections.Concurrent; +using MP.Core.DTO; +using System.Collections.Concurrent; namespace MP.IOC.Services { diff --git a/MP.IOC/Services/RedisWeightProvider.cs b/MP.IOC/Services/RedisWeightProvider.cs index 7a7f9c26..929f5d17 100644 --- a/MP.IOC/Services/RedisWeightProvider.cs +++ b/MP.IOC/Services/RedisWeightProvider.cs @@ -1,4 +1,5 @@ -using StackExchange.Redis; +using MP.Core.DTO; +using StackExchange.Redis; namespace MP.IOC.Services {