เพิ่ม export type รายงานเกษียณ

This commit is contained in:
Harid Promsri (Bright) 2023-08-26 15:29:38 +07:00
parent 185e4ab225
commit 61e5e4cbd2

View file

@ -28,16 +28,18 @@ namespace BMA.EHR.Report.Service.Controllers
_configuration = configuration;
}
#region
/// <summary>
/// รายงานหน้าประกาศเกษียณ
/// </summary>
/// <param name="Id">Id ของรอบเกษียณ</param>
/// <param name="exportType">pdf, docx หรือ xlsx</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{Id}")]
public async Task<ActionResult<ResponseObject>> GetProfileRetirement([FromRoute] Guid Id)
[HttpGet("{exportType}/{Id}")]
public async Task<ActionResult<ResponseObject>> 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
}
}