162 lines
4.5 KiB
C#
162 lines
4.5 KiB
C#
using global::Microsoft.AspNetCore.Components;
|
|
using MP.Core.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<List<string>> E_FluxSel { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> E_TotalCount { get; set; }
|
|
[Parameter]
|
|
public EventCallback<int> E_TotalRec { get; set; }
|
|
|
|
[Parameter]
|
|
public string IdxMaccSel { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public int NumRecPage { get; set; }
|
|
|
|
[Parameter]
|
|
public int PageNum { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
protected List<string> FluxList
|
|
{
|
|
get => fluxList;
|
|
set
|
|
{
|
|
fluxList = value;
|
|
E_FluxSel.InvokeAsync(value).ConfigureAwait(false);
|
|
}
|
|
}
|
|
|
|
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 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;
|
|
}
|
|
}
|
|
|
|
protected int TotalCount
|
|
{
|
|
get => totalCount;
|
|
set
|
|
{
|
|
if (totalCount != value)
|
|
{
|
|
totalCount = value;
|
|
E_TotalCount.InvokeAsync(value).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|
|
protected int TotalRecords
|
|
{
|
|
get => totRecords;
|
|
set
|
|
{
|
|
if (totRecords != value)
|
|
{
|
|
totRecords = value;
|
|
E_TotalRec.InvokeAsync(value).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
#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.FluxLogPareto(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
|
|
TotalCount = ListComplete.Count;
|
|
TotalRecords = ListComplete.Sum(x => x.Qty);
|
|
FluxList = ListComplete.Select(x => x.CodFlux).ToList();
|
|
}
|
|
// 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 string idxMaccLast = "";
|
|
private bool isProcessing = false;
|
|
private int totalCount = 0;
|
|
private int totRecords = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private List<string> fluxList { get; set; } = new List<string>();
|
|
private Periodo lastPeriodo { get; set; } = new Periodo();
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |