diff --git a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs index 392cd1ef..0db4c4ab 100644 --- a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs @@ -136,6 +136,21 @@ namespace BMA.EHR.Application.Repositories.Reports return data; } + + public async Task GetExamAvatarCandidateAsync(Guid id) + { + var data = await _dbExamContext.Set().AsQueryable() + .Where(x => x.Id == id) + .Select(p => new + { + AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id, + }) + .FirstOrDefaultAsync(); + + if (data == null) + throw new Exception(GlobalMessages.CandidateNotFound); + return data.AvatarId; + } #endregion #endregion diff --git a/BMA.EHR.Domain/ModelsExam/Candidate/Candidate.cs b/BMA.EHR.Domain/ModelsExam/Candidate/Candidate.cs index 17db4824..497e38b5 100644 --- a/BMA.EHR.Domain/ModelsExam/Candidate/Candidate.cs +++ b/BMA.EHR.Domain/ModelsExam/Candidate/Candidate.cs @@ -78,10 +78,10 @@ namespace BMA.EHR.Domain.ModelsExam.Candidate public string? ResultC { get; set; } [Comment("Id รูปโปรไฟล์")] - public virtual Document? ProfileImg { get; set; } + public Document? ProfileImg { get; set; } [Comment("Id หลักฐานชำระเงิน")] - public virtual Document? PaymentImg { get; set; } + public Document? PaymentImg { get; set; } [Comment("ลำดับที่สอบได้")] public string? Number { get; set; } diff --git a/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs b/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs index ed8e299a..3e797e53 100644 --- a/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs +++ b/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs @@ -24,6 +24,7 @@ namespace BMA.EHR.Infrastructure.Persistence public DbSet Educations { get; set; } public DbSet PeriodExams { get; set; } public DbSet PositionExams { get; set; } + public DbSet Documents { get; set; } #endregion diff --git a/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs b/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs index f734b7ec..a81ad505 100644 --- a/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Authorization; using Swashbuckle.AspNetCore.Annotations; using Telerik.Reporting; using Telerik.Reporting.Processing; +using BMA.EHR.Application.Repositories; +using System.Drawing; namespace BMA.EHR.Report.Service.Controllers { @@ -20,12 +22,15 @@ namespace BMA.EHR.Report.Service.Controllers private readonly CandidateReportRepository _service; private readonly IWebHostEnvironment _hostingEnvironment; private readonly IConfiguration _configuration; + private readonly MinIOService _minIOService; - public CandidateReportController(CandidateReportRepository service, IWebHostEnvironment hostingEnvironment, IConfiguration configuration) + public CandidateReportController(CandidateReportRepository service, IWebHostEnvironment hostingEnvironment, + MinIOService minIOService, IConfiguration configuration) { _service = service; _hostingEnvironment = hostingEnvironment; _configuration = configuration; + _minIOService = minIOService; } #region ใบสมัคร @@ -43,6 +48,7 @@ namespace BMA.EHR.Report.Service.Controllers { var candidate = await _service.GetExamCandidateAsync(Id); var careers = await _service.GetExamCareerCandidateAsync(Id); + var avatar = await _service.GetExamAvatarCandidateAsync(Id); if (candidate != null) { var mimeType = ""; @@ -65,6 +71,18 @@ namespace BMA.EHR.Report.Service.Controllers var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; tblData.DataSource = careers; + if (avatar != Guid.Parse("00000000-0000-0000-0000-000000000000")) + { + try + { + // Get avatar Image + var picContent = (await _minIOService.DownloadFileAsync(avatar)).FileContent; + var pictureBox = (Telerik.Reporting.PictureBox)report.Items["detailSection1"].Items["picAvatar"]; + pictureBox.Value = Image.FromStream(new MemoryStream(picContent)); + } + catch { } + } + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); InstanceReportSource instanceReportSource = new InstanceReportSource() { diff --git a/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp b/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp index bee54d91..def63f0a 100644 Binary files a/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp and b/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp.bak b/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp.bak deleted file mode 100644 index 5eae62b6..00000000 Binary files a/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp.bak and /dev/null differ