Files
mapo-core/MP.SPEC/Pages/FluxLogStatus.razor.cs
T
2023-10-21 12:41:44 +02:00

140 lines
3.8 KiB
C#

using global::Microsoft.AspNetCore.Components;
using MP.SPEC.Data;
using NLog;
using System;
using static EgwCoreLib.Utils.DtUtils;
using static MP.Data.Enum;
namespace MP.SPEC.Pages
{
public partial class FluxLogStatus
{
#region Protected Fields
protected int numRecPage = 10;
protected int pageNum = 1;
protected int totalCount = 0;
#endregion Protected Fields
#region Protected Properties
protected Dictionary<string, string> ListMacchineAll { get; set; } = new Dictionary<string, string>();
protected List<string> fluxList { get; set; } = new List<string>();
[Inject]
protected MpDataService MDataServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task ReloadMacchine()
{
if (ListMacchineAll == null || ListMacchineAll.Count == 0)
{
var rawData = await MDataServ.MacchineGetFilt("*");
// trasformo!
if (rawData != null)
{
ListMacchineAll = rawData.ToDictionary(x => x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}");
}
}
}
protected void SaveNumRec(int newNum)
{
if (numRecPage != newNum)
{
numRecPage = newNum;
}
}
protected void SavePage(int newNum)
{
if (pageNum != newNum)
{
pageNum = newNum;
}
}
protected async Task SetPeriodo(Periodo newPeriodo)
{
if (!CurrPeriodo.Equals(newPeriodo))
{
CurrPeriodo = newPeriodo;
}
await Task.Delay(1);
}
protected async Task SetTotCount(int numRec)
{
totalCount = numRec;
await Task.Delay(1);
}
protected async Task SaveFluxList(List<string> newList)
{
fluxList = newList;
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Properties
private Periodo CurrPeriodo { get; set; } = new Periodo();
private string idxMaccSel { get; set; } = "";
private bool isProcessing { get; set; } = false;
#endregion Private Properties
#region Private Methods
private async Task ReloadData()
{
await ReloadMacchine();
DateTime dtEnd = DateTime.Today.AddDays(1);
DateTime dtStart = dtEnd.AddMonths(-1);
CurrPeriodo = new Periodo(dtStart, dtEnd);
}
/// <summary>
/// Esegue cleanup dati
/// </summary>
/// <returns></returns>
protected async Task DoCleanup()
{
isProcessing = true;
// processo i flussi in subset x mandare update ad avanzamento
await MDataServ.FluxLogDataRedux(idxMaccSel, fluxList, CurrPeriodo, ValMode, IntReq);
isProcessing = false;
}
/// <summary>
/// Tempo atteso processing
/// - da calcolare in abse al num eventi e alla tab logProcessing...
/// </summary>
private int expTimeMsec = 10000;
private int countFlux = 0;
private int numFlux
{
get => fluxList.Count * 10;
}
protected ValSelection ValMode = ValSelection.Center;
protected DataInterval IntReq = DataInterval.hour;
#endregion Private Methods
}
}