แนบไฟลืหนังสือเวียน
This commit is contained in:
parent
d47404a5b4
commit
7fd22e2c10
9 changed files with 83 additions and 11 deletions
|
|
@ -123,6 +123,75 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </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("copy/36/{exportType}/{id}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDeceasedReportCopyAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
|
||||
var data = await _repository.GetRetirementDeceasedAsync(id);
|
||||
if (data != null || head != null)
|
||||
{
|
||||
var mergeData = new
|
||||
{
|
||||
Oc = head.GetType().GetProperty("Oc").GetValue(head),
|
||||
Number = head.GetType().GetProperty("Number").GetValue(head),
|
||||
Date = head.GetType().GetProperty("Date").GetValue(head),
|
||||
Subject = head.GetType().GetProperty("Subject").GetValue(head),
|
||||
Send = head.GetType().GetProperty("Send").GetValue(head),
|
||||
FullName = data.GetType().GetProperty("FullName").GetValue(data),
|
||||
Position = data.GetType().GetProperty("Position").GetValue(data),
|
||||
Reason = data.GetType().GetProperty("Reason").GetValue(data),
|
||||
DeceasedDate = data.GetType().GetProperty("Date").GetValue(data),
|
||||
CurrentDate = data.GetType().GetProperty("CurrentDate").GetValue(data),
|
||||
DeceasedNumber = data.GetType().GetProperty("Number").GetValue(data),
|
||||
Location = data.GetType().GetProperty("Location").GetValue(data),
|
||||
};
|
||||
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 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp");
|
||||
ReportPackager reportPacker = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||
}
|
||||
report.DataSource = mergeData;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report,
|
||||
};
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// อัปไฟล์บันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue