5d72d21fb1
Update gestione paginazione (visibile solo dove serve) + fix calcolo di alcuni intems male filtrati
276 lines
8.7 KiB
C#
276 lines
8.7 KiB
C#
using LiMan.DB.DTO;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using static EgwCoreLib.Razor.Sorter;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class InstAppRelStatus : IDisposable
|
|
{
|
|
public void Dispose()
|
|
{
|
|
MServ.EA_SelCodApp -= MServ_EA_SelCodApp;
|
|
MServ.EA_SelCodImp -= MServ_EA_SelCodImp;
|
|
MServ.EA_SelCodInst -= MServ_EA_SelCodInst;
|
|
}
|
|
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<AppStatusDTO> AppStats { get; set; } = new List<AppStatusDTO>();
|
|
|
|
[Parameter]
|
|
public List<AppRelStatusDTO> AppRelList { get; set; } = new List<AppRelStatusDTO>();
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
if (string.IsNullOrEmpty(sortField))
|
|
{
|
|
sortField = "NumInst";
|
|
sortAsc = false;
|
|
}
|
|
MServ.EA_SelCodApp += MServ_EA_SelCodApp;
|
|
MServ.EA_SelCodImp += MServ_EA_SelCodImp;
|
|
MServ.EA_SelCodInst += MServ_EA_SelCodInst;
|
|
}
|
|
|
|
private void MServ_EA_SelCodApp()
|
|
{
|
|
// cerco codApp sel...
|
|
string newCodApp = MServ.UsrParamGet("CodApp");
|
|
if (!CodAppSel.Equals(newCodApp))
|
|
{
|
|
var recSel = AppStats.FirstOrDefault(x => x.CodApp == newCodApp);
|
|
DoSelect(recSel);
|
|
}
|
|
CodAppSel = newCodApp;
|
|
}
|
|
|
|
private void MServ_EA_SelCodInst()
|
|
{
|
|
string newCodInst = MServ.UsrParamGet("CodInst");
|
|
if (!CodInstSel.Equals(newCodInst) && !string.IsNullOrEmpty(CodInstSel))
|
|
{
|
|
DoSelect(null);
|
|
}
|
|
CodInstSel = newCodInst;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezionato CodImp (PC)
|
|
/// </summary>
|
|
private void MServ_EA_SelCodImp()
|
|
{
|
|
CodImpSel = MServ.UsrParamGet("CodImp");
|
|
HasCodImp = !string.IsNullOrEmpty(CodImpSel);
|
|
}
|
|
|
|
private string CodAppSel = "";
|
|
private string CodImpSel = "";
|
|
private string CodInstSel = "";
|
|
private bool HasCodImp = false;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
isLoading = true;
|
|
UpdateTable();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void setNumPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
UpdateTable();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void setNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
currPage = 1;
|
|
UpdateTable();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void SortRequested(SortCallBack e)
|
|
{
|
|
isLoading = true;
|
|
if (sortField == e.ParamName)
|
|
{
|
|
sortAsc = e.IsAscending;
|
|
}
|
|
sortField = e.ParamName;
|
|
UpdateTable();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int currPage = 1;
|
|
private bool isLoading = false;
|
|
private int numRecord = 10;
|
|
private string sKey = "InstAppRelStatus";
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private AppStatusDTO? CurrRecord { get; set; } = null;
|
|
|
|
private List<AppStatusDTO> ListRecord { get; set; } = new List<AppStatusDTO>();
|
|
|
|
private List<AppStatusDTO> SearchRecord { get; set; } = new List<AppStatusDTO>();
|
|
|
|
private bool sortAsc
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
var sVal = MServ.UsrParamGet($"{sKey}_sort");
|
|
if (!string.IsNullOrEmpty(sVal))
|
|
{
|
|
bool.TryParse(sVal, out answ);
|
|
}
|
|
return answ;
|
|
}
|
|
set => MServ.UsrParamSet($"{sKey}_sort", $"{value}");
|
|
}
|
|
|
|
private string sortField
|
|
{
|
|
get => MServ.UsrParamGet($"{sKey}_field");
|
|
set => MServ.UsrParamSet($"{sKey}_field", $"{value}");
|
|
}
|
|
|
|
private string tblColMain
|
|
{
|
|
get => CurrRecord == null ? "col-12" : HasCodImp ? "col-1" : "col-3";
|
|
}
|
|
private string tblColDet
|
|
{
|
|
get => CurrRecord == null ? "col-1" : HasCodImp ? "col-12" : "col-9";
|
|
}
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string checkSelect(string codApp)
|
|
{
|
|
string answ = (CurrRecord != null && codApp == CurrRecord.CodApp) ? "table-info" : "";
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Selezoine record corrente
|
|
/// </summary>
|
|
/// <param name="selRec"></param>
|
|
private void DoSelect(AppStatusDTO selRec)
|
|
{
|
|
CurrRecord = selRec;
|
|
CodAppSel = selRec != null ? selRec.CodApp : "";
|
|
MServ.UsrParamSet("CodApp", CodAppSel);
|
|
string numApp = selRec != null ? $"{selRec.NumInst}" : "";
|
|
MServ.UsrParamSet("NumApp", numApp);
|
|
string numLic = selRec != null ? $"{selRec.NumImp}" : "";
|
|
MServ.UsrParamSet("NumLic", numLic);
|
|
string lastVers = selRec != null ? selRec.VersNumCurrent : "";
|
|
MServ.UsrParamSet("LastVers", lastVers);
|
|
string score = selRec != null ? $"{selRec.UpdateScore:P1}" : "";
|
|
MServ.UsrParamSet("Score", score);
|
|
MServ.ReportSelCodApp();
|
|
}
|
|
|
|
private void UpdateTable()
|
|
{
|
|
SearchRecord = AppStats;
|
|
totalCount = SearchRecord.Count;
|
|
switch (sortField)
|
|
{
|
|
case "CodApp":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.CodApp).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.CodApp).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
break;
|
|
|
|
case "NumInst":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.NumInst).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.NumInst).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
break;
|
|
|
|
case "NumImp":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.NumImp).ThenByDescending(x => x.NumInst).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.NumImp).ThenByDescending(x => x.NumInst).ToList();
|
|
}
|
|
break;
|
|
|
|
case "VersNumCurrent":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.VersNumCurrent).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.VersNumCurrent).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
break;
|
|
|
|
case "UpdateScore":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.UpdateScore).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.UpdateScore).ThenByDescending(x => x.NumImp).ToList();
|
|
}
|
|
break;
|
|
|
|
default:
|
|
SearchRecord = SearchRecord
|
|
.OrderByDescending(x => x.NumImp)
|
|
.ThenByDescending(x => x.NumInst)
|
|
.ToList();
|
|
break;
|
|
}
|
|
ListRecord = SearchRecord
|
|
.Skip((currPage - 1) * numRecord)
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |