Files
Samuele Locatelli b1afa82a91 Continuo spostamento servizi in Data:
- GpwDataSrvice
- MessageService
- ogni dipendenza (aggiunti using, in _import non basta...)
2024-09-07 11:40:28 +02:00

175 lines
4.5 KiB
C#

using GPW.CORE.Data.DbModels;
using GPW.CORE.Data.DTO;
using GPW.CORE.Data.Services;
using Microsoft.AspNetCore.Components;
using static GPW.CORE.Data.DTO.ReportDataDTO;
namespace GPW.CORE.WRKLOG.Components.Compo
{
public partial class MyRepStats
{
#region Public Properties
[Parameter]
public ReportDataDTO? CurrData { get; set; }
[Parameter]
public EventCallback<bool> E_ReqReload { get; set; }
[Parameter]
public bool ShowVert { get; set; }
#endregion Public Properties
#region Protected Fields
protected decimal maxVal = 1;
#endregion Protected Fields
#region Protected Properties
[Inject]
protected MessageService AppMServ { get; set; } = null!;
protected RegAttivitaModel? clonedRA
{
get
{
return AppMServ.clonedRA;
}
set
{
AppMServ.clonedRA = value;
}
}
[Inject]
protected GpwDataService DataService { get; set; } = null!;
protected string[]? histData { get; set; } = null;
protected string[]? histLabel { get; set; } = null;
protected int numDays
{
get => (CurrData != null) ? CurrData.TimbrExpl.Count : 0;
}
protected int numProj
{
get => (CurrData != null) ? CurrData.ProjTotal.Count : 0;
}
protected int numRA
{
get => (CurrData != null) ? CurrData.ListRA.Count : 0;
}
protected List<ProjData>? paretoDetail { get; set; } = null;
protected int selProj { get; set; } = 0;
#endregion Protected Properties
#region Protected Methods
protected string checkCss(int idxProj)
{
return selProj == idxProj ? "bg-dark text-light" : "";
}
protected override void OnParametersSet()
{
// sistemazione etichette e dati grafico..
fixHist();
}
protected string progrWidth(decimal itemVal)
{
return $"{itemVal / maxVal:P1}".Replace(",", ".");
}
protected async Task ReportDeleted()
{
selProj = 0;
await Task.Delay(1);
}
/// <summary>
/// Indico item selezionato
/// </summary>
protected void ReportSelect(RegAttivitaModel selRecord)
{
// recupero attivita selezionata in curr record
currRecord = selRecord;
}
protected void ResetClone()
{
clonedRA = null;
}
protected async Task ResetDayAgenda()
{
selProj = 0;
await Task.Delay(1);
}
protected async Task selectProj(int idxProj)
{
await Task.Delay(1);
selProj = idxProj;
if (CurrData.ListRA != null)
{
selRA = CurrData.ListRA
.Where(x => x.FasiNav.IdxProgetto == idxProj)
.OrderByDescending(x => x.Inizio)
.ToList();
}
}
protected async Task UpdRegAttData()
{
currRecord = null;
// resetto tutte le cache report
await DataService.ReportResetCacheDip(0);
// evento x reload...
await E_ReqReload.InvokeAsync(true);
}
#endregion Protected Methods
#region Private Fields
private RegAttivitaModel? currRecord = null;
#endregion Private Fields
#region Private Properties
private List<RegAttivitaModel>? selRA { get; set; } = null;
#endregion Private Properties
#region Private Methods
private void fixHist()
{
// prendo i dati progetti ordinati...
if (CurrData != null && CurrData.ProjTotal != null)
{
var pareto = CurrData.ProjTotal.OrderByDescending(x => x.TotOre).ToDictionary(x => x.Cliente + "|" + x.NomeProj, x => $"{x.TotOre:N1}".Replace(",", "."));
// costruisco elenco valori
histData = pareto.Values.ToArray();
// elenco labels
histLabel = pareto.Keys.ToArray();
// calcola max val
maxVal = CurrData.ProjTotal.Max(x => x.TotOre);
paretoDetail = CurrData.ProjTotal.OrderByDescending(x => x.TotOre).ToList();
}
}
#endregion Private Methods
}
}