2025-02-18 09:49:54 +07:00
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
|
using BMA.EHR.Organization.Service.Extensions;
|
2023-04-17 21:24:52 +07:00
|
|
|
|
using BMA.EHR.Profile.Service.Controllers;
|
2023-04-25 22:36:58 +07:00
|
|
|
|
using BMA.EHR.Recruit.Service.Services;
|
2023-04-17 21:24:52 +07:00
|
|
|
|
using BMA.EHR.Report.Service.Data;
|
|
|
|
|
|
using BMA.EHR.Report.Service.Responses;
|
2025-11-12 23:23:04 +07:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using iText.Kernel.Font;
|
|
|
|
|
|
using iText.Kernel.Pdf;
|
|
|
|
|
|
using iText.Layout.Element;
|
|
|
|
|
|
using iText.Layout.Properties;
|
|
|
|
|
|
using iText.Layout;
|
|
|
|
|
|
using iText.IO.Font;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System;
|
2023-04-17 21:24:52 +07:00
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2025-02-18 09:49:54 +07:00
|
|
|
|
using Newtonsoft.Json;
|
2023-04-17 21:24:52 +07:00
|
|
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
|
|
|
|
using Telerik.Reporting;
|
|
|
|
|
|
using Telerik.Reporting.Processing;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BMA.EHR.Report.Service.Controllers
|
|
|
|
|
|
{
|
2024-05-24 13:49:17 +07:00
|
|
|
|
[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 RecruitService _recruitService;
|
2025-02-18 09:49:54 +07:00
|
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
2024-05-24 13:49:17 +07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region " Constructor and Destructor "
|
|
|
|
|
|
|
|
|
|
|
|
public RecruitReportController(ApplicationDbContext context,
|
|
|
|
|
|
IWebHostEnvironment hostingEnvironment,
|
|
|
|
|
|
IConfiguration configuration,
|
2025-02-18 09:49:54 +07:00
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
2024-05-24 13:49:17 +07:00
|
|
|
|
RecruitService recruitService)
|
|
|
|
|
|
{
|
|
|
|
|
|
this._context = context;
|
|
|
|
|
|
this._hostingEnvironment = hostingEnvironment;
|
|
|
|
|
|
this._configuration = configuration;
|
|
|
|
|
|
this._recruitService = recruitService;
|
2025-02-18 09:49:54 +07:00
|
|
|
|
this._httpContextAccessor = httpContextAccessor;
|
2024-05-24 13:49:17 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-18 09:49:54 +07:00
|
|
|
|
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
|
2024-05-24 13:49:17 +07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#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>
|
|
|
|
|
|
|
|
|
|
|
|
[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
|
|
|
|
|
|
{
|
2025-09-15 00:11:36 +07:00
|
|
|
|
var _data = await _context.Recruits.AsQueryable()
|
|
|
|
|
|
.Include(x => x.RecruitImport)
|
|
|
|
|
|
.Where(x => x.RecruitImport.Id == id)
|
|
|
|
|
|
.Where(x => x.ExamId == examId)
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
|
if (_data == null)
|
|
|
|
|
|
return Error("ไม่พบข้อมูลในระบบ");
|
|
|
|
|
|
|
2025-09-15 16:03:21 +07:00
|
|
|
|
// if (_data.AuthName == null || _data.AuthName == "")
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var apiUrl = $"{_configuration["API"]}/org/find/head/officer";
|
|
|
|
|
|
// using (var client = new HttpClient())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
|
|
|
|
|
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
|
|
|
|
|
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
|
|
|
|
|
// var _res = await client.SendAsync(_req);
|
|
|
|
|
|
// var _result = await _res.Content.ReadAsStringAsync();
|
|
|
|
|
|
// if (_res.IsSuccessStatusCode)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// var org = JsonConvert.DeserializeObject<dynamic>(_result);
|
|
|
|
|
|
// _data.AuthName = org.result.name == null ? "" : org.result.name;
|
|
|
|
|
|
// _data.AuthPosition = org.result.position == null ? "" : org.result.position;
|
|
|
|
|
|
// await _context.SaveChangesAsync();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2025-09-15 00:11:36 +07:00
|
|
|
|
|
2024-05-24 13:49:17 +07:00
|
|
|
|
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(),
|
2025-09-15 16:03:21 +07:00
|
|
|
|
AuthName = p.RecruitImport.AuthName,
|
|
|
|
|
|
AuthPosition = p.RecruitImport.AuthPosition
|
2024-05-24 13:49:17 +07:00
|
|
|
|
})
|
|
|
|
|
|
.FirstOrDefaultAsync();
|
2025-09-08 14:08:49 +07:00
|
|
|
|
if (data == null)
|
|
|
|
|
|
return Error("ไม่พบข้อมูลในระบบ");
|
2024-05-24 13:49:17 +07:00
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
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.CitizenId}_{data.FullName}.pdf");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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.Recruits.AsQueryable()
|
|
|
|
|
|
.Include(x => x.RecruitImport)
|
|
|
|
|
|
.Include(x => x.Documents)
|
|
|
|
|
|
.ThenInclude(x => x.DocumentFile)
|
|
|
|
|
|
.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,
|
|
|
|
|
|
CitizenId = p.CitizenId,
|
|
|
|
|
|
p.Prefix,
|
|
|
|
|
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
2025-10-27 11:24:40 +07:00
|
|
|
|
DateOfBirth = p.DateOfBirth.HasValue && p.DateOfBirth.Value != DateTime.MinValue
|
|
|
|
|
|
? p.DateOfBirth.Value.ToThaiShortDate()
|
|
|
|
|
|
: "",
|
2024-05-24 13:49:17 +07:00
|
|
|
|
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(),
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-25 15:51:22 +07:00
|
|
|
|
FullA = sr == null ? 0.0 : sr.FullA,
|
|
|
|
|
|
SumA = sr == null ? 0.0 : sr.SumA,
|
2025-09-03 11:18:56 +07:00
|
|
|
|
//FullB = sr == null ? 0.0 : sr.FullB,
|
|
|
|
|
|
//SumB = sr == null ? 0.0 : sr.SumB,
|
2025-03-25 15:51:22 +07:00
|
|
|
|
FullC = sr == null ? 0.0 : sr.FullC,
|
|
|
|
|
|
SumC = sr == null ? 0.0 : sr.SumC,
|
2024-05-24 13:49:17 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
.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;
|
|
|
|
|
|
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.CitizenId}_{data.FullName}.pdf");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("candidate/{id:length(36)}")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> 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
|
|
|
|
|
|
{
|
2024-08-11 13:39:12 +07:00
|
|
|
|
ExamId = p.ExamId != null ? p.ExamId.ToThaiNumber() : string.Empty,
|
2024-05-24 13:49:17 +07:00
|
|
|
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
|
|
|
|
|
PositionName = p.PositionName,
|
|
|
|
|
|
ExamName =
|
2025-09-07 23:29:01 +07:00
|
|
|
|
$"ครั้งที่ {(p.RecruitImport != null ? p.RecruitImport.Order.ToString().ToThaiNumber() : "")}/{(p.RecruitImport != null ? p.RecruitImport.Year.ToThaiYear().ToString().ToThaiNumber() : "")}",
|
2024-05-24 13:49:17 +07:00
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
2024-08-11 13:39:12 +07:00
|
|
|
|
if (data.Count == 0) return Error("ไม่พบข้อมูลในระบบ");
|
2024-05-24 13:49:17 +07:00
|
|
|
|
|
2025-01-08 17:44:55 +07:00
|
|
|
|
//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;
|
|
|
|
|
|
//report.ReportParameters["ExamName"].Value = data[0].ExamName.ToThaiNumber();
|
|
|
|
|
|
//var tbl = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
|
|
|
|
|
//tbl.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");
|
|
|
|
|
|
var examName = data[0].ExamName;
|
|
|
|
|
|
var _data = new
|
2024-05-24 13:49:17 +07:00
|
|
|
|
{
|
2025-01-08 17:44:55 +07:00
|
|
|
|
template = "rptCandidateList",
|
|
|
|
|
|
reportName = $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}",
|
|
|
|
|
|
data = new
|
|
|
|
|
|
{
|
|
|
|
|
|
examName = examName,
|
|
|
|
|
|
data = data
|
|
|
|
|
|
}
|
2024-05-24 13:49:17 +07:00
|
|
|
|
};
|
2025-01-08 17:44:55 +07:00
|
|
|
|
return Success(_data);
|
2024-05-24 13:49:17 +07:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Error(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-29 10:47:49 +07:00
|
|
|
|
/// <summary>
|
2025-11-14 16:38:56 +07:00
|
|
|
|
/// รายชื่อผู้มีสิทธิ์สอบ แสดงรายชื่อแบ่งตามตำแหน่ง (สอบแข่งขัน)
|
2025-05-29 10:47:49 +07:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id">รหัสรอบการสอบ</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
|
|
|
|
[HttpGet("candidate-new/{id:length(36)}")]
|
|
|
|
|
|
[AllowAnonymous]
|
2025-11-14 16:38:56 +07:00
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
2025-05-29 10:47:49 +07:00
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetCandidateNewListReportAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = await _context.Recruits.AsQueryable()
|
|
|
|
|
|
.Include(x => x.RecruitImport)
|
|
|
|
|
|
.Where(x => x.RecruitImport.Id == id)
|
|
|
|
|
|
.OrderBy(x => x.ExamId)
|
|
|
|
|
|
.Select(p => new
|
|
|
|
|
|
{
|
|
|
|
|
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
|
|
|
|
|
PositionName = p.PositionName,
|
2025-11-14 16:38:56 +07:00
|
|
|
|
Remark = !string.IsNullOrEmpty(p.Remark) ? p.Remark.ToThaiNumber() : "",
|
|
|
|
|
|
ExamId = !string.IsNullOrEmpty(p.ExamId) ? p.ExamId.ToThaiNumber() : "",
|
2025-05-29 10:47:49 +07:00
|
|
|
|
ExamName =
|
2025-09-07 23:29:01 +07:00
|
|
|
|
$"ครั้งที่ {(p.RecruitImport != null ? p.RecruitImport.Order.ToString().ToThaiNumber() : "")}/{(p.RecruitImport != null ? p.RecruitImport.Year.ToThaiYear().ToString().ToThaiNumber() : "")}",
|
2025-05-29 10:47:49 +07:00
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
|
return Error("ไม่พบข้อมูลในระบบ");
|
2025-05-29 10:47:49 +07:00
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
var examName = data.First().ExamName;
|
2025-05-29 10:47:49 +07:00
|
|
|
|
|
|
|
|
|
|
var groupData = data
|
|
|
|
|
|
.GroupBy(x => x.PositionName)
|
|
|
|
|
|
.Select(g => new
|
|
|
|
|
|
{
|
|
|
|
|
|
PositionName = $"ตำแหน่ง {g.Key}",
|
|
|
|
|
|
Total = $"จำนวน {g.Count().ToString().ToThaiNumber()} ราย",
|
|
|
|
|
|
Persons = g.Select((x, index) => new
|
|
|
|
|
|
{
|
|
|
|
|
|
No = (index + 1).ToString().ToThaiNumber(),
|
2025-11-14 16:38:56 +07:00
|
|
|
|
ExamId = x.ExamId,
|
2025-05-29 10:47:49 +07:00
|
|
|
|
FullName = x.FullName,
|
|
|
|
|
|
Remark = x.Remark
|
|
|
|
|
|
}).ToList()
|
|
|
|
|
|
})
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
// เตรียม MemoryStream
|
|
|
|
|
|
using (var stream = new MemoryStream())
|
2025-05-29 10:47:49 +07:00
|
|
|
|
{
|
2025-11-14 16:38:56 +07:00
|
|
|
|
// สร้าง PDF document
|
|
|
|
|
|
using (var writer = new PdfWriter(stream))
|
|
|
|
|
|
using (var pdf = new PdfDocument(writer))
|
|
|
|
|
|
using (var document = new Document(pdf, iText.Kernel.Geom.PageSize.A4))
|
2025-05-29 10:47:49 +07:00
|
|
|
|
{
|
2025-11-14 16:38:56 +07:00
|
|
|
|
// กำหนดฟ้อนต์ TH-Sarabun
|
|
|
|
|
|
var fontPath = System.IO.Path.Combine(Environment.CurrentDirectory, "Fonts", "THSarabun.ttf");
|
|
|
|
|
|
var font = PdfFontFactory.CreateFont(fontPath, "Identity-H");
|
|
|
|
|
|
document.SetFont(font).SetFontSize(16);
|
|
|
|
|
|
|
|
|
|
|
|
// ตั้งค่าระยะขอบ top, right, bottom, left
|
|
|
|
|
|
document.SetMargins(30, 15, 20, 15);
|
2025-05-29 10:47:49 +07:00
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
// Title
|
|
|
|
|
|
var title = new Paragraph(
|
|
|
|
|
|
$"รายชื่อผู้ชำระค่าธรรมเนียมการสมัครสอบการแข่งขันเพื่อบรรจุและแต่งตั้งบุคคลเข้ารับราชการเป็นข้าราชการกรุงเทพมหานครสามัญ {examName ?? ""}"
|
|
|
|
|
|
)
|
|
|
|
|
|
.SetBold()
|
2026-03-02 17:45:47 +07:00
|
|
|
|
.SetMultipliedLeading(1.0f)
|
2025-11-14 16:38:56 +07:00
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER);
|
|
|
|
|
|
|
|
|
|
|
|
document.Add(title);
|
2026-03-02 17:45:47 +07:00
|
|
|
|
float[] columnWidths = { 10f, 20f, 45f, 25f };
|
2025-11-14 16:38:56 +07:00
|
|
|
|
// Loop Groups
|
|
|
|
|
|
foreach (var group in groupData)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Group Header (ตำแหน่ง)
|
|
|
|
|
|
Paragraph positionHeader = new Paragraph($"{group.PositionName} {group.Total}")
|
|
|
|
|
|
.SetBold()
|
2026-03-02 17:45:47 +07:00
|
|
|
|
.SetMultipliedLeading(1.0f)
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER)
|
|
|
|
|
|
.SetMarginBottom(5);
|
2025-11-14 16:38:56 +07:00
|
|
|
|
|
|
|
|
|
|
document.Add(positionHeader);
|
|
|
|
|
|
|
2026-03-02 17:45:47 +07:00
|
|
|
|
var table = new iText.Layout.Element.Table(UnitValue.CreatePercentArray(columnWidths)).UseAllAvailableWidth();
|
2025-11-14 16:38:56 +07:00
|
|
|
|
|
|
|
|
|
|
// Table Header
|
|
|
|
|
|
string[] headers = { "ลำดับที่", "เลขประจำตัวสอบ", "ชื่อ-สกุล", "หมายเหตุ" };
|
|
|
|
|
|
foreach (var h in headers)
|
|
|
|
|
|
{
|
2026-03-02 17:45:47 +07:00
|
|
|
|
table.AddHeaderCell(new Cell()
|
|
|
|
|
|
.Add(new Paragraph(h).SetMultipliedLeading(1.0f))
|
2025-11-14 21:25:11 +07:00
|
|
|
|
.SetBold()
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER));
|
2025-11-14 16:38:56 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Table Details
|
|
|
|
|
|
foreach (var x in group.Persons)
|
|
|
|
|
|
{
|
2026-03-02 17:45:47 +07:00
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(x.No ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER));
|
|
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(x.ExamId ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER));
|
|
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(x.FullName ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.LEFT));
|
|
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(x.Remark ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER));
|
2025-11-14 16:38:56 +07:00
|
|
|
|
}
|
|
|
|
|
|
document.Add(table);
|
|
|
|
|
|
// เว้นระหว่าง groups
|
2026-03-02 17:45:47 +07:00
|
|
|
|
document.Add(new Paragraph("").SetMarginBottom(15));
|
2025-11-14 16:38:56 +07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return File(stream.ToArray(), "application/pdf", $"รายชื่อผู้มีสิทธิ์สอบ_{examName}");
|
|
|
|
|
|
}
|
2025-05-29 10:47:49 +07:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Error(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-24 13:49:17 +07:00
|
|
|
|
[HttpGet("pass/{id:length(36)}")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetPassExamListReportAsync(Guid id)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2025-09-15 15:18:52 +07:00
|
|
|
|
var data = await _context.Recruits.AsQueryable()
|
2024-05-24 13:49:17 +07:00
|
|
|
|
.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,
|
2024-08-11 13:39:12 +07:00
|
|
|
|
ExamId = p.ExamId != null ? p.ExamId.ToThaiNumber() : string.Empty,
|
2024-05-24 13:49:17 +07:00
|
|
|
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
|
|
|
|
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
2025-09-03 11:18:56 +07:00
|
|
|
|
ExamName = p.RecruitImport.Order == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order.ToString().ToThaiNumber()}/{p.RecruitImport.Year.ToThaiYear().ToString().ToThaiNumber()}",
|
2025-09-15 15:18:52 +07:00
|
|
|
|
Number = sr == null || sr.Number == null ? 0 : Convert.ToInt32(sr.Number),
|
2025-11-12 23:23:04 +07:00
|
|
|
|
|
2025-09-07 23:29:01 +07:00
|
|
|
|
SumScore = sr == null
|
|
|
|
|
|
? "๐"
|
2025-09-15 15:18:52 +07:00
|
|
|
|
: (((sr.SumA > 0 ? sr.SumA : 0) + (sr.SumB > 0 ? sr.SumB : 0) + (sr.SumC > 0 ? sr.SumC : 0)).ToString()).ToThaiNumber(),
|
2024-05-24 13:49:17 +07:00
|
|
|
|
})
|
|
|
|
|
|
.OrderBy(x => x.Number)
|
|
|
|
|
|
.Where(x => x.Id == id)
|
|
|
|
|
|
.Where(x => x.ExamResult == "ผ่าน")
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
2025-11-12 23:23:04 +07:00
|
|
|
|
if (data.Count == 0)
|
2025-09-15 15:18:52 +07:00
|
|
|
|
return Error("ไม่พบข้อมูลในระบบ");
|
2024-08-11 13:39:12 +07:00
|
|
|
|
|
|
|
|
|
|
var data_ = data.Select(x => new
|
|
|
|
|
|
{
|
|
|
|
|
|
x.ExamName,
|
2025-09-15 15:18:52 +07:00
|
|
|
|
Number = x.Number.ToString().ToThaiNumber(),
|
2024-08-11 13:39:12 +07:00
|
|
|
|
x.ExamId,
|
|
|
|
|
|
x.FullName,
|
|
|
|
|
|
x.SumScore
|
|
|
|
|
|
}).ToList();
|
2024-05-24 13:49:17 +07:00
|
|
|
|
|
2025-01-08 17:44:55 +07:00
|
|
|
|
var examName = data[0].ExamName;
|
|
|
|
|
|
var _data = new
|
2024-05-24 13:49:17 +07:00
|
|
|
|
{
|
2025-01-08 17:44:55 +07:00
|
|
|
|
template = "rptPassExamList",
|
|
|
|
|
|
reportName = $"รายชื่อผู้สอบแข่งขันได้_{data.First().ExamName}",
|
|
|
|
|
|
data = new
|
|
|
|
|
|
{
|
|
|
|
|
|
examName = examName,
|
|
|
|
|
|
data = data_
|
|
|
|
|
|
}
|
2024-05-24 13:49:17 +07:00
|
|
|
|
};
|
2025-01-08 17:44:55 +07:00
|
|
|
|
return Success(_data);
|
2024-05-24 13:49:17 +07:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// รายชื่อผู้สอบแข่งขันได้ แสดงรายชื่อแบ่งตามตำแหน่ง (สอบแข่งขัน)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id">รหัสรอบการสอบ</param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
2025-11-12 23:23:04 +07:00
|
|
|
|
[HttpGet("pass-new/{id:length(36)}")]
|
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
2025-11-14 16:38:56 +07:00
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetPassExamNewListReportAsync(Guid id)
|
2025-11-12 23:23:04 +07:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var data = await _context.Recruits.AsQueryable()
|
|
|
|
|
|
.Include(x => x.RecruitImport)
|
|
|
|
|
|
.ThenInclude(x => x.ScoreImport)
|
|
|
|
|
|
.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
|
|
|
|
|
|
{
|
2025-11-14 16:38:56 +07:00
|
|
|
|
PositionName = p.PositionName,
|
2025-11-12 23:23:04 +07:00
|
|
|
|
FullName = $"{p.Prefix}{p.FirstName} {p.LastName}",
|
|
|
|
|
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
|
|
|
|
|
ExamName = p.RecruitImport.Order == null
|
|
|
|
|
|
? ""
|
|
|
|
|
|
: $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order.ToString().ToThaiNumber()}/{p.RecruitImport.Year.ToThaiYear().ToString().ToThaiNumber()}",
|
|
|
|
|
|
Number = sr == null || sr.Number == null ? 0 : Convert.ToInt32(sr.Number),
|
|
|
|
|
|
SumScore = sr == null
|
|
|
|
|
|
? "๐"
|
|
|
|
|
|
: (((decimal)(sr.SumA > 0 ? sr.SumA : 0) + (sr.SumB > 0 ? sr.SumB : 0) + (sr.SumC > 0 ? sr.SumC : 0)).ToString("0.00")).ToThaiNumber(),
|
|
|
|
|
|
})
|
|
|
|
|
|
.OrderBy(x => x.Number)
|
|
|
|
|
|
.Where(x => x.ExamResult == "ผ่าน")
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (data.Count == 0)
|
|
|
|
|
|
return Error("ไม่พบข้อมูลในระบบ");
|
|
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
var examName = data.First().ExamName;
|
|
|
|
|
|
|
|
|
|
|
|
// Group by PositionName
|
|
|
|
|
|
var groupData = data
|
|
|
|
|
|
.GroupBy(g => g.PositionName)
|
|
|
|
|
|
.Select(g => new
|
|
|
|
|
|
{
|
|
|
|
|
|
PositionName = $"ตำแหน่ง {g.Key}",
|
|
|
|
|
|
Total = $"จำนวน {g.Count().ToString().ToThaiNumber()} ราย",
|
|
|
|
|
|
Persons = g.Select((x) => new
|
|
|
|
|
|
{
|
|
|
|
|
|
Number = x.Number > 0 ? x.Number.ToString().ToThaiNumber() : "",
|
|
|
|
|
|
FullName = x.FullName,
|
|
|
|
|
|
SumScore = x.SumScore
|
|
|
|
|
|
}).ToList()
|
|
|
|
|
|
})
|
|
|
|
|
|
.ToList();
|
2025-11-12 23:23:04 +07:00
|
|
|
|
|
|
|
|
|
|
using (var stream = new MemoryStream())
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var writer = new PdfWriter(stream))
|
|
|
|
|
|
using (var pdf = new PdfDocument(writer))
|
|
|
|
|
|
using (var document = new Document(pdf, iText.Kernel.Geom.PageSize.A4))
|
|
|
|
|
|
{
|
|
|
|
|
|
var fontPath = System.IO.Path.Combine(Environment.CurrentDirectory, "Fonts", "THSarabun.ttf");
|
|
|
|
|
|
var font = PdfFontFactory.CreateFont(fontPath, "Identity-H");
|
|
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
document.SetFont(font).SetFontSize(16);
|
2025-11-12 23:23:04 +07:00
|
|
|
|
document.SetMargins(30, 15, 20, 15);
|
|
|
|
|
|
|
2025-11-14 16:38:56 +07:00
|
|
|
|
var title = new Paragraph($"รายชื่อผู้สอบแข่งขันได้\n{examName}")
|
2026-03-02 17:45:47 +07:00
|
|
|
|
.SetMultipliedLeading(1.0f)
|
2025-11-12 23:23:04 +07:00
|
|
|
|
.SetBold()
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER);
|
|
|
|
|
|
|
|
|
|
|
|
document.Add(title);
|
2026-03-02 17:45:47 +07:00
|
|
|
|
float[] columnWidths = { 10f, 20f, 45f, 25f };
|
2025-11-14 16:38:56 +07:00
|
|
|
|
foreach (var g in groupData)
|
2025-11-12 23:23:04 +07:00
|
|
|
|
{
|
2025-11-14 16:38:56 +07:00
|
|
|
|
// Header per group
|
|
|
|
|
|
Paragraph positionHeader = new Paragraph($"{g.PositionName} {g.Total}")
|
2026-03-02 17:45:47 +07:00
|
|
|
|
.SetMultipliedLeading(1.0f)
|
2025-11-14 16:38:56 +07:00
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER)
|
2026-03-02 17:45:47 +07:00
|
|
|
|
.SetBold()
|
|
|
|
|
|
.SetMarginBottom(5);
|
2025-11-14 16:38:56 +07:00
|
|
|
|
|
|
|
|
|
|
document.Add(positionHeader);
|
|
|
|
|
|
|
2026-03-02 17:45:47 +07:00
|
|
|
|
var table = new iText.Layout.Element.Table(UnitValue.CreatePercentArray(columnWidths)).UseAllAvailableWidth();
|
2025-11-14 16:38:56 +07:00
|
|
|
|
|
|
|
|
|
|
string[] headers = { "ลำดับที่", "สนามสอบ", "ชื่อ - นามสกุล", "คะแนนสอบ" };
|
|
|
|
|
|
foreach (var h in headers)
|
|
|
|
|
|
{
|
2026-03-02 17:45:47 +07:00
|
|
|
|
table.AddHeaderCell(new Cell()
|
|
|
|
|
|
.Add(new Paragraph(h).SetMultipliedLeading(1.0f))
|
2025-11-14 16:38:56 +07:00
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER)
|
|
|
|
|
|
.SetBold());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var p in g.Persons)
|
|
|
|
|
|
{
|
2026-03-02 17:45:47 +07:00
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(p.Number ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER));
|
2025-11-14 16:38:56 +07:00
|
|
|
|
table.AddCell(new Cell());
|
2026-03-02 17:45:47 +07:00
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(p.FullName ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.LEFT));
|
|
|
|
|
|
table.AddCell(new Cell().Add(new Paragraph(p.SumScore ?? "").SetMultipliedLeading(1.0f))
|
|
|
|
|
|
.SetTextAlignment(TextAlignment.CENTER));
|
2025-11-14 16:38:56 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
document.Add(table);
|
2026-03-02 17:45:47 +07:00
|
|
|
|
document.Add(new Paragraph("").SetMarginBottom(15));
|
2025-11-12 23:23:04 +07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-14 16:38:56 +07:00
|
|
|
|
return File(stream.ToArray(), "application/pdf", $"รายชื่อผู้สอบแข่งขันได้_{examName}");
|
2025-11-12 23:23:04 +07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-24 13:49:17 +07:00
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
2023-04-17 21:24:52 +07:00
|
|
|
|
}
|