รายงานสอบคัดเลือก
This commit is contained in:
parent
e98888ee3a
commit
58b890d6a5
2 changed files with 130 additions and 0 deletions
|
|
@ -298,6 +298,58 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
[HttpGet("candidate-exam/{id:length(36)}")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetCandidateExamListReportAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.Candidates.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.Where(x => x.PeriodExam.Id == id)
|
||||
.Where(x => x.SeatNumber != null || x.SeatNumber != "")
|
||||
.OrderBy(x => x.SeatNumber)
|
||||
.Select(p => new
|
||||
{
|
||||
ExamId = p.SeatNumber,
|
||||
FullName = $"{p.FirstName} {p.LastName}",
|
||||
PositionName = "",
|
||||
ExamName =
|
||||
$"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||
}).ToListAsync();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCandidateList.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;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}.pdf");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("pass/{id:length(36)}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
|
|
@ -360,6 +412,80 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
.Where(x => x.ExamResult == "ผ่าน")
|
||||
.ToListAsync();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.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;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report
|
||||
};
|
||||
|
||||
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายชื่อผู้สอบแข่งขันได้_{data.First().ExamName}.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("pass-exam/{id:length(36)}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetPassExam2ListReportAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _context.Candidates.AsQueryable()
|
||||
.Include(x => x.PeriodExam)
|
||||
.ThenInclude(x => x.ScoreImport)
|
||||
|
||||
.Select(p => new
|
||||
{
|
||||
Id = p.PeriodExam.Id,
|
||||
ExamId = p.SeatNumber,
|
||||
CitizenId = p.CitizenId,
|
||||
FullName = $"{p.FirstName} {p.LastName}",
|
||||
DateOfBirth = p.DateOfBirth.Value.ToThaiShortDate(),
|
||||
|
||||
ExamName = $"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
|
||||
|
||||
Number = p.Number,
|
||||
|
||||
FullA = 0,
|
||||
SumA =0,
|
||||
FullB = p.PointTotalB,
|
||||
SumB = p.PointB,
|
||||
FullC = p.PointTotalC,
|
||||
SumC = p.PointC,
|
||||
SumScore = p.PointB + p.PointC,
|
||||
ExamResult = p.Pass
|
||||
|
||||
})
|
||||
.OrderBy(x => x.Number)
|
||||
.Where(x => x.Id == id)
|
||||
.Where(x => x.ExamResult == "ผ่าน")
|
||||
.ToListAsync();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report report = null;
|
||||
|
|
|
|||
|
|
@ -236,6 +236,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
$"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
|
||||
}).ToListAsync();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCandidateList.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report report = null;
|
||||
|
|
@ -329,6 +331,8 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
.Where(x => x.ExamResult == "ผ่าน")
|
||||
.ToListAsync();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report report = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue