no message

This commit is contained in:
Kittapath 2024-06-25 09:27:34 +07:00
parent c1cfaa3b6d
commit 468bd38e0b
9 changed files with 247 additions and 166 deletions

View file

@ -54,7 +54,7 @@ namespace BMA.EHR.Report.Service.Controllers
#region " C-PM-01 "
private async Task<byte[]> GenerateCommandReportType01_Cover(Guid commandId, string exportType)
private async Task<dynamic> GenerateCommandReportType01_Cover(Guid commandId, string exportType)
{
try
{
@ -83,34 +83,40 @@ namespace BMA.EHR.Report.Service.Controllers
AuthorizedPosition = raw_data.AuthorizedPosition,
Subject = $"เรื่อง {raw_data.CommandSubject}",
};
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp");
ReportPackager reportPackager = new ReportPackager();
Telerik.Reporting.Report? report = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
var content = new
{
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
}
report.DataSource = command;
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
if (exportType == "docx")
deviceInfo["OutputFormat"] = "DOCX";
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = report
template = "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1",
reportName = "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1",
data = command
};
// var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp");
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo);
// ReportPackager reportPackager = new ReportPackager();
// Telerik.Reporting.Report? report = null;
// using (var sourceStream = System.IO.File.OpenRead(rptFile))
// {
// report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
// }
var content = result.DocumentBytes;
// report.DataSource = command;
return content;
// System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
// if (exportType == "docx")
// deviceInfo["OutputFormat"] = "DOCX";
// InstanceReportSource instanceReportSource = new InstanceReportSource()
// {
// ReportDocument = report
// };
// ReportProcessor reportProcessor = new ReportProcessor(_configuration);
// RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo);
// var content = result.DocumentBytes;
return command;
}
catch
{
@ -2640,7 +2646,14 @@ namespace BMA.EHR.Report.Service.Controllers
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType01_Cover(id, exportType);
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "Type01_Cover",
reportName = "Type01_Cover",
data = contentData
};
return Success(data);
// return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
}
catch
{