diff --git a/BMA.EHR.Application/Common/Interfaces/IApplicationDBExamContext.cs b/BMA.EHR.Application/Common/Interfaces/IApplicationDBExamContext.cs new file mode 100644 index 00000000..ef2ca3a7 --- /dev/null +++ b/BMA.EHR.Application/Common/Interfaces/IApplicationDBExamContext.cs @@ -0,0 +1,14 @@ +using BMA.EHR.Domain.Models.MetaData; +using Microsoft.EntityFrameworkCore; + +namespace BMA.EHR.Application.Common.Interfaces +{ + public interface IApplicationDBExamContext + { + DbSet Set() where T : class; + + void Attatch(T entity) where T : class; + + Task SaveChangesAsync(); + } +} diff --git a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs index bc9e36ff..392cd1ef 100644 --- a/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/CandidateReportRepository.cs @@ -20,6 +20,7 @@ namespace BMA.EHR.Application.Repositories.Reports #region " Fields " private readonly IApplicationDBContext _dbContext; + private readonly IApplicationDBExamContext _dbExamContext; private readonly IWebHostEnvironment _hostingEnvironment; private readonly MinIOService _documentService; private readonly OrganizationCommonRepository _organizationCommonRepository; @@ -29,11 +30,13 @@ namespace BMA.EHR.Application.Repositories.Reports #region " Constructor and Destructor " public CandidateReportRepository(IApplicationDBContext dbContext, - MinIOService documentService, - OrganizationCommonRepository organizationCommonRepository, - IWebHostEnvironment hostEnvironment) + IApplicationDBExamContext dbExamContext, + MinIOService documentService, + OrganizationCommonRepository organizationCommonRepository, + IWebHostEnvironment hostEnvironment) { _dbContext = dbContext; + _dbExamContext = dbExamContext; _hostingEnvironment = hostEnvironment; _organizationCommonRepository = organizationCommonRepository; _documentService = documentService; @@ -46,11 +49,12 @@ namespace BMA.EHR.Application.Repositories.Reports #region ใบสมัครสอบ public async Task GetExamCandidateAsync(Guid id) { - var data = await _dbContext.Set().AsQueryable() + var data = await _dbExamContext.Set().AsQueryable() .Where(x => x.Id == id) .Select(p => new { p.Id, + AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id, ExamIdenNumber = p.ExamIdenNumber, PositionName = p.PositionExam == null ? "" : p.PositionExam.PositionName, PeriodExamName = p.PeriodExam == null ? "" : p.PeriodExam.Name, @@ -88,7 +92,7 @@ namespace BMA.EHR.Application.Repositories.Reports DurationStart = y.DurationStart.ToThaiShortDate2(), DurationEnd = y.DurationEnd.ToThaiShortDate2(), RangeDate = y.RangeDate, - }), + }).ToList(), RegistAddress = p.RegistAddress, RegistProvinceName = p.RegistProvinceName, @@ -114,34 +118,23 @@ namespace BMA.EHR.Application.Repositories.Reports if (data == null) throw new Exception(GlobalMessages.CandidateNotFound); return data; + } + public async Task GetExamCareerCandidateAsync(Guid id) + { + var data = await _dbExamContext.Set().AsQueryable() + .Where(x => x.Candidate != null) + .Where(x => x.Candidate.Id == id) + .Select(p => new + { + Position = p.Position, + Type = p.Type, + DurationStart = p.DurationStart.ToThaiShortDate2(), + DurationEnd = p.DurationEnd.ToThaiShortDate2(), + RangeDate = p.RangeDate, + }) + .ToListAsync(); - // string Prefix = string.IsNullOrEmpty(data.Prefix.ToString()) ? string.Empty : data.Prefix.ToString(); - // string FirstName = string.IsNullOrEmpty(data.FirstName.ToString()) ? string.Empty : data.FirstName.ToString(); - // string LastName = string.IsNullOrEmpty(data.LastName.ToString()) ? string.Empty : data.LastName.ToString(); - // string FullName = $"{Prefix} {FirstName} {LastName}"; - // string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "วันที่ - เดือน - พ.ศ. -" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber(); - // string CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber(); - // return new - // { - // FullName, - // Date, - // CurrentDate, - // data.Position, - // data.PositionExecutive, - // data.PositionType, - // data.PositionLine, - // data.PositionLevel, - // data.Organization, - // data.PositionId, - // data.PositionExecutiveId, - // data.PositionTypeId, - // data.PositionLineId, - // data.PositionLevelId, - // data.OrganizationId, - // data.Number, - // data.Location, - // data.Reason, - // }; + return data; } #endregion diff --git a/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs b/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs index 9c6923d7..9b92e779 100644 --- a/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs +++ b/BMA.EHR.Infrastructure/InfrastructureServiceRegistration.cs @@ -41,7 +41,7 @@ namespace BMA.EHR.Infrastructure }), ServiceLifetime.Transient); - services.AddScoped(provider => provider.GetService()); + services.AddScoped(provider => provider.GetService()); return services; } diff --git a/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs b/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs index 7b723d77..ed8e299a 100644 --- a/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs +++ b/BMA.EHR.Infrastructure/Persistence/ApplicationDBExamContext.cs @@ -16,7 +16,7 @@ using Microsoft.EntityFrameworkCore; namespace BMA.EHR.Infrastructure.Persistence { - public class ApplicationDBExamContext : DbContext, IApplicationDBContext + public class ApplicationDBExamContext : DbContext, IApplicationDBExamContext { #region " From Existing Database " public DbSet Candidates { get; set; } diff --git a/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs b/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs index fdf60331..f734b7ec 100644 --- a/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CandidateReportController.cs @@ -42,6 +42,7 @@ namespace BMA.EHR.Report.Service.Controllers public async Task> GetExamCandidate([FromRoute] Guid Id, string exportType = "pdf") { var candidate = await _service.GetExamCandidateAsync(Id); + var careers = await _service.GetExamCareerCandidateAsync(Id); if (candidate != null) { var mimeType = ""; @@ -60,6 +61,10 @@ namespace BMA.EHR.Report.Service.Controllers report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); } report.DataSource = candidate; + + var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + tblData.DataSource = careers; + 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 82cf8558..bee54d91 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 new file mode 100644 index 00000000..5eae62b6 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/ผลสอบคัดเลือกรายบุคคล.trdp.bak differ