155 lines
4.4 KiB
C#
155 lines
4.4 KiB
C#
using DnsClient.Protocol;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.JSInterop;
|
|
using MP.AppAuth.Models;
|
|
using MP.AppAuth.Services;
|
|
using MP.Land.Data;
|
|
using NLog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Land.Pages
|
|
{
|
|
public partial class IobList : ComponentBase, IDisposable
|
|
{
|
|
#region Private Fields
|
|
|
|
/// <summary>
|
|
/// Classe logger
|
|
/// </summary>
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
private List<MacchineModel> ListRecords = new List<MacchineModel>();
|
|
private List<MacchineModel> SearchRecords = new List<MacchineModel>();
|
|
private List<MacchineModel> AllRecords = new List<MacchineModel>();
|
|
|
|
private string Titolo = "";
|
|
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected AppAuthService AppDService { get; set; }
|
|
|
|
[Inject]
|
|
protected MessageService AppMService { get; set; }
|
|
|
|
[Inject]
|
|
protected IConfiguration Configuration { get; set; }
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
ListRecords = null;
|
|
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
|
|
GC.Collect();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
ListRecords = null;
|
|
Titolo = "Elenco IOB Amministrati";
|
|
AppMService.ShowSearch = true;
|
|
AppMService.PageName = "IobList";
|
|
AppMService.PageIcon = "fas fa-computer pe-2";
|
|
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
|
|
DataInit();
|
|
}
|
|
|
|
private string searchVal = "";
|
|
|
|
private void AppMService_EA_SearchUpdated()
|
|
{
|
|
isLoading = true;
|
|
searchVal = AppMService.SearchVal;
|
|
currPage = 1;
|
|
RefreshDisplay();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void DataInit()
|
|
{
|
|
isLoading = true;
|
|
// importante altrimenti NON mostra update UI
|
|
AllRecords = AppDService.MacchineGetAll();
|
|
RefreshDisplay();
|
|
isLoading = false;
|
|
}
|
|
|
|
private bool isLoading = false;
|
|
private int currPage = 1;
|
|
private int numRecord = 10;
|
|
|
|
protected void SetNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
RefreshDisplay();
|
|
}
|
|
|
|
protected void SetPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
RefreshDisplay();
|
|
}
|
|
|
|
private void RefreshDisplay()
|
|
{
|
|
// se ho ricerca filtro...
|
|
if (string.IsNullOrEmpty(searchVal))
|
|
{
|
|
SearchRecords = AllRecords;
|
|
}
|
|
else
|
|
{
|
|
SearchRecords = AllRecords
|
|
.Where(x => x.Nome.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|
|
|| x.CodMacchina.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|
|
|| x.Descrizione.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)
|
|
|| x.IdxMacchina.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase))
|
|
.ToList();
|
|
}
|
|
// conto record
|
|
totalCount = SearchRecords.Count();
|
|
// fix paginazione
|
|
ListRecords = SearchRecords
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
|
|
protected string checkSelect(MacchineModel IdxODL)
|
|
{
|
|
string answ = "";
|
|
#if false
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.IdxOdl == IdxODL) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
#endif
|
|
return answ;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |