68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using DevExpress.Blazor.Reporting;
|
|
using DevExpress.DataAccess;
|
|
using DevExpress.DataAccess.Json;
|
|
using DevExpress.XtraReports;
|
|
using DevExpress.XtraReports.UI;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.WebUtilities;
|
|
using TestDevExpress.Components.Reports;
|
|
|
|
namespace TestDevExpress.Components.Pages
|
|
{
|
|
public partial class ReportViewer
|
|
{
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
// assegno il parametro basePath da conf
|
|
string basePath = _config.GetValue<string>("ServerConf:ImageBaseUrl") ?? "https://iis01.egalware.com/Lux/srv/api/window/svgfile/";
|
|
currReport.Parameters["pBasePath"].Value = basePath;
|
|
|
|
//cerco id da URL x offerta da mostrare
|
|
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("OfferId", out var offerId))
|
|
{
|
|
if (currReport.Parameters["pOfferId"] != null)
|
|
{
|
|
currReport.Parameters["pOfferId"].Value = offerId;
|
|
|
|
// 2. Cerca il JsonDataSource e aggiorna l'URL manualmente
|
|
var jsonDataSource = currReport.DataSource as JsonDataSource;
|
|
if (jsonDataSource != null)
|
|
{
|
|
// Costruiamo l'URL finale
|
|
string urlCompleto = $"https://iis01.egalware.com/Lux/srv/api/report/offert/{offerId}";
|
|
|
|
// Assegniamo l'URL "pulito" al data source del report
|
|
jsonDataSource.JsonSource = new UriJsonSource(new Uri(urlCompleto));
|
|
|
|
// IMPORTANTE: Dirottiamo la connessione perché non usi quella di appsettings.json
|
|
jsonDataSource.ConnectionName = null;
|
|
}
|
|
|
|
currReport.RequestParameters = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private OfferReport currReport = new();
|
|
private DxReportViewer? reportViewer;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IConfiguration _config { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |