เชื่อมฐานข้อมูล
This commit is contained in:
parent
2ebedb9bb2
commit
160ff2abcf
1 changed files with 21 additions and 105 deletions
|
|
@ -49,6 +49,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#region " Private "
|
||||
|
||||
#region " C-PM-01 "
|
||||
|
||||
private async Task<byte[]> GenerateCommandReportType01_Cover(Guid commandId, string exportType)
|
||||
{
|
||||
try
|
||||
|
|
@ -158,6 +160,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-01 คำสั่งบรรจุและแต่งตั้ง: สำหรับผู้สอบแข่งขันได้ "
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -174,7 +178,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult GetCommandType01CoverReport(Guid id, string exportType = "pdf")
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandType01CoverReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -186,10 +190,16 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp");
|
||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
||||
var contentData = await GenerateCommandReportType01_Cover(id, exportType);
|
||||
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
|
||||
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp");
|
||||
//var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
//return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -211,10 +221,14 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public IActionResult GetCommandType01AttachmentReport(Guid id, string exportType = "pdf")
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandType01AttachmentReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
var mimeType = "";
|
||||
switch (exportType.Trim().ToLower())
|
||||
{
|
||||
|
|
@ -223,10 +237,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp");
|
||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
|
||||
return File(contentData, mimeType, $"command-attachment.{exportType.Trim().ToLower()}");
|
||||
var contentData = await GenerateCommandReportType01_Attachment(id, exportType);
|
||||
return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -1465,102 +1477,6 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// รายงานหน้าคำสั่ง
|
||||
/// </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("cover/{exportType}/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandCoverReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
switch (cmd.CommandType.CommandCode.Trim().ToUpper())
|
||||
{
|
||||
case "C-PM-01":
|
||||
case "C-PM-02":
|
||||
case "C-PM-03":
|
||||
{
|
||||
var contentData = await GenerateCommandReportType01_Cover(id, exportType);
|
||||
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// รายงานเอกสารแนบท้าย
|
||||
/// </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("attachment/{exportType}/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandAttachmentReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
switch (cmd.CommandType.CommandCode.Trim().ToUpper())
|
||||
{
|
||||
case "C-PM-01":
|
||||
case "C-PM-02":
|
||||
case "C-PM-03":
|
||||
{
|
||||
var contentData = await GenerateCommandReportType01_Attachment(id, exportType);
|
||||
return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue