เพิ่ม api รายงานประกาศเกษียณข้าราชการ/ move old template

This commit is contained in:
Harid Promsri (Bright) 2023-08-23 13:50:44 +07:00
parent c179b14839
commit 24bc852341
88 changed files with 39 additions and 29 deletions

View file

@ -2,6 +2,7 @@
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Application.Repositories.Reports;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Swashbuckle.AspNetCore.Annotations;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
@ -12,8 +13,8 @@ namespace BMA.EHR.Report.Service.Controllers
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
//[Authorize]
[SwaggerTag("API รายงานระบบเกษียณ")]
[Authorize]
[SwaggerTag("รายงานระบบเกษียณ")]
public class RetireReportController : BaseController
{
private readonly RetireReportRepository _service;
@ -33,11 +34,44 @@ namespace BMA.EHR.Report.Service.Controllers
var retire = await _service.GetProfileRetirementdAsync(Id);
if (retire == null)
{
return NotFound(retire);
return NotFound();
}
else
{
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"32-ประกาศเกษียณลูกจ้างประจำ.trdp");
var reportfile = "";
var returnfile = "";
switch (retire.GetType().GetProperty("Type").GetValue(retire))
{
case "OFFICER":
if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD")
{
reportfile = $"31-ประกาศเกษียณข้าราชการ-1.trdp";
returnfile = $"ประกาศเกษียณข้าราชการ.pdf";
}
else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT")
{
reportfile = $"31-ประกาศเกษียณข้าราชการ-2.trdp";
returnfile = $"แก้ไขประกาศเกษียณข้าราชการ.pdf";
}
else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE")
{
reportfile = $"31-ประกาศเกษียณข้าราชการ-3.trdp";
returnfile = $"ยกเลิกประกาศเกษียณข้าราชการ.pdf";
}
else
{
return Error(retire.GetType().GetProperty("TypeReport").ToString());
}
break;
case "EMPLOYEE":
reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ.trdp";
returnfile = $"ประกาศเกษียณลูกจ้าง";
break;
default:
return BadRequest(retire);
}
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", reportfile);
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
@ -78,9 +112,8 @@ namespace BMA.EHR.Report.Service.Controllers
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, "application/pdf", $"ประกาศเกษียณลูกจ้างประจำ{null}.pdf");
return File(content, "application/pdf", returnfile);
}
//return Success(retire);
}