131 lines
4.4 KiB
C#
131 lines
4.4 KiB
C#
// <autogenerated />
|
|
using DevExpress.DataAccess.Json;
|
|
using DevExpress.XtraReports.Services;
|
|
using DevExpress.XtraReports.UI;
|
|
using Lux.Report.Data.DTO;
|
|
using Lux.Report.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.IO.Compression;
|
|
|
|
namespace Lux.Report.Server.Components.Compo
|
|
{
|
|
public partial class ReportViewer
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public ReportViewConfDto RepViewConf { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public Dictionary<string, string> RequestDict { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (RepViewConf != null && RequestDict != null)
|
|
{
|
|
doShow = false;
|
|
Report = null;
|
|
//string reqRep = "\\\\stor01\\TEAM DRIVES\\40_FileUpload\\LuxUploads\\reports\\Offerta\\Offerta_01.repx";
|
|
string repPath = Path.Combine("reports", RepViewConf.ReportType, RepViewConf.ReportFile);
|
|
|
|
// recupero da DB e URL conf parametri e valori correnti...
|
|
List<ParamConfigDto> paramsConfig = new();
|
|
|
|
// se esiste il file...
|
|
if (FService.FileExists(repPath))
|
|
{
|
|
// lettura file report
|
|
var repData = FService.ReadAllBytes(repPath);
|
|
using (MemoryStream ms = new MemoryStream(repData))
|
|
{
|
|
Report = XtraReport.FromStream(ms);
|
|
var ds = ComposeJsonDataSource(RepViewConf.DataFullUrl, paramsConfig, RequestDict);
|
|
ds.Fill();
|
|
Report.DataSource = ds;
|
|
Report.DataMember = "";
|
|
// deve diventare dinamico da paramsConfig + ParamsVal +...
|
|
foreach (DevExpress.XtraReports.Parameters.Parameter param in Report.Parameters)
|
|
{
|
|
if(param.Name.Equals("pImgPath"))
|
|
Report.Parameters["pImgPath"].Value = RepViewConf.ImgFullUrl;
|
|
}
|
|
doShow = true;
|
|
}
|
|
}
|
|
}
|
|
//base.OnParametersSet();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private bool doShow = false;
|
|
|
|
private string pdfUrl = "";
|
|
|
|
private XtraReport? Report = null;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IFileService FService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IReportProvider reportProvider { get; set; }
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Composizione DataSource Json
|
|
/// </summary>
|
|
/// <param name="rawDataUrl">URL di partenza</param>
|
|
/// <param name="paramsConfig">Configurazione dei parametri da applicare</param>
|
|
/// <param name="paramsVal">Valore corrente parametri</param>
|
|
/// <returns></returns>
|
|
private JsonDataSource ComposeJsonDataSource(string rawDataUrl, List<ParamConfigDto> paramsConfig, Dictionary<string, string> paramsVal)
|
|
{
|
|
// Create a new JSON source.
|
|
var jsonSource = new UriJsonSource()
|
|
{
|
|
Uri = new Uri(rawDataUrl)
|
|
};
|
|
int reqID = 7;
|
|
string codGroup = "";
|
|
if (paramsVal.ContainsKey("ReqID"))
|
|
{
|
|
var rawData = paramsVal["ReqID"];
|
|
int.TryParse(rawData, out reqID);
|
|
}
|
|
if (paramsVal.ContainsKey("codGroup"))
|
|
{
|
|
codGroup = paramsVal["codGroup"];
|
|
}
|
|
|
|
jsonSource.PathParameters.Add(new PathParameter("ReqId", typeof(int), reqID));
|
|
if (!string.IsNullOrEmpty(codGroup) && rawDataUrl.Contains("matreq-sale-ord"))
|
|
{
|
|
jsonSource.QueryParameters.Add(new QueryParameter("codGroup", typeof(string), codGroup));
|
|
}
|
|
// Assign the JSON source to the data source.
|
|
var datasource = new JsonDataSource()
|
|
{
|
|
JsonSource = jsonSource
|
|
};
|
|
return datasource;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |