noti หนังสือเวียน

This commit is contained in:
Bright 2025-04-03 14:19:39 +07:00
parent 38edf0ea41
commit 0191491b7c
2 changed files with 21 additions and 46 deletions

View file

@ -10,5 +10,8 @@
public string name { get; set; } public string name { get; set; }
public string url { get; set; } public string url { get; set; }
public bool? isReport { get; set; }
} }
} }

View file

@ -435,25 +435,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
{ {
if (higher.profileId != null) if (higher.profileId != null)
{ {
//var payload_attach = new List<PayloadAttachment>(); var payload_attach = new List<PayloadAttachment>();
//payload_attach.Add(new PayloadAttachment payload_attach.Add(new PayloadAttachment
//{ {
// name = "หนังสือเวียนถึงแก่กรรม", name = "หนังสือเวียนถึงแก่กรรม",
// url = $"{_configuration["APIV2"]}/report/deceased/copy/36/{retirementDeceased.Id}" url = $"{_configuration["API"]}/retirement/deceased/report/36/{retirementDeceased.Id}",
//}); isReport = true
});
//var payload = new CommandPayload() var payload = new CommandPayload()
//{ {
// attachments = payload_attach attachments = payload_attach
//}; };
//var payload_str = JsonConvert.SerializeObject(payload); var payload_str = JsonConvert.SerializeObject(payload);
await _repositoryNoti.PushNotificationAsync( await _repositoryNoti.PushNotificationAsync(
Guid.Parse(higher.profileId), Guid.Parse(higher.profileId),
$"หนังสือเวียนถึงแก่กรรมของ {higher.prefix}{higher.firstName} {higher.lastName}", $"หนังสือเวียนถึงแก่กรรมของ {higher.prefix}{higher.firstName} {higher.lastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {retirementDeceased.prefix}{retirementDeceased.firstName} {retirementDeceased.lastName}", $"แจ้งข่าวการถึงแก่กรรมของ {retirementDeceased.prefix}{retirementDeceased.firstName} {retirementDeceased.lastName}",
//payload_str, payload_str,
"",
"", "",
true, true,
true true
@ -773,7 +773,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
payload_attach.Add(new PayloadAttachment payload_attach.Add(new PayloadAttachment
{ {
name = "หนังสือเวียนถึงแก่กรรม", 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() var payload = new CommandPayload()
@ -921,43 +923,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
Location = detail.GetType().GetProperty("Location")?.GetValue(detail), Location = detail.GetType().GetProperty("Location")?.GetValue(detail),
}; };
var reqPayload = new var data = new
{ {
template = "deceased", template = "deceased",
reportName = "docx-report", reportName = "docx-report",
data = mergeData data = mergeData
}; };
return Success(data);
//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 catch
{ {