diff --git a/BMA.EHR.Report.Service/Controllers/RetireReportController.cs b/BMA.EHR.Report.Service/Controllers/RetireReportController.cs index 8508289a..f6ab4da2 100644 --- a/BMA.EHR.Report.Service/Controllers/RetireReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/RetireReportController.cs @@ -28,16 +28,18 @@ namespace BMA.EHR.Report.Service.Controllers _configuration = configuration; } + #region ประกาศเกษียณราชการ /// /// รายงานหน้าประกาศเกษียณ /// /// Id ของรอบเกษียณ + /// pdf, docx หรือ xlsx /// /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("{Id}")] - public async Task> GetProfileRetirement([FromRoute] Guid Id) + [HttpGet("{exportType}/{Id}")] + public async Task> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf") { var retire = await _service.GetProfileRetirementdAsync(Id); if (retire == null) @@ -48,23 +50,24 @@ namespace BMA.EHR.Report.Service.Controllers { var reportfile = ""; var returnfile = ""; + exportType = exportType.Trim(); switch (retire.GetType().GetProperty("Type").GetValue(retire)) { case "OFFICER": if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD") { reportfile = $"31-ประกาศเกษียณข้าราชการ-1.trdp"; - returnfile = $"ประกาศเกษียณข้าราชการ.pdf"; + returnfile = $"ประกาศเกษียณข้าราชการ.{exportType}"; } else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT") { reportfile = $"31-ประกาศเกษียณข้าราชการ-2.trdp"; - returnfile = $"แก้ไขประกาศเกษียณข้าราชการ.pdf"; + returnfile = $"แก้ไขประกาศเกษียณข้าราชการ.{exportType}"; } else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE") { reportfile = $"31-ประกาศเกษียณข้าราชการ-3.trdp"; - returnfile = $"ยกเลิกประกาศเกษียณข้าราชการ.pdf"; + returnfile = $"ยกเลิกประกาศเกษียณข้าราชการ.{exportType}"; } else { @@ -94,7 +97,7 @@ namespace BMA.EHR.Report.Service.Controllers foreach (var profile in retire.GetType().GetProperty("profile").GetValue(retire)) { - string thaiOrder = profile.GetType().GetProperty("order").GetValue(profile).ToString()+"."; + string thaiOrder = profile.GetType().GetProperty("order").GetValue(profile).ToString() + "."; thaiOrder = thaiOrder.ToThaiNumber(); _profileList.Add(new { @@ -116,10 +119,11 @@ namespace BMA.EHR.Report.Service.Controllers }; ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo); + RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo); var content = result.DocumentBytes; - return File(content, "application/pdf", returnfile); + return File(content, $"application/{exportType}", returnfile); } } + #endregion } }