diff --git a/BMA.EHR.Report.Service.csproj b/BMA.EHR.Report.Service.csproj
index 6f6930f..96d16fc 100644
--- a/BMA.EHR.Report.Service.csproj
+++ b/BMA.EHR.Report.Service.csproj
@@ -90,9 +90,15 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
+
+ PreserveNewest
+
diff --git a/Controllers/ExamReportController.cs b/Controllers/ExamReportController.cs
index 31bb248..d8bffcf 100644
--- a/Controllers/ExamReportController.cs
+++ b/Controllers/ExamReportController.cs
@@ -249,6 +249,145 @@ namespace BMA.EHR.Report.Service.Controllers
}
}
+ [HttpGet("candidate/{id:length(36)}")]
+ [AllowAnonymous]
+ public async Task> GetCandidateListReportAsync(Guid id)
+ {
+ try
+ {
+ var data = await _context.Disables.AsQueryable()
+ .Include(x => x.PeriodExam)
+ .Where(x => x.PeriodExam.Id == id)
+ .OrderBy(x => x.ExamId)
+ .Select(p => new
+ {
+ ExamId = p.ExamId,
+ FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
+ PositionName = p.PositionName,
+ ExamName =
+ $"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}",
+ }).ToListAsync();
+
+ 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)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> GetPassExamListReportAsync(Guid id)
+ {
+ try
+ {
+ var data = await _context.Disables.AsQueryable()
+ .Include(x => x.PeriodExam)
+ .ThenInclude(x => x.ScoreImport)
+ .Include(x => x.Documents)
+ .ThenInclude(x => x.DocumentFile)
+
+
+ .Join(_context.DisableScores.AsQueryable()
+ .Include(x => x.ScoreImport)
+ .Where(x => x.ScoreImport.PeriodExamId == id)
+ .Where(x => x.ExamStatus == "ผ่าน"),
+ rc => new { id = rc.PeriodExam.Id, examId = rc.ExamId },
+ sc => new { id = sc.ScoreImport.PeriodExamId, examId = sc.ExamId },
+ (p, sr) => new
+ {
+ Id = p.PeriodExam.Id,
+ 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,
+
+
+
+ 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,
+ SumScore = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
+
+
+
+ })
+ .OrderBy(x => x.Number)
+ .Where(x => x.Id == id)
+ .Where(x => x.ExamResult == "ผ่าน")
+ .ToListAsync();
+
+ 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, "เกิดข้อผิดพลาดในการแสดงรายงาน");
+ }
+ }
+
#endregion
}
}
diff --git a/Controllers/RecruitReportController.cs b/Controllers/RecruitReportController.cs
index c95d7bd..d05e2f0 100644
--- a/Controllers/RecruitReportController.cs
+++ b/Controllers/RecruitReportController.cs
@@ -13,36 +13,36 @@ using Telerik.Reporting.Processing;
namespace BMA.EHR.Report.Service.Controllers
{
- [Route("api/v{version:apiVersion}/report/recruit")]
- [ApiVersion("1.0")]
- [ApiController]
- [Produces("application/json")]
- [Authorize]
- [SwaggerTag("รายงานข้อมูลการสอบแข่งขัน")]
- public class RecruitReportController : BaseController
- {
- #region " Fields "
+ [Route("api/v{version:apiVersion}/report/recruit")]
+ [ApiVersion("1.0")]
+ [ApiController]
+ [Produces("application/json")]
+ [Authorize]
+ [SwaggerTag("รายงานข้อมูลการสอบแข่งขัน")]
+ public class RecruitReportController : 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 = "ㅤ";
private readonly RecruitService _recruitService;
- #endregion
+ #endregion
- #region " Constructor and Destructor "
+ #region " Constructor and Destructor "
- public RecruitReportController(ApplicationDbContext context,
- IWebHostEnvironment hostingEnvironment,
- IConfiguration configuration,
+ public RecruitReportController(ApplicationDbContext context,
+ IWebHostEnvironment hostingEnvironment,
+ IConfiguration configuration,
RecruitService recruitService)
- {
- this._context = context;
- this._hostingEnvironment = hostingEnvironment;
- this._configuration = configuration;
+ {
+ this._context = context;
+ this._hostingEnvironment = hostingEnvironment;
+ this._configuration = configuration;
this._recruitService = recruitService;
- }
+ }
#endregion
@@ -61,65 +61,65 @@ namespace BMA.EHR.Report.Service.Controllers
/// เมื่อเกิดข้อผิดพลาดในการทำงาน
[HttpGet("certificate/{type:int}/{id:length(36)}/{examId}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [ProducesResponseType(StatusCodes.Status401Unauthorized)]
- [ProducesResponseType(StatusCodes.Status500InternalServerError)]
- public async Task> GetCertificateReportAsync(Guid id, string examId,int type)
- {
- try
- {
- var data = await _context.Recruits.AsQueryable()
- .Include(x => x.RecruitImport)
- .Where(x => x.RecruitImport.Id == id)
- .Where(x => x.ExamId == examId)
- .Join(_context.RecruitScores.AsQueryable()
- .Include(x => x.ScoreImport),
- rc => new { rc.RecruitImport.Year, rc.ExamId },
- sc => new { sc.ScoreImport.Year, sc.ExamId },
- (p, sr) => new
- {
- ExamID = p.ExamId,
- p.CitizenId,
- Order = p.RecruitImport.Order,
- Year = p.RecruitImport.Year.ToThaiYear(),
- FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
- ExamResult = sr == null ? "" : sr.ExamStatus,
- EndDate = p.RecruitImport.RegisterEndDate == null ? "-" : p.RecruitImport.RegisterEndDate.Value.ToThaiFullDate3(),
- AuthName = "นายณัฐพงศ์ ดิษยบุตร",
- AuthPosition = "หัวหน้าสำนักงาน ก.ก."
- })
- .FirstOrDefaultAsync();
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> GetCertificateReportAsync(Guid id, string examId, int type)
+ {
+ try
+ {
+ var data = await _context.Recruits.AsQueryable()
+ .Include(x => x.RecruitImport)
+ .Where(x => x.RecruitImport.Id == id)
+ .Where(x => x.ExamId == examId)
+ .Join(_context.RecruitScores.AsQueryable()
+ .Include(x => x.ScoreImport),
+ rc => new { rc.RecruitImport.Year, rc.ExamId },
+ sc => new { sc.ScoreImport.Year, sc.ExamId },
+ (p, sr) => new
+ {
+ ExamID = p.ExamId,
+ p.CitizenId,
+ Order = p.RecruitImport.Order,
+ Year = p.RecruitImport.Year.ToThaiYear(),
+ FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
+ ExamResult = sr == null ? "" : sr.ExamStatus,
+ EndDate = p.RecruitImport.RegisterEndDate == null ? "-" : p.RecruitImport.RegisterEndDate.Value.ToThaiFullDate3(),
+ AuthName = "นายณัฐพงศ์ ดิษยบุตร",
+ AuthPosition = "หัวหน้าสำนักงาน ก.ก."
+ })
+ .FirstOrDefaultAsync();
- 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);
- }
+ 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);
+ }
- 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, "เกิดข้อผิดพลาดในการแสดงรายงาน");
+ }
+ }
///
/// แสดงเอกสารผลสอบ
@@ -137,9 +137,9 @@ namespace BMA.EHR.Report.Service.Controllers
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task> GetScoreReportAsync(Guid id, string examId)
- {
- try
- {
+ {
+ try
+ {
var data = await _context.Recruits.AsQueryable()
.Include(x => x.RecruitImport)
.Include(x => x.Documents)
@@ -152,7 +152,7 @@ namespace BMA.EHR.Report.Service.Controllers
sc => new { sc.ScoreImport.Year, sc.ExamId },
(p, sr) => new
{
- ExamId= p.ExamId,
+ ExamId = p.ExamId,
CitizenId = p.CitizenId,
p.Prefix,
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
@@ -160,14 +160,14 @@ namespace BMA.EHR.Report.Service.Controllers
Gender = p.Gendor,
Degree = p.Educations.First().Degree,
Major = p.Educations.First().Major,
-
- ExamResult = sr == null ? "" : sr.ExamStatus,
-
+
+ ExamResult = sr == null ? "" : sr.ExamStatus,
+
University = p.Educations.First().University,
PositionName = p.PositionName,
ExamName = $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
-
-
+
+
Number = sr == null ? "" : sr.Number,
ExamCount = _recruitService.GetExamCount(p.CitizenId),
ScoreExpire = p.RecruitImport.AnnouncementDate == null ? "" : p.RecruitImport.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
@@ -181,7 +181,7 @@ namespace BMA.EHR.Report.Service.Controllers
SumC = sr == null ? 0 : sr.SumC,
-
+
})
.FirstOrDefaultAsync();
@@ -208,11 +208,153 @@ namespace BMA.EHR.Report.Service.Controllers
var content = result.DocumentBytes;
return File(content, "application/pdf", $"ผลคะแนนสอบ_{data.CitizenId}_{data.FullName}.pdf");
}
- catch (Exception ex)
- {
+ catch (Exception ex)
+ {
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
}
- }
+ }
+
+
+ [HttpGet("candidate/{id:length(36)}")]
+ public async Task> GetCandidateListReportAsync(Guid id)
+ {
+ try
+ {
+ var data = await _context.Recruits.AsQueryable()
+ .Include(x => x.RecruitImport)
+ .Include(x => x.Documents)
+ .ThenInclude(x => x.DocumentFile)
+ .Where(x => x.RecruitImport.Id == id)
+ .OrderBy(x => x.ExamId)
+ .Select(p => new
+ {
+ ExamId = p.ExamId,
+ FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
+ PositionName = p.PositionName,
+ ExamName =
+ $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
+ }).ToListAsync();
+
+ 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)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> GetPassExamListReportAsync(Guid id)
+ {
+ try
+ {
+ var data = await _context.Recruits.AsQueryable()
+ .Include(x => x.RecruitImport)
+ .ThenInclude(x => x.ScoreImport)
+ .Include(x => x.Documents)
+ .ThenInclude(x => x.DocumentFile)
+
+
+ .Join(_context.RecruitScores.AsQueryable()
+ .Include(x => x.ScoreImport)
+ .Where(x => x.ScoreImport.RecruitImportId == id)
+ .Where(x => x.ExamStatus == "ผ่าน"),
+ rc => new { id = rc.RecruitImport.Id, examId = rc.ExamId },
+ sc => new { id = sc.ScoreImport.RecruitImportId, examId = sc.ExamId },
+ (p, sr) => new
+ {
+ Id = p.RecruitImport.Id,
+ 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.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
+
+
+ Number = sr == null ? "" : sr.Number,
+ ExamCount = _recruitService.GetExamCount(p.CitizenId),
+ ScoreExpire = p.RecruitImport.AnnouncementDate == null ? "" : p.RecruitImport.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,
+ SumScore = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
+
+
+
+ })
+ .OrderBy(x => x.Number)
+ .Where(x => x.Id == id)
+ .Where(x => x.ExamResult == "ผ่าน")
+ .ToListAsync();
+
+ 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, "เกิดข้อผิดพลาดในการแสดงรายงาน");
+ }
+ }
#endregion
}
diff --git a/Report/Recruit/rptCandidateList.trdp b/Report/Recruit/rptCandidateList.trdp
new file mode 100644
index 0000000..4f6b27e
Binary files /dev/null and b/Report/Recruit/rptCandidateList.trdp differ
diff --git a/Report/Recruit/rptPassExamList.trdp b/Report/Recruit/rptPassExamList.trdp
new file mode 100644
index 0000000..ea03174
Binary files /dev/null and b/Report/Recruit/rptPassExamList.trdp differ