Linear Flow (ทดสอบเฉพาะคำสั่ง C-PM-01) #224
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 2m57s
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 2m57s
This commit is contained in:
parent
7d2be029b6
commit
4a8d349415
1 changed files with 56 additions and 39 deletions
|
|
@ -1989,49 +1989,66 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
Console.WriteLine($"[RecruitReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
Console.WriteLine($"[RecruitReportExcecute] resultData built successfully with {resultData?.Count ?? 0} records");
|
||||||
|
#region Old: Circular Flow
|
||||||
|
// Console.WriteLine($"[RecruitReportExcecute] 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($"[RecruitReportExcecute] External API response status: {_res.StatusCode}");
|
||||||
|
// if (_res.IsSuccessStatusCode)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine("[RecruitReportExcecute] 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($"[RecruitReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||||
|
// await _context.SaveChangesAsync();
|
||||||
|
// Console.WriteLine("[RecruitReportExcecute] Database save completed successfully");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Console.Error.WriteLine($"[RecruitReportExcecute] External API call failed with status: {_res.StatusCode}");
|
||||||
|
// Console.Error.WriteLine($"[RecruitReportExcecute] Response content: {_result}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
#endregion
|
||||||
|
|
||||||
Console.WriteLine($"[RecruitReportExcecute] Calling external API: {_configuration["API"]}/org/command/excexute/create-officer-profile");
|
// New: Linear Flow
|
||||||
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
placementProfile.ForEach(profile =>
|
||||||
using (var client = new HttpClient())
|
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
profile.PlacementStatus = "DONE";
|
||||||
client.DefaultRequestHeaders.Add("api-key", _configuration["API_KEY"]);
|
if (req.refIds.Length > 0)
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
|
||||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
|
||||||
{
|
{
|
||||||
data = resultData
|
profile.commandId = req.refIds[0].commandId;
|
||||||
});
|
profile.refCommandCode = req.refIds[0].commandCode;
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
profile.refCommandDate = req.refIds[0].commandDateAffect;
|
||||||
Console.WriteLine($"[RecruitReportExcecute] External API response status: {_res.StatusCode}");
|
profile.refCommandName = req.refIds[0].commandName;
|
||||||
if (_res.IsSuccessStatusCode)
|
profile.refCommandNo = $"{req.refIds[0].commandNo}/{req.refIds[0].commandYear.ToThaiYear()}";
|
||||||
{
|
profile.templateDoc = req.refIds[0].remark;
|
||||||
Console.WriteLine("[RecruitReportExcecute] 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($"[RecruitReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
|
||||||
await _context.SaveChangesAsync();
|
|
||||||
Console.WriteLine("[RecruitReportExcecute] Database save completed successfully");
|
|
||||||
}
|
}
|
||||||
else
|
});
|
||||||
{
|
Console.WriteLine($"[RecruitReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||||
Console.Error.WriteLine($"[RecruitReportExcecute] External API call failed with status: {_res.StatusCode}");
|
await _context.SaveChangesAsync();
|
||||||
Console.Error.WriteLine($"[RecruitReportExcecute] Response content: {_result}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine($"[RecruitReportExcecute] Process completed successfully at {DateTime.Now}");
|
Console.WriteLine($"[RecruitReportExcecute] Process completed successfully at {DateTime.Now}");
|
||||||
return Success();
|
return Success(resultData);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue