report ประวัติทำงาน

This commit is contained in:
Kittapath 2023-10-09 11:25:07 +07:00
parent 0043e86fa3
commit 4e90ffadb2
7 changed files with 46 additions and 34 deletions

View file

@ -0,0 +1,14 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Common.Interfaces
{
public interface IApplicationDBExamContext
{
DbSet<T> Set<T>() where T : class;
void Attatch<T>(T entity) where T : class;
Task<int> SaveChangesAsync();
}
}

View file

@ -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<dynamic> GetExamCandidateAsync(Guid id)
{
var data = await _dbContext.Set<Candidate>().AsQueryable()
var data = await _dbExamContext.Set<Candidate>().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<dynamic> GetExamCareerCandidateAsync(Guid id)
{
var data = await _dbExamContext.Set<Career>().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

View file

@ -41,7 +41,7 @@ namespace BMA.EHR.Infrastructure
}),
ServiceLifetime.Transient);
services.AddScoped<IApplicationDBContext>(provider => provider.GetService<ApplicationDBExamContext>());
services.AddScoped<IApplicationDBExamContext>(provider => provider.GetService<ApplicationDBExamContext>());
return services;
}

View file

@ -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<Candidate> Candidates { get; set; }

View file

@ -42,6 +42,7 @@ namespace BMA.EHR.Report.Service.Controllers
public async Task<ActionResult<ResponseObject>> 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()
{