266 lines
7.0 KiB
C#
266 lines
7.0 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.Data.DTO;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class ListDossiers : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<Dossiers> RecordSel { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<FluxLogDTO> RecordSelFlux { get; set; }
|
|
|
|
[Parameter]
|
|
public SelectDossierParams SelFilter { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> TotRecordChanged { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
private FluxLogDTO? currFluxLogDto = null;
|
|
|
|
|
|
public string checkSelPar(FluxLogDTO recordSel)
|
|
{
|
|
string answ = "";
|
|
if (currFluxLogDto != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currFluxLogDto.CodFlux == recordSel.CodFlux && currFluxLogDto.dtEvento== recordSel.dtEvento) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
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 void Dispose()
|
|
{
|
|
currRecord = null;
|
|
SearchRecords = null;
|
|
ListRecords = null;
|
|
GC.Collect();
|
|
}
|
|
private SelectDossierParams lastFilter { get; set; } = new SelectDossierParams() { CurrPage = -1 };
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (!lastFilter.Equals(SelFilter))
|
|
{
|
|
lastFilter = SelFilter.clone();
|
|
await reloadData(true);
|
|
}
|
|
}
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Eliminazione record selezionato (previa conferma)
|
|
/// </summary>
|
|
/// <param name="selRec"></param>
|
|
/// <returns></returns>
|
|
protected async Task deleteRecord(Dossiers selRec)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Eliminazione Dossier: sei sicuro di voler procedere?"))
|
|
return;
|
|
await Task.Delay(1);
|
|
var done = await MDService.DossiersDeleteRecord(selRec);
|
|
currRecord = null;
|
|
await reloadData(true);
|
|
visualizzaFlux = true;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task editRecord(FluxLogDTO selRec)
|
|
{
|
|
currFluxLogDto = selRec;
|
|
// indico record selezionato
|
|
await RecordSelFlux.InvokeAsync(selRec);
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
ListStati = await MDService.AnagStatiComm();
|
|
await reloadData(true);
|
|
}
|
|
|
|
protected async void OnSeachUpdated()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
currPage = 1;
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
protected async Task selRecord(Dossiers selRec)
|
|
{
|
|
currRecord = selRec;
|
|
await RecordSel.InvokeAsync(selRec);
|
|
listaFlux = MDService.getFluxLog(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 FluxLogDTO? currRecordFlux;
|
|
private List<Dossiers>? ListRecords;
|
|
private List<ListValues>? ListStati;
|
|
|
|
private List<Dossiers>? SearchRecords;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage
|
|
{
|
|
get => SelFilter.CurrPage;
|
|
set => SelFilter.CurrPage = value;
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private List<FluxLogDTO>? listaFlux { get; set; } = null;
|
|
|
|
private int MaxRecord
|
|
{
|
|
get => SelFilter.MaxRecord;
|
|
}
|
|
|
|
private int numRecord
|
|
{
|
|
get => SelFilter.NumRec;
|
|
set => SelFilter.NumRec = value;
|
|
}
|
|
|
|
private string SelArticolo
|
|
{
|
|
get => SelFilter.CodArticolo;
|
|
}
|
|
|
|
private DateTime SelDtEnd
|
|
{
|
|
get => SelFilter.DtEnd;
|
|
}
|
|
private DateTime SelDtStart
|
|
{
|
|
get => SelFilter.DtStart;
|
|
}
|
|
|
|
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 Task reloadData(bool setChanged)
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelArticolo, SelDtStart, SelDtEnd);
|
|
totalCount = SearchRecords.Count;
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
if (setChanged)
|
|
{
|
|
await InvokeAsync(() => StateHasChanged());
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
private async Task toggleTableFlux()
|
|
{
|
|
visualizzaFlux = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private string tradFase(string codFase)
|
|
{
|
|
string answ = codFase;
|
|
if (ListStati != null && ListStati.Count > 0)
|
|
{
|
|
var recSel = ListStati.FirstOrDefault(x => x.value == codFase);
|
|
if (recSel != null)
|
|
{
|
|
answ = recSel.label;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private async Task closeTableFlux()
|
|
{
|
|
currFluxLogDto = null;
|
|
currRecord = null;
|
|
visualizzaFlux = true;
|
|
await RecordSelFlux.InvokeAsync(currFluxLogDto);
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |