fill ส่วนหัวหนังสือเวียน

This commit is contained in:
Harid Promsri (Bright) 2023-09-14 10:03:21 +07:00
parent fef7af3f87
commit b8e6a589e0
3 changed files with 28 additions and 8 deletions

View file

@ -57,7 +57,7 @@ namespace BMA.EHR.Report.Service.Controllers
/// <summary>
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
/// </summary>
/// <param name="id">id </param>
/// <param name="id">Id รายการบันทึกเวียนแจ้งการถึงแก่กรรม</param>
/// <param name="exportType">pdf, docx หรือ xlsx</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
@ -68,9 +68,25 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
var data = await _repository.GetRetirementDeceasedAsync(id);
if (data != null)
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())
{
@ -86,7 +102,7 @@ namespace BMA.EHR.Report.Service.Controllers
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
}
report.DataSource = data;
report.DataSource = mergeData;
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
@ -94,7 +110,7 @@ namespace BMA.EHR.Report.Service.Controllers
};
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
return File(result.DocumentBytes, mimeType, $"deceased.{exportType.Trim().ToLower()}");
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
}
else
{