Merge branch 'develop' into working

# Conflicts:
#	Controllers/DisableReportController.cs
This commit is contained in:
Suphonchai Phoonsawat 2023-06-17 06:06:18 +07:00
commit 072f150eed
34 changed files with 15259 additions and 2576 deletions

View file

@ -84,43 +84,98 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
}
}
private List<Guid?> GetAllIdByRoot(Guid id)
{
try
{
var ret = new List<Guid?>();
var oc = _contextMetadata.Organizations.FirstOrDefault(x => x.Id == id && x.IsActive);
if (oc != null)
ret.Add(oc.Id);
var child = _contextMetadata.Organizations.AsQueryable().Where(x => x.ParentId == id && x.IsActive).ToList();
if (child.Any())
{
foreach (var item in child)
{
ret.AddRange(GetAllIdByRoot(item.Id));
}
}
return ret;
}
catch
{
throw;
}
}
public async Task<IEnumerable<PeriodExamCandidateResponseItem>> GetsAsync(string type, bool showAll = true)
{
return await _context.PeriodExams.AsQueryable()
.Where(p => p.IsActive)
.Where(p => p.CheckDisability == false)
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == true : p.AnnouncementExam == false))
.OrderByDescending(d => d.CreatedAt)
.Select(x => new PeriodExamCandidateResponseItem
{
ExamDate = x.ExamDate,
AnnouncementEndDate = x.AnnouncementEndDate,
AnnouncementStartDate = x.AnnouncementStartDate,
AnnouncementDate = x.AnnouncementDate,
CheckDisability = x.CheckDisability,
CheckDocument = x.CheckDocument,
Detail = x.Detail,
Fee = x.Fee,
Id = x.Id,
IsActive = x.IsActive,
Name = x.Name,
Note = x.Note,
OrganizationCodeId = x.OrganizationCodeId,
OrganizationCodeName = x.OrganizationCodeName,
OrganizationId = x.OrganizationId,
OrganizationName = x.OrganizationName,
PaymentEndDate = x.PaymentEndDate,
PaymentKrungThai = x.PaymentKrungThai,
AnnouncementExam = x.AnnouncementExam,
Category = x.Category,
PaymentStartDate = x.PaymentStartDate,
RegisterEndDate = x.RegisterEndDate,
RegisterStartDate = x.RegisterStartDate,
Round = x.Round,
SetSeat = x.SetSeat,
Year = x.Year,
})
.ToListAsync();
var periodExams = await _context.PeriodExams.AsQueryable()
.Where(p => p.IsActive)
.Where(p => p.CheckDisability == false)
.Where(p => type.ToUpper() == "ALL" ? (p.AnnouncementExam == true || p.AnnouncementExam == false) : (type.ToUpper() == "EXAM" ? p.AnnouncementExam == true : p.AnnouncementExam == false))
.OrderByDescending(d => d.CreatedAt).ToListAsync();
var profileOrganizations = await _contextMetadata.ProfileOrganizations.AsQueryable()
.ToListAsync();
var _periodExams = (from x in periodExams
join po in profileOrganizations on Guid.Parse(x.CreatedUserId) equals po?.UserId into poGroup
from po in poGroup.DefaultIfEmpty()
select new PeriodExamCandidateResponseItem
{
ExamDate = x.ExamDate,
AnnouncementEndDate = x.AnnouncementEndDate,
AnnouncementStartDate = x.AnnouncementStartDate,
AnnouncementDate = x.AnnouncementDate,
CheckDisability = x.CheckDisability,
CheckDocument = x.CheckDocument,
Detail = x.Detail,
Fee = x.Fee,
Id = x.Id,
IsActive = x.IsActive,
Name = x.Name,
Note = x.Note,
OrganizationCodeId = x.OrganizationCodeId,
OrganizationCodeName = x.OrganizationCodeName,
OrganizationId = x.OrganizationId,
OrganizationName = x.OrganizationName,
PaymentEndDate = x.PaymentEndDate,
PaymentKrungThai = x.PaymentKrungThai,
AnnouncementExam = x.AnnouncementExam,
Category = x.Category,
PaymentStartDate = x.PaymentStartDate,
RegisterEndDate = x.RegisterEndDate,
RegisterStartDate = x.RegisterStartDate,
Round = x.Round,
SetSeat = x.SetSeat,
Year = x.Year,
OcId = po == null ? null : po.OrganizationId,
CreatedUserId = x.CreatedUserId,
}).AsQueryable()
.ToList();
var roles = _httpContextAccessor?.HttpContext?.User?.FindAll(ClaimTypes.Role)?.Select(c => c.Value).ToList();
if (!roles.Contains("head"))
{
var criteria = new List<Guid?>();
var profileOrganization = await _contextMetadata.ProfileOrganizations.AsQueryable()
.FirstOrDefaultAsync(x => x.UserId == Guid.Parse(UserId));
if (profileOrganization == null)
return new List<PeriodExamCandidateResponseItem>();
var ocId = _contextMetadata.Organizations.AsQueryable()
.FirstOrDefault(x => x.Id == profileOrganization.OrganizationId);
if (ocId == null)
return new List<PeriodExamCandidateResponseItem>();
criteria = GetAllIdByRoot(ocId.Id);
if (criteria.Any())
_periodExams = _periodExams.Where(x => x.CreatedUserId == UserId || criteria.Contains(x.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OcId)).ToList();
}
return _periodExams;
}
public async Task<PeriodExamCandidateResponseItem?> GetsExamAndCandidateAsync(string examId, bool showAll = true)
@ -172,6 +227,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
TypeName = b.TypeName,
PositionId = b.PositionId,
PositionName = b.PositionName,
HighDegree = b.HighDegree,
}).ToList(),
Documents = x.PeriodExamDocuments.OrderBy(o => o.CreatedAt).Select(b => new FileListResponse
{
@ -226,7 +282,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
Name = periodExam.Name,
Round = periodExam.Round,
Year = periodExam.Year,
Status = DateTime.Now > periodExam.PaymentEndDate,
Status = periodExam.PaymentEndDate == null ? true : DateTime.Now > periodExam.PaymentEndDate,
SetSeat = periodExam.SetSeat,
};
}
@ -325,6 +381,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
PeriodExam = periodExam,
PositionId = position.PositionId,
PositionName = position.PositionName,
HighDegree = position.HighDegree,
TypeId = position.TypeId,
TypeName = position.TypeName,
CreatedAt = DateTime.Now,
@ -448,6 +505,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
position.PositionId = positionData.PositionId;
position.PositionName = positionData.PositionName;
position.HighDegree = positionData.HighDegree;
position.TypeId = positionData.TypeId;
position.TypeName = positionData.TypeName;
position.LastUpdatedAt = DateTime.Now;
@ -478,6 +536,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
PeriodExam = periodExam,
PositionId = position.PositionId,
PositionName = position.PositionName,
HighDegree = position.HighDegree,
TypeId = position.TypeId,
TypeName = position.TypeName,
CreatedAt = DateTime.Now,
@ -600,10 +659,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
var candidate = await _context.Candidates.AsQueryable()
.Include(x => x.ProfileImg)
.OrderByDescending(d => d.CreatedAt)
.Where(x => x.PeriodExam == periodExam && x.Status != "register" && x.Status != "rejectRegister")
.Where(x => x.PeriodExam == periodExam && x.RegisterDate != null && x.Status != "register" && x.Status != "rejectRegister")
.ToListAsync();
if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null)
candidate = candidate.OrderBy(x => x.Number).ToList();
candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList();
var i = 0;
foreach (var item in candidate)
{
@ -621,7 +680,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
.Where(x => x.PeriodExam == periodExam && x.Status == status)
.ToListAsync();
if (candidate.Where(x => x.Status == "done").FirstOrDefault() != null)
candidate = candidate.OrderBy(x => x.Number).ToList();
candidate = candidate.OrderBy(x => Convert.ToInt32(x.Number)).ToList();
var i = 0;
foreach (var item in candidate)
{
@ -821,23 +880,23 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
for (int row = 2; row <= rowCount; row++)
{
System.Diagnostics.Debug.WriteLine(worksheet);
if (worksheet.Cells[row, 1].Value != null)
// if (worksheet.Cells[row, 2].Value != null)
// {
list.Add(new RequestImportSeat
{
list.Add(new RequestImportSeat
{
Number = worksheet.Cells[row, 1].Value != null ? worksheet.Cells[row, 1].Value.ToString() : null,
CitizenId = worksheet.Cells[row, 2].Value != null ? worksheet.Cells[row, 2].Value.ToString() : null,
ExamIdenNumber = worksheet.Cells[row, 3].Value != null ? worksheet.Cells[row, 3].Value.ToString() : null,
SeatNumber = worksheet.Cells[row, 4].Value != null ? worksheet.Cells[row, 4].Value.ToString() : null,
PointTotalB = worksheet.Cells[row, 5].Value != null ? worksheet.Cells[row, 5].Value.ToString() : null,
PointB = worksheet.Cells[row, 6].Value != null ? worksheet.Cells[row, 6].Value.ToString() : null,
ResultB = worksheet.Cells[row, 7].Value != null ? worksheet.Cells[row, 7].Value.ToString() : null,
PointTotalC = worksheet.Cells[row, 8].Value != null ? worksheet.Cells[row, 8].Value.ToString() : null,
PointC = worksheet.Cells[row, 9].Value != null ? worksheet.Cells[row, 9].Value.ToString() : null,
ResultC = worksheet.Cells[row, 10].Value != null ? worksheet.Cells[row, 10].Value.ToString() : null,
Pass = worksheet.Cells[row, 11].Value != null ? (worksheet.Cells[row, 11].Value.ToString()) : null,
});
}
Number = worksheet.Cells[row, 4].Value != null ? worksheet.Cells[row, 4].Value.ToString() : null,
CitizenId = worksheet.Cells[row, 5].Value != null ? worksheet.Cells[row, 5].Value.ToString() : null,
ExamIdenNumber = worksheet.Cells[row, 6].Value != null ? worksheet.Cells[row, 6].Value.ToString() : null,
SeatNumber = worksheet.Cells[row, 7].Value != null ? worksheet.Cells[row, 7].Value.ToString() : null,
PointTotalB = worksheet.Cells[row, 8].Value != null ? worksheet.Cells[row, 8].Value.ToString() : null,
PointB = worksheet.Cells[row, 9].Value != null ? worksheet.Cells[row, 9].Value.ToString() : null,
ResultB = worksheet.Cells[row, 10].Value != null ? worksheet.Cells[row, 10].Value.ToString() : null,
PointTotalC = worksheet.Cells[row, 11].Value != null ? worksheet.Cells[row, 11].Value.ToString() : null,
PointC = worksheet.Cells[row, 12].Value != null ? worksheet.Cells[row, 12].Value.ToString() : null,
ResultC = worksheet.Cells[row, 13].Value != null ? worksheet.Cells[row, 13].Value.ToString() : null,
Pass = worksheet.Cells[row, 14].Value != null ? (worksheet.Cells[row, 14].Value.ToString()) : null,
});
// }
}
}
}
@ -863,7 +922,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
foreach (var candidate in candidates)
{
var item = items.FirstOrDefault(x => x.CitizenId == candidate.CitizenId && x.ExamIdenNumber.Trim().ToUpper() == candidate.ExamIdenNumber.Trim().ToUpper());
if (candidate.ExamIdenNumber == null || candidate.CitizenId == null)
continue;
var item = items.FirstOrDefault(x => x.CitizenId == candidate.CitizenId && x.ExamIdenNumber == candidate.ExamIdenNumber);
if (item != null)
{
@ -872,7 +933,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.SeatNumber = item.SeatNumber;
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: รอเจ้าหน้าที่สรุปคะแนนสอบ";
if (candidate.Email != null) _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
candidate.Status = "checkPoint";
}
else
@ -881,7 +942,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
if (candidate.Email != null) _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
}
candidate.Status = "waiver";
}
@ -892,7 +953,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
if (candidate.Email != null) _mailService.SendMailToUser(subject, body, candidate.Email);
if (candidate.Email != null && candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
}
candidate.Status = "waiver";
}
@ -919,6 +980,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
foreach (var candidate in candidates)
{
if (candidate.ExamIdenNumber == null || candidate.CitizenId == null)
continue;
var item = items.FirstOrDefault(x => x.CitizenId == candidate.CitizenId && x.ExamIdenNumber == candidate.ExamIdenNumber);
if (item != null)
@ -935,7 +998,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
candidate.Number = item.Number;
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สอบคัดเลือกสำเร็จ";
if (candidate.Email != null) _mailService.SendMailToUser(subject, body, candidate.Email);
// if (candidate.Email != null&& candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
candidate.Status = "done";
}
else
@ -944,9 +1007,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
if (candidate.Email != null) _mailService.SendMailToUser(subject, body, candidate.Email);
// if (candidate.Email != null&& candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
}
candidate.Status = "waiver";
// candidate.Status = "waiver";
}
}
else
@ -955,9 +1018,9 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
var subject = "แจ้งผลการสมัครสอบคัดเลือก " + periodExam.Name;
var body = candidate.FirstName + " " + candidate.LastName + " สถานะการสมัครสอบ: สละสิทธิ์สอบ";
if (candidate.Email != null) _mailService.SendMailToUser(subject, body, candidate.Email);
// if (candidate.Email != null&& candidate.Email != "") _mailService.SendMailToUser(subject, body, candidate.Email);
}
candidate.Status = "waiver";
// candidate.Status = "waiver";
}
periodExam.SetSeat = true;
}
@ -999,32 +1062,38 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.TabColor = System.Drawing.Color.Black;
// summarySheet.DefaultRowHeight = 17;
summarySheet.Row(1).Style.Font.Bold = true;
summarySheet.Cells[1, 1].Value = "ลำดับที่สอบได้";
summarySheet.Cells[1, 2].Value = "เลขบัตรประชาชน";
summarySheet.Cells[1, 3].Value = "เลขประจำตัวสอบ";
summarySheet.Cells[1, 4].Value = "เลขที่นั่งสอบ";
summarySheet.Cells[1, 5].Value = "คะแนนเต็มภาค ข";
summarySheet.Cells[1, 6].Value = "คะแนนภาค ข";
summarySheet.Cells[1, 7].Value = "ผลสอบภาค ข";
summarySheet.Cells[1, 8].Value = "คะแนนเต็มภาค ค";
summarySheet.Cells[1, 9].Value = "คะแนนภาค ค";
summarySheet.Cells[1, 10].Value = "ผลสอบภาค ค";
summarySheet.Cells[1, 11].Value = "ผลการสอบ";
summarySheet.Cells[1, 1].Value = "ชำระค่าธรรมเนียม";
summarySheet.Cells[1, 2].Value = "วันเวลาชำระ";
summarySheet.Cells[1, 3].Value = "วันและเวลาที่สมัคร";
summarySheet.Cells[1, 4].Value = "ลำดับที่สอบได้";
summarySheet.Cells[1, 5].Value = "เลขบัตรประชาชน";
summarySheet.Cells[1, 6].Value = "เลขประจำตัวสอบ";
summarySheet.Cells[1, 7].Value = "เลขที่นั่งสอบ";
summarySheet.Cells[1, 8].Value = "คะแนนเต็มภาค ข";
summarySheet.Cells[1, 9].Value = "คะแนนภาค ข";
summarySheet.Cells[1, 10].Value = "ผลสอบภาค ข";
summarySheet.Cells[1, 11].Value = "คะแนนเต็มภาค ค";
summarySheet.Cells[1, 12].Value = "คะแนนภาค ค";
summarySheet.Cells[1, 13].Value = "ผลสอบภาค ค";
summarySheet.Cells[1, 14].Value = "ผลการสอบ";
int row = 2;
foreach (var item in candidates)
{
summarySheet.Cells[row, 1].Value = item.Number;
summarySheet.Cells[row, 2].Value = item.CitizenId;
summarySheet.Cells[row, 3].Value = item.ExamIdenNumber;
summarySheet.Cells[row, 4].Value = item.SeatNumber;
summarySheet.Cells[row, 5].Value = item.PointTotalB;
summarySheet.Cells[row, 6].Value = item.PointB;
summarySheet.Cells[row, 7].Value = item.ResultB;
summarySheet.Cells[row, 8].Value = item.PointTotalC;
summarySheet.Cells[row, 9].Value = item.PointC;
summarySheet.Cells[row, 10].Value = item.ResultC;
summarySheet.Cells[row, 11].Value = item.Pass;
summarySheet.Cells[row, 1].Value = item.PaymentDate == null ? "ยังไม่ชำระเงิน" : "ชำระแล้ว";
summarySheet.Cells[row, 2].Value = item.PaymentDate == null ? "" : item.PaymentDate.Value.ToThaiShortDateTime();
summarySheet.Cells[row, 3].Value = item.RegisterDate == null ? "" : item.RegisterDate.Value.ToThaiShortDateTime();
summarySheet.Cells[row, 4].Value = item.Number;
summarySheet.Cells[row, 5].Value = item.CitizenId;
summarySheet.Cells[row, 6].Value = item.ExamIdenNumber;
summarySheet.Cells[row, 7].Value = item.SeatNumber;
summarySheet.Cells[row, 8].Value = item.PointTotalB;
summarySheet.Cells[row, 9].Value = item.PointB;
summarySheet.Cells[row, 10].Value = item.ResultB;
summarySheet.Cells[row, 11].Value = item.PointTotalC;
summarySheet.Cells[row, 12].Value = item.PointC;
summarySheet.Cells[row, 13].Value = item.ResultC;
summarySheet.Cells[row, 14].Value = item.Pass;
row++;
}
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
@ -1084,7 +1153,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
{
Id = 3,
Name = "จำนวนผู้เข้ารับการคัดเลือกทั้งหมด",
Count = periodExam.Candidate.Where(x=>x.PaymentImg!=null).Count()
Count = periodExam.Candidate.Where(x=>x.SeatNumber != null).Count()
},
new DashboardResponseItem
{
@ -1167,7 +1236,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
OccupationDepartment = c.OccupationDepartment,
OccupationEmail = c.OccupationEmail,
OccupationTelephone = c.OccupationTelephone,
RegisterDate = c.RegisterDate,
Number = c.Number,
ExamIdenNumber = c.ExamIdenNumber,
@ -1243,6 +1312,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[1, 51].Value = "ผลสอบภาค ค";
summarySheet.Cells[1, 52].Value = "ผลการสอบ";
summarySheet.Cells[1, 53].Value = "วันที่สมัคร";
summarySheet.Cells[1, 54].Value = "วันเและเวลาที่สมัคร";
int row = 2;
foreach (var item in candidates)
@ -1279,7 +1349,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[row, 22].Value = item.MarryFullName;
summarySheet.Cells[row, 23].Value = item.FatherFullName;
summarySheet.Cells[row, 24].Value = item.MotherFullName;
summarySheet.Cells[row, 25].Value = GenerateStatusOccupation(item.OccupationType);
summarySheet.Cells[row, 25].Value = item.OccupationType == null ? null : GenerateStatusOccupation(item.OccupationType);
summarySheet.Cells[row, 26].Value = item.OccupationPosition;
summarySheet.Cells[row, 27].Value = item.OccupationCompany;
summarySheet.Cells[row, 28].Value = item.OccupationDepartment;
@ -1302,6 +1372,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[row, 51].Value = item.ResultC;
summarySheet.Cells[row, 52].Value = item.Pass;
summarySheet.Cells[row, 53].Value = item.CreatedAt.Date.ToThaiShortDate();
summarySheet.Cells[row, 54].Value = item.RegisterDate;
row++;
}
var careers = await _context.Careers
@ -1336,7 +1407,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[row, 22].Value = item.MarryFullName;
summarySheet.Cells[row, 23].Value = item.FatherFullName;
summarySheet.Cells[row, 24].Value = item.MotherFullName;
summarySheet.Cells[row, 25].Value = GenerateStatusOccupation(item.OccupationType);
summarySheet.Cells[row, 25].Value = item.OccupationType == null ? null : GenerateStatusOccupation(item.OccupationType);
summarySheet.Cells[row, 26].Value = item.OccupationPosition;
summarySheet.Cells[row, 27].Value = item.OccupationCompany;
summarySheet.Cells[row, 28].Value = item.OccupationDepartment;
@ -1359,6 +1430,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[row, 51].Value = item.ResultC;
summarySheet.Cells[row, 52].Value = item.Pass;
summarySheet.Cells[row, 53].Value = item.CreatedAt.Date.ToThaiShortDate();
summarySheet.Cells[row, 54].Value = item.RegisterDate;
row++;
}
if (educations.Count() == 0 && careers.Count() == 0)
@ -1387,7 +1459,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[row, 22].Value = item.MarryFullName;
summarySheet.Cells[row, 23].Value = item.FatherFullName;
summarySheet.Cells[row, 24].Value = item.MotherFullName;
summarySheet.Cells[row, 25].Value = GenerateStatusOccupation(item.OccupationType);
summarySheet.Cells[row, 25].Value = item.OccupationType == null ? null : GenerateStatusOccupation(item.OccupationType);
summarySheet.Cells[row, 26].Value = item.OccupationPosition;
summarySheet.Cells[row, 27].Value = item.OccupationCompany;
summarySheet.Cells[row, 28].Value = item.OccupationDepartment;
@ -1405,6 +1477,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
summarySheet.Cells[row, 51].Value = item.ResultC;
summarySheet.Cells[row, 52].Value = item.Pass;
summarySheet.Cells[row, 53].Value = item.CreatedAt.Date.ToThaiShortDate();
summarySheet.Cells[row, 54].Value = item.RegisterDate;
row++;
}
}
@ -1580,6 +1653,54 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
stream.Position = 0;
return stream;
}
public async Task<MemoryStream> DownloadCandidatePaymentAllAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Where(x => x.CheckDisability == false)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates
.AsQueryable()
.Where(x => x.PeriodExam == periodExam)
.Select(c => new
{
CitizenId = c.CitizenId,
FullName = $"{c.PrefixName}{c.FirstName} {c.LastName}",
PaymentDate = c.PaymentDate,
})
.ToListAsync();
var stream = new MemoryStream();
using (var package = new ExcelPackage(stream))
{
var summarySheet = package.Workbook.Worksheets.Add("Payment");
summarySheet.TabColor = System.Drawing.Color.Black;
summarySheet.Row(1).Style.Font.Bold = true;
summarySheet.Cells[1, 1].Value = "เลขบัตรประชาชน";
summarySheet.Cells[1, 2].Value = "ชื่อ-สกุล";
summarySheet.Cells[1, 3].Value = "ชำระค่าธรรมเนียม";
summarySheet.Cells[1, 4].Value = "วันเวลาชำระ";
int row = 2;
foreach (var item in candidates)
{
summarySheet.Cells[row, 1].Value = item.CitizenId;
summarySheet.Cells[row, 2].Value = item.FullName;
summarySheet.Cells[row, 3].Value = item.PaymentDate == null ? "ยังไม่ชำระเงิน" : "ชำระแล้ว";
summarySheet.Cells[row, 4].Value = item.PaymentDate == null ? "" : item.PaymentDate.Value;
row++;
}
summarySheet.Cells[summarySheet.Dimension.Address].AutoFitColumns();
package.Save();
}
stream.Position = 0;
return stream;
}
#endregion
}
}