50d77248f9
- fix ricerca ultime attivazioni con sel periodo - trim elenco clienti attivazioni da elenco
168 lines
5.0 KiB
C#
168 lines
5.0 KiB
C#
using Liman.CadCam.DbModel;
|
|
using Liman.CadCam.Services;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using System;
|
|
using System.Linq;
|
|
using LiMan.DB;
|
|
using LiMan.DB.DBModels;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class SearchEnroll : IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
public string searchVal { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
AppMessages.EA_SearchUpdated -= AppMessages_EA_SearchUpdated;
|
|
LMDService.EnrollMessPipe.EA_NewMessage -= async (sender, e) => await EnrollMessPipe_EA_NewMessage(sender, e);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMessages { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected LiManDataService LMDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
AppMessages.EA_SearchUpdated += AppMessages_EA_SearchUpdated;
|
|
LMDService.EnrollMessPipe.EA_NewMessage += async (sender, e) => await EnrollMessPipe_EA_NewMessage(sender, e);
|
|
await ReloadLicData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rimozione richieste scadute
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task RemoveOld()
|
|
{
|
|
await LMDService.EnrollReqPurgeInvalid();
|
|
await LMDService.FlushEnrollCache();
|
|
LMDService.EnrollMessPipe.sendMessage("PurgedOld");
|
|
searchVal = "";
|
|
}
|
|
/// <summary>
|
|
/// Idx licenza selezionata
|
|
/// </summary>
|
|
private int SelIdxLic = 0;
|
|
private List<LicenzaModel> ListLicenze;
|
|
private async Task ReloadLicData()
|
|
{
|
|
SelectNext currFilt = new SelectNext()
|
|
{
|
|
ApplicazioneSel = "UpdateManager"
|
|
};
|
|
var rawList = await LMDService.LicenzeNextGetFilt(currFilt);
|
|
ListLicenze = rawList
|
|
.OrderBy(x => x.CodApp)
|
|
.ThenBy(x => x.CodInst)
|
|
.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// formattazione opzione licenza da mostrare in select
|
|
/// </summary>
|
|
/// <param name="licItem"></param>
|
|
/// <param name="doShort"></param>
|
|
/// <returns></returns>
|
|
protected string formatLic(LicenzaModel licItem, bool doShort)
|
|
{
|
|
|
|
string answ = $"{licItem.CodApp} | {licItem.CodInst} | {licItem.Attivazioni.Count} / {licItem.NumLicenze}";
|
|
if (doShort)
|
|
{
|
|
answ = $"{licItem.CodApp.Substring(0, 5)}...{licItem.CodApp.Substring(licItem.CodApp.Length - 3)} | {licItem.CodInst} | {licItem.Attivazioni.Count} / {licItem.NumLicenze}";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
|
|
private DateTime dtStart = new DateTime(2024, 1, 1);
|
|
private DateTime dtEnd = DateTime.Today.AddDays(1);
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool isLoading = false;
|
|
|
|
/// <summary>
|
|
/// Indica se mostrare tutte le richieste o solo quelle Attive(aperte/non confermate)
|
|
/// </summary>
|
|
private bool showAll = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private bool hasUpdate { get; set; } = false;
|
|
private List<ProductModel> ListProd { get; set; } = new List<ProductModel>();
|
|
|
|
/// <summary>
|
|
/// Testo associato al toogle button delle richieste Attive / Tutte
|
|
/// </summary>
|
|
private string selMessage
|
|
{
|
|
get => showAll ? "Mostra tutte" : "Solo Attive";
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void AppMessages_EA_SearchUpdated()
|
|
{
|
|
ReloadData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Evento refresh legato a ricezione evento da MessagePipe
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private async Task EnrollMessPipe_EA_NewMessage(object sender, EventArgs e)
|
|
{
|
|
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
|
// qualsiasi messaggio fa scattare reload data
|
|
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
|
{
|
|
hasUpdate = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
await Task.Delay(2500);
|
|
hasUpdate = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
isLoading = true;
|
|
if (searchVal != AppMessages.SearchVal)
|
|
{
|
|
searchVal = AppMessages.SearchVal;
|
|
}
|
|
isLoading = false;
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |