fix ใบสมัคร
This commit is contained in:
parent
ec8a6de291
commit
04b20e49c9
2 changed files with 120 additions and 62 deletions
|
|
@ -88,38 +88,38 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
{
|
||||
p.Id,
|
||||
AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id,
|
||||
ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber,
|
||||
PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName,
|
||||
PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName,
|
||||
PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name,
|
||||
PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString(),
|
||||
PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString(),
|
||||
ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber.ToThaiNumber(),
|
||||
PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName.ToThaiNumber(),
|
||||
PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName.ToThaiNumber(),
|
||||
PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name.ToThaiNumber(),
|
||||
PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString().ToThaiNumber(),
|
||||
PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString().ToThaiNumber(),
|
||||
|
||||
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
|
||||
Religion = p.ReligionName == null ? "-" : p.ReligionName,
|
||||
Nationality = p.Nationality == null ? "-" : p.Nationality,
|
||||
DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2(),
|
||||
Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
|
||||
CitizenId = p.CitizenId == null ? "-" : p.CitizenId,
|
||||
DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2().ToThaiNumber(),
|
||||
Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0).ToThaiNumber(),
|
||||
CitizenId = p.CitizenId == null ? "-" : p.CitizenId.ToThaiNumber(),
|
||||
|
||||
EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName,
|
||||
EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName.ToThaiNumber(),
|
||||
EducationName = p.Educations.FirstOrDefault() == null ? null : (p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาตรี" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาโท" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาเอก" ? p.Educations.FirstOrDefault().EducationName : null),
|
||||
EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor,
|
||||
EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor.ToThaiNumber(),
|
||||
EducationLocation = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLocation,
|
||||
EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2(),
|
||||
EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores,
|
||||
EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2().ToThaiNumber(),
|
||||
EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores.ToThaiNumber(),
|
||||
EducationType = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationType,
|
||||
EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelHighName,
|
||||
|
||||
OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-")),
|
||||
OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition,
|
||||
OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.ToString(),
|
||||
OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.Value.ToString("N0").ToThaiNumber(),
|
||||
OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup,
|
||||
OccupationPile = p.OccupationPile == null ? "-" : p.OccupationPile,
|
||||
OccupationOrg = p.OccupationOrg == null ? "-" : p.OccupationOrg,
|
||||
OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone,
|
||||
OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone.ToThaiNumber(),
|
||||
|
||||
CareersTotal = sb.ToString(),
|
||||
CareersTotal = sb.ToString().ToThaiNumber(),
|
||||
// Careers = p.Careers.Select(y => new
|
||||
// {
|
||||
// Position = y.Position,
|
||||
|
|
@ -129,24 +129,24 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
// RangeDate = y.RangeDate,
|
||||
// }).ToList(),
|
||||
|
||||
RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress,
|
||||
RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress.ToThaiNumber(),
|
||||
RegistProvinceName = p.RegistProvinceName == null ? "-" : p.RegistProvinceName,
|
||||
RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName,
|
||||
RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName,
|
||||
RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode,
|
||||
CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress) : p.CurrentAddress,
|
||||
RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode.ToThaiNumber(),
|
||||
CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress.ToThaiNumber()) : p.CurrentAddress.ToThaiNumber(),
|
||||
CurrentProvinceName = p.CurrentProvinceName == null ? (p.RegistProvinceName == null ? "-" : p.RegistProvinceName) : p.CurrentProvinceName,
|
||||
CurrentDistrictName = p.CurrentDistrictName == null ? (p.RegistDistrictName == null ? "-" : p.RegistDistrictName) : p.CurrentDistrictName,
|
||||
CurrentSubDistrictName = p.CurrentSubDistrictName == null ? (p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName) : p.CurrentSubDistrictName,
|
||||
CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode) : p.CurrentZipCode,
|
||||
Telephone = p.Telephone == null ? "-" : p.Telephone,
|
||||
CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode.ToThaiNumber()) : p.CurrentZipCode.ToThaiNumber(),
|
||||
Telephone = p.Telephone == null ? "-" : p.Telephone.ToThaiNumber(),
|
||||
Email = p.Email == null ? "-" : p.Email,
|
||||
|
||||
ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}",
|
||||
ContactRelations = p.ContactRelations == null ? "-" : p.ContactRelations,
|
||||
ContactTel = p.ContactTel == null ? "-" : p.ContactTel,
|
||||
ContactTel = p.ContactTel == null ? "-" : p.ContactTel.ToThaiNumber(),
|
||||
|
||||
RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate(),
|
||||
RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate().ToThaiNumber(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
if (data == null)
|
||||
|
|
@ -176,10 +176,10 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
{
|
||||
Position = item.Position,
|
||||
Type = item.Type,
|
||||
DurationStart = item.DurationStart,
|
||||
DurationEnd = item.DurationEnd,
|
||||
RangeDate = item.RangeDate,
|
||||
Index = retVal,
|
||||
DurationStart = item.DurationStart.ToThaiNumber(),
|
||||
DurationEnd = item.DurationEnd.ToThaiNumber(),
|
||||
RangeDate = item.RangeDate.ToThaiNumber(),
|
||||
Index = retVal.ToString().ToThaiNumber(),
|
||||
};
|
||||
data.Add(_data);
|
||||
retVal++;
|
||||
|
|
|
|||
|
|
@ -52,47 +52,105 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
var avatar = await _service.GetExamAvatarCandidateAsync(Id);
|
||||
if (candidate != null)
|
||||
{
|
||||
var mimeType = "";
|
||||
switch (exportType.Trim().ToLower())
|
||||
{
|
||||
case "pdf": mimeType = "application/pdf"; break;
|
||||
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
//var mimeType = "";
|
||||
//switch (exportType.Trim().ToLower())
|
||||
//{
|
||||
// case "pdf": mimeType = "application/pdf"; break;
|
||||
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
//}
|
||||
|
||||
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"ผลสอบคัดเลือกรายบุคคล.trdp");
|
||||
ReportPackager reportPacker = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||
}
|
||||
report.DataSource = candidate;
|
||||
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"ผลสอบคัดเลือกรายบุคคล.trdp");
|
||||
//ReportPackager reportPacker = new ReportPackager();
|
||||
//Telerik.Reporting.Report? report = null;
|
||||
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
//{
|
||||
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||
//}
|
||||
//report.DataSource = candidate;
|
||||
|
||||
var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"];
|
||||
tblData.DataSource = careers;
|
||||
//var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"];
|
||||
//tblData.DataSource = careers;
|
||||
|
||||
Console.WriteLine("000000");
|
||||
if (avatar != Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get avatar Image
|
||||
var picContent = await _minIOExamService.DownloadFileAsync(avatar);
|
||||
var pictureBox = (Telerik.Reporting.PictureBox)report.Items["detailSection1"].Items["picAvatar"];
|
||||
pictureBox.Value = Image.FromStream(new MemoryStream(picContent.FileContent));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
//Console.WriteLine("000000");
|
||||
//if (avatar != Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// // Get avatar Image
|
||||
//var picContent = await _minIOExamService.DownloadFileAsync(avatar);
|
||||
//var pictureBox = (Telerik.Reporting.PictureBox)report.Items["detailSection1"].Items["picAvatar"];
|
||||
//pictureBox.Value = Image.FromStream(new MemoryStream(picContent.FileContent));
|
||||
// }
|
||||
// catch { }
|
||||
//}
|
||||
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
//InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
//{
|
||||
// ReportDocument = report,
|
||||
//};
|
||||
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
//return File(result.DocumentBytes, mimeType, $"ใบสมัครสอบคัดเลือก.{exportType.Trim().ToLower()}");
|
||||
var mapData = new
|
||||
{
|
||||
ReportDocument = report,
|
||||
Id = candidate.GetType().GetProperty("Id").GetValue(candidate),
|
||||
AvatarId = candidate.GetType().GetProperty("AvatarId").GetValue(candidate),
|
||||
PeriodExamName = candidate.GetType().GetProperty("PeriodExamName").GetValue(candidate),
|
||||
PeriodExamRound = candidate.GetType().GetProperty("PeriodExamRound").GetValue(candidate),
|
||||
PeriodExamYear = candidate.GetType().GetProperty("PeriodExamYear").GetValue(candidate),
|
||||
PositionName = candidate.GetType().GetProperty("PositionName").GetValue(candidate),
|
||||
PositionLevelName = candidate.GetType().GetProperty("PositionLevelName").GetValue(candidate),
|
||||
FullName = candidate.GetType().GetProperty("FullName").GetValue(candidate),
|
||||
Nationality = candidate.GetType().GetProperty("Nationality").GetValue(candidate),
|
||||
Religion = candidate.GetType().GetProperty("Religion").GetValue(candidate),
|
||||
CitizenId = candidate.GetType().GetProperty("CitizenId").GetValue(candidate),
|
||||
DateOfBirth = candidate.GetType().GetProperty("DateOfBirth").GetValue(candidate),
|
||||
Age = candidate.GetType().GetProperty("Age").GetValue(candidate),
|
||||
EducationLevelExamName = candidate.GetType().GetProperty("EducationLevelExamName").GetValue(candidate),
|
||||
EducationName = candidate.GetType().GetProperty("EducationName").GetValue(candidate),
|
||||
EducationMajor = candidate.GetType().GetProperty("EducationMajor").GetValue(candidate),
|
||||
EducationLocation = candidate.GetType().GetProperty("EducationLocation").GetValue(candidate),
|
||||
EducationEndDate = candidate.GetType().GetProperty("EducationEndDate").GetValue(candidate),
|
||||
EducationScores = candidate.GetType().GetProperty("EducationScores").GetValue(candidate),
|
||||
EducationType = candidate.GetType().GetProperty("EducationType").GetValue(candidate),
|
||||
EducationLevelHighName = candidate.GetType().GetProperty("EducationLevelHighName").GetValue(candidate),
|
||||
ExamIdenNumber = candidate.GetType().GetProperty("ExamIdenNumber").GetValue(candidate),
|
||||
OccupationPositionType = candidate.GetType().GetProperty("OccupationPositionType").GetValue(candidate),
|
||||
OccupationPosition = candidate.GetType().GetProperty("OccupationPosition").GetValue(candidate),
|
||||
OccupationSalary = candidate.GetType().GetProperty("OccupationSalary").GetValue(candidate),
|
||||
OccupationGroup = candidate.GetType().GetProperty("OccupationGroup").GetValue(candidate),
|
||||
OccupationPile = candidate.GetType().GetProperty("OccupationPile").GetValue(candidate),
|
||||
OccupationOrg = candidate.GetType().GetProperty("OccupationOrg").GetValue(candidate),
|
||||
OccupationTelephone = candidate.GetType().GetProperty("OccupationTelephone").GetValue(candidate),
|
||||
CareersTotal = candidate.GetType().GetProperty("CareersTotal").GetValue(candidate),
|
||||
RegistAddress = candidate.GetType().GetProperty("RegistAddress").GetValue(candidate),
|
||||
RegistProvinceName = candidate.GetType().GetProperty("RegistProvinceName").GetValue(candidate),
|
||||
RegistDistrictName = candidate.GetType().GetProperty("RegistDistrictName").GetValue(candidate),
|
||||
RegistSubDistrictName = candidate.GetType().GetProperty("RegistSubDistrictName").GetValue(candidate),
|
||||
RegistZipCode = candidate.GetType().GetProperty("RegistZipCode").GetValue(candidate),
|
||||
CurrentAddress = candidate.GetType().GetProperty("CurrentAddress").GetValue(candidate),
|
||||
CurrentProvinceName = candidate.GetType().GetProperty("CurrentProvinceName").GetValue(candidate),
|
||||
CurrentDistrictName = candidate.GetType().GetProperty("CurrentDistrictName").GetValue(candidate),
|
||||
CurrentSubDistrictName = candidate.GetType().GetProperty("CurrentSubDistrictName").GetValue(candidate),
|
||||
CurrentZipCode = candidate.GetType().GetProperty("CurrentZipCode").GetValue(candidate),
|
||||
Telephone = candidate.GetType().GetProperty("Telephone").GetValue(candidate),
|
||||
Email = candidate.GetType().GetProperty("Email").GetValue(candidate),
|
||||
ContactFullName = candidate.GetType().GetProperty("ContactFullName").GetValue(candidate),
|
||||
ContactRelations = candidate.GetType().GetProperty("ContactRelations").GetValue(candidate),
|
||||
ContactTel = candidate.GetType().GetProperty("ContactTel").GetValue(candidate),
|
||||
RegisterDate = candidate.GetType().GetProperty("RegisterDate").GetValue(candidate),
|
||||
Url = "https://bma-ehr.frappet.synology.me/assets/avatar_user-89f22423.jpg",
|
||||
Careers = careers,
|
||||
};
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
return File(result.DocumentBytes, mimeType, $"ใบสมัครสอบคัดเลือก.{exportType.Trim().ToLower()}");
|
||||
|
||||
var data = new {
|
||||
template = "ผลสอบคัดเลือกรายบุคคล",
|
||||
reportName = "docx-report",
|
||||
data = mapData
|
||||
};
|
||||
return Success(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue