Merge branch 'feature/MoveReportRef' into develop

This commit is contained in:
Samuele Locatelli
2023-05-26 12:08:55 +02:00
7 changed files with 79 additions and 51 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>WebDoorCreator - Egalware</i>
<h4>Version: 0.9.2305.2610</h4>
<h4>Version: 0.9.2305.2612</h4>
<br /> Release note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2305.2610
0.9.2305.2612
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2305.2610</version>
<version>0.9.2305.2612</version>
<url>http://nexus.steamware.net/repository/SWS/WDC/stable/WDC.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/WDC/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>
@@ -263,11 +263,14 @@ namespace WebDoorCreator.UI.Components.DoorMan
protected async Task ReloadData()
{
// 2023.05.26 - report inserito come servizio nell'app
#if false
var confData = await WDService.ConfigGetKey("prt_ReportServerUrl");
if (confData != null)
{
reportBaseUrl = confData.valore;
}
}
#endif
if (!AddDoorDict.ContainsKey("ADD NEW DOOR"))
{
@@ -386,6 +389,7 @@ namespace WebDoorCreator.UI.Components.DoorMan
#endregion Private Properties
#if false
public string reportBaseUrl { get; set; } = "http://w2019-sql-steam/reportserver?/Test/WebDoor/";
protected async Task reportUrl(int orderId)
@@ -393,8 +397,19 @@ namespace WebDoorCreator.UI.Components.DoorMan
var url = $"{reportBaseUrl}ReportOrder&OrderID={orderId}&rs:Command=Render&rs:format=PDF";
await JSRuntime.InvokeAsync<object>("open", url, "_blank");
}
#endif
//NavManager.NavigateTo(url, true);
/// <summary>
/// Path del servizio di recupero report in PDF
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
protected async Task reportUrl(int orderId)
{
var url = $"api/Report/GetOrderReport?OrderId={orderId}&Format=PDF";
// chiamo apertura via jscript in target _blank
await JSRuntime.InvokeAsync<object>("open", url, "_blank");
}
}
}
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.JSInterop;
using System.Security.Policy;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.Data.Services;
using WebDoorCreator.UI.Data;
@@ -326,7 +327,10 @@ namespace WebDoorCreator.UI.Components.Order
}
protected string reportUrl(int orderId)
{
return $"{reportBaseUrl}ReportOrder&OrderID={orderId}&rs:Command=Render&rs:format=PDF";
return $"api/Report/GetOrderReport?OrderId={orderId}&Format=PDF";
#if false
return $"{reportBaseUrl}ReportOrder&OrderID={orderId}&rs:Command=Render&rs:format=PDF";
#endif
}
protected async Task setOrd2Show(int orderId)
@@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Reporting.NETCore;
using NLog;
using System.Data;
using ToDataTable;
using WebDoorCreator.Data.Services;
namespace WebDoorCreator.UI.Controllers
@@ -11,11 +13,11 @@ namespace WebDoorCreator.UI.Controllers
{
#region Public Constructors
public ReportController(IConfiguration configuration, QueueDataService DataService)
public ReportController(IConfiguration configuration, WebDoorCreatorService DataService)
{
Log.Info("Starting ReportController");
_configuration = configuration;
QDataServ = DataService;
WDCService = DataService;
Log.Info("Avviato ReportController");
}
@@ -30,38 +32,23 @@ namespace WebDoorCreator.UI.Controllers
return "OK";
}
[HttpGet("GetReport")]
public async Task<IActionResult> GetReport(int OrderId, string Format)
/// <summary>
/// Restituisce report dato ordine e formato
/// </summary>
/// <param name="OrderId">ID univoco ordine</param>
/// <param name="Format">Formato: PDF/HTML/DOCX/XLSX</param>
/// <returns></returns>
[HttpGet("GetOrderReport")]
public async Task<IActionResult> GetOrderReport(int OrderId, string Format)
{
// dato il servizio è impostato il file rdlc e la struttura data DS da passare
await Task.Delay(1);
string FileName = $"DCA-Order-{OrderId:00000000}";
string Extension = "";
string MimeType = "";
switch (Format.ToUpper())
{
case "HTML":
Extension = "html";
MimeType = "text/html";
break;
// inizializzo parametri report di default
Core.ReportViewer.Report.RenderParams currParams = new Core.ReportViewer.Report.RenderParams(Format);
currParams.FileName = $"DCA-Order-{OrderId:00000000}";
case "DOCX":
Extension = "docx";
MimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
break;
case "XLSX":
Extension = "xlsx";
MimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
break;
case "PDF":
default:
Extension = "pdf";
MimeType = "application/pdf";
break;
}
// restituisco oggetto
return PrepareReport(FileName, Format, Extension, MimeType);
// restituisco oggetto ReportOrder specifico
return await OrderReportGet(OrderId, currParams);
}
#endregion Public Methods
@@ -76,25 +63,45 @@ namespace WebDoorCreator.UI.Controllers
#region Private Properties
private decimal GizmoPrice { get; set; }
private QueueDataService QDataServ { get; set; } = null!;
private decimal WidgetPrice { get; set; }
private WebDoorCreatorService WDCService { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private IActionResult PrepareReport(string FileName, string renderFormat, string extension, string mimeType)
/// <summary>
/// Restituisce filestream del report richiesto
/// </summary>
/// <param name="OrderId">ID Ordine</param>
/// <param name="CurrParams">Parametri rendering report</param>
/// <returns></returns>
private async Task<IActionResult> OrderReportGet(int OrderId, Core.ReportViewer.Report.RenderParams CurrParams)
{
using (var report = new LocalReport())
{
// setup parametri
List<ReportParameter> RepParams = new List<ReportParameter>();
RepParams.Add(new ReportParameter("OrderID", $"{OrderId}"));
// setup DsReport
Dictionary<string, DataTable> DsDict = new Dictionary<string, DataTable>();
// recupero tab dati config...
var confList = await WDCService.ConfigGetAll();
DataTable tabDatiConf = confList.ToDataTable();
tabDatiConf.TableName = "DataSetConfig";
// aggiungo a dizionario
DsDict.Add("DataSetConfig", tabDatiConf);
// recupero dati veri del report...
var repDetailData = await WDCService.PreRepOrderGetByKey(OrderId);
DataTable tabDati = repDetailData.ToDataTable();
tabDati.TableName = "DataSetOrderReportExpl";
// aggiungo dizionario
DsDict.Add("DataSetOrderReportExpl", tabDati);
// carico dati nel report...
Core.ReportViewer.Report.Load(report, "Report.rdlc", DsDict);
var rawData = report.Render(renderFormat);
return File(rawData, mimeType, $"{FileName}.{extension}");
Core.ReportViewer.Report.Load(report, "ReportOrder.rdlc", RepParams, DsDict);
var rawData = report.Render(CurrParams.RenderFormat);
return File(rawData, CurrParams.MimeType, $"{CurrParams.FileName}.{CurrParams.Extension}");
}
}
+7 -5
View File
@@ -3,15 +3,11 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.9.2305.2610</Version>
<Version>0.9.2305.2612</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-WebDoorCreator.UI-dfe95fed-1398-4144-bd43-8b3a765d6608</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Controllers\ReportController.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="compilerconfig.json" />
</ItemGroup>
@@ -76,6 +72,12 @@
<None Include="Properties\PublishProfiles\IIS02.pubxml.user" />
<None Include="Properties\PublishProfiles\IISProfile.pubxml.user" />
</ItemGroup>
<ItemGroup>
<None Update="Reports\ReportOrder.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
</Target>