214 lines
5.3 KiB
C#
214 lines
5.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.SPEC.Components;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Pages
|
|
{
|
|
public partial class ODL
|
|
{
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Inizializzazione con periodo e arrotondamento
|
|
/// </summary>
|
|
/// <param name="minRound"></param>
|
|
/// <returns></returns>
|
|
public static DateTime RoundDatetime(int minRound)
|
|
{
|
|
TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
|
|
int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound;
|
|
DateTime endRounded = DateTime.Today.AddMinutes(minDay);
|
|
return endRounded;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected DataPager? pagerODL = null!;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected bool isActive
|
|
{
|
|
get => currFilter.IsActive;
|
|
set => currFilter.IsActive = value;
|
|
}
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
protected DateTime selDtEnd
|
|
{
|
|
get => currFilter.DtEnd;
|
|
set
|
|
{
|
|
if (currFilter.DtEnd != value)
|
|
{
|
|
currFilter.DtEnd = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected DateTime selDtStart
|
|
{
|
|
get => currFilter.DtStart;
|
|
set
|
|
{
|
|
if (currFilter.DtStart != value)
|
|
{
|
|
currFilter.DtStart = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var allGruppiData = await MDService.ElencoGruppiFase();
|
|
if (allGruppiData != null)
|
|
{
|
|
ListGruppiFase = allGruppiData.Where(x => x.SelEnabled).ToList();
|
|
}
|
|
ListStati = await MDService.AnagStatiComm();
|
|
ListMacchine = await MDService.MacchineWithFlux(currFilter.DtStart, currFilter.DtEnd);
|
|
padCodXdl = await MDService.tryGetConfig("padCodXdl");
|
|
}
|
|
|
|
protected async Task pgResetReq(bool doReset)
|
|
{
|
|
if (doReset)
|
|
{
|
|
await Task.Delay(1);
|
|
if (pagerODL != null)
|
|
{
|
|
pagerODL.resetCurrPage();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void resetFase()
|
|
{
|
|
selStato = "*";
|
|
}
|
|
|
|
protected void resetMacchina()
|
|
{
|
|
selMacchina = "*";
|
|
}
|
|
|
|
protected void setDtMax()
|
|
{
|
|
// copio il filtro
|
|
currFilter.DtEnd = RoundDatetime(5);
|
|
currFilter.DtStart = RoundDatetime(5).AddDays(-10);
|
|
}
|
|
|
|
protected void UpdateTotCount(int newTotCount)
|
|
{
|
|
totalCount = newTotCount;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<string>? ListMacchine;
|
|
|
|
private List<MP.Data.DatabaseModels.ListValues>? ListStati;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private SelectOdlParams currFilter { get; set; } = new SelectOdlParams();
|
|
|
|
private int currPage
|
|
{
|
|
get => currFilter.CurrPage;
|
|
set => currFilter.CurrPage = value;
|
|
}
|
|
|
|
private bool filtActive
|
|
{
|
|
get => selMacchina != "*" || selStato != "*";
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private string leftStringCSS
|
|
{
|
|
get => isActive ? "text-secondary" : "text-dark fw-bold";
|
|
}
|
|
|
|
private List<AnagGruppi>? ListGruppiFase { get; set; } = null;
|
|
|
|
private int numRecord
|
|
{
|
|
get => currFilter.NumRec;
|
|
set => currFilter.NumRec = value;
|
|
}
|
|
|
|
private string padCodXdl { get; set; } = "00000";
|
|
|
|
private string rightStringCSS
|
|
{
|
|
get => isActive ? "text-dark fw-bold" : "text-secondary";
|
|
}
|
|
|
|
private string selMacchina
|
|
{
|
|
get => currFilter.IdxMacchina;
|
|
set => currFilter.IdxMacchina = value;
|
|
}
|
|
|
|
private string selStato
|
|
{
|
|
get => currFilter.CodStato;
|
|
set => currFilter.CodStato = value;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => currFilter.TotCount;
|
|
set => currFilter.TotCount = value;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task updateFilter(SelectOdlParams newParams)
|
|
{
|
|
isLoading = true;
|
|
await Task.Delay(1);
|
|
currPage = 1;
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
currFilter = newParams;
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |