เพิ่มคำสั่งยกเลิกลา

This commit is contained in:
Kittapath 2024-07-18 20:37:17 +07:00
parent bcf0c0bfdb
commit 033fc915d0
12 changed files with 19309 additions and 88 deletions

View file

@ -1321,7 +1321,7 @@ namespace BMA.EHR.Application.Repositories.Commands
Seq = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Organization = p.OrganizationPositionOld,
OldOrganization = p.OrganizationOld,
OldOrganization = p.OrganizationOld,
OldPositionName = p.positionOld,
OldPositionLevel = p.PositionLevelOld,
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
@ -1395,6 +1395,106 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
public async Task<List<CommandType40Response?>?> GetCommandType40AttachmentAsync(Guid id, string token)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.Include(c => c.Command)
.Where(c => c.Command.Id == id)
.ToListAsync();
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var data = new List<CommandType40Response>();
var no = 1;
foreach (var d in raw_data)
{
var apiUrl = $"{_configuration["API"]}/org/pos/act/{d.RefDisciplineId}/{d.RefPlacementProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org == null || org.result == null)
continue;
var receiver = new CommandType40Response
{
no = no.ToString().ToThaiNumber(),
fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}",
organization = org.result.organization,
position = org.result.position,
postype = org.result.postype,
poslevel = org.result.poslevel,
organizationNew = org.result.organizationNew,
dateStart = d.Command.ActStartDate == null ? "-" : d.Command.ActStartDate.Value.ToThaiFullDate3().ToThaiNumber(),
dateEnd = d.Command.ActEndDate == null ? "-" : d.Command.ActEndDate.Value.ToThaiFullDate3().ToThaiNumber(),
order = org.result.order,
};
no = no + 1;
data.Add(receiver);
}
}
return data;
}
catch
{
throw;
}
}
public async Task<List<CommandType17Response>> GetCommandType41AttachmentAsync(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.Include(c => c.Command)
.Where(c => c.Command.Id == id)
.ToListAsync();
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var report_data = (from r in raw_data
join p in _dbContext.Set<RetirementResign>()
//.Include(p => p.Profile)
//.ThenInclude(p => p.Position)
//.Include(p => p.Profile)
//.ThenInclude(p => p.Salaries)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType17Response
{
Seq = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
PositionName = p.PositionOld ?? "",
Organization = p.OrganizationPositionOld ?? "",
PositionLevel = p.PositionLevelOld ?? "",
PositionType = p.PositionTypeOld ?? "",
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
//Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Remark = p.Reason ?? "",
RemarkHorizontal = p.RemarkHorizontal,
})
.ToList();
return report_data;
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -206,6 +206,12 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-38":
result = await GetReceiver38Async(command, token);
break;
case "C-PM-40":
result = await GetReceiver40Async(command, token);
break;
case "C-PM-41":
result = await GetReceiver41Async(command);
break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
@ -2670,6 +2676,112 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
/// <summary>
/// C-PM-40
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task<List<CommandReceiver>> GetReceiver40Async(Command command, string token)
{
try
{
var resultData = new List<CommandReceiver>();
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/pos/act/profile";
var response = new PassSalaryResponse();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject<PassSalaryResponse>(result);
var seq = 1;
foreach (var d in response!.result)
{
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = d.citizenId,
Prefix = d.prefix == null ? "" : d.prefix,
FirstName = d.firstName,
LastName = d.lastName,
RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId),
RefDisciplineId = d.id,
};
seq++;
resultData.Add(receiver);
}
}
return resultData;
}
catch
{
throw;
}
}
/// <summary>
/// C-PM-41
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task<List<CommandReceiver>> GetReceiver41Async(Command command)
{
try
{
var result = new List<CommandReceiver>();
// TODO : ต้องมา list คนตามประเภทอีกครั้งนึง
// 1. หารายชื่อที่ถูกเลือกไปแล้ว ในประเภทเดียวกัน
var otherCommandReceivers = await _dbContext.Set<CommandReceiver>()
.Include(x => x.Command)
.ThenInclude(x => x.CommandType)
.Where(x => x.Command.CommandType.CommandCode.Trim().ToUpper() == "C-PM-41")
.Where(x => x.Command.Id != command.Id)
.Select(x => x.CitizenId)
.ToListAsync();
// 2. Query
var appointPeople = await _dbContext.Set<RetirementResign>()
.Where(x => !otherCommandReceivers.Contains(x.citizenId))
.Where(x => x.Status.Trim().ToUpper() == "DONE" || x.Status.Trim().ToUpper() == "DONECANCEL")
.OrderBy(x => x.citizenId)
.ToListAsync();
// 3. Create new Record
var seq = 1;
foreach (var item in appointPeople)
{
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = item.citizenId == null ? "" : item.citizenId,
Prefix = item.prefix == null ? "" : item.prefix,
FirstName = item.firstName == null ? "" : item.firstName,
LastName = item.lastName == null ? "" : item.lastName,
RefPlacementProfileId = item.Id,
Amount = item.AmountOld,
};
seq++;
result.Add(receiver);
}
return result;
}
catch
{
throw;
}
}
#endregion
#region " Execute and Deploy "
@ -2793,6 +2905,12 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-38":
await ExecuteCommand38Async(command, token);
break;
case "C-PM-40":
await ExecuteCommand40Async(command, token);
break;
case "C-PM-41":
await ExecuteCommand41Async(command, token);
break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
@ -8463,7 +8581,7 @@ namespace BMA.EHR.Application.Repositories.Commands
/// <summary>
/// C-PM-33 - คำสั่งยุติเรื่อง
/// C-PM-33 - คำสั่งเลื่อนเงินเดือน
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
@ -8476,7 +8594,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PersonId = x.RefPlacementProfileId,
Id = x.RefDisciplineId,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
templateDoc = "คำสั่งเลื่อนเงินเดือน คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var baseAPI = _configuration["API"];
@ -8508,14 +8626,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คุณได้รับคำสั่งเลื่อนเงินเดือน เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8529,7 +8647,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งยุติเรื่อง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งเลื่อนเงินเดือน เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Type = "LINK",
Payload = payload_str,
@ -8551,7 +8669,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งเลื่อนเงินเดือน คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8569,14 +8687,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งเลื่อนเงินเดือน คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
@ -8618,7 +8736,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PersonId = x.RefPlacementProfileId,
Id = x.RefDisciplineId,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
templateDoc = "คำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var baseAPI = _configuration["API"];
@ -8650,14 +8768,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คุณได้รับคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8671,7 +8789,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งยุติเรื่อง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Type = "LINK",
Payload = payload_str,
@ -8693,7 +8811,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8711,14 +8829,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งค่าตอบแทนพิเศษ และผู้ไม่ได้เลื่อน คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
@ -8760,7 +8878,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PersonId = x.RefPlacementProfileId,
Id = x.RefDisciplineId,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
templateDoc = "คำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var baseAPI = _configuration["API"];
@ -8792,13 +8910,13 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คุณได้รับคำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8812,7 +8930,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งยุติเรื่อง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Type = "LINK",
Payload = payload_str,
@ -8834,7 +8952,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8852,14 +8970,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งเลื่อนเงินเดือนข้าราชการเกษียณ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
@ -8901,7 +9019,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PersonId = x.RefPlacementProfileId,
Id = x.RefDisciplineId,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
templateDoc = "คำสั่งเลื่อนขั้นค่าจ้าง คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var baseAPI = _configuration["API"];
@ -8933,14 +9051,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คุณได้รับคำสั่งเลื่อนขั้นค่าจ้าง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8954,7 +9072,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งยุติเรื่อง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งเลื่อนขั้นค่าจ้าง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Type = "LINK",
Payload = payload_str,
@ -8976,7 +9094,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งเลื่อนขั้นค่าจ้าง คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -8994,14 +9112,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งเลื่อนขั้นค่าจ้าง คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
@ -9043,7 +9161,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PersonId = x.RefPlacementProfileId,
Id = x.RefDisciplineId,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
templateDoc = "คำสั่งให้ลูกจ้างประจำได้รับค่าตอบแทนพิเศษ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var baseAPI = _configuration["API"];
@ -9075,14 +9193,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คุณได้รับคำสั่งให้ลูกจ้างประจำได้รับค่าตอบแทนพิเศษ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -9096,7 +9214,7 @@ namespace BMA.EHR.Application.Repositories.Commands
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งยุติเรื่อง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับคำสั่งให้ลูกจ้างประจำได้รับค่าตอบแทนพิเศษ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = recv.RefPlacementProfileId.Value,
Type = "LINK",
Payload = payload_str,
@ -9118,7 +9236,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งให้ลูกจ้างประจำได้รับค่าตอบแทนพิเศษ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -9136,14 +9254,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งให้ลูกจ้างประจำได้รับค่าตอบแทนพิเศษ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
@ -9257,7 +9375,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งปรับโครงสร้าง คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
@ -9275,14 +9393,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งปรับโครงสร้าง คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
@ -9309,6 +9427,266 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
/// <summary>
/// C-PM-40 - คำสั่งให้ข้าราชการรักษาการในตำแหน่ง
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task ExecuteCommand40Async(Command command, string token = "")
{
try
{
var payload_attach = command.Documents
.Select(x => new PayloadAttachment
{
name = x.Category == "cover" ? "สำเนาคำสั่ง" : "สำเนาเอกสารแนบท้าย",
url = $"{_configuration["API"]}/order/download/attachment/{x.Document.Id}"
})
.ToList();
var payload = new CommandPayload()
{
attachments = payload_attach
};
var payload_str = JsonConvert.SerializeObject(payload);
foreach (var cc in command.Deployments)
{
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 = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_dbContext.Set<Inbox>().Add(inbox);
}
if (cc.IsSendMail)
{
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 = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_dbContext.Set<Notification>().Add(noti);
}
// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
command.CommandStatusId = cmdStatus!.Id;
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
/// <summary>
/// C-PM-41 - คำสั่งยกเลิกการลาออก
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task ExecuteCommand41Async(Command command, string token = "")
{
try
{
// create command payload
var payload_attach = command.Documents
.Select(x => new PayloadAttachment
{
name = x.Category == "cover" ? "สำเนาคำสั่ง" : "สำเนาเอกสารแนบท้าย",
url = $"{_configuration["API"]}/order/download/attachment/{x.Document.Id}"
})
.ToList();
var payload = new CommandPayload()
{
attachments = payload_attach
};
var payload_str = JsonConvert.SerializeObject(payload);
foreach (var recv in command.Receivers)
{
var data = await _dbContext.Set<RetirementResign>()
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrl, new
{
isLeave = false,
leaveReason = _null,
dateLeave = _null,
});
var _result = await _res.Content.ReadAsStringAsync();
}
var apiUrlSalary = $"{baseAPI}/org/profile/salary";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = data.profileId,
date = command.CommandAffectDate,
amount = recv.Amount,
positionSalaryAmount = recv.PositionSalaryAmount,
mouthSalaryAmount = recv.MouthSalaryAmount,
posNo = data.PositionNumberOld,
position = data.PositionOld,
positionLine = "",
positionPathSide = "",
positionExecutive = "",
positionType = data.PositionTypeOld,
positionLevel = data.PositionLevelOld,
refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
templateDoc = "คำสั่งยกเลิกการลาออก คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
});
var _result = await _res.Content.ReadAsStringAsync();
}
// // update placementstatus
data.Status = "DONEREJECT";
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");
if (data.profileId != null)
{
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 = Guid.Parse(data.profileId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_dbContext.Set<Inbox>().Add(inbox);
var noti = new Notification
{
Body = $"คุณได้รับคำสั่งยกเลิกการลาออก เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = Guid.Parse(data.profileId),
Type = "LINK",
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_dbContext.Set<Notification>().Add(noti);
}
await _dbContext.SaveChangesAsync();
}
// send cc noti inbox
foreach (var cc in command.Deployments)
{
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 = Guid.Parse(cc.ReceiveUserId),
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_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 = Guid.Parse(cc.ReceiveUserId),
Type = "LINK",
Payload = payload_str,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
_dbContext.Set<Notification>().Add(noti);
}
// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
command.CommandStatusId = cmdStatus!.Id;
await _dbContext.SaveChangesAsync();
}
catch
{
throw;
}
}
#endregion
#region " Regenerate Json File "