Linear Flow (C-PM-01, C-PM-02, C-PM-14) #224
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 5m38s
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 5m38s
This commit is contained in:
parent
4a8d349415
commit
35179d8cfc
2 changed files with 194 additions and 162 deletions
|
|
@ -2395,51 +2395,67 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
Console.WriteLine($"[CandidateReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
||||
|
||||
Console.WriteLine($"[CandidateReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
||||
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||
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
|
||||
{
|
||||
data = resultData
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
Console.WriteLine($"[CandidateReportExcecute] External API response status: {_res.StatusCode}");
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
Console.WriteLine("[CandidateReportExcecute] External API call successful - updating placement profiles");
|
||||
placementProfile.ForEach(profile =>
|
||||
{
|
||||
profile.PlacementStatus = "DONE";
|
||||
if (req.refIds.Length > 0)
|
||||
{
|
||||
profile.commandId = req.refIds[0].commandId;
|
||||
profile.refCommandCode = req.refIds[0].commandCode;
|
||||
profile.refCommandDate = req.refIds[0].commandDateAffect;
|
||||
profile.refCommandName = req.refIds[0].commandName;
|
||||
profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
||||
profile.templateDoc = req.refIds[0].remark;
|
||||
}
|
||||
});
|
||||
Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||
await _context.SaveChangesAsync();
|
||||
Console.WriteLine("[CandidateReportExcecute] Database save completed successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine($"[CandidateReportExcecute] External API call failed with status: {_res.StatusCode}");
|
||||
Console.Error.WriteLine($"[CandidateReportExcecute] Response content: {_result}");
|
||||
}
|
||||
}
|
||||
#region Old: Circular Flow
|
||||
// Console.WriteLine($"[CandidateReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
||||
// var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||
// 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
|
||||
// {
|
||||
// data = resultData
|
||||
// });
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
// Console.WriteLine($"[CandidateReportExcecute] External API response status: {_res.StatusCode}");
|
||||
// if (_res.IsSuccessStatusCode)
|
||||
// {
|
||||
// Console.WriteLine("[CandidateReportExcecute] External API call successful - updating placement profiles");
|
||||
// placementProfile.ForEach(profile =>
|
||||
// {
|
||||
// profile.PlacementStatus = "DONE";
|
||||
// if (req.refIds.Length > 0)
|
||||
// {
|
||||
// profile.commandId = req.refIds[0].commandId;
|
||||
// profile.refCommandCode = req.refIds[0].commandCode;
|
||||
// profile.refCommandDate = req.refIds[0].commandDateAffect;
|
||||
// profile.refCommandName = req.refIds[0].commandName;
|
||||
// profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
||||
// profile.templateDoc = req.refIds[0].remark;
|
||||
// }
|
||||
// });
|
||||
// Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||
// await _context.SaveChangesAsync();
|
||||
// Console.WriteLine("[CandidateReportExcecute] Database save completed successfully");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Console.Error.WriteLine($"[CandidateReportExcecute] External API call failed with status: {_res.StatusCode}");
|
||||
// Console.Error.WriteLine($"[CandidateReportExcecute] Response content: {_result}");
|
||||
// }
|
||||
// }
|
||||
#endregion
|
||||
|
||||
// // update placementstatus
|
||||
// placementProfile.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||
// await _context.SaveChangesAsync();
|
||||
// New: Linear Flow
|
||||
placementProfile.ForEach(profile =>
|
||||
{
|
||||
profile.PlacementStatus = "DONE";
|
||||
if (req.refIds.Length > 0)
|
||||
{
|
||||
profile.commandId = req.refIds[0].commandId;
|
||||
profile.refCommandCode = req.refIds[0].commandCode;
|
||||
profile.refCommandDate = req.refIds[0].commandDateAffect;
|
||||
profile.refCommandName = req.refIds[0].commandName;
|
||||
profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
||||
profile.templateDoc = req.refIds[0].remark;
|
||||
}
|
||||
});
|
||||
Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||
await _context.SaveChangesAsync();
|
||||
Console.WriteLine($"[CandidateReportExcecute] Process completed successfully at {DateTime.Now}");
|
||||
return Success();
|
||||
// Return resultData for Node to process directly (Linear Flow)
|
||||
return Success(resultData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue