Files
mapo-core/MP.SPEC/Components/FLStatusList.razor.cs
T
Samuele Locatelli 571ac2cea8 SPEC:
- inizio pagina gest fluxLog e pareto eventi
- ok visualizzazione ultimo mese
2023-10-20 18:54:28 +02:00

126 lines
3.5 KiB
C#

using global::Microsoft.AspNetCore.Components;
using MP.Data.DTO;
using MP.SPEC.Data;
using NLog;
using static EgwCoreLib.Utils.DtUtils;
namespace MP.SPEC.Components
{
public partial class FLStatusList
{
#region Public Properties
[Parameter]
public Periodo CurrPeriodo { get; set; } = new Periodo();
[Parameter]
public EventCallback<int> E_TotalCount { get; set; }
[Parameter]
public string IdxMaccSel { get; set; } = "";
[Parameter]
public int NumRecPage { get; set; } = 10;
[Parameter]
public int PageNum { get; set; } = 1;
#endregion Public Properties
#region Protected Properties
protected List<ParetoFluxLogDTO> ListComplete { get; set; } = new List<ParetoFluxLogDTO>();
protected List<ParetoFluxLogDTO> ListPaged { get; set; } = new List<ParetoFluxLogDTO>();
[Inject]
protected MpDataService MDataServ { get; set; } = null!;
protected int TotalCount
{
get => totalCount;
set
{
if (totalCount != value)
{
totalCount = value;
E_TotalCount.InvokeAsync(value).ConfigureAwait(false);
}
}
}
protected int numDay
{
get
{
var numRaw = (int)CurrPeriodo.Fine.Subtract(CurrPeriodo.Inizio).TotalDays;
int answ = numRaw > 1 ? numRaw : 1;
return answ;
}
}
protected int numHour
{
get
{
var numRaw = (int)CurrPeriodo.Fine.Subtract(CurrPeriodo.Inizio).TotalHours;
int answ = numRaw > 1 ? numRaw : 1;
return answ;
}
}
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
/// <summary>
/// Aggiorno valori produzione alla data richiesta...
/// </summary>
/// <param name="newDate"></param>
protected async Task ReloadData()
{
isProcessing = true;
await Task.Delay(1);
if (!string.IsNullOrEmpty(IdxMaccSel) && (!IdxMaccSel.Equals(idxMaccLast) || !CurrPeriodo.Equals(lastPeriodo)))
{
idxMaccLast = IdxMaccSel;
lastPeriodo = CurrPeriodo;
ListComplete = await MDataServ.ParetoFluxLog(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
TotalCount = ListComplete.Count;
}
// esegue paginazione
UpdateTable();
isProcessing = false;
await Task.Delay(1);
}
protected void UpdateTable()
{
// esegue paginazione
if (TotalCount > NumRecPage)
{
ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList();
}
else
{
ListPaged = ListComplete;
}
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private bool isProcessing = false;
private int totalCount = 0;
private string idxMaccLast = "";
private Periodo lastPeriodo { get; set; } = new Periodo();
#endregion Private Fields
}
}