diff --git a/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs b/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs new file mode 100644 index 00000000..c6136721 --- /dev/null +++ b/BMA.EHR.Report.Service/Controllers/InsigniaReportController.cs @@ -0,0 +1,347 @@ +using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Shared; +using BMA.EHR.Application.Repositories.Reports; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; +using Swashbuckle.AspNetCore.Annotations; +using DocumentFormat.OpenXml.Drawing; +using Telerik.Reporting; +using Telerik.Reporting.Processing; +using System.IO; + +namespace BMA.EHR.Report.Service.Controllers +{ + [Route("api/v{version:apiVersion}/report/insignia")] + [ApiVersion("2.0")] + [ApiController] + [Produces("application/json")] + [Authorize] + [SwaggerTag("API รายงานระบบเครื่องราชอิสริยาภรณ์")] + public class InsigniaReportController : BaseController + { + #region " Fields " + + private readonly IWebHostEnvironment _hostingEnvironment; + private readonly IConfiguration _configuration; + //private readonly ProbationReportRepository _repository; + private readonly GenericReportGenerator _reportGenerator; + + + #endregion + + #region " Constuctor and Destructor " + + public InsigniaReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, /*ProbationReportRepository repository,*/ GenericReportGenerator reportGenerator) + { + + _hostingEnvironment = hostingEnvironment; + _configuration = configuration; + //_repository = repository; + _reportGenerator = reportGenerator; + } + + #endregion + + #region " Methods " + + #region 39-แบบ ขร1 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นสายสะพาย + /// + /// 39-แบบ ขร1 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นสายสะพาย + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("39/{exportType}/{id}")] + public IActionResult GetInsignia39ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"39-แบบ ขร1 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นสายสะพาย.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 40-แบบ ขร2 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นต่ำกว่าสายสะพาย + /// + /// 40-แบบ ขร2 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นต่ำกว่าสายสะพาย + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("40/{exportType}/{id}")] + public IActionResult GetInsignia40ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"40-แบบ ขร2 บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ ข้าราชการ ชั้นต่ำกว่าสายสะพาย.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 41-แบบ ขร3 บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชฯ + /// + /// 41-แบบ ขร3 บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชฯ + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("41/{exportType}/{id}")] + public IActionResult GetInsignia41ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"41-แบบ ขร3 บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชฯ.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 42-แบบ ขร4 บัญชีแสดงคุณสมบัติของข้าราชการซึ่งเสนอขอเครื่องราชฯ + /// + /// 42-แบบ ขร4 บัญชีแสดงคุณสมบัติของข้าราชการซึ่งเสนอขอเครื่องราชฯ + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("42/{exportType}/{id}")] + public IActionResult GetInsignia42ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"42-แบบ ขร4 บัญชีแสดงคุณสมบัติของข้าราชการซึ่งเสนอขอเครื่องราชฯ.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 43-บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี + /// + /// 43-บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("43/{exportType}/{id}")] + public IActionResult GetInsignia43ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"43-บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 44-บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ + /// + /// 44-บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("44/{exportType}/{id}")] + public IActionResult GetInsignia44ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"44-บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา + /// + /// 45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("45/{exportType}/{id}")] + public IActionResult GetInsignia45ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 46-ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา + /// + /// 46-ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("46/{exportType}/{id}")] + public IActionResult GetInsignia46ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"46-ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"insignia.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #endregion + } +} diff --git a/BMA.EHR.Report.Service/Controllers/ProbationReportController.cs b/BMA.EHR.Report.Service/Controllers/ProbationReportController.cs new file mode 100644 index 00000000..4a59d21f --- /dev/null +++ b/BMA.EHR.Report.Service/Controllers/ProbationReportController.cs @@ -0,0 +1,335 @@ +using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Shared; +using BMA.EHR.Application.Repositories.Reports; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; +using Swashbuckle.AspNetCore.Annotations; +using DocumentFormat.OpenXml.Drawing; +using Telerik.Reporting; +using Telerik.Reporting.Processing; +using System.IO; + +namespace BMA.EHR.Report.Service.Controllers +{ + [Route("api/v{version:apiVersion}/report/probation")] + [ApiVersion("2.0")] + [ApiController] + [Produces("application/json")] + [Authorize] + [SwaggerTag("API รายงานระบทดลองงาน")] + public class ProbationReportController : BaseController + { + #region " Fields " + + private readonly IWebHostEnvironment _hostingEnvironment; + private readonly IConfiguration _configuration; + //private readonly ProbationReportRepository _repository; + private readonly GenericReportGenerator _reportGenerator; + + + #endregion + + #region " Constuctor and Destructor " + + public ProbationReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration,/* ProbationReportRepository repository*/ GenericReportGenerator reportGenerator) + { + + _hostingEnvironment = hostingEnvironment; + _configuration = configuration; + //_repository = repository; + _reportGenerator = reportGenerator; + } + + #endregion + + #region " Methods " + + #region 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ + /// + /// 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ + /// + /// assign id ของแบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("13/{exportType}/{id}")] + /*public async Task> GetProbationReportAsync(Guid id, string exportType = "pdf") + { + try + { + + string authorizationHeader = Request.Headers["Authorization"]; + string token = string.Empty; + id = Guid.Parse("f26581e7-2736-4988-b3c3-13c0bb3b15b3"); // fix ไว้ทดสอบเฉยๆเดี๋ยวมาลบครับ + + if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer ")) + { + token = authorizationHeader.Substring("Bearer ".Length).Trim(); + var probation = await _repository.GetProbationAssignAsync(id, token); + return probation != null ? Success(probation) : NotFound(id); + } + else + { + return Unauthorized(); + } + } + catch + { + throw; + } + }*/ + public IActionResult GetProbation13ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล + /// + /// 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("14/{exportType}/{id}")] + public IActionResult GetProbation14ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล-1.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา + /// + /// 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("15/{exportType}/{id}")] + public IActionResult GetProbation15ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา-1.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา + /// + /// 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("16/{exportType}/{id}")] + public IActionResult GetProbation16ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา-1.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ + /// + /// 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("17/{exportType}/{id}")] + public IActionResult GetProbation17ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ-1.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน + /// + /// 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("18/{exportType}/{id}")] + public IActionResult GetProbation18ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน-1.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #region 19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายเวลา + /// + /// 19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายเวลา + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("19/{exportType}/{id}")] + public IActionResult GetProbation19ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายเวลา.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"probation.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #endregion + } +} diff --git a/BMA.EHR.Report.Service/Controllers/ResignReportController.cs b/BMA.EHR.Report.Service/Controllers/ResignReportController.cs new file mode 100644 index 00000000..d5f434dc --- /dev/null +++ b/BMA.EHR.Report.Service/Controllers/ResignReportController.cs @@ -0,0 +1,88 @@ +using BMA.EHR.Domain.Common; +using BMA.EHR.Domain.Extensions; +using BMA.EHR.Domain.Shared; +using BMA.EHR.Application.Repositories.Reports; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ModelBinding.Binders; +using Swashbuckle.AspNetCore.Annotations; +using DocumentFormat.OpenXml.Drawing; +using Telerik.Reporting; +using Telerik.Reporting.Processing; +using System.IO; + +namespace BMA.EHR.Report.Service.Controllers +{ + [Route("api/v{version:apiVersion}/report/resign")] + [ApiVersion("2.0")] + [ApiController] + [Produces("application/json")] + [Authorize] + [SwaggerTag("API รายงานระบบลาออก")] + public class ResignReportController : BaseController + { + #region " Fields " + + private readonly IWebHostEnvironment _hostingEnvironment; + private readonly IConfiguration _configuration; + //private readonly ProbationReportRepository _repository; + private readonly GenericReportGenerator _reportGenerator; + + + #endregion + + #region " Constuctor and Destructor " + + public ResignReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, /*ProbationReportRepository repository,*/ GenericReportGenerator reportGenerator) + { + + _hostingEnvironment = hostingEnvironment; + _configuration = configuration; + //_repository = repository; + _reportGenerator = reportGenerator; + } + + #endregion + + #region " Methods " + + #region 33-แบบฟอร์มหนังสือขอลาออกจากราชการ + /// + /// 33-แบบฟอร์มหนังสือขอลาออกจากราชการ + /// + /// id + /// pdf, docx หรือ xlsx + /// + /// เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("33/{exportType}/{id}")] + public IActionResult GetResign33ConvertReportAsync(Guid id, string exportType = "pdf") + { + try + { + + var mimeType = ""; + switch (exportType.Trim().ToLower()) + { + case "pdf": mimeType = "application/pdf"; break; + case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; + case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; + } + + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp"); + var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + + return File(contentData, mimeType, $"resign.{exportType.Trim().ToLower()}"); + + } + catch + { + throw; + } + } + #endregion + + #endregion + } +} 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 } }