แก้ไขรายงาน และส่วนของการแสดงภาพ Avatar

This commit is contained in:
Suphonchai Phoonsawat 2023-05-11 10:59:04 +07:00
parent f7d24cacc1
commit 2f3a07d6cd
3 changed files with 48 additions and 6 deletions

View file

@ -106,7 +106,8 @@ namespace BMA.EHR.Report.Service.Controllers
SalaryAmount = p.Salaries.Count == 0 ? "-" SalaryAmount = p.Salaries.Count == 0 ? "-"
: $"{p.Salaries.OrderByDescending(s => s.Date.Value).FirstOrDefault().Amount.Value.ToString("#,##0")}", : $"{p.Salaries.OrderByDescending(s => s.Date.Value).FirstOrDefault().Amount.Value.ToString("#,##0")}",
Education = p.Educations.Count == 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(); }).FirstOrDefault();
var data = new List<dynamic>(); var data = new List<dynamic>();
@ -200,7 +201,8 @@ namespace BMA.EHR.Report.Service.Controllers
AppointText = c == 1 ? "(เริ่มรับราชการ)" : "", AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(), SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
PositionName = s.PositionName, PositionName = s.PositionName,
OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false) OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false),
}; };
data.Add(ret); data.Add(ret);
} }
@ -218,6 +220,19 @@ namespace BMA.EHR.Report.Service.Controllers
} }
report.DataSource = data; 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(); System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource() InstanceReportSource instanceReportSource = new InstanceReportSource()
@ -447,6 +462,15 @@ namespace BMA.EHR.Report.Service.Controllers
var content = result.DocumentBytes; var content = result.DocumentBytes;
// page2 // 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 var salary = (from s in _context.ProfileSalaries
join pos in _context.PositionPaths on s.PositionId equals pos.Id join pos in _context.PositionPaths on s.PositionId equals pos.Id
join pos_no in _context.PositionNumbers on s.PosNoId equals pos_no.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, RefAll = s.SalaryRef,
PositionType = pos_type.Name, PositionType = pos_type.Name,
PositionLevel = pos_lv.Name, PositionLevel = pos_lv.Name,
PositionAmount = s.PositionSalaryAmount, PositionAmount = s.PositionSalaryAmount == null ? "" : s.PositionSalaryAmount.Value.ToString().ToInteger().ToNumericText(),
FullName = $"{s.Profile.FirstName} {s.Profile.LastName}", FullName = profile2.FullName,
OcFullPath = _profileService.GetOrganizationNameFullPath(s.Profile.OcId.Value, false, false), OcFullPath = profile2.OcFullPath
}).ToList(); }).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"); var rptFile2 = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptKK1_Page2.trdp");
ReportPackager reportPackager2 = new ReportPackager(); ReportPackager reportPackager2 = new ReportPackager();

Binary file not shown.

Binary file not shown.