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 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>(currReport.FileConfDataRaw) ?? new(); } isLoading = false; } private List ReportList = new(); private Dictionary DictAlias = new(); private List ListRepFiles = new List(); 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); } /// /// recupero elenco file per tipo di report /// 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(); } /// /// Recupero descrizione report /// /// Nome file /// private string Descrizione(string currFileName) { string ans = ""; // cerco nel dizionario... if (DictAlias.ContainsKey(currFileName)) { ans = DictAlias[currFileName]; } return ans; } } }