Files
gpw_next/GPW.CORE.WRKLOG/Components/Compo/MyRepStats.razor.cs
T
Samuele Locatelli 5722ad4167 WRKLOG 8.0
- porting blazor 8.0
- riorganizzazione area components
- add componenti da 6
- spostamento ver 6 a old (migrata comunque)
2024-09-04 15:28:37 +02:00

180 lines
4.6 KiB
C#

using GPW.CORE.Data.DbModels;
using GPW.CORE.Data.DTO;
using GPW.CORE.WRKLOG.Data;
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 => currData;
set
{
currData = value;
// sistemazione etichette e dati grafico..
fixHist();
}
}
[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 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 string checkCss(int idxProj)
{
return selProj == idxProj ? "bg-dark text-light" : "";
}
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 ReportDataDTO? currData { get; set; }
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
}
}