Files
Samuele E. Locatelli 57c41c7a60 MP-PROG
- fix naming DbModels
2025-03-08 10:48:56 +01:00

153 lines
3.9 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.FileData;
using MP.FileData.DbModels;
using MP.Prog.Data;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MP.Prog.Components
{
public partial class RevList
{
#region Public Properties
[Parameter]
public FileModel CurrRec { get; set; }
/// <summary>
/// Evento selezione rev x confronto, valore = rev
/// </summary>
[Parameter]
public EventCallback<int> EC_selRev { get; set; }
/// <summary>
/// Evento richiesta approvazione versione, valore = record
/// </summary>
[Parameter]
public EventCallback<FileModel> EC_reqAppr { get; set; }
/// <summary>
/// Evento richeista eliminazione da DB del File
/// </summary>
[Parameter]
public EventCallback<FileModel> EC_reqDelete { get; set; }
#endregion Public Properties
#region Protected Properties
[Inject]
protected FileArchDataService FDService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MessageService MServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Restituisce size calcolata
/// </summary>
/// <param name="origSize"></param>
/// <returns></returns>
protected string CalcSize(long origSize)
{
return MeasureUtils.SizeSuffix(origSize, 1);
}
/// <summary>
/// Forza approvazione utente corrente
/// </summary>
/// <returns></returns>
protected async Task FileSetUserApp(FileModel CurrRec)
{
await EC_reqAppr.InvokeAsync(CurrRec);
await Task.Delay(100);
await ReloadData();
}
/// <summary>
/// Selezione Rev x display confronto
/// </summary>
/// <returns></returns>
protected async Task SelRev(FileModel CurrRec)
{
await EC_selRev.InvokeAsync(CurrRec.Rev);
await ReloadData();
}
/// <summary>
/// Elimina record (non approvato) corrente e riattiva precedente
/// </summary>
/// <returns></returns>
protected async Task DeleteRec(FileModel CurrRec)
{
await EC_reqDelete.InvokeAsync(CurrRec);
await Task.Delay(100);
await ReloadData();
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected async Task ReloadData()
{
// valutare recupero info + redis + pagiazione EX POST...
if (CurrRec != null)
{
ListRecords = FDService.FileGetAllRevByKey(CurrRec.FileId);
}
else
{
ListRecords = new List<FileModel>();
}
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
private List<FileModel> ListRecords;
#endregion Private Fields
#region Private Methods
private string cssStatusByCod(FileState currStatus)
{
string answ = "badge";
switch (currStatus)
{
case FileState.Changed:
answ += " text-bg-warning";
break;
case FileState.Missing:
answ += " text-bg-danger";
break;
case FileState.Ok:
answ += " text-bg-success";
break;
case FileState.ND:
default:
answ += " text-bg-light";
break;
}
return answ;
}
#endregion Private Methods
}
}