แก้ไฟล์ build
This commit is contained in:
parent
9fb82fb45a
commit
d6573a6d0c
15 changed files with 1676 additions and 374 deletions
|
|
@ -1,90 +1,90 @@
|
|||
using BMA.EHR.Core;
|
||||
// using BMA.EHR.Core;
|
||||
using BMA.EHR.Report.Service.Responses;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BMA.EHR.Profile.Service.Controllers
|
||||
{
|
||||
public class BaseController : ControllerBase
|
||||
{
|
||||
#region " Methods "
|
||||
public class BaseController : ControllerBase
|
||||
{
|
||||
#region " Methods "
|
||||
|
||||
#region " Protected "
|
||||
#region " Protected "
|
||||
|
||||
#region " IActionResult "
|
||||
#region " IActionResult "
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Success(string message, object? result = null)
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
return Ok(new ResponseObject
|
||||
{
|
||||
Status = StatusCodes.Status200OK,
|
||||
Message = message,
|
||||
Result = result
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok(new ResponseObject
|
||||
{
|
||||
Status = StatusCodes.Status200OK,
|
||||
Message = message
|
||||
});
|
||||
}
|
||||
protected virtual ActionResult<ResponseObject> Success(string message, object? result = null)
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
return Ok(new ResponseObject
|
||||
{
|
||||
Status = StatusCodes.Status200OK,
|
||||
Message = message,
|
||||
Result = result
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
return Ok(new ResponseObject
|
||||
{
|
||||
Status = StatusCodes.Status200OK,
|
||||
Message = message
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Success(object? result = null)
|
||||
{
|
||||
return Success(GlobalMessages.Success, result);
|
||||
}
|
||||
protected virtual ActionResult<ResponseObject> Success(object? result = null)
|
||||
{
|
||||
return Success("สำเร็จ", result);
|
||||
}
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Error(string message, string result, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
return StatusCode((int)statusCode, new ResponseObject
|
||||
{
|
||||
Status = statusCode,
|
||||
Message = message,
|
||||
Result = result
|
||||
});
|
||||
}
|
||||
protected virtual ActionResult<ResponseObject> Error(string message, string result, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
return StatusCode((int)statusCode, new ResponseObject
|
||||
{
|
||||
Status = statusCode,
|
||||
Message = message,
|
||||
Result = result
|
||||
});
|
||||
}
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Error(string message, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
return Error(message, message, statusCode);
|
||||
}
|
||||
protected virtual ActionResult<ResponseObject> Error(string message, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
return Error(message, message, statusCode);
|
||||
}
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Error(Exception exception, string message, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
var msg = exception.Message;
|
||||
var inner = exception.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
msg += $" {inner.Message}\r\n";
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
protected virtual ActionResult<ResponseObject> Error(Exception exception, string message, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
var msg = exception.Message;
|
||||
var inner = exception.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
msg += $" {inner.Message}\r\n";
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
|
||||
return Error(message, msg, statusCode);
|
||||
}
|
||||
return Error(message, msg, statusCode);
|
||||
}
|
||||
|
||||
protected virtual ActionResult<ResponseObject> Error(Exception exception, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
var msg = exception.Message;
|
||||
var inner = exception.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
msg += $" {inner.Message}\r\n";
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
protected virtual ActionResult<ResponseObject> Error(Exception exception, int statusCode = StatusCodes.Status500InternalServerError)
|
||||
{
|
||||
var msg = exception.Message;
|
||||
var inner = exception.InnerException;
|
||||
while (inner != null)
|
||||
{
|
||||
msg += $" {inner.Message}\r\n";
|
||||
inner = inner.InnerException;
|
||||
}
|
||||
|
||||
return Error(msg, msg, statusCode);
|
||||
}
|
||||
return Error(msg, msg, statusCode);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ using Swashbuckle.AspNetCore.Annotations;
|
|||
using Telerik.Reporting.Processing;
|
||||
using Telerik.Reporting;
|
||||
using BMA.EHR.Report.Service.Responses;
|
||||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Core;
|
||||
using BMA.EHR.Organization.Service.Extensions;
|
||||
// using BMA.EHR.Core;
|
||||
using System.Text;
|
||||
|
||||
namespace BMA.EHR.Report.Service.Controllers
|
||||
|
|
@ -344,7 +344,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}).ToListAsync();
|
||||
|
||||
if (data.Count == 0)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
return Error("ไม่พบข้อมูลในระบบ");
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptCandidateList.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
|
|
@ -427,7 +427,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
.ToListAsync();
|
||||
|
||||
if (data.Count == 0)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
return Error("ไม่พบข้อมูลในระบบ");
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
|
|
@ -496,7 +496,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
.ToListAsync();
|
||||
|
||||
if (data.Count == 0)
|
||||
return Error(GlobalMessages.DataNotFound);
|
||||
return Error("ไม่พบข้อมูลในระบบ");
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Recruit", $"rptPassExamList.trdp");
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using BMA.EHR.Core;
|
||||
using BMA.EHR.Extensions;
|
||||
// using BMA.EHR.Core;
|
||||
using BMA.EHR.Organization.Service.Extensions;
|
||||
using BMA.EHR.Profile.Service.Controllers;
|
||||
using BMA.EHR.Profile.Service.Services;
|
||||
using BMA.EHR.Recruit.Service.Services;
|
||||
|
|
@ -746,7 +746,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}).ToList();
|
||||
|
||||
if (!profile.Any())
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
return Error("ไม่พบข้อมูลในระบบ", StatusCodes.Status404NotFound);
|
||||
|
||||
// certificate
|
||||
var cert = (from c in _context.ProfileCertificates.AsQueryable()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using BMA.EHR.Extensions;
|
||||
using BMA.EHR.Organization.Service.Extensions;
|
||||
using BMA.EHR.Profile.Service.Controllers;
|
||||
using BMA.EHR.Recruit.Service.Services;
|
||||
using BMA.EHR.Report.Service.Data;
|
||||
|
|
@ -13,355 +13,355 @@ 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 RecruitService _recruitService;
|
||||
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,
|
||||
RecruitService recruitService)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
this._recruitService = recruitService;
|
||||
}
|
||||
public RecruitReportController(ApplicationDbContext context,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IConfiguration configuration,
|
||||
RecruitService recruitService)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
this._recruitService = recruitService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#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.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();
|
||||
[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.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, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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}",
|
||||
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
||||
Gender = p.Gendor,
|
||||
Degree = p.Educations.First().Degree,
|
||||
Major = p.Educations.First().Major,
|
||||
/// <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}",
|
||||
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
||||
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()}",
|
||||
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(),
|
||||
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,
|
||||
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();
|
||||
})
|
||||
.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);
|
||||
}
|
||||
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();
|
||||
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, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[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
|
||||
{
|
||||
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();
|
||||
[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
|
||||
{
|
||||
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();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
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);
|
||||
}
|
||||
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();
|
||||
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.First().ExamName}.pdf");
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}.pdf");
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
[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
|
||||
{
|
||||
var data = await _context.Recruits.AsQueryable()
|
||||
.Include(x => x.RecruitImport)
|
||||
.ThenInclude(x => x.ScoreImport)
|
||||
.Include(x => x.Documents)
|
||||
.ThenInclude(x => x.DocumentFile)
|
||||
[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
|
||||
{
|
||||
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,
|
||||
.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,
|
||||
ExamResult = sr == null ? "" : sr.ExamStatus,
|
||||
|
||||
University = p.Educations.First().University,
|
||||
PositionName = p.PositionName,
|
||||
ExamName = $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
|
||||
University = p.Educations.First().University,
|
||||
PositionName = p.PositionName,
|
||||
ExamName = $"{p.RecruitImport.Name} ครั้งที่ {p.RecruitImport.Order}/{p.RecruitImport.Year.ToThaiYear()}",
|
||||
|
||||
|
||||
Number = sr == null ? 99999 : Convert.ToInt32(sr.Number),
|
||||
ExamCount = _recruitService.GetExamCount(p.CitizenId),
|
||||
ScoreExpire = p.RecruitImport.AnnouncementDate == null ? "" : p.RecruitImport.AnnouncementDate.Value.AddYears(2).ToThaiShortDate(),
|
||||
Number = sr == null ? 99999 : Convert.ToInt32(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,
|
||||
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();
|
||||
})
|
||||
.OrderBy(x => x.Number)
|
||||
.Where(x => x.Id == id)
|
||||
.Where(x => x.ExamResult == "ผ่าน")
|
||||
.ToListAsync();
|
||||
|
||||
if (data.Count == 0) return Success();
|
||||
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);
|
||||
}
|
||||
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();
|
||||
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.First().ExamName}.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายชื่อผู้สอบแข่งขันได้_{data.First().ExamName}.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue