197 lines
5.1 KiB
C#
197 lines
5.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class ListDossiers
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<Dossiers> RecordSel { get; set; }
|
|
|
|
[Parameter]
|
|
public SelectDossierParams SelFilter { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> TotRecordChanged { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public string checkSelect(Dossiers recordSel)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.IdxMacchina == recordSel.IdxMacchina && currRecord.DtRif == recordSel.DtRif) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public async Task reloadData(bool setChanged)
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord);
|
|
totalCount = SearchRecords.Count;
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
if (setChanged)
|
|
{
|
|
await InvokeAsync(() => StateHasChanged());
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService MessageService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MessageService.EA_PageUpdated += MessageService_EA_PageUpdated;
|
|
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
|
|
|
ListRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord);
|
|
|
|
await reloadData();
|
|
}
|
|
|
|
protected async void OnSeachUpdated()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
currPage = 1;
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
protected async Task selRecord(Dossiers selRec)
|
|
{
|
|
currRecord = selRec;
|
|
await RecordSel.InvokeAsync(selRec);
|
|
listaFlux = MDService.convertToFluxLog(selRec.Valore);
|
|
await toggleTableFlux();
|
|
}
|
|
|
|
protected async Task UpdateData()
|
|
{
|
|
currRecord = null;
|
|
await reloadData(true);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int _totalCount = 0;
|
|
private Dossiers? currRecord = null;
|
|
private List<Dossiers>? ListRecords;
|
|
private List<Dossiers>? SearchRecords;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage
|
|
{
|
|
get => MessageService.currPage;
|
|
set => MessageService.currPage = value;
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
private List<FluxLog>? listaFlux { get; set; } = null;
|
|
|
|
private int MaxRecord
|
|
{
|
|
get => SelFilter.MaxRecord;
|
|
}
|
|
|
|
private int numRecord
|
|
{
|
|
get => MessageService.numRecord;
|
|
set => MessageService.numRecord = value;
|
|
}
|
|
|
|
private DateTime SelDtRef
|
|
{
|
|
get => SelFilter.DtRef;
|
|
}
|
|
|
|
private string SelMacchina
|
|
{
|
|
get => SelFilter.IdxMacchina;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => _totalCount;
|
|
set
|
|
{
|
|
if (_totalCount != value)
|
|
{
|
|
_totalCount = value;
|
|
TotRecordChanged.InvokeAsync(value);
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool visualizzaFlux { get; set; } = true;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async void MessageService_EA_PageUpdated()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
private async Task reloadData()
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord);
|
|
totalCount = SearchRecords.Count;
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task toggleTableFlux()
|
|
{
|
|
visualizzaFlux = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private async Task unToggleTableFlux()
|
|
{
|
|
currRecord = null;
|
|
visualizzaFlux = true;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |