ปรับ Report Resign, Deceased

This commit is contained in:
Bright 2024-08-02 17:45:47 +07:00
parent 197f8f7150
commit 6bb5c90964
3 changed files with 69 additions and 57 deletions

View file

@ -57,12 +57,11 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("33/{exportType}/{id}")]
public async Task<ActionResult<ResponseObject>> GetResign33ConvertReportAsync(string id= "08dbca15-bb57-4b2e-8435-69116599421b", string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetResign33ConvertReportAsync(Guid id, string exportType = "pdf")
{
try
{
Guid ids = Guid.Parse(id);
var resign = await _service.GetResignByUser(ids);
var resign = await _service.GetResignByUser(id);
if (resign == null)
return NotFound();
@ -75,37 +74,43 @@ namespace BMA.EHR.Report.Service.Controllers
}
//var FullName = resign.GetType().GetProperty("FirstName").GetValue(resign);
var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-2.trdp");
//var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-2.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report1 = null;
Telerik.Reporting.Report? report2 = null;
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report1 = null;
//Telerik.Reporting.Report? report2 = null;
using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//{
// report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
//}
//report1.DataSource = resign;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report1);
//reportBook.Reports.Add(report2);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//return File(result.DocumentBytes, mimeType, $"แบบฟอร์มหนังสือขอลาออกจากราชการ.{exportType.Trim().ToLower()}");
var data = new
{
report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
}
report1.DataSource = resign;
var reportBook = new ReportBook();
reportBook.Reports.Add(report1);
reportBook.Reports.Add(report2);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
template = "resign",
reportName = "docx-report",
data = resign
};
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
return File(result.DocumentBytes, mimeType, $"แบบฟอร์มหนังสือขอลาออกจากราชการ.{exportType.Trim().ToLower()}");
return Success(data);
}
catch
{