diff --git a/Controllers/ProfileReportController.cs b/Controllers/ProfileReportController.cs index 0f11718..7c05bab 100644 --- a/Controllers/ProfileReportController.cs +++ b/Controllers/ProfileReportController.cs @@ -106,7 +106,8 @@ namespace BMA.EHR.Report.Service.Controllers SalaryAmount = p.Salaries.Count == 0 ? "-" : $"{p.Salaries.OrderByDescending(s => s.Date.Value).FirstOrDefault().Amount.Value.ToString("#,##0")}", Education = p.Educations.Count == 0 ? "-" - : $"{p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Degree} {p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Field}" + : $"{p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Degree} {p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Field}", + AvatarId = p.Avatar == null ? "" : p.Avatar.Id.ToString("D") }).FirstOrDefault(); var data = new List(); @@ -200,7 +201,8 @@ namespace BMA.EHR.Report.Service.Controllers AppointText = c == 1 ? "(เริ่มรับราชการ)" : "", SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(), PositionName = s.PositionName, - OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false) + OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false), + }; data.Add(ret); } @@ -218,6 +220,19 @@ namespace BMA.EHR.Report.Service.Controllers } report.DataSource = data; + + if (profile.AvatarId != "") + { + try + { + // Get avatar Image + var picContent = (await _minioService.DownloadFileAsync(Guid.Parse(profile.AvatarId))).FileContent; + var pictureBox = (Telerik.Reporting.PictureBox)report.Items["groupHeaderSection"].Items["picAvatar"]; + pictureBox.Value = Image.FromStream(new MemoryStream(picContent)); + } + catch { } + } + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); InstanceReportSource instanceReportSource = new InstanceReportSource() @@ -420,7 +435,7 @@ namespace BMA.EHR.Report.Service.Controllers var tblEducation = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblEducation"]; tblEducation.DataSource = education; - if(profile.First().AvatarId != "") + if (profile.First().AvatarId != "") { try { @@ -447,6 +462,15 @@ namespace BMA.EHR.Report.Service.Controllers var content = result.DocumentBytes; // page2 + var profile2 = (from p in _context.Profiles + join pf in _context.Prefixes on p.PrefixId equals pf.Id + where p.Id == id + select new + { + FullName = $"{pf.Name}{p.FirstName} {p.LastName}", + OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false), + }).FirstOrDefault(); + var salary = (from s in _context.ProfileSalaries join pos in _context.PositionPaths on s.PositionId equals pos.Id join pos_no in _context.PositionNumbers on s.PosNoId equals pos_no.Id @@ -464,11 +488,29 @@ namespace BMA.EHR.Report.Service.Controllers RefAll = s.SalaryRef, PositionType = pos_type.Name, PositionLevel = pos_lv.Name, - PositionAmount = s.PositionSalaryAmount, - FullName = $"{s.Profile.FirstName} {s.Profile.LastName}", - OcFullPath = _profileService.GetOrganizationNameFullPath(s.Profile.OcId.Value, false, false), + PositionAmount = s.PositionSalaryAmount == null ? "" : s.PositionSalaryAmount.Value.ToString().ToInteger().ToNumericText(), + FullName = profile2.FullName, + OcFullPath = profile2.OcFullPath }).ToList(); + while (salary.Count < 20) + { + salary.Add(new + { + SalaryDate = "", + Position = "", + PosNo = "", + Rank = "", + Salary = "", + RefAll = "", + PositionType = "", + PositionLevel = "", + PositionAmount = "", + FullName = profile2.FullName, + OcFullPath = profile2.OcFullPath + }); + } + var rptFile2 = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptKK1_Page2.trdp"); ReportPackager reportPackager2 = new ReportPackager(); diff --git a/Report/Profile/rptKK1_Page1.trdp b/Report/Profile/rptKK1_Page1.trdp index 28ffe18..f936f44 100644 Binary files a/Report/Profile/rptKK1_Page1.trdp and b/Report/Profile/rptKK1_Page1.trdp differ diff --git a/Report/Profile/rptShortKp7.trdp b/Report/Profile/rptShortKp7.trdp index 78dce00..5c5dd7a 100644 Binary files a/Report/Profile/rptShortKp7.trdp and b/Report/Profile/rptShortKp7.trdp differ