149 lines
3.6 KiB
C#
149 lines
3.6 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.MONO.UI;
|
|
using MP.MONO.UI.Shared;
|
|
using MP.MONO.UI.Components;
|
|
using MP.MONO.Data.DbModels;
|
|
|
|
namespace MP.MONO.UI.Components
|
|
{
|
|
public partial class PrevMaintTask
|
|
{
|
|
|
|
private List<PrevMaintTaskModel>? ListRecords = null;
|
|
|
|
// FARE!!! filtro macchina
|
|
private int MachineId = 1;
|
|
|
|
private List<PrevMaintTaskModel>? SearchRecords = null;
|
|
|
|
|
|
private int _MaxRecord = 200;
|
|
|
|
|
|
private int MaxRecord
|
|
{
|
|
get
|
|
{
|
|
return _MaxRecord;
|
|
}
|
|
set
|
|
{
|
|
if (_MaxRecord != value)
|
|
{
|
|
_MaxRecord = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
if (SearchRecords != null)
|
|
{
|
|
answ = SearchRecords.Count;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
protected void ForceReload(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
}
|
|
|
|
protected void ForceReloadPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
await Task.Delay(1);
|
|
SearchRecords = await MMDataService.PrevMaintTaskGetFilt(MachineId, 0, MaxRecord);
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
protected async Task reloadFromMessage()
|
|
{
|
|
isLoading = true;
|
|
ListRecords = null;
|
|
await Task.Delay(300);
|
|
await ReloadData();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() =>
|
|
{
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
protected bool doSetup = false;
|
|
|
|
protected async Task SetupAlarms()
|
|
{
|
|
await Task.Delay(1);
|
|
doSetup = !doSetup;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
private int _currPage { get; set; } = 1;
|
|
|
|
private int _numRecord { get; set; } = 10;
|
|
|
|
private int currPage
|
|
{
|
|
get => _currPage;
|
|
set
|
|
{
|
|
if (_currPage != value)
|
|
{
|
|
_currPage = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private int numRecord
|
|
{
|
|
get => _numRecord;
|
|
set
|
|
{
|
|
if (_numRecord != value)
|
|
{
|
|
_numRecord = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} |