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 "
private async Task<dynamic> GenerateCommandReportType01_Cover(Guid commandId, string exportType)
private async Task<byte[]> GenerateCommandReportType01_Cover(Guid commandId, string exportType)
{
try
{
@ -83,40 +83,34 @@ namespace BMA.EHR.Report.Service.Controllers
AuthorizedPosition = raw_data.AuthorizedPosition,
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",
reportName = "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1",
data = command
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
};
// 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))
// {
// report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
// }
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo);
// report.DataSource = command;
var content = result.DocumentBytes;
// 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;
return content;
}
catch
{
@ -2646,14 +2640,7 @@ namespace BMA.EHR.Report.Service.Controllers
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType01_Cover(id, exportType);
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()}");
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
}
catch
{