90 lines
2.5 KiB
C#
90 lines
2.5 KiB
C#
using DevExpress.Blazor.Reporting;
|
|
using DevExpress.XtraReports.Services;
|
|
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();
|
|
|
|
//// aggiungo servizio x chiamate http REST
|
|
//builder.Services.AddHttpClient();
|
|
|
|
//builder.Services.AddDevExpressBlazor();
|
|
builder.Services.AddDevExpressServerSideBlazorReportViewer();
|
|
|
|
builder.Services.AddMvc();
|
|
builder.Services.AddDevExpressBlazorReporting();
|
|
|
|
builder.WebHost.UseWebRoot("wwwroot");
|
|
builder.WebHost.UseStaticWebAssets();
|
|
|
|
builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();
|
|
|
|
//builder.Services.AddScoped<IReportProvider, TestMyReportProvider>();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.UseDevExpressBlazorReporting();
|
|
// 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();
|