Add Report Template

This commit is contained in:
Suphonchai Phoonsawat 2023-08-23 18:30:52 +07:00
parent 3e2fc6905f
commit 031e25c04f
92 changed files with 42 additions and 9 deletions

View file

@ -1042,12 +1042,47 @@ namespace BMA.EHR.ReportV2.Service.Controllers
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
}
return StatusCode(500, new { message = "ยังไม่มีไฟล์ Template สำหรับสร้างรายงาน!!" });
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-1.trdp");
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp");
//var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
}
catch
{
throw;
}
}
//return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
/// <summary>
/// เอกสารแนบท้าย C-PM-15 คำสั่งให้ช่วยราชการ
/// </summary>
/// <param name="id">Record 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("c-pm-15/attachment/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public IActionResult GetCommandType15AttachmentReport(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 = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp");
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
return File(contentData, mimeType, $"command-attachment.{exportType.Trim().ToLower()}");
}
catch
{
@ -1085,12 +1120,10 @@ namespace BMA.EHR.ReportV2.Service.Controllers
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
}
return StatusCode(500, new { message = "ยังไม่มีไฟล์ Template สำหรับสร้างรายงาน!!" });
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp");
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp");
//var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
//return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
}
catch
{