no message
This commit is contained in:
parent
e947f08f8e
commit
1d3f8973e0
1 changed files with 82 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ using Newtonsoft.Json.Linq;
|
|||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Controllers
|
||||
{
|
||||
|
|
@ -882,5 +883,86 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// รายงานบันทึกเวียนแจ้งการถึงแก่กรรม
|
||||
/// </summary>
|
||||
/// <param name="id">Id รายการบันทึกเวียนแจ้งการถึงแก่กรรม</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("report/36/{id}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetDeceasedNotiReportAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var head = await _repositoryRetireReport.GetHeadRetirementDeceasedAsync(id);
|
||||
var detail = await _repositoryRetireReport.GetRetirementDeceasedAsync(id);
|
||||
|
||||
if (detail == null || head == null)
|
||||
{
|
||||
return Error("รายการบันทึกเวียนแจ้งการถึงแก่กรรม", 404);
|
||||
}
|
||||
|
||||
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 = detail.GetType().GetProperty("FullName")?.GetValue(detail),
|
||||
Position = detail.GetType().GetProperty("Position")?.GetValue(detail),
|
||||
Reason = detail.GetType().GetProperty("Reason")?.GetValue(detail),
|
||||
DeceasedDate = detail.GetType().GetProperty("Date")?.GetValue(detail),
|
||||
CurrentDate = detail.GetType().GetProperty("CurrentDate")?.GetValue(detail),
|
||||
DeceasedNumber = detail.GetType().GetProperty("Number")?.GetValue(detail),
|
||||
Location = detail.GetType().GetProperty("Location")?.GetValue(detail),
|
||||
};
|
||||
|
||||
var reqPayload = new
|
||||
{
|
||||
template = "deceased",
|
||||
reportName = "docx-report",
|
||||
data = mergeData
|
||||
};
|
||||
|
||||
|
||||
//using (var client = new HttpClient())
|
||||
//{
|
||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
// var _req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
|
||||
// var _res = await client.PostAsJsonAsync(_apiUrl, new
|
||||
// {
|
||||
// isLeave = true,
|
||||
// leaveReason = "ถึงแก่กรรม",
|
||||
// dateLeave = req.Date,
|
||||
// });
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
//}
|
||||
|
||||
|
||||
var apiUrl = "https://report-server.frappet.synology.me/api/v1/report-template/docx";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
//client.DefaultRequestHeaders.Add("accept", "application/pdf");
|
||||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/pdf"));
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, reqPayload);
|
||||
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
var fileBytes = await _res.Content.ReadAsByteArrayAsync();
|
||||
return File(fileBytes, "application/pdf", "report");
|
||||
}
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue