ออกคำสั่ง C-PM-11, C-PM-12

This commit is contained in:
Bright 2024-06-18 13:28:56 +07:00
parent ee2aa136b9
commit 70815b47f2

View file

@ -2582,10 +2582,10 @@ namespace BMA.EHR.Application.Repositories.Commands
await ExecuteCommand10Async(command);
break;
case "C-PM-11":
await ExecuteCommand11Async(command);
await ExecuteCommand11Async(command, token);
break;
case "C-PM-12":
await ExecuteCommand12Async(command);
await ExecuteCommand12Async(command, token);
break;
case "C-PM-13":
await ExecuteCommand13Async(command, token);
@ -5370,7 +5370,7 @@ namespace BMA.EHR.Application.Repositories.Commands
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task ExecuteCommand11Async(Command command)
private async Task ExecuteCommand11Async(Command command, string token = "")
{
try
{
@ -5392,143 +5392,159 @@ namespace BMA.EHR.Application.Repositories.Commands
foreach (var recv in command.Receivers)
{
var data = await _dbContext.Set<Profile>()
.Include(x => x.Salaries)
.ThenInclude(x => x.PositionLevel)
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
data.IsProbation = false;
var lastSarary = data.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
var order = 1;
if (lastSarary != null && lastSarary.Order != null)
order = lastSarary.Order.Value + 1;
var salary = new ProfileSalary
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command11/{recv.RefPlacementProfileId}";
using (var client = new HttpClient())
{
Order = order,
Date = command.CommandAffectDate,
Amount = lastSarary == null ? null : lastSarary.Amount,
PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary == null ? null : lastSarary.OcId,
PositionId = lastSarary == null ? null : lastSarary.PositionId,
PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
PositionEmployeeLevelId = null,
PositionEmployeePositionId = null,
PositionEmployeePositionSideId = null,
PosNoEmployee = "",
//PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
//PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
IsActive = true,
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
};
if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
data.Salaries.Add(salary);
// update placementstatus
//data.Status = "DONE";
await _dbContext.SaveChangesAsync();
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
var inbox = new Inbox
{
Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
var noti = new Notification
{
Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Type = "LINK",
Payload = payload_str,
};
_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
}
// send cc noti inbox
foreach (var cc in command.Deployments)
{
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
if (pf != null)
{
if (cc.IsSendInbox)
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
var inbox = new Inbox
{
Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
}
if (cc.IsSendMail)
{
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
}
var noti = new Notification
{
Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Type = "LINK",
Payload = payload_str,
};
_dbContext.Set<Notification>().Add(noti);
profileId = recv.RefPlacementProfileId,
date = command.CommandAffectDate,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
salaryRef = "คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}"
});
var _result = await _res.Content.ReadAsStringAsync();
}
//var data = await _dbContext.Set<Profile>()
// .Include(x => x.Salaries)
// .ThenInclude(x => x.PositionLevel)
// .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
//if (data == null)
// throw new Exception(GlobalMessages.DataNotFound);
//data.IsProbation = false;
//var lastSarary = data.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
//var order = 1;
//if (lastSarary != null && lastSarary.Order != null)
// order = lastSarary.Order.Value + 1;
//var salary = new ProfileSalary
//{
// Order = order,
// Date = command.CommandAffectDate,
// Amount = lastSarary == null ? null : lastSarary.Amount,
// PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
// MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
// SalaryClass = "",
// SalaryRef = "คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
// OcId = lastSarary == null ? null : lastSarary.OcId,
// PositionId = lastSarary == null ? null : lastSarary.PositionId,
// PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
// PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
// PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
// OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
// PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
// CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// CommandTypeName = command.CommandType.Name,
// PositionEmployeeGroupId = null,
// PositionEmployeeLevelId = null,
// PositionEmployeePositionId = null,
// PositionEmployeePositionSideId = null,
// PosNoEmployee = "",
// //PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
// PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
// //PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
// IsActive = true,
// CreatedAt = DateTime.Now,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
//};
//if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
//if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
//data.Salaries.Add(salary);
//// update placementstatus
////data.Status = "DONE";
//await _dbContext.SaveChangesAsync();
//// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
//// Send noti inbox and email
//var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
//var body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
//_emailSenderService.SendMail(subject, body, "dev@frappet.com");
//var inbox = new Inbox
//{
// Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = data.Id,
// Payload = payload_str,
//};
//_dbContext.Set<Inbox>().Add(inbox);
//var noti = new Notification
//{
// Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = data.Id,
// Type = "LINK",
// Payload = payload_str,
//};
//_dbContext.Set<Notification>().Add(noti);
//await _dbContext.SaveChangesAsync();
}
//// send cc noti inbox
//foreach (var cc in command.Deployments)
//{
// var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
// if (pf != null)
// {
// if (cc.IsSendInbox)
// {
// var inbox = new Inbox
// {
// Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Payload = payload_str,
// };
// _dbContext.Set<Inbox>().Add(inbox);
// }
// if (cc.IsSendMail)
// {
// // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// // Send noti inbox and email
// var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// var body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
// }
// var noti = new Notification
// {
// Body = $"คำสั่งให้ข้าราชการที่มีผลการทดลองปฏิบัติหน้าที่ราชการไม่ต่ำกว่ามาตรฐานที่กำหนดรับราชการต่อไป คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Type = "LINK",
// Payload = payload_str,
// };
// _dbContext.Set<Notification>().Add(noti);
// }
//}
// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
command.CommandStatusId = cmdStatus!.Id;
@ -5546,7 +5562,7 @@ namespace BMA.EHR.Application.Repositories.Commands
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task ExecuteCommand12Async(Command command)
private async Task ExecuteCommand12Async(Command command, string token = "")
{
try
{
@ -5568,154 +5584,170 @@ namespace BMA.EHR.Application.Repositories.Commands
foreach (var recv in command.Receivers)
{
var data = await _dbContext.Set<Profile>()
.Include(x => x.Salaries)
.ThenInclude(x => x.PositionLevel)
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
data.IsActive = false;
data.IsLeave = true;
data.LeaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
data.LeaveDate = command.CommandAffectDate;
var lastSarary = data.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
var order = 1;
if (lastSarary != null && lastSarary.Order != null)
order = lastSarary.Order.Value + 1;
var salary = new ProfileSalary
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command12/{recv.RefPlacementProfileId}";
using (var client = new HttpClient())
{
Order = order,
Date = command.CommandAffectDate,
Amount = lastSarary == null ? null : lastSarary.Amount,
PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
OcId = lastSarary == null ? null : lastSarary.OcId,
PositionId = lastSarary == null ? null : lastSarary.PositionId,
PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
PositionEmployeeLevelId = null,
PositionEmployeePositionId = null,
PositionEmployeePositionSideId = null,
PosNoEmployee = "",
//PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
//PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
IsActive = true,
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
};
if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
data.Salaries.Add(salary);
// remove profile position
var profilePosition = await _dbContext.Set<ProfilePosition>()
.Include(x => x.Profile)
.Include(x => x.OrganizationPosition)
.FirstOrDefaultAsync(x => x.Profile!.Id == data.Id);
if (profilePosition != null)
_dbContext.Set<ProfilePosition>().Remove(profilePosition);
// update placementstatus
//data.Status = "DONE";
await _dbContext.SaveChangesAsync();
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
var inbox = new Inbox
{
Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = data.Id,
Type = "LINK",
Payload = payload_str,
};
_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync();
}
// send cc noti inbox
foreach (var cc in command.Deployments)
{
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
if (pf != null)
{
if (cc.IsSendInbox)
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
var inbox = new Inbox
{
Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Payload = payload_str,
};
_dbContext.Set<Inbox>().Add(inbox);
}
if (cc.IsSendMail)
{
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
}
var noti = new Notification
{
Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Type = "LINK",
Payload = payload_str,
};
_dbContext.Set<Notification>().Add(noti);
profileId = recv.RefPlacementProfileId,
date = command.CommandAffectDate,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
salaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var _result = await _res.Content.ReadAsStringAsync();
}
//var data = await _dbContext.Set<Profile>()
// .Include(x => x.Salaries)
// .ThenInclude(x => x.PositionLevel)
// .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
//if (data == null)
// throw new Exception(GlobalMessages.DataNotFound);
//data.IsActive = false;
//data.IsLeave = true;
//data.LeaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
//data.LeaveDate = command.CommandAffectDate;
//var lastSarary = data.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
//var order = 1;
//if (lastSarary != null && lastSarary.Order != null)
// order = lastSarary.Order.Value + 1;
//var salary = new ProfileSalary
//{
// Order = order,
// Date = command.CommandAffectDate,
// Amount = lastSarary == null ? null : lastSarary.Amount,
// PositionSalaryAmount = lastSarary == null ? null : lastSarary.PositionSalaryAmount,
// MouthSalaryAmount = lastSarary == null ? null : lastSarary.MouthSalaryAmount,
// SalaryClass = "",
// SalaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
// OcId = lastSarary == null ? null : lastSarary.OcId,
// PositionId = lastSarary == null ? null : lastSarary.PositionId,
// PositionLevel = lastSarary == null ? null : lastSarary.PositionLevel,
// PositionLineId = lastSarary == null ? null : lastSarary.PositionLineId,
// PositionTypeId = lastSarary == null ? null : lastSarary.PositionTypeId,
// OrganizationShortNameId = lastSarary == null ? null : lastSarary.OrganizationShortNameId,
// PosNoId = lastSarary == null ? null : lastSarary.PosNoId,
// CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
// CommandTypeName = command.CommandType.Name,
// PositionEmployeeGroupId = null,
// PositionEmployeeLevelId = null,
// PositionEmployeePositionId = null,
// PositionEmployeePositionSideId = null,
// PosNoEmployee = "",
// //PositionPathSideId = lastSarary == null ? null : lastSarary.PositionPathSideId == null,
// PositionExecutiveId = lastSarary == null ? null : lastSarary.PositionExecutiveId,
// //PositionExecutiveSideId = lastSarary == null ? null : lastSarary.PositionExecutiveSideId,
// IsActive = true,
// CreatedAt = DateTime.Now,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
//};
//if (lastSarary != null && lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
//if (lastSarary != null && lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
//data.Salaries.Add(salary);
//// remove profile position
//var profilePosition = await _dbContext.Set<ProfilePosition>()
// .Include(x => x.Profile)
// .Include(x => x.OrganizationPosition)
// .FirstOrDefaultAsync(x => x.Profile!.Id == data.Id);
//if (profilePosition != null)
// _dbContext.Set<ProfilePosition>().Remove(profilePosition);
//// update placementstatus
////data.Status = "DONE";
//await _dbContext.SaveChangesAsync();
//// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
//// Send noti inbox and email
//var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
//var body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
//_emailSenderService.SendMail(subject, body, "dev@frappet.com");
//var inbox = new Inbox
//{
// Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = data.Id,
// Payload = payload_str,
//};
//_dbContext.Set<Inbox>().Add(inbox);
//var noti = new Notification
//{
// Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = data.Id,
// Type = "LINK",
// Payload = payload_str,
//};
//_dbContext.Set<Notification>().Add(noti);
//await _dbContext.SaveChangesAsync();
}
//// send cc noti inbox
//foreach (var cc in command.Deployments)
//{
// var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
// if (pf != null)
// {
// if (cc.IsSendInbox)
// {
// var inbox = new Inbox
// {
// Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Payload = payload_str,
// };
// _dbContext.Set<Inbox>().Add(inbox);
// }
// if (cc.IsSendMail)
// {
// // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// // Send noti inbox and email
// var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// var body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
// }
// var noti = new Notification
// {
// Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = pf.Id,
// Type = "LINK",
// Payload = payload_str,
// };
// _dbContext.Set<Notification>().Add(noti);
// }
//}
// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
command.CommandStatusId = cmdStatus!.Id;