260 lines
7.3 KiB
C#
260 lines
7.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using MP.SPEC;
|
|
using MP.SPEC.Shared;
|
|
using MP.SPEC.Components;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.SPEC.Data;
|
|
using System.Diagnostics;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class ListDossiers
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public SelectDossierParams SelFilter { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> TotRecordChanged { get; set; }
|
|
[Parameter]
|
|
public EventCallback<Dossiers> RecordSel { 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;
|
|
}
|
|
|
|
#if false
|
|
public void Dispose()
|
|
{
|
|
aTimer.Elapsed -= ElapsedTimer;
|
|
MessageService.EA_PageUpdated -= MessageService_EA_PageUpdated;
|
|
MessageService.EA_SearchUpdated -= OnSeachUpdated;
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
#endif
|
|
|
|
//public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
|
//{
|
|
// if (!isLoading && LiveUpdate)
|
|
// {
|
|
// aTimer.Stop();
|
|
// // inizio misura esecuzione
|
|
// Stopwatch stopWatch = new Stopwatch();
|
|
// stopWatch.Start();
|
|
// var pUpd = Task.Run(async () =>
|
|
// {
|
|
// await Task.Delay(1);
|
|
// await InvokeAsync(() => reloadData(true));
|
|
// });
|
|
// pUpd.Wait();
|
|
// // misuro tempo esecuzione
|
|
// stopWatch.Stop();
|
|
// TimeSpan ts = stopWatch.Elapsed;
|
|
// int deltaTime = RefreshPeriod - (int)ts.TotalMilliseconds;
|
|
// aTimer.Interval = deltaTime > 100 ? deltaTime : 100;
|
|
// aTimer.Start();
|
|
// }
|
|
//}
|
|
|
|
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;
|
|
}
|
|
|
|
//public void StartTimer()
|
|
//{
|
|
// //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod);
|
|
// aTimer = new System.Timers.Timer(RefreshPeriod);
|
|
// aTimer.Elapsed += ElapsedTimer;
|
|
// aTimer.Enabled = true;
|
|
// //aTimer.AutoReset = true;
|
|
// aTimer.Start();
|
|
//}
|
|
|
|
#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!;
|
|
|
|
//protected int RefreshPeriod
|
|
//{
|
|
// get => SelFilter.TempoAgg;
|
|
//}
|
|
//protected int RefreshPeriod { get; set; } = 5000;
|
|
|
|
#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 Task selRecord(Dossiers selRec)
|
|
{
|
|
currRecord = selRec;
|
|
await RecordSel.InvokeAsync(selRec);
|
|
listaFlux = MDService.convertToFluxLog(selRec.Valore);
|
|
toggleTableFlux();
|
|
}
|
|
|
|
protected async void OnSeachUpdated()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
//currPage = 1;
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
protected async Task UpdateData()
|
|
{
|
|
currRecord = null;
|
|
await reloadData(true);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
//private static System.Timers.Timer aTimer = null!;
|
|
|
|
private int _totalCount = 0;
|
|
private Dossiers? currRecord = null;
|
|
private List<Dossiers>? ListRecords;
|
|
private List<Dossiers>? SearchRecords;
|
|
private List<FluxLog>? listaFlux { get; set; } = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage
|
|
{
|
|
get => MessageService.currPage;
|
|
set => MessageService.currPage = value;
|
|
}
|
|
|
|
private bool visualizzaFlux { get; set; } = true;
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private int MaxRecord
|
|
{
|
|
get => SelFilter.MaxRecord;
|
|
}
|
|
|
|
private int numRecord
|
|
{
|
|
get => MessageService.numRecord;
|
|
set => MessageService.numRecord = value;
|
|
}
|
|
|
|
private string SelMacchina
|
|
{
|
|
get => SelFilter.IdxMacchina;
|
|
}
|
|
private DateTime SelDtRef
|
|
{
|
|
get => SelFilter.DtRef;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => _totalCount;
|
|
set
|
|
{
|
|
if (_totalCount != value)
|
|
{
|
|
_totalCount = value;
|
|
TotRecordChanged.InvokeAsync(value);
|
|
}
|
|
}
|
|
}
|
|
|
|
#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()
|
|
{
|
|
|
|
visualizzaFlux = true;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |