space posno
Some checks failed
release-dev / release-dev (push) Failing after 10s

This commit is contained in:
moss 2025-04-05 16:45:44 +07:00
parent 179d61cc16
commit 887d015276
22 changed files with 20618 additions and 444 deletions

View file

@ -317,11 +317,13 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> CreateDiscipline([FromForm] DisciplineComplaint_AppealRequest req)
{
var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position";
var id = "";
var type = "";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
@ -331,78 +333,85 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
if (org == null || org.result == null)
return Success(new { data = new List<dynamic>(), total = 0 });
var id = org.result.profileId;
id = org.result.profileId;
if (id == "")
return Success(new { data = new List<dynamic>(), total = 0 });
var disciplineComplaint_Appeal = new Domain.Models.Discipline.DisciplineComplaint_Appeal
type = org.result.profileType;
}
var disciplineComplaint_Appeal = new Domain.Models.Discipline.DisciplineComplaint_Appeal
{
Title = req.Title,
Description = req.Description,
Status = "NEW",
Type = req.Type.Trim().ToUpper(),
Year = req.Year == null ? DateTime.Now.Year : req.Year,
CaseType = req.CaseType,
CaseNumber = req.CaseNumber,
Fullname = req.Fullname,
CitizenId = req.CitizenId,
ProfileId = id,
Position = req.Position,
Oc = req.Oc,
profileType = type,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var disciplineComplaint_Appeal_History = new DisciplineComplaint_Appeal_History
{
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
Status = "NEW",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
// await _context.DisciplineComplaint_Appeals.AddAsync(disciplineComplaint_Appeal);
await _context.DisciplineComplaint_Appeal_Historys.AddAsync(disciplineComplaint_Appeal_History);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
foreach (var file in Request.Form.Files)
{
Title = req.Title,
Description = req.Description,
Status = "NEW",
Type = req.Type.Trim().ToUpper(),
Year = req.Year == null ? DateTime.Now.Year : req.Year,
CaseType = req.CaseType,
CaseNumber = req.CaseNumber,
Fullname = req.Fullname,
CitizenId = req.CitizenId,
ProfileId = id,
Position = req.Position,
Oc = req.Oc,
profileType = org.result.profileType,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var disciplineComplaint_Appeal_History = new DisciplineComplaint_Appeal_History
{
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
Status = "NEW",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
// await _context.DisciplineComplaint_Appeals.AddAsync(disciplineComplaint_Appeal);
await _context.DisciplineComplaint_Appeal_Historys.AddAsync(disciplineComplaint_Appeal_History);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
foreach (var file in Request.Form.Files)
var fileExtension = Path.GetExtension(file.FileName);
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
var fileExtension = Path.GetExtension(file.FileName);
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
var disciplineComplaint_Appeal_Doc = new DisciplineComplaint_Appeal_Doc
{
var disciplineComplaint_Appeal_Doc = new DisciplineComplaint_Appeal_Doc
{
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
Document = _doc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.DisciplineComplaint_Appeal_Docs.AddAsync(disciplineComplaint_Appeal_Doc);
}
DisciplineComplaint_Appeal = disciplineComplaint_Appeal,
Document = _doc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.DisciplineComplaint_Appeal_Docs.AddAsync(disciplineComplaint_Appeal_Doc);
}
}
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
var refId = new List<Guid>();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
}
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/workflow/find/director";
var refId = new List<Guid>();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var __res = await client.PostAsJsonAsync(apiUrlOrg, new
{
refId = new List<Guid> { id },
refId = new List<Guid> { Guid.Parse(id) },
});
var __result = await __res.Content.ReadAsStringAsync();
var __org = JsonConvert.DeserializeObject<DirectorRequest>(__result);
@ -410,6 +419,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
{
refId = __org.result.Select(x => Guid.Parse(x.id)).ToList();
}
await _repositoryNoti.PushNotificationsAsync(
refId.ToArray(),
$"มีคำขอยื่นอุทธรณ์/ร้องทุกข์จาก {req.Fullname}",
@ -419,10 +429,10 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
true,
true
);
await _context.SaveChangesAsync();
return Success(disciplineComplaint_Appeal.Id);
}
await _context.SaveChangesAsync();
return Success(disciplineComplaint_Appeal.Id);
}
/// <summary>