using EgwCoreLib.Razor.Data; using Microsoft.AspNetCore.Components; using MP.Data.DbModels; using MP.SPEC.Data; namespace MP.SPEC.Components { public partial class ODLPlot { #region Public Fields public List colors = new List(); public List Data = new List(); public List Labels = new List(); #endregion Public Fields #region Public Properties [Parameter] public bool hideSpenta { get; set; } public int OdlId { get => _selParam; } [Parameter] public int SelectedOdl { get => _selParam; set => _selParam = value; } #endregion Public Properties #region Protected Properties protected int _selParam { get; set; } = -1; [Inject] protected MpDataService MDService { get; set; } = null!; #endregion Protected Properties #region Protected Methods protected override async Task OnInitializedAsync() { isLoading = true; await Task.Delay(1); } protected override async Task OnParametersSetAsync() { await ReloadData(); await Task.Delay(1); } protected async Task ReloadData() { Data.Clear(); Labels.Clear(); colors.Clear(); ListRecords = await MDService.StatOdl(SelectedOdl); // se hideSpenta --> filtro stato 11 = spenta... if (hideSpenta) { ListRecords = ListRecords.Where(x => x.Semaforo != "sGr").ToList(); } foreach (var record in ListRecords) { Data.Add(record.TotDurata); Labels.Add($"{record.Descrizione} - {record.TotDurata:N1}min"); if (record.Css == "yellow") { colors.Add(new DoughnutStyling("orange", "ccc")); } else if (record.Css == "blue") { colors.Add(new DoughnutStyling("#2874A6", "ccc")); } else { colors.Add(new DoughnutStyling(record.Css, "ccc")); } } await Task.Delay(1); isLoading = false; } #endregion Protected Methods #region Private Fields private List? ListRecords = null; #endregion Private Fields #region Private Properties private bool isLoading { get; set; } = false; #endregion Private Properties } }