Merge branch 'develop' into working
# Conflicts: # Controllers/DisableReportController.cs
This commit is contained in:
commit
072f150eed
34 changed files with 15259 additions and 2576 deletions
|
|
@ -38,6 +38,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly MetadataDbContext _contextMetadata;
|
||||
private readonly MinIOService _minioService;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly DisableService _disableService;
|
||||
|
|
@ -50,6 +51,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
#region " Constructor and Destructor "
|
||||
|
||||
public DisableController(ApplicationDbContext context,
|
||||
MetadataDbContext contextMetadata,
|
||||
MinIOService minioService,
|
||||
IWebHostEnvironment webHostEnvironment,
|
||||
DisableService disableService,
|
||||
|
|
@ -57,6 +59,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
ILogger<DisableController> logger)
|
||||
{
|
||||
_context = context;
|
||||
_contextMetadata = contextMetadata;
|
||||
_minioService = minioService;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_disableService = disableService;
|
||||
|
|
@ -175,6 +178,32 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
throw;
|
||||
}
|
||||
}
|
||||
private List<Guid?> GetAllIdByRoot(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ret = new List<Guid?>();
|
||||
|
||||
var oc = _contextMetadata.Organizations.FirstOrDefault(x => x.Id == id && x.IsActive);
|
||||
if (oc != null)
|
||||
ret.Add(oc.Id);
|
||||
|
||||
var child = _contextMetadata.Organizations.AsQueryable().Where(x => x.ParentId == id && x.IsActive).ToList();
|
||||
if (child.Any())
|
||||
{
|
||||
foreach (var item in child)
|
||||
{
|
||||
ret.AddRange(GetAllIdByRoot(item.Id));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -659,11 +688,49 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
||||
ScoreCount = x.ScoreImport.Scores.Count(),
|
||||
|
||||
}
|
||||
},
|
||||
x.CreatedUserId,
|
||||
})
|
||||
.ToListAsync();
|
||||
var profileOrganizations = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||
.ToListAsync();
|
||||
var _periodExams = (from x in data
|
||||
join po in profileOrganizations on Guid.Parse(x.CreatedUserId) equals po?.UserId into poGroup
|
||||
from po in poGroup.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
x.Id,
|
||||
x.Year,
|
||||
x.Name,
|
||||
x.Round,
|
||||
x.ImportDate,
|
||||
x.ExamCount,
|
||||
x.Score,
|
||||
x.CreatedUserId,
|
||||
OcId = po == null ? null : po.OrganizationId,
|
||||
}).AsQueryable()
|
||||
.ToList();
|
||||
|
||||
return Success(data);
|
||||
var roles = _httpContextAccessor?.HttpContext?.User?.FindAll(ClaimTypes.Role)?.Select(c => c.Value).ToList();
|
||||
if (!roles.Contains("head"))
|
||||
{
|
||||
var criteria = new List<Guid?>();
|
||||
var profileOrganization = await _contextMetadata.ProfileOrganizations.AsQueryable()
|
||||
.FirstOrDefaultAsync(x => x.UserId == Guid.Parse(UserId));
|
||||
|
||||
if (profileOrganization == null)
|
||||
return Success(new List<dynamic>());
|
||||
|
||||
var ocId = _contextMetadata.Organizations.AsQueryable()
|
||||
.FirstOrDefault(x => x.Id == profileOrganization.OrganizationId);
|
||||
if (ocId == null)
|
||||
return Success(new List<dynamic>());
|
||||
criteria = GetAllIdByRoot(ocId.Id);
|
||||
if (criteria.Any())
|
||||
_periodExams = _periodExams.Where(x => x.CreatedUserId == UserId || criteria.Contains(x.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OcId)).ToList();
|
||||
}
|
||||
|
||||
return Success(_periodExams);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1619,7 +1686,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
Number = sr == null ? "" : sr.Number,
|
||||
CitizenId = p.CitizenId,
|
||||
ExamCount = 0,
|
||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.AddYears(2).ToThaiShortDate(),
|
||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
||||
ScoreResult = sr == null ? null : new
|
||||
{
|
||||
ScoreAFull = sr.FullA,
|
||||
|
|
@ -1669,11 +1736,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
announcement_startDate = r.AnnouncementStartDate == null ? "" : r.AnnouncementStartDate.ToString("yyyy-mm-dd"),
|
||||
announcement_endDate = r.AnnouncementEndDate == null ? "" : r.AnnouncementEndDate.ToString("yyyy-MM-dd"),
|
||||
announcementExam = true,
|
||||
register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.ToString("yyyy-MM-dd"),
|
||||
register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.ToString("yyyy-MM-dd"),
|
||||
payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.ToString("yyyy-MM-dd"),
|
||||
payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.ToString("yyyy-MM-dd"),
|
||||
exam_date = r.ExamDate == null ? "" : r.ExamDate.ToString("yyyy-MM-dd")
|
||||
register_startDate = r.RegisterStartDate == null ? "" : r.RegisterStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
register_endDate = r.RegisterEndDate == null ? "" : r.RegisterEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_startDate = r.PaymentStartDate == null ? "" : r.PaymentStartDate.Value.ToString("yyyy-MM-dd"),
|
||||
payment_endDate = r.PaymentEndDate == null ? "" : r.PaymentEndDate.Value.ToString("yyyy-MM-dd"),
|
||||
exam_date = r.ExamDate == null ? "" : r.ExamDate.Value.ToString("yyyy-MM-dd")
|
||||
|
||||
})
|
||||
.ToList();
|
||||
|
|
|
|||
|
|
@ -15,240 +15,240 @@ using BMA.EHR.Recurit.Exam.Service.Models;
|
|||
|
||||
namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/candidate/disable-exam/report")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("รายงานข้อมูลการสอบแข่งขัน")]
|
||||
public class DisableReportController : BaseController
|
||||
{
|
||||
#region " Fields "
|
||||
[Route("api/v{version:apiVersion}/candidate/disable-exam/report")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
[SwaggerTag("รายงานข้อมูลการสอบแข่งขัน")]
|
||||
public class DisableReportController : BaseController
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string space = "ㅤ";
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string space = "ㅤ";
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public DisableReportController(ApplicationDbContext context,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IConfiguration configuration,
|
||||
DisableService disableService)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
}
|
||||
public DisableReportController(ApplicationDbContext context,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IConfiguration configuration,
|
||||
DisableService disableService)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
private int GetExamCountTes(string citizenId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = _context.Candidates.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
#endregion
|
||||
private int GetExamCountTes(string citizenId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = _context.Candidates.AsQueryable()
|
||||
.Where(x => x.CitizenId == citizenId)
|
||||
.Count();
|
||||
|
||||
return count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#region " Methods "
|
||||
#region " Methods "
|
||||
|
||||
/// <summary>
|
||||
/// แสดงหนังสือรับรอง
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสรอบการสอบ</param>
|
||||
/// <param name="examId">เลขประจำตัวผู้สมัครสอบ</param>
|
||||
/// <param name="type">ชนิดของรายงาน</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
/// <summary>
|
||||
/// แสดงหนังสือรับรอง
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสรอบการสอบ</param>
|
||||
/// <param name="examId">เลขประจำตัวผู้สมัครสอบ</param>
|
||||
/// <param name="type">ชนิดของรายงาน</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
|
||||
[HttpGet("certificate/{type:int}/{id:length(36)}/{examId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCertificateReportAsync(Guid id, string examId, int type)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
.Where(x => x.ExamId == examId)
|
||||
.Join(_context.DisableScores.AsQueryable()
|
||||
.Include(x => x.ScoreImport),
|
||||
rc => new { rc.PeriodExam.Year, rc.ExamId },
|
||||
sc => new { sc.ScoreImport.Year, sc.ExamId },
|
||||
(p, sr) => new
|
||||
{
|
||||
ExamID = p.ExamId,
|
||||
p.CitizenId,
|
||||
Order = p.PeriodExam.Round,
|
||||
Year = p.PeriodExam.Year.Value.ToThaiYear(),
|
||||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
EndDate = p.PeriodExam.RegisterEndDate.ToThaiFullDate3(),
|
||||
AuthName = "นายณัฐพงศ์ ดิษยบุตร",
|
||||
AuthPosition = "หัวหน้าสำนักงาน ก.ก."
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
[HttpGet("certificate/{type:int}/{id:length(36)}/{examId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCertificateReportAsync(Guid id, string examId, int type)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
.Where(x => x.ExamId == examId)
|
||||
.Join(_context.DisableScores.AsQueryable()
|
||||
.Include(x => x.ScoreImport),
|
||||
rc => new { rc.PeriodExam.Year, rc.ExamId },
|
||||
sc => new { sc.ScoreImport.Year, sc.ExamId },
|
||||
(p, sr) => new
|
||||
{
|
||||
ExamID = p.ExamId,
|
||||
p.CitizenId,
|
||||
Order = p.PeriodExam.Round,
|
||||
Year = p.PeriodExam.Year.Value.ToThaiYear(),
|
||||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
EndDate = p.PeriodExam.RegisterEndDate == null ? null : p.PeriodExam.RegisterEndDate.Value.ToThaiFullDate3(),
|
||||
AuthName = "นายณัฐพงศ์ ดิษยบุตร",
|
||||
AuthPosition = "หัวหน้าสำนักงาน ก.ก."
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCertificate{type}.trdp");
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCertificate{type}.trdp");
|
||||
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
|
||||
report.DataSource = data;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
report.DataSource = data;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"หนังสือรับรอง_{data.CitizenId}_{data.FullName}.pdf");
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"หนังสือรับรอง_{data.CitizenId}_{data.FullName}.pdf");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// แสดงเอกสารผลสอบ
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสรอบการสอบ</param>
|
||||
/// <param name="examId">เลขประจำตัวผู้สมัครสอบ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("score/{id:length(36)}/{examId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetScoreReportAsync(Guid id, string examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Include(x => x.Documents)
|
||||
.ThenInclude(x => x.DocumentFile)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
.Where(x => x.ExamId == examId)
|
||||
.Join(_context.DisableScores.AsQueryable()
|
||||
.Include(x => x.ScoreImport),
|
||||
rc => new { rc.PeriodExam.Year, rc.ExamId },
|
||||
sc => new { sc.ScoreImport.Year, sc.ExamId },
|
||||
(p, sr) => new
|
||||
{
|
||||
ExamId = p.ExamId,
|
||||
CitizenId = p.CitizenId,
|
||||
p.Prefix,
|
||||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
||||
Gender = p.Gendor,
|
||||
Degree = p.Educations.First().Degree,
|
||||
Major = p.Educations.First().Major,
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
University = p.Educations.First().University,
|
||||
PositionName = p.PositionName,
|
||||
ExamName = $"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||
Number = sr == null ? "" : sr.Number,
|
||||
// ExamCount = 10,
|
||||
// ExamCount = GetExamCountTes(p.CitizenId),
|
||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.AddYears(2).ToThaiShortDate(),
|
||||
FullA = sr == null ? 0 : sr.FullA,
|
||||
SumA = sr == null ? 0 : sr.SumA,
|
||||
FullB = sr == null ? 0 : sr.FullB,
|
||||
SumB = sr == null ? 0 : sr.SumB,
|
||||
FullC = sr == null ? 0 : sr.FullC,
|
||||
SumC = sr == null ? 0 : sr.SumC,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptExamResult.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
/// <summary>
|
||||
/// แสดงเอกสารผลสอบ
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสรอบการสอบ</param>
|
||||
/// <param name="examId">เลขประจำตัวผู้สมัครสอบ</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("score/{id:length(36)}/{examId}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetScoreReportAsync(Guid id, string examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.Disables.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Include(x => x.Documents)
|
||||
.ThenInclude(x => x.DocumentFile)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
.Where(x => x.ExamId == examId)
|
||||
.Join(_context.DisableScores.AsQueryable()
|
||||
.Include(x => x.ScoreImport),
|
||||
rc => new { rc.PeriodExam.Year, rc.ExamId },
|
||||
sc => new { sc.ScoreImport.Year, sc.ExamId },
|
||||
(p, sr) => new
|
||||
{
|
||||
ExamId = p.ExamId,
|
||||
CitizenId = p.CitizenId,
|
||||
p.Prefix,
|
||||
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
||||
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
||||
Gender = p.Gendor,
|
||||
Degree = p.Educations.First().Degree,
|
||||
Major = p.Educations.First().Major,
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
University = p.Educations.First().University,
|
||||
PositionName = p.PositionName,
|
||||
ExamName = $"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||
Number = sr == null ? "" : sr.Number,
|
||||
// ExamCount = 10,
|
||||
// ExamCount = GetExamCountTes(p.CitizenId),
|
||||
ScoreExpire = p.PeriodExam.AnnouncementDate == null ? "" : p.PeriodExam.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
||||
FullA = sr == null ? 0 : sr.FullA,
|
||||
SumA = sr == null ? 0 : sr.SumA,
|
||||
FullB = sr == null ? 0 : sr.FullB,
|
||||
SumB = sr == null ? 0 : sr.SumB,
|
||||
FullC = sr == null ? 0 : sr.FullC,
|
||||
SumC = sr == null ? 0 : sr.SumC,
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptExamResult.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
|
||||
report.DataSource = data;
|
||||
if (data != null)
|
||||
{
|
||||
var _data = new
|
||||
{
|
||||
ExamId = data.ExamId,
|
||||
CitizenId = data.CitizenId,
|
||||
Prefix = data.Prefix,
|
||||
FullName = data.FullName,
|
||||
DateOfBirth = data.DateOfBirth,
|
||||
Gender = data.Gender,
|
||||
Degree = data.Degree,
|
||||
Major = data.Major,
|
||||
ExamResult = data.ExamResult,
|
||||
University = data.University,
|
||||
PositionName = data.PositionName,
|
||||
ExamName = data.ExamName,
|
||||
Number = data.Number,
|
||||
ExamCount = GetExamCountTes(data.CitizenId),
|
||||
ScoreExpire = data.ScoreExpire,
|
||||
FullA = data.FullA,
|
||||
SumA = data.SumA,
|
||||
FullB = data.FullB,
|
||||
SumB = data.SumB,
|
||||
FullC = data.FullC,
|
||||
SumC = data.SumC,
|
||||
};
|
||||
report.DataSource = _data;
|
||||
}
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
report.DataSource = data;
|
||||
if (data != null)
|
||||
{
|
||||
var _data = new
|
||||
{
|
||||
ExamId = data.ExamId,
|
||||
CitizenId = data.CitizenId,
|
||||
Prefix = data.Prefix,
|
||||
FullName = data.FullName,
|
||||
DateOfBirth = data.DateOfBirth,
|
||||
Gender = data.Gender,
|
||||
Degree = data.Degree,
|
||||
Major = data.Major,
|
||||
ExamResult = data.ExamResult,
|
||||
University = data.University,
|
||||
PositionName = data.PositionName,
|
||||
ExamName = data.ExamName,
|
||||
Number = data.Number,
|
||||
ExamCount = GetExamCountTes(data.CitizenId),
|
||||
ScoreExpire = data.ScoreExpire,
|
||||
FullA = data.FullA,
|
||||
SumA = data.SumA,
|
||||
FullB = data.FullB,
|
||||
SumB = data.SumB,
|
||||
FullC = data.FullC,
|
||||
SumC = data.SumC,
|
||||
};
|
||||
report.DataSource = _data;
|
||||
}
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"ผลคะแนนสอบ_{data.CitizenId}_{data.FullName}.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"ผลคะแนนสอบ_{data.CitizenId}_{data.FullName}.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -804,6 +804,34 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
|
|||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// โหลดผู้สมัครสอบ(รายละเอียดชำระเงิน)
|
||||
/// </summary>
|
||||
/// <param name="examId">รหัสรอบสมัคร</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบ(รายละเอียดชำระเงิน)สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("download/payment/{examId:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> DownloadCandidatePaymentAllAsync(string examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stream = await _periodExamService.DownloadCandidatePaymentAllAsync(examId);
|
||||
|
||||
string excelName = $"Candidate_Payment_{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx";
|
||||
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName);
|
||||
// return Success();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue