This commit is contained in:
parent
38edf0ea41
commit
7716a6fd02
2 changed files with 21 additions and 46 deletions
|
|
@ -10,5 +10,8 @@
|
|||
public string name { get; set; }
|
||||
|
||||
public string url { get; set; }
|
||||
|
||||
public bool? isReport { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -435,25 +435,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
if (higher.profileId != null)
|
||||
{
|
||||
//var payload_attach = new List<PayloadAttachment>();
|
||||
//payload_attach.Add(new PayloadAttachment
|
||||
//{
|
||||
// name = "หนังสือเวียนถึงแก่กรรม",
|
||||
// url = $"{_configuration["APIV2"]}/report/deceased/copy/36/{retirementDeceased.Id}"
|
||||
//});
|
||||
var payload_attach = new List<PayloadAttachment>();
|
||||
payload_attach.Add(new PayloadAttachment
|
||||
{
|
||||
name = "หนังสือเวียนถึงแก่กรรม",
|
||||
url = $"{_configuration["API"]}/retirement/deceased/report/36/{retirementDeceased.Id}",
|
||||
isReport = true
|
||||
});
|
||||
|
||||
//var payload = new CommandPayload()
|
||||
//{
|
||||
// attachments = payload_attach
|
||||
//};
|
||||
var payload = new CommandPayload()
|
||||
{
|
||||
attachments = payload_attach
|
||||
};
|
||||
|
||||
//var payload_str = JsonConvert.SerializeObject(payload);
|
||||
var payload_str = JsonConvert.SerializeObject(payload);
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse(higher.profileId),
|
||||
$"หนังสือเวียนถึงแก่กรรมของ {higher.prefix}{higher.firstName} {higher.lastName}",
|
||||
$"แจ้งข่าวการถึงแก่กรรมของ {retirementDeceased.prefix}{retirementDeceased.firstName} {retirementDeceased.lastName}",
|
||||
//payload_str,
|
||||
"",
|
||||
payload_str,
|
||||
"",
|
||||
true,
|
||||
true
|
||||
|
|
@ -773,7 +773,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
payload_attach.Add(new PayloadAttachment
|
||||
{
|
||||
name = "หนังสือเวียนถึงแก่กรรม",
|
||||
url = $"{_configuration["APIV2"]}/report/deceased/copy/36/{retirementDeceased.Id}"
|
||||
//url = $"{_configuration["APIV2"]}/report/deceased/copy/36/{retirementDeceased.Id}"
|
||||
url = $"{_configuration["API"]}/retirement/deceased/report/36/{retirementDeceased.Id}",
|
||||
isReport = true
|
||||
});
|
||||
|
||||
var payload = new CommandPayload()
|
||||
|
|
@ -921,43 +923,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
Location = detail.GetType().GetProperty("Location")?.GetValue(detail),
|
||||
};
|
||||
|
||||
var reqPayload = new
|
||||
var data = 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();
|
||||
}
|
||||
return Success(data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue