487 lines
15 KiB
C#
487 lines
15 KiB
C#
using EgwCoreLib.Razor.Data;
|
|
using LiMan.DB;
|
|
using LiMan.DB.DTO;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using static EgwCoreLib.Razor.Sorter;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class InstAppPareto : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<AppRelStatusDTO> AppDetList { get; set; } = new List<AppRelStatusDTO>();
|
|
|
|
[Parameter]
|
|
public AppStatusDTO CurrRecord { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
LMDService.TaskMessPipe.EA_NewMessage -= async (sender, e) => await TaskMessPipe_EA_NewMessage(sender, e);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
protected List<AppRelStatusDTO> ListRecord { get; set; } = new List<AppRelStatusDTO>();
|
|
|
|
[Inject]
|
|
protected LiManDataService LMDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
protected List<AppRelStatusDTO> SearchRecord { get; set; } = new List<AppRelStatusDTO>();
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
LMDService.TaskMessPipe.EA_NewMessage += async (sender, e) => await TaskMessPipe_EA_NewMessage(sender, e);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Evento refresh legato a ricezione evento da MessagePipe
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private async Task TaskMessPipe_EA_NewMessage(object sender, EventArgs e)
|
|
{
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// qualsiasi messaggio fa scattare reload data
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
|
{
|
|
// verifico se sia il cod impianto selezionato, nel faso forzo refreesh...
|
|
if (!string.IsNullOrEmpty(CodImpSel) && CodImpSel.Equals(currArgs.newMessage))
|
|
{
|
|
isLoading = true;
|
|
ReloadTaskStatus();
|
|
await ReloadTaskResults();
|
|
isLoading = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
ReloadData();
|
|
ReloadTaskStatus();
|
|
ReloadCharts();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset filtro cliente...
|
|
/// </summary>
|
|
/// <param name="currRec"></param>
|
|
protected void ResetCliente()
|
|
{
|
|
HasFlitCli = false;
|
|
CodInstSel = "";
|
|
// salvo nelle preferenze i valori CodImp e PcInst
|
|
MServ.UsrParamSet("Cliente", "");
|
|
MServ.UsrParamSet("CodInst", "");
|
|
MServ.UsrParamSet("CodImp", "");
|
|
MServ.UsrParamSet("PcInst", "");
|
|
// Richiedo azione x gestione dettaglio info
|
|
MServ.ReportSelCodInst();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset filtro PC/Impiego...
|
|
/// </summary>
|
|
/// <param name="currRec"></param>
|
|
protected void ResetCodImp()
|
|
{
|
|
HasFlitImp = false;
|
|
CodImpSel = "";
|
|
// salvo nelle preferenze i valori CodImp e PcInst
|
|
MServ.UsrParamSet("CodImp", "");
|
|
MServ.UsrParamSet("PcInst", "");
|
|
// Richiedo azione x gestione dettaglio info
|
|
MServ.ReportSelCodImp();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set filtro cliente...
|
|
/// </summary>
|
|
/// <param name="currRec"></param>
|
|
protected void SetCliente(AppRelStatusDTO currRec)
|
|
{
|
|
HasFlitCli = true;
|
|
CodInstSel = currRec.CodInst;
|
|
// salvo nelle preferenze i valori CodImp e PcInst
|
|
MServ.UsrParamSet("Cliente", currRec.Cliente);
|
|
MServ.UsrParamSet("CodInst", currRec.CodInst);
|
|
MServ.UsrParamSet("CodImp", "");
|
|
MServ.UsrParamSet("PcInst", "");
|
|
// Richiedo azione x gestione dettaglio info
|
|
MServ.ReportSelCodInst();
|
|
// se era selezionato impianto lo deseleziona...
|
|
if (HasFlitImp)
|
|
{
|
|
CodImpSel = "";
|
|
HasFlitImp = false;
|
|
MServ.ReportSelCodImp();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set filtro PC/Impiego...
|
|
/// </summary>
|
|
/// <param name="currRec"></param>
|
|
protected void SetCodImp(AppRelStatusDTO currRec)
|
|
{
|
|
HasFlitImp = true;
|
|
CodImpSel = currRec.CodImp;
|
|
AppInstList = AppDetList
|
|
.Where(x => x.CodImp == currRec.CodImp)
|
|
.ToList();
|
|
// se era selezionato cliente lo riseleziono...
|
|
if (HasFlitCli)
|
|
{
|
|
CodInstSel = currRec.CodInst;
|
|
MServ.ReportSelCodInst();
|
|
}
|
|
// salvo nelle preferenze i valori CodImp e PcInst
|
|
MServ.UsrParamSet("Cliente", currRec.Cliente);
|
|
MServ.UsrParamSet("CodInst", currRec.CodInst);
|
|
MServ.UsrParamSet("CodImp", currRec.CodImp);
|
|
MServ.UsrParamSet("PcInst", currRec.PcInst);
|
|
// Richiedo azione x gestione dettaglio info
|
|
MServ.ReportSelCodImp();
|
|
}
|
|
|
|
protected void setNumPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
ReloadData();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void setNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
ReloadData();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected void SortRequested(SortCallBack e)
|
|
{
|
|
isLoading = true;
|
|
if (sortField == e.ParamName)
|
|
{
|
|
sortAsc = e.IsAscending;
|
|
}
|
|
sortField = e.ParamName;
|
|
ReloadData();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<AppRelStatusDTO> AppInstList = new List<AppRelStatusDTO>();
|
|
private List<DoughnutStyling> ChartColor = new List<DoughnutStyling>();
|
|
private double[] ChartData = new double[1];
|
|
private string[] ChartLabels = new string[1];
|
|
private string CodImpSel = "";
|
|
private string CodInstSel = "";
|
|
private int currPage = 1;
|
|
private bool HasFlitCli = false;
|
|
private bool HasFlitImp = false;
|
|
private bool isLoading = false;
|
|
private int numRecord = 10;
|
|
private string sKey = "InstAppPareto";
|
|
private Dictionary<string, string> TaskDone = new Dictionary<string, string>();
|
|
private Dictionary<string, string> TaskReq = new Dictionary<string, string>();
|
|
private Dictionary<string, string> TaskRun = new Dictionary<string, string>();
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
private string cssNumPill(int numRec)
|
|
{
|
|
return numRec > 0 ? "text-bg-primary" : "text-bg-secondary";
|
|
}
|
|
|
|
private bool showDetail = false;
|
|
|
|
private Dictionary<string, string> DetailData = new Dictionary<string, string>();
|
|
|
|
private void showDetReq()
|
|
{
|
|
showDetail = true;
|
|
DetailData = new Dictionary<string, string>(TaskReq);
|
|
}
|
|
private void showDetRun()
|
|
{
|
|
showDetail = true;
|
|
DetailData = new Dictionary<string, string>(TaskRun);
|
|
}
|
|
private void showDetDone()
|
|
{
|
|
showDetail = true;
|
|
DetailData = new Dictionary<string, string>(TaskDone);
|
|
}
|
|
|
|
#region Private Properties
|
|
|
|
private string CssDivDetail
|
|
{
|
|
get => HasFlitImp ? "col-7" : "col-5";
|
|
}
|
|
|
|
private string CssDivMain
|
|
{
|
|
get => HasFlitImp ? "col-5" : "col-7";
|
|
}
|
|
|
|
private string CssResetCli
|
|
{
|
|
get => HasFlitCli ? "" : "disabled";
|
|
}
|
|
|
|
private string CssResetImp
|
|
{
|
|
get => HasFlitImp ? "" : "disabled";
|
|
}
|
|
|
|
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}");
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string CssBtnImp(string CodImp)
|
|
{
|
|
return HasFlitImp && CodImpSel == CodImp ? "btn-primary" : "btn-outline-primary";
|
|
}
|
|
|
|
private string CssBtnInst(string CodInst)
|
|
{
|
|
return HasFlitCli && CodInstSel == CodInst ? "btn-dark" : "btn-outline-dark";
|
|
}
|
|
|
|
private string cssVers(AppRelStatusDTO rec)
|
|
{
|
|
string answ = "";
|
|
switch (rec.UpToDateStatus)
|
|
{
|
|
case 4:
|
|
answ = "text-success fw-bold";
|
|
break;
|
|
|
|
case 3:
|
|
answ = "text-success";
|
|
break;
|
|
|
|
case 2:
|
|
answ = "text-warning";
|
|
break;
|
|
|
|
case 1:
|
|
answ = "text-danger";
|
|
break;
|
|
|
|
case 0:
|
|
answ = "text-danger fw-bold";
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private void MServ_EA_TaskUpdate()
|
|
{
|
|
}
|
|
|
|
private void ReloadCharts()
|
|
{
|
|
// sistemo info x grafico... se ho impieghi uso quello, altrimenti istanze...
|
|
if (CurrRecord.NumImp > 0)
|
|
{
|
|
ChartData = SearchRecord
|
|
.GroupBy(x => x.VersNumInstall)
|
|
.Select(g => (double)g.Sum(x => x.NumImp))
|
|
.ToArray();
|
|
}
|
|
else
|
|
{
|
|
ChartData = SearchRecord
|
|
.GroupBy(x => x.VersNumInstall)
|
|
.Select(g => (double)g.Count())
|
|
.ToArray();
|
|
}
|
|
|
|
ChartLabels = SearchRecord
|
|
.GroupBy(x => x.VersNumInstall)
|
|
.Select(g => g.Key)
|
|
.ToArray();
|
|
ChartColor.Clear();
|
|
var listStatus = SearchRecord
|
|
.GroupBy(x => x.VersNumInstall)
|
|
.Select(g => g.First().UpToDateStatus)
|
|
.ToList();
|
|
foreach (var item in listStatus)
|
|
{
|
|
switch (item)
|
|
{
|
|
case 4:
|
|
ChartColor.Add(new DoughnutStyling("#12FF06", "#006900"));
|
|
break;
|
|
|
|
case 3:
|
|
ChartColor.Add(new DoughnutStyling("#ABFF69", "#11AA11"));
|
|
break;
|
|
|
|
case 2:
|
|
ChartColor.Add(new DoughnutStyling("#FFE493", "#AAFF00"));
|
|
break;
|
|
|
|
case 1:
|
|
ChartColor.Add(new DoughnutStyling("#FF6900", "#953500"));
|
|
break;
|
|
|
|
case 0:
|
|
ChartColor.Add(new DoughnutStyling("#AA3600", "#AA0000"));
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
SearchRecord = CurrRecord.DetailInstalled;
|
|
totalCount = SearchRecord.Count;
|
|
switch (sortField)
|
|
{
|
|
case "NumImp":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.NumImp).ThenByDescending(x => x.VersNumInstall).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.NumImp).ThenByDescending(x => x.VersNumInstall).ToList();
|
|
}
|
|
break;
|
|
|
|
case "VersNumInstall":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.VersNumInstall).ThenBy(x => x.PcInst).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.VersNumInstall).ThenBy(x => x.PcInst).ToList();
|
|
}
|
|
break;
|
|
|
|
case "PcInst":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.PcInst).ThenByDescending(x => x.VersNumInstall).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.PcInst).ThenByDescending(x => x.VersNumInstall).ToList();
|
|
}
|
|
break;
|
|
|
|
case "CodInst":
|
|
if (sortAsc)
|
|
{
|
|
SearchRecord = SearchRecord.OrderBy(x => x.CodInst).ThenByDescending(x => x.VersNumInstall).ToList();
|
|
}
|
|
else
|
|
{
|
|
SearchRecord = SearchRecord.OrderByDescending(x => x.CodInst).ThenByDescending(x => x.VersNumInstall).ToList();
|
|
}
|
|
break;
|
|
|
|
default:
|
|
SearchRecord = SearchRecord
|
|
.OrderByDescending(x => x.VersNumInstall)
|
|
.ThenBy(x => x.PcInst)
|
|
.ToList();
|
|
break;
|
|
}
|
|
|
|
// paginazione
|
|
ListRecord = SearchRecord
|
|
.Skip((currPage - 1) * numRecord)
|
|
.Take(numRecord)
|
|
.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Esegue update stato task
|
|
/// </summary>
|
|
private void ReloadTaskStatus()
|
|
{
|
|
TaskReq = new Dictionary<string, string>();
|
|
TaskRun = new Dictionary<string, string>();
|
|
TaskDone = new Dictionary<string, string>();
|
|
if (!string.IsNullOrEmpty(CodImpSel))
|
|
{
|
|
TaskReq = LMDService.TaskReqGet(CodImpSel);
|
|
TaskRun = LMDService.TaskRunGet(CodImpSel);
|
|
TaskDone = LMDService.TaskDoneGet(CodImpSel);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rilegge risultato task come obj specifici in area DONE...
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task ReloadTaskResults()
|
|
{
|
|
if (TaskDone != null && TaskDone.Count > 0)
|
|
{
|
|
await Task.Delay(100);
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |