UPdate report con stampa PDF
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user