Linear Flow (RetirementService) #224
All checks were successful
Build & Deploy Retirement Service / build (push) Successful in 2m4s

This commit is contained in:
harid 2026-06-19 09:22:33 +07:00
parent e926866918
commit 71966eb4e9
4 changed files with 213 additions and 179 deletions

View file

@ -846,9 +846,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = await _context.RetirementOthers
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
string? _null = null;
var resultData = (from p in data
@ -912,24 +909,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
orgChild4New = p.child4
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // await _context.SaveChangesAsync();
// // }
}
return Success();
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // await _context.SaveChangesAsync();
// // // }
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
/// <summary>
@ -1098,9 +1103,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = await _context.RetirementOthers
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
string? _null = null;
var resultData = (from p in data
@ -1164,24 +1166,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
orgChild4New = p.child4
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // await _context.SaveChangesAsync();
// // }
}
return Success();
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // await _context.SaveChangesAsync();
// // // }
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
}
}

View file

@ -642,10 +642,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = await _context.RetirementOuts
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
var resultData = (from p in data
join r in req.refIds
on p.Id.ToString() equals r.refId
@ -688,31 +684,39 @@ namespace BMA.EHR.Retirement.Service.Controllers
resignId = p.Id,
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
if (data.Count > 0)
{
if (data[0].profileType == "EMPLOYEE")
{
apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
}
}
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // await _context.SaveChangesAsync();
// // }
}
return Success();
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
// if (data.Count > 0)
// {
// if (data[0].profileType == "EMPLOYEE")
// {
// apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
// }
// }
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // await _context.SaveChangesAsync();
// // // }
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
}
}

View file

@ -2907,10 +2907,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = await _context.RetirementResigns
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
var resultData = (from p in data
join r in req.refIds
on p.Id.ToString() equals r.refId
@ -2955,24 +2951,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
remark = r.remark,
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // await _context.SaveChangesAsync();
// // }
}
return Success();
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // await _context.SaveChangesAsync();
// // // }
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
/// <summary>
@ -3102,10 +3106,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = await _context.RetirementResigns
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
var resultData = (from p in data
join r in req.refIds
on p.Id.ToString() equals r.refId
@ -3149,18 +3149,26 @@ namespace BMA.EHR.Retirement.Service.Controllers
remark = r.remark,
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
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
{
data = resultData,
});
}
return Success();
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
// 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
// {
// data = resultData,
// });
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
/// <summary>
@ -3298,11 +3306,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Include(x => x.RetirementResign)
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
await _context.SaveChangesAsync();
string? _null = null;
var resultData = (from p in data
join r in req.refIds
@ -3346,7 +3349,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
resignId = p.RetirementResign.Id,
}).ToList();
var baseAPIOrg = _configuration["API"];
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
//var reportDone = false;
//if (data.Where(profile => profile.Status == "DONE").Any())
//{
@ -3354,23 +3358,23 @@ namespace BMA.EHR.Retirement.Service.Controllers
//}
//if (reportDone == true)
//{
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
// // await _context.SaveChangesAsync();
// // }
}
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
// // // await _context.SaveChangesAsync();
// // // }
// }
//}
//else
//{
@ -3392,7 +3396,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
// }
// }
//}
return Success();
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
data.ForEach(profile => profile.RetirementResign.Status = "CANCEL");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
#region 33-

View file

@ -2405,10 +2405,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = await _context.RetirementResignEmployees
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
var resultData = (from p in data
join r in req.refIds
on p.Id.ToString() equals r.refId
@ -2451,24 +2447,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
resignId = p.Id,
}).ToList();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // await _context.SaveChangesAsync();
// // }
}
return Success();
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // await _context.SaveChangesAsync();
// // // }
// }
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
/// <summary>
@ -2604,11 +2608,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Include(x => x.RetirementResignEmployee)
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
.ToListAsync();
// Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
await _context.SaveChangesAsync();
string? _null = null;
var resultData = (from p in data
join r in req.refIds
@ -2650,7 +2649,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
resignId = p.RetirementResignEmployee.Id
}).ToList();
var baseAPIOrg = _configuration["API"];
#region Old: Circular Flow
// var baseAPIOrg = _configuration["API"];
//var reportDone = false;
//if (data.Where(profile => profile.Status == "DONE").Any())
//{
@ -2659,23 +2659,23 @@ namespace BMA.EHR.Retirement.Service.Controllers
//if (reportDone == true)
//{
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
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
{
data = resultData,
});
// // var _result = await _res.Content.ReadAsStringAsync();
// // if (_res.IsSuccessStatusCode)
// // {
// // data.ForEach(profile => profile.Status = "DONE");
// // data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
// // await _context.SaveChangesAsync();
// // }
}
// var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
// 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
// {
// data = resultData,
// });
// // // var _result = await _res.Content.ReadAsStringAsync();
// // // if (_res.IsSuccessStatusCode)
// // // {
// // // data.ForEach(profile => profile.Status = "DONE");
// // // data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
// // // await _context.SaveChangesAsync();
// // // }
// }
//}
//else
//{
@ -2697,7 +2697,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
// }
// }
//}
return Success();
#endregion
// New: Linear Flow - Task #224 ปรับให้เป็น process ที่ควรบันทึกตามลำดับ
data.ForEach(profile => profile.Status = "DONE");
data.ForEach(profile => profile.RetirementResignEmployee.Status = "CANCEL");
await _context.SaveChangesAsync();
// Return resultData for Node to process directly (Linear Flow)
return Success(resultData);
}
/// <summary>