80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using EgwCoreLib.Lux.Data.DbModel.Report;
|
|
using EgwCoreLib.Lux.Data.Services.Report;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Lux.UI.Components.Compo.Common
|
|
{
|
|
public partial class PrintModal
|
|
{
|
|
[Parameter]
|
|
public string url { get; set; } = "";
|
|
[Parameter]
|
|
public int currId { get; set; }
|
|
[Parameter]
|
|
public string repType { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_Close { get; set; }
|
|
|
|
[Inject]
|
|
private IFileService FService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IReportService RService { get; set; } = null!;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
isLoading = true;
|
|
LoadFileList();
|
|
ReportList = await RService.GetAllAsync();
|
|
ReportModel currReport = ReportList.FirstOrDefault(x => x.Name.Contains(repType)) ?? new();
|
|
// fix alias disponibili
|
|
if (!string.IsNullOrEmpty(currReport.FileConfDataRaw))
|
|
{
|
|
DictAlias = JsonConvert.DeserializeObject<Dictionary<string, string>>(currReport.FileConfDataRaw) ?? new();
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
private List<ReportModel> ReportList = new();
|
|
private Dictionary<string, string> DictAlias = new();
|
|
private List<string> ListRepFiles = new List<string>();
|
|
private bool isLoading = false;
|
|
|
|
private string DoPrint(string SelFile)
|
|
{
|
|
return $"{url}/download?ReqId={currId}&RepType={repType}&SelFile={SelFile}";
|
|
}
|
|
private Task DoCloseModal()
|
|
{
|
|
return EC_Close.InvokeAsync(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// recupero elenco file per tipo di report
|
|
/// </summary>
|
|
private void LoadFileList()
|
|
{
|
|
string repPath = Path.Combine("reports", repType);
|
|
var rawList = FService.ListFile(repPath, "*.repx", true);
|
|
ListRepFiles = rawList.Select(x => Path.GetFileName(x)).ToList();
|
|
var SelFile = ListRepFiles.FirstOrDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Recupero descrizione report
|
|
/// </summary>
|
|
/// <param name="currFileName"> Nome file</param>
|
|
/// <returns></returns>
|
|
private string Descrizione(string currFileName)
|
|
{
|
|
string ans = "";
|
|
// cerco nel dizionario...
|
|
if (DictAlias.ContainsKey(currFileName))
|
|
{
|
|
ans = DictAlias[currFileName];
|
|
}
|
|
return ans;
|
|
}
|
|
}
|
|
} |