แบบฟอร์มลาออก
This commit is contained in:
parent
bf111fab00
commit
16cccbf88e
4 changed files with 117 additions and 8 deletions
|
|
@ -25,7 +25,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
//private readonly ProbationReportRepository _repository;
|
||||
private readonly RetireReportRepository _service;
|
||||
private readonly GenericReportGenerator _reportGenerator;
|
||||
|
||||
|
||||
|
|
@ -33,12 +33,12 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#region " Constuctor and Destructor "
|
||||
|
||||
public ResignReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, /*ProbationReportRepository repository,*/ GenericReportGenerator reportGenerator)
|
||||
public ResignReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, RetireReportRepository service, GenericReportGenerator reportGenerator)
|
||||
{
|
||||
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_configuration = configuration;
|
||||
//_repository = repository;
|
||||
_service = service;
|
||||
_reportGenerator = reportGenerator;
|
||||
}
|
||||
|
||||
|
|
@ -57,11 +57,15 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("33/{exportType}/{id}")]
|
||||
public IActionResult GetResign33ConvertReportAsync(Guid id, string exportType = "pdf")
|
||||
public async Task<ActionResult<ResponseObject>> GetResign33ConvertReportAsync(string id= "08dbca15-bb57-4b2e-8435-69116599421b", string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Guid ids = Guid.Parse(id);
|
||||
var resign = await _service.GetResignByUser(ids);
|
||||
if (resign == null)
|
||||
return NotFound();
|
||||
|
||||
var mimeType = "";
|
||||
switch (exportType.Trim().ToLower())
|
||||
{
|
||||
|
|
@ -69,11 +73,38 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
//var FullName = resign.GetType().GetProperty("FirstName").GetValue(resign);
|
||||
|
||||
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
|
||||
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
|
||||
var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
|
||||
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-2.trdp");
|
||||
|
||||
return File(contentData, mimeType, $"resign.{exportType.Trim().ToLower()}");
|
||||
ReportPackager reportPacker = new ReportPackager();
|
||||
Telerik.Reporting.Report? report1 = null;
|
||||
Telerik.Reporting.Report? report2 = null;
|
||||
|
||||
using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
|
||||
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
|
||||
|
||||
{
|
||||
report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
|
||||
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
|
||||
}
|
||||
|
||||
report1.DataSource = resign;
|
||||
|
||||
var reportBook = new ReportBook();
|
||||
reportBook.Reports.Add(report1);
|
||||
reportBook.Reports.Add(report2);
|
||||
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = reportBook,
|
||||
};
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
return File(result.DocumentBytes, mimeType, $"แบบฟอร์มหนังสือขอลาออกจากราชการ.{exportType.Trim().ToLower()}");
|
||||
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue