เพิ่ม log api candidate/report/excecute
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m59s
All checks were successful
Build & Deploy Placement Service / build (push) Successful in 1m59s
This commit is contained in:
parent
aeb2ceea6f
commit
f50ad38503
1 changed files with 26 additions and 1 deletions
|
|
@ -2198,8 +2198,11 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
[HttpPost("candidate/report/excecute")]
|
[HttpPost("candidate/report/excecute")]
|
||||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteCandidate([FromBody] ReportExecuteRequest req)
|
public async Task<ActionResult<ResponseObject>> PostReportExecuteCandidate([FromBody] ReportExecuteRequest req)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] Starting execution at {DateTime.Now}");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] Request received with {req?.refIds?.Length ?? 0} refIds");
|
||||||
var placementProfile = await _context.PlacementProfiles
|
var placementProfile = await _context.PlacementProfiles
|
||||||
.Include(x => x.PlacementCertificates)
|
.Include(x => x.PlacementCertificates)
|
||||||
.Include(x => x.PlacementEducations)
|
.Include(x => x.PlacementEducations)
|
||||||
|
|
@ -2207,8 +2210,15 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] Found {placementProfile?.Count ?? 0} placement profiles");
|
||||||
|
|
||||||
if (placementProfile == null)
|
if (placementProfile == null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("[CandidateReportExcecute] PlacementProfile is null - returning NotFound");
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("[CandidateReportExcecute] Building resultData from placement profiles and refIds");
|
||||||
|
|
||||||
var resultData = (from p in placementProfile
|
var resultData = (from p in placementProfile
|
||||||
join r in req.refIds
|
join r in req.refIds
|
||||||
|
|
@ -2366,6 +2376,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
},
|
},
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
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";
|
var apiUrl = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||||
using (var client = new HttpClient())
|
using (var client = new HttpClient())
|
||||||
{
|
{
|
||||||
|
|
@ -2377,8 +2390,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
data = resultData
|
data = resultData
|
||||||
});
|
});
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] External API response status: {_res.StatusCode}");
|
||||||
if (_res.IsSuccessStatusCode)
|
if (_res.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("[CandidateReportExcecute] External API call successful - updating placement profiles");
|
||||||
placementProfile.ForEach(profile =>
|
placementProfile.ForEach(profile =>
|
||||||
{
|
{
|
||||||
profile.PlacementStatus = "DONE";
|
profile.PlacementStatus = "DONE";
|
||||||
|
|
@ -2392,17 +2407,27 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
profile.templateDoc = req.refIds[0].remark;
|
profile.templateDoc = req.refIds[0].remark;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] Saving changes to database for {placementProfile.Count} profiles");
|
||||||
await _context.SaveChangesAsync();
|
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // update placementstatus
|
// // update placementstatus
|
||||||
// placementProfile.ForEach(profile => profile.PlacementStatus = "DONE");
|
// placementProfile.ForEach(profile => profile.PlacementStatus = "DONE");
|
||||||
// await _context.SaveChangesAsync();
|
// await _context.SaveChangesAsync();
|
||||||
|
Console.WriteLine($"[CandidateReportExcecute] Process completed successfully at {DateTime.Now}");
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.Error.WriteLine($"[CandidateReportExcecute] Error occurred: {ex.Message}");
|
||||||
|
Console.Error.WriteLine($"[CandidateReportExcecute] Stack trace: {ex.StackTrace}");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue