ff7ca06f16
- Aggiunto comportamento refresh su azioni client - Modifiche minori visualizzazione
129 lines
3.6 KiB
C#
129 lines
3.6 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;
|
|
|
|
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 Task.Delay(1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rimozione richieste scadute
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task RemoveOld()
|
|
{
|
|
await LMDService.EnrollReqPurgeInvalid();
|
|
await LMDService.FlushEnrollCache();
|
|
LMDService.EnrollMessPipe.sendMessage("PurgedOld");
|
|
searchVal = "";
|
|
}
|
|
|
|
#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
|
|
}
|
|
} |