UPdate report con stampa PDF

This commit is contained in:
Annamaria Sassi
2026-04-01 17:59:49 +02:00
parent 050e698eed
commit 29762cd69c
6 changed files with 446 additions and 66 deletions
+46
View File
@@ -1,9 +1,17 @@
using DevExpress.Blazor.Reporting;
using DevExpress.XtraReports.Web.Extensions;
using Microsoft.AspNetCore.Localization;
using System.Globalization;
using TestDevExpress.Components;
using TestDevExpress.Components.Reports;
var builder = WebApplication.CreateBuilder(args);
// gestione configurazione
ConfigurationManager _config = builder.Configuration;
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
@@ -37,4 +45,42 @@ app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
// cultura IT...
var supportedCultures = new[]{
new CultureInfo("it-IT")
};
app.MapGet("/download-offer", (int id) =>
{
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/offert";
string imgFullUrl = $"{apiUrl}/{imgUrl}/";
string dataFullUrl = $"{apiUrl}/{dataUrl}";
var report = new OfferReport(dataFullUrl, id);
report.Parameters["pBasePath"].Value = imgFullUrl;
using var ms = new MemoryStream();
report.ExportToPdf(ms);
ms.Position = 0;
string fName = $"Offert_{id:00000000}.pdf";
return Results.File(
ms.ToArray(),
"application/pdf",
fName
);
});
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("it-IT"),
SupportedCultures = supportedCultures,
FallBackToParentCultures = false
});
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT");
app.Run();