Aggiunto parametro codGroup nella sorgente dati dei report

This commit is contained in:
Annamaria Sassi
2026-04-30 17:12:28 +02:00
parent edca6ca957
commit c455a2347f
6 changed files with 40 additions and 10 deletions
@@ -6,6 +6,7 @@
int reqId,
string repType,
string selFile,
string codGroup,
string imgFullUrl,
string dataFullUrl
);
+8 -3
View File
@@ -20,11 +20,12 @@ namespace Lux.Report.Data.Services
int reqId,
string repType,
string selFile,
string codGroup,
string imgFullUrl,
string dataFullUrl
)
{
_logger.LogInformation($"Generating PDF for reqId={reqId}, repType={repType}, selFile={selFile}");
_logger.LogInformation($"Generating PDF for reqId={reqId}, repType={repType}, selFile={selFile}, codGroup={codGroup}");
string repPath = Path.Combine("reports", repType, selFile);
@@ -37,7 +38,7 @@ namespace Lux.Report.Data.Services
using (MemoryStream ms = new MemoryStream(repData))
{
var Report = XtraReport.FromStream(ms);
var ds = ComposeJsonDataSource(dataFullUrl, reqId);
var ds = ComposeJsonDataSource(dataFullUrl, reqId, codGroup);
ds.Fill();
Report.DataSource = ds;
Report.DataMember = "";
@@ -82,7 +83,7 @@ namespace Lux.Report.Data.Services
/// <param name="rawDataUrl">URL di partenza</param>
/// <param name="reqId">ID record richiesto</param>
/// <returns></returns>
private JsonDataSource ComposeJsonDataSource(string rawDataUrl, int reqId)
private JsonDataSource ComposeJsonDataSource(string rawDataUrl, int reqId, string codGroup)
{
// Create a new JSON source.
var jsonSource = new UriJsonSource()
@@ -91,6 +92,10 @@ namespace Lux.Report.Data.Services
};
jsonSource.PathParameters.Add(new PathParameter("ReqId", typeof(int), reqId));
if (!string.IsNullOrEmpty(codGroup))
{
jsonSource.QueryParameters.Add(new QueryParameter("codGroup", typeof(string), codGroup));
}
// Assign the JSON source to the data source.
var datasource = new JsonDataSource()
{
@@ -102,15 +102,22 @@ namespace Lux.Report.Server.Components.Compo
Uri = new Uri(rawDataUrl)
};
int reqID = 7;
if (RequestDict.ContainsKey("ReqID"))
string codGroup = "";
if (paramsVal.ContainsKey("ReqID"))
{
var rawData = RequestDict["ReqID"];
var rawData = paramsVal["ReqID"];
int.TryParse(rawData, out reqID);
}
if (paramsVal.ContainsKey("codGroup"))
{
codGroup = paramsVal["codGroup"];
}
// sistemo origine dati x download
pdfUrl = $"download-offer?id={reqID}";
jsonSource.PathParameters.Add(new PathParameter("ReqId", typeof(int), reqID));
if (!string.IsNullOrEmpty(codGroup) && rawDataUrl.Contains("matreq-sale-ord"))
{
jsonSource.QueryParameters.Add(new QueryParameter("codGroup", typeof(string), codGroup));
}
// Assign the JSON source to the data source.
var datasource = new JsonDataSource()
{
@@ -52,6 +52,19 @@ namespace Lux.Report.Server.Components.Pages
}
}
protected string CodGroup
{
get => reqGroup;
set
{
if (reqGroup != value)
{
reqGroup = value;
UpdateParams();
}
}
}
#endregion Protected Properties
#region Protected Methods
@@ -101,6 +114,7 @@ namespace Lux.Report.Server.Components.Pages
private string reqID = "0";
private string selFile = "";
private string reqGroup = "";
#endregion Private Fields
@@ -162,11 +176,12 @@ namespace Lux.Report.Server.Components.Pages
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}";
pdfUrl = $"download?ReqId={ReqID}&RepType={RepType}&SelFile={SelFile}&CodGroup={CodGroup}";
}
/// <summary>
@@ -203,6 +218,7 @@ namespace Lux.Report.Server.Components.Pages
CurrParam.Add("RepType", RepType);
CurrParam.Add("SelFile", SelFile);
CurrParam.Add("ReqID", ReqID);
CurrParam.Add("codGroup", CodGroup);
}
#endregion Private Methods
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2604.2812</Version>
<Version>1.1.2604.3017</Version>
</PropertyGroup>
<ItemGroup>
+2 -1
View File
@@ -73,6 +73,7 @@ app.MapGet("/download", async (
int? reqId,
string? repType,
string? selFile,
string? codGroup,
IPdfReportService pdfService
) =>
{
@@ -114,7 +115,7 @@ app.MapGet("/download", async (
break;
}
string dataFullUrl = $"{apiUrl}/{dataUrl}/{dataReportUrl}";
var pdf = await pdfService.GeneratePdfAsync(reqId.Value, repType, selFile, imgFullUrl, dataFullUrl);
var pdf = await pdfService.GeneratePdfAsync(reqId.Value, repType, selFile, codGroup, imgFullUrl, dataFullUrl);
string fName = $"{repType}_{reqId:00000000}.pdf";
return Results.File(pdf, "application/pdf", fName);
});