134 lines
3.6 KiB
C#
134 lines
3.6 KiB
C#
using LiMan.DB;
|
|
using LiMan.DB.DBModels;
|
|
using LiMan.DB.DTO;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class InstallInfoStats
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
LMDService.EnrollMessPipe.EA_NewMessage -= async (sender, e) => await EnrollMessPipe_EA_NewMessage(sender, e);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected LiManDataService LMDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
LMDService.EnrollMessPipe.EA_NewMessage += async (sender, e) => await EnrollMessPipe_EA_NewMessage(sender, e);
|
|
await ReloadLicData();
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool doFiltClienti = false;
|
|
|
|
private List<InstallazioneModel> ListInstall;
|
|
|
|
/// <summary>
|
|
/// Codice installazione selezionata
|
|
/// </summary>
|
|
protected string CodInstSel
|
|
{
|
|
get => codInstSel;
|
|
set
|
|
{
|
|
if (codInstSel != value)
|
|
{
|
|
codInstSel = value;
|
|
isLoading = true;
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await ReloadData();
|
|
});
|
|
pUpd.Wait();
|
|
isLoading = false;
|
|
}
|
|
}
|
|
}
|
|
private string codInstSel = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private string cssBtnCli
|
|
{
|
|
get => doFiltClienti ? "btn-info" : "btn-primary";
|
|
}
|
|
|
|
private DateTime DtFine { get; set; } = DateTime.Today.AddHours(DateTime.Now.Hour);
|
|
|
|
private DateTime DtInizio { get; set; } = DateTime.Today.AddMonths(-1);
|
|
|
|
private InstallStatusDTO InfoStats { get; set; } = new InstallStatusDTO();
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Evento refresh legato a ricezione evento da MessagePipe
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private async Task EnrollMessPipe_EA_NewMessage(object sender, EventArgs e)
|
|
{
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// qualsiasi messaggio fa scattare reload data
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
|
{
|
|
isLoading = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
await ReloadLicData();
|
|
await ReloadData();
|
|
isLoading = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
InfoStats = await LMDService.InstallStatusGetInfo(DtInizio, DtFine, CodInstSel);
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task ReloadLicData()
|
|
{
|
|
ListInstall = await LMDService.InstallazioniNextGetAll();
|
|
}
|
|
|
|
private void TglFiltCli()
|
|
{
|
|
doFiltClienti = !doFiltClienti;
|
|
if (!doFiltClienti)
|
|
{
|
|
CodInstSel = "";
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |