no message

This commit is contained in:
Kittapath 2024-06-25 09:46:08 +07:00
parent 468bd38e0b
commit a35cc0bdef

View file

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