94 lines
3.7 KiB
C#
94 lines
3.7 KiB
C#
using DevExpress.Blazor.Reporting;
|
|
using DevExpress.DataAccess;
|
|
using DevExpress.DataAccess.Json;
|
|
using DevExpress.Drawing.Internal.Fonts.Interop;
|
|
using DevExpress.Security;
|
|
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
|
|
|
|
private string pdfUrl
|
|
{
|
|
get => $"download-offer?id={oID}";
|
|
}
|
|
private int oID = 0;
|
|
protected override void OnInitialized()
|
|
{
|
|
// calcolo i parametri x IMG e Json da conf
|
|
|
|
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}";
|
|
|
|
//cerco id da URL x offerta da mostrare
|
|
var uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("OfferId", out var offerId))
|
|
{
|
|
|
|
int.TryParse(offerId, out oID);
|
|
|
|
|
|
currReport = new OfferReport(dataFullUrl, oID);
|
|
currReport.Parameters["pBasePath"].Value = imgFullUrl;
|
|
|
|
// currReport.Parameters["pBasePath"].Value = basePath;
|
|
// if (currReport.Parameters["pOfferId"] != null)
|
|
// {
|
|
// currReport.Parameters["pOfferId"].Value = offerId;
|
|
|
|
//#if false
|
|
// // 2. Cerca il JsonDataSource e aggiorna l'URL manualmente
|
|
// var jsonDataSource = currReport.DataSource as JsonDataSource;
|
|
// if (jsonDataSource != null)
|
|
// {
|
|
// // Costruiamo l'URL finale
|
|
// //string baseUrl = _config.GetValue<string>("connectionStrings:JsonConnection") ?? "https://iis01.egalware.com/Lux/srv/api/report/offert/";
|
|
// string baseUrl = _config.GetConnectionString("JsonConnection") ?? "https://iis01.egalware.com/Lux/srv/api/report/offert/";
|
|
|
|
|
|
// string urlCompleto = $"{baseUrl}{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;
|
|
// }
|
|
//#endif
|
|
|
|
// 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
|
|
}
|
|
} |