Refactor LeaveProcessJobStatusRepository to update API endpoint paths and comment out JSON file writing logic

This commit is contained in:
Suphonchai Phoonsawat 2026-03-31 11:28:12 +07:00
parent a50153f32c
commit 932d5e75c7

View file

@ -420,28 +420,28 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
} }
// Write employees to JSON file // Write employees to JSON file
var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt"; // var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt";
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Exports", fileName); // var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Exports", fileName);
// Ensure directory exists // // Ensure directory exists
var directory = Path.GetDirectoryName(filePath); // var directory = Path.GetDirectoryName(filePath);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) // if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
{ // {
Directory.CreateDirectory(directory); // Directory.CreateDirectory(directory);
} // }
var jsonOptions = new JsonSerializerOptions // var jsonOptions = new JsonSerializerOptions
{ // {
WriteIndented = true, // WriteIndented = true,
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping // Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}; // };
var jsonContent = JsonSerializer.Serialize(employees, jsonOptions); // var jsonContent = JsonSerializer.Serialize(employees, jsonOptions);
await File.WriteAllTextAsync(filePath, jsonContent); // await File.WriteAllTextAsync(filePath, jsonContent);
} }
//call api //call api
var apiPath = $"{_configuration["API"]}/org/profile/absent-late/batch"; var apiPath = $"{_configuration["API"]}/org/unauthorize/profile/absent-late/batch";
var apiKey = _configuration["API_KEY"]; var apiKey = _configuration["API_KEY"];
var body = new var body = new
{ {
@ -702,41 +702,41 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
} }
// Write employees to JSON file // Write employees to JSON file
var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt"; // var fileName = $"employees_{DateTime.Now:yyyyMMdd_HHmmss}.txt";
var filePath = Path.Combine(_env.ContentRootPath, "Exports", fileName); // var filePath = Path.Combine(_env.ContentRootPath, "Exports", fileName);
// Ensure directory exists // // Ensure directory exists
var directory = Path.GetDirectoryName(filePath); // var directory = Path.GetDirectoryName(filePath);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) // if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
{ // {
Directory.CreateDirectory(directory); // Directory.CreateDirectory(directory);
} // }
var jsonOptions = new JsonSerializerOptions // var jsonOptions = new JsonSerializerOptions
{ // {
WriteIndented = true, // WriteIndented = true,
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping // Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}; // };
var jsonContent = JsonSerializer.Serialize(employees, jsonOptions); // var jsonContent = JsonSerializer.Serialize(employees, jsonOptions);
Console.WriteLine($"Writing file to: {filePath}"); // Console.WriteLine($"Writing file to: {filePath}");
await File.WriteAllTextAsync(filePath, jsonContent); // await File.WriteAllTextAsync(filePath, jsonContent);
Console.WriteLine($"File written successfully: {fileName}"); // Console.WriteLine($"File written successfully: {fileName}");
} }
//call api // call api
// var apiPath = $"{_configuration["API"]}/org/profile-employee/absent-late/batch"; var apiPath = $"{_configuration["API"]}/org/unauthorize/profile-employee/absent-late/batch";
// var apiKey = _configuration["API_KEY"]; var apiKey = _configuration["API_KEY"];
// var body = new var body = new
// { {
// records = employees records = employees
// }; };
// var apiResult = await PostExternalAPIAsync(apiPath, AccessToken ?? "", body, apiKey); var apiResult = await PostExternalAPIAsync(apiPath, AccessToken ?? "", body, apiKey);
// if(apiResult == "") if(apiResult == "")
// { {
// throw new Exception($"เรียก API {apiPath} ไม่สำเร็จ"); throw new Exception($"เรียก API {apiPath} ไม่สำเร็จ");
// } }
} }