226 lines
6.4 KiB
C#
226 lines
6.4 KiB
C#
// <autogenerated />
|
|
using DevExpress.CodeParser;
|
|
using Lux.Report.Data.DTO;
|
|
using Lux.Report.Data.Services;
|
|
using Lux.Report.Server.Components.Compo;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.WebUtilities;
|
|
|
|
namespace Lux.Report.Server.Components.Pages
|
|
{
|
|
public partial class Reports
|
|
{
|
|
#region Protected Properties
|
|
|
|
protected string RepType
|
|
{
|
|
get => repType;
|
|
set
|
|
{
|
|
if (repType != value)
|
|
{
|
|
repType = value;
|
|
LoadFileList();
|
|
UpdateConf();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected string ReqID
|
|
{
|
|
get => reqID;
|
|
set
|
|
{
|
|
if (reqID != value)
|
|
{
|
|
reqID = value;
|
|
UpdateParams();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected string SelFile
|
|
{
|
|
get => selFile;
|
|
set
|
|
{
|
|
if (selFile != value)
|
|
{
|
|
selFile = value;
|
|
UpdateConf();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected string CodGroup
|
|
{
|
|
get => reqGroup;
|
|
set
|
|
{
|
|
if (reqGroup != value)
|
|
{
|
|
reqGroup = value;
|
|
UpdateParams();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
// recupero dati da URL
|
|
GetQueryParams();
|
|
|
|
// recupero da conf i parametri base
|
|
string apiUrl = _config.GetValue<string>("ServerConf:ApiBaseUrl") ?? "https://iis01.egalware.com/lux/srv/api";
|
|
string imgUrl = _config.GetValue<string>("ServerConf:ImageUrl") ?? "image";
|
|
string dataUrl = _config.GetValue<string>("ServerConf:DataUrl") ?? "report";
|
|
|
|
//string dataReportUrl = "offert"; // da recuperare dal DB
|
|
|
|
// calcolo valori specifici del report
|
|
imgFullUrl = $"{apiUrl}/{imgUrl}/";
|
|
dataFullUrl = $"{apiUrl}/{dataUrl}/{dataReportUrl}";
|
|
|
|
// recupero da URL il reportFile richiesto
|
|
LoadFileList();
|
|
UpdateConf();
|
|
doShow = true;
|
|
//base.OnInitialized();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private ReportViewConfDto CurrConf = new();
|
|
private Dictionary<string, string> CurrParam = new();
|
|
private string dataFullUrl = "";
|
|
private string dataReportUrl = "";
|
|
private bool doShow = false;
|
|
|
|
private bool forceRepType = false;
|
|
private bool forceSelFile = false;
|
|
private string imgFullUrl = "";
|
|
|
|
private List<string> ListRepFiles = new List<string>();
|
|
|
|
private string pdfUrl = "download";
|
|
|
|
private string repType = "Offerta";
|
|
|
|
private string reqID = "0";
|
|
private string selFile = "";
|
|
private string reqGroup = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IConfiguration _config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IFileService FService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void GetQueryParams()
|
|
{
|
|
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
|
var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(uri.Query);
|
|
|
|
RepType = query.TryGetValue("repType", out var rep) ? rep.ToString() : "";
|
|
// verifico esistenza folder...
|
|
string dirPath = Path.Combine("reports", RepType);
|
|
if (!FService.FolderExists(dirPath) || string.IsNullOrEmpty(RepType))
|
|
{
|
|
repType = "Offerta";
|
|
}
|
|
|
|
// rivedere da DB... FixMe ToDo !!!
|
|
switch (RepType)
|
|
{
|
|
case "Offerta":
|
|
dataReportUrl = "offert";
|
|
break;
|
|
|
|
case "Ordine":
|
|
dataReportUrl = "order";
|
|
break;
|
|
|
|
case "Template":
|
|
dataReportUrl = "template";
|
|
break;
|
|
|
|
case "MaterialReqOrd":
|
|
dataReportUrl = "matreq-sale-ord";
|
|
break;
|
|
|
|
case "MaterialReqOrdRow":
|
|
dataReportUrl = "matreq-sale-ord-row";
|
|
break;
|
|
|
|
case "BuyOrder":
|
|
dataReportUrl = "buyorder";
|
|
break;
|
|
}
|
|
|
|
SelFile = query.TryGetValue("selFile", out var sel) ? sel.ToString() : "";
|
|
ReqID = query.TryGetValue("reqId", out var rID) ? rID.ToString() : "0";
|
|
CodGroup = query.TryGetValue("codGroup", out var rGroup) ? rGroup.ToString() : "";
|
|
forceRepType = !string.IsNullOrEmpty(RepType);
|
|
forceSelFile = !string.IsNullOrEmpty(SelFile);
|
|
|
|
// sistemo download URL
|
|
pdfUrl = $"download?ReqId={ReqID}&RepType={RepType}&SelFile={SelFile}&CodGroup={CodGroup}";
|
|
}
|
|
|
|
/// <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();
|
|
if (!forceSelFile)
|
|
{
|
|
SelFile = ListRepFiles.FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
private void UpdateConf()
|
|
{
|
|
CurrConf = new ReportViewConfDto()
|
|
{
|
|
ReportType = repType,
|
|
ReportFile = selFile,
|
|
DataFullUrl = dataFullUrl,
|
|
ImgFullUrl = imgFullUrl
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update parametri Live
|
|
/// </summary>
|
|
private void UpdateParams()
|
|
{
|
|
CurrParam = new();
|
|
CurrParam.Add("RepType", RepType);
|
|
CurrParam.Add("SelFile", SelFile);
|
|
CurrParam.Add("ReqID", ReqID);
|
|
CurrParam.Add("codGroup", CodGroup);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |