2023-04-06 16:38:26 +07:00
|
|
|
using Amazon.S3.Model;
|
|
|
|
|
using BMA.EHR.Extensions;
|
2023-03-24 15:16:00 +07:00
|
|
|
using BMA.EHR.Recruit.Service.Core;
|
|
|
|
|
using BMA.EHR.Recruit.Service.Data;
|
2023-04-06 16:38:26 +07:00
|
|
|
using BMA.EHR.Recruit.Service.Extensions;
|
2023-03-24 15:16:00 +07:00
|
|
|
using BMA.EHR.Recruit.Service.Models.Recruits;
|
|
|
|
|
using BMA.EHR.Recruit.Service.Requests.Recruits;
|
2023-03-17 14:24:43 +07:00
|
|
|
using BMA.EHR.Recruit.Service.Responses;
|
|
|
|
|
using BMA.EHR.Recruit.Service.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2023-03-24 15:16:00 +07:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-04-06 16:38:26 +07:00
|
|
|
using MySqlConnector;
|
|
|
|
|
using OfficeOpenXml;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
using Sentry;
|
2023-03-17 14:24:43 +07:00
|
|
|
using Swashbuckle.AspNetCore.Annotations;
|
2023-04-06 16:38:26 +07:00
|
|
|
using System.Data;
|
2023-03-24 15:16:00 +07:00
|
|
|
using System.Net;
|
2023-04-11 17:15:55 +07:00
|
|
|
using System.Security.Claims;
|
2023-03-24 15:16:00 +07:00
|
|
|
using System.Text;
|
2023-03-17 14:24:43 +07:00
|
|
|
|
|
|
|
|
namespace BMA.EHR.Recruit.Service.Controllers
|
|
|
|
|
{
|
2023-03-25 21:01:46 +07:00
|
|
|
[Route("api/v{version:apiVersion}/recruit")]
|
|
|
|
|
[ApiVersion("1.0")]
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Produces("application/json")]
|
|
|
|
|
[Authorize]
|
|
|
|
|
[SwaggerTag("จัดการข้อมูลการสอบแข่งขัน")]
|
|
|
|
|
public class RecruitController : BaseController
|
|
|
|
|
{
|
|
|
|
|
#region " Fields "
|
|
|
|
|
|
|
|
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
|
private readonly MinIOService _minioService;
|
|
|
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
|
|
private readonly RecruitService _recruitService;
|
|
|
|
|
|
2023-04-11 17:15:55 +07:00
|
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
|
private readonly ILogger<RecruitController> _logger;
|
|
|
|
|
|
2023-03-25 21:01:46 +07:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region " Constructor and Destructor "
|
|
|
|
|
|
|
|
|
|
public RecruitController(ApplicationDbContext context,
|
|
|
|
|
MinIOService minioService,
|
|
|
|
|
IWebHostEnvironment webHostEnvironment,
|
2023-04-11 17:15:55 +07:00
|
|
|
RecruitService recruitService,
|
|
|
|
|
IHttpContextAccessor httpContextAccessor,
|
|
|
|
|
ILogger<RecruitController> logger)
|
2023-03-25 21:01:46 +07:00
|
|
|
{
|
|
|
|
|
_context = context;
|
|
|
|
|
_minioService = minioService;
|
|
|
|
|
_webHostEnvironment = webHostEnvironment;
|
|
|
|
|
_recruitService = recruitService;
|
2023-04-11 17:15:55 +07:00
|
|
|
_httpContextAccessor = httpContextAccessor;
|
|
|
|
|
_logger = logger;
|
2023-03-25 21:01:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-04-11 17:15:55 +07:00
|
|
|
#region " Properties "
|
|
|
|
|
|
|
|
|
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
|
|
|
|
|
|
|
|
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-03-25 21:01:46 +07:00
|
|
|
#region " Methods "
|
|
|
|
|
|
|
|
|
|
#region " Private "
|
|
|
|
|
|
|
|
|
|
private int GetColumnIndex(string[] columns, string name, bool partial = false)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (partial)
|
|
|
|
|
return Array.FindIndex(columns, x => x.Contains(name)) + 1;
|
|
|
|
|
else
|
|
|
|
|
return Array.FindIndex(columns, x => x == name) + 1;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string CalculateDiff(DateTime d1, DateTime d2)
|
|
|
|
|
{
|
|
|
|
|
if (d1 > d2) return "ข้อมูลไม่ถูกต้อง";
|
|
|
|
|
|
|
|
|
|
TimeSpan sp = d2.Subtract(d1);
|
|
|
|
|
int yy = sp.Days / 365;
|
|
|
|
|
int mm = (sp.Days - (yy * 365)) / 30;
|
|
|
|
|
int dd = (sp.Days - (yy * 365) - (mm * 30));
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
sb.Clear();
|
|
|
|
|
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
|
|
|
|
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
|
|
|
|
//sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<int> GetExamCount(Guid exam)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return await _context.RecruitPayments.AsQueryable()
|
|
|
|
|
.Include(x => x.Recruit)
|
|
|
|
|
.ThenInclude(x => x.RecruitImport)
|
|
|
|
|
.Where(x => x.Recruit.RecruitImport.Id == exam)
|
|
|
|
|
.CountAsync();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<int> GetPassExamCount(Guid exam)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return await _context.RecruitScores.AsQueryable()
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.Where(x => x.ScoreImport.Id == exam)
|
|
|
|
|
.Where(x => x.ExamStatus == "ผ่าน")
|
|
|
|
|
.CountAsync();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task<int> GetScoreCount(Guid exam)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return await _context.RecruitScores.AsQueryable()
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.Where(x => x.ScoreImport.Id == exam)
|
|
|
|
|
.CountAsync();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region " Ex. Upload, Download and Delete file "
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ตัวอย่างในการเขียน api เพื่อทำการ upload file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
2023-03-31 16:12:19 +07:00
|
|
|
/// <response code="200">เมื่อทำการ upload สำเร็จ</response>
|
2023-03-25 21:01:46 +07:00
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
|
|
|
[HttpPost("upload"), DisableRequestSizeLimit]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> UploadFile()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return Error(GlobalMessages.NoFileToUpload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
|
var doc = await _minioService.UploadFileAsync(file);
|
|
|
|
|
|
|
|
|
|
return Success(doc);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-31 16:12:19 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// ตัวอย่างในการเขียน api เพื่อทำการ delete file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">รหัสไฟล์ในฐานข้อมูล</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อทำการ delete file สำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
2023-03-25 21:01:46 +07:00
|
|
|
[HttpGet("delete/{id:length(36)}")]
|
2023-03-31 16:12:19 +07:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
2023-03-25 21:01:46 +07:00
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> DeleteFile(Guid id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await _minioService.DeleteFileAsync(id);
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
}
|
2023-04-03 12:19:09 +07:00
|
|
|
catch (Exception ex)
|
2023-03-25 21:01:46 +07:00
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-31 16:12:19 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// ตัวอย่างในการเขียน api เพื่อทำการ download file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">รหัสไฟล์ในฐานข้อมูล</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อทำการ download file สำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
2023-03-25 21:01:46 +07:00
|
|
|
[HttpGet("download/{id:length(36)}")]
|
2023-03-31 16:12:19 +07:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
2023-03-25 21:01:46 +07:00
|
|
|
[AllowAnonymous]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> DownloadFile(Guid id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var file_data = await _minioService.DownloadFileAsync(id);
|
|
|
|
|
|
|
|
|
|
Response.Headers["Content-Disposition"] = $"inline; filename={file_data.FileName}";
|
|
|
|
|
|
|
|
|
|
var ret = new FileContentResult(file_data.FileContent, file_data.FileType)
|
|
|
|
|
{
|
|
|
|
|
FileDownloadName = file_data.FileName
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region " จัดการรอบการสมัครสอบแข่งขัน "
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// แสดงข้อมูลรอบการสอบแข่งขัน
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
2023-04-03 12:19:09 +07:00
|
|
|
[HttpGet("period")]
|
2023-03-25 21:01:46 +07:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
2023-04-03 12:19:09 +07:00
|
|
|
public async Task<ActionResult<ResponseObject>> GetPeriodsAsync()
|
2023-03-25 21:01:46 +07:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable()
|
2023-04-06 16:38:26 +07:00
|
|
|
.Include(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.Scores)
|
2023-03-25 21:01:46 +07:00
|
|
|
.OrderByDescending(x => x.Year)
|
|
|
|
|
.ThenByDescending(x => x.Order)
|
2023-04-06 16:38:26 +07:00
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.Year,
|
|
|
|
|
x.Name,
|
|
|
|
|
x.Order,
|
|
|
|
|
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
|
|
|
|
ExamCount = x.Recruits.Count(),
|
|
|
|
|
Score = x.ScoreImport == null ? null :
|
|
|
|
|
new
|
|
|
|
|
{
|
|
|
|
|
ID = x.ScoreImport.Id,
|
|
|
|
|
ImportYear = x.ScoreImport.Year,
|
|
|
|
|
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
|
|
|
|
ScoreCount = x.ScoreImport.Scores.Count(),
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-03-25 21:01:46 +07:00
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
return Success(data);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-04-03 09:18:43 +07:00
|
|
|
/// แสดงข้อมูลรอบการสอบแข่งขันเป็นรายการ
|
2023-03-25 21:01:46 +07:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">รหัสรอบการสอบแข่งขัน</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
2023-04-03 12:19:09 +07:00
|
|
|
[HttpGet("period/{id:length(36)}")]
|
2023-03-25 21:01:46 +07:00
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
2023-04-03 12:19:09 +07:00
|
|
|
public async Task<ActionResult<ResponseObject>> GetPeriodByIdAsync(Guid id)
|
2023-03-25 21:01:46 +07:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.Include(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Addresses)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Occupations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Certificates)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Educations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Payments)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Documents)
|
|
|
|
|
.ThenInclude(x => x.DocumentFile)
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
return Success(data);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// เพิ่มข้อมูลรอบการจัดสอบแข่งขัน
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req">Request parameters</param>
|
|
|
|
|
/// <returns></returns>
|
2023-04-03 12:19:09 +07:00
|
|
|
/// <response code="200">เมื่อทำการเพิ่มข้อมูลสำเร็จ</response>
|
2023-03-25 21:01:46 +07:00
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
|
|
|
[HttpPost("period")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> PostPeriodAsync([FromBody] PostRecruitImportRequest req)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (req == null)
|
|
|
|
|
return Error(GlobalMessages.InvalidRequestParam, (int)HttpStatusCode.BadRequest);
|
|
|
|
|
|
|
|
|
|
await _context.RecruitImports.AddAsync(new RecruitImport
|
|
|
|
|
{
|
|
|
|
|
Year = req.Year,
|
|
|
|
|
Name = req.Name,
|
|
|
|
|
Order = req.Order,
|
2023-04-23 12:00:07 +07:00
|
|
|
Detail = req.Detail,
|
|
|
|
|
Fee = req.Fee,
|
|
|
|
|
AnnouncementStartDate = req.AnnouncementStartDate,
|
|
|
|
|
AnnouncementEndDate = req.AnnouncementEndDate,
|
|
|
|
|
RegisterStartDate = req.RegisterStartDate,
|
|
|
|
|
RegisterEndDate = req.RegisterEndDate,
|
|
|
|
|
ExamDate = req.ExamDate,
|
|
|
|
|
PaymentStartDate = req.PaymentStartDate,
|
|
|
|
|
PaymentEndDate = req.PaymentEndDate,
|
|
|
|
|
Note = req.Note,
|
2023-03-25 21:01:46 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 12:00:07 +07:00
|
|
|
/// <summary>
|
|
|
|
|
/// แก้ไขข้อมูลรอบการจัดสอบแข่งขัน
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">รหัสรอบการสอบแข่งขัน</param>
|
|
|
|
|
/// <param name="req">Request parameters</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อทำการเพิ่มข้อมูลสำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
|
|
|
[HttpPut("period/{id:length(36)}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> PutPeriodAsync(Guid id, [FromBody] PostRecruitImportRequest req)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable().FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
|
|
|
|
|
|
|
|
|
data.Name = req.Name;
|
|
|
|
|
data.Year = req.Year;
|
|
|
|
|
data.Order = req.Order;
|
|
|
|
|
data.Detail = req.Detail;
|
|
|
|
|
data.Fee = req.Fee;
|
|
|
|
|
data.AnnouncementEndDate = req.AnnouncementEndDate;
|
|
|
|
|
data.AnnouncementStartDate = req.AnnouncementStartDate;
|
|
|
|
|
data.RegisterStartDate = req.RegisterStartDate;
|
|
|
|
|
data.RegisterEndDate = req.RegisterEndDate;
|
|
|
|
|
data.PaymentEndDate = req.PaymentEndDate;
|
|
|
|
|
data.PaymentStartDate = req.PaymentStartDate;
|
|
|
|
|
data.ExamDate = req.ExamDate;
|
|
|
|
|
data.Note = req.Note;
|
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-03 12:19:09 +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>
|
|
|
|
|
[HttpDelete("period/{id:length(36)}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> DeletePeriodAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.Include(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Addresses)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Occupations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Certificates)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Educations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Payments)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Documents)
|
|
|
|
|
.ThenInclude(x => x.DocumentFile)
|
2023-04-06 16:38:26 +07:00
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.Scores)
|
2023-04-03 12:19:09 +07:00
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
_context.RecruitImports.Remove(data);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-25 21:01:46 +07:00
|
|
|
#endregion
|
|
|
|
|
|
2023-04-06 16:38:26 +07:00
|
|
|
#region " Candidate Files "
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// แสดงข้อมูลสำหรับหน้าจอ รายการนำเข้าข้อมูลผู้สมัครสอบแข่งขัน
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อแสดงรายการข้อมูลสำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
|
|
|
[HttpGet("candidate")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetCandidateFilesAsync()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.Include(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.Scores)
|
|
|
|
|
.OrderByDescending(x => x.Year)
|
|
|
|
|
.ThenByDescending(x => x.Order)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.Year,
|
|
|
|
|
x.Name,
|
|
|
|
|
x.Order,
|
|
|
|
|
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
|
|
|
|
ExamCount = x.Recruits.Count(),
|
|
|
|
|
Score = x.ScoreImport == null ? null :
|
|
|
|
|
new
|
|
|
|
|
{
|
|
|
|
|
ID = x.ScoreImport.Id,
|
|
|
|
|
ImportYear = x.ScoreImport.Year,
|
|
|
|
|
ImportDate = x.CreatedAt.Date.ToThaiShortDate(),
|
|
|
|
|
ScoreCount = x.ScoreImport.Scores.Count(),
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
return Success(data);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// นำเข้ารายชื่อผู้สมัครสอบแข่งขัน
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <response code="200">เมื่อทำนำเข้าข้อมูลสำเร็จ</response>
|
|
|
|
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
|
|
|
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
|
|
|
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
|
|
|
|
[HttpPost("candidate"), DisableRequestSizeLimit]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> ImportCandidateFileAsync([FromForm] PostRecruitImportRequest req)
|
|
|
|
|
{
|
|
|
|
|
var tmpDir = Path.Combine(_webHostEnvironment.ContentRootPath, "tmp");
|
|
|
|
|
if (!Directory.Exists(tmpDir))
|
|
|
|
|
Directory.CreateDirectory(tmpDir);
|
|
|
|
|
|
|
|
|
|
var importFile = Path.Combine(tmpDir, $"c_{DateTime.Now.ToString("ddMMyyyyHHmmss")}.xlsx");
|
|
|
|
|
var import_doc_id = "";
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return Error(GlobalMessages.NoFileToUpload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
|
var doc = await _minioService.UploadFileAsync(file);
|
|
|
|
|
import_doc_id = doc.Id.ToString("D");
|
|
|
|
|
|
|
|
|
|
var fileContent = (await _minioService.DownloadFileAsync(doc.Id)).FileContent;
|
|
|
|
|
|
|
|
|
|
// สร้างรอบการบรรจุ โดยเอาเข้ามูลมาใส่จาก Request
|
|
|
|
|
var imported = new RecruitImport
|
|
|
|
|
{
|
|
|
|
|
Year = req.Year,
|
|
|
|
|
Order = req.Order,
|
|
|
|
|
Name = req.Name,
|
|
|
|
|
ImportFile = doc,
|
2023-04-11 17:15:55 +07:00
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
|
|
|
ImportHostories = new List<RecruitImportHistory>
|
|
|
|
|
{
|
|
|
|
|
new RecruitImportHistory
|
|
|
|
|
{
|
|
|
|
|
Description = "นำเข้าข้อมูลผู้สมัครสอบแข่งขัน",
|
|
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-06 16:38:26 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _context.RecruitImports.AddAsync(imported);
|
|
|
|
|
|
|
|
|
|
// import datafile
|
|
|
|
|
System.IO.File.WriteAllBytes(importFile, fileContent);
|
|
|
|
|
|
|
|
|
|
using (var c_package = new ExcelPackage(new FileInfo(importFile)))
|
|
|
|
|
{
|
|
|
|
|
// loop from sheet2 to end
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < c_package.Workbook.Worksheets.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var workSheet = c_package.Workbook.Worksheets[i];
|
|
|
|
|
var totalRows = workSheet.Dimension.Rows;
|
|
|
|
|
var cols = workSheet.GetHeaderColumns();
|
|
|
|
|
|
|
|
|
|
int row = 2;
|
|
|
|
|
|
|
|
|
|
while (row <= totalRows)
|
|
|
|
|
{
|
|
|
|
|
var cell1 = workSheet?.Cells[row, 1]?.GetValue<string>();
|
|
|
|
|
if (cell1 == "" || cell1 == null) break;
|
|
|
|
|
|
|
|
|
|
var r = new Models.Recruits.Recruit();
|
|
|
|
|
r.ExamId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ExamID)]?.GetValue<string>();
|
|
|
|
|
r.CitizenId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalID)]?.GetValue<string>();
|
|
|
|
|
r.Prefix = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Prefix)]?.GetValue<string>();
|
|
|
|
|
r.FirstName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.FirstName)]?.GetValue<string>();
|
|
|
|
|
r.LastName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.LastName)]?.GetValue<string>();
|
|
|
|
|
r.Gendor = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Gender)]?.GetValue<string>();
|
|
|
|
|
r.National = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.National)]?.GetValue<string>().IsNull("");
|
|
|
|
|
r.Race = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Race)]?.GetValue<string>().IsNull("");
|
|
|
|
|
r.Religion = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Religion)]?.GetValue<string>().IsNull("");
|
|
|
|
|
r.DateOfBirth = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.DateOfBirth)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
|
|
|
|
|
r.Marry = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Marry)]?.GetValue<string>();
|
|
|
|
|
r.Isspecial = "N";
|
|
|
|
|
r.CitizenCardIssuer = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardIssue)]?.GetValue<string>();
|
|
|
|
|
r.CitizenCardExpireDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardExpireDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
|
|
|
|
|
r.ApplyDate = (DateTime)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ApplyDate)]?.GetValue<DateTime>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// address
|
|
|
|
|
r.Addresses.Add(new RecruitAddress()
|
|
|
|
|
{
|
|
|
|
|
Address = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Address)]?.GetValue<string>() ?? "",
|
|
|
|
|
Moo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Moo)]?.GetValue<string>() ?? "",
|
|
|
|
|
Soi = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Soi)]?.GetValue<string>() ?? "",
|
|
|
|
|
Road = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Road)]?.GetValue<string>() ?? "",
|
|
|
|
|
District = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.District)]?.GetValue<string>() ?? "",
|
|
|
|
|
Amphur = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amphur)]?.GetValue<string>() ?? "",
|
|
|
|
|
Province = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Province)]?.GetValue<string>() ?? "",
|
|
|
|
|
ZipCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ZipCode)]?.GetValue<string>() ?? "",
|
|
|
|
|
Telephone = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Telephone)]?.GetValue<string>() ?? "",
|
|
|
|
|
Mobile = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Mobile)]?.GetValue<string>() ?? "",
|
2023-04-11 17:15:55 +07:00
|
|
|
Address1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Address1)]?.GetValue<string>() ?? "",
|
2023-04-06 16:38:26 +07:00
|
|
|
Moo1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Moo1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Soi1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Soi1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Road1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Road1)]?.GetValue<string>() ?? "",
|
|
|
|
|
District1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.District1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Amphur1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amphur1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Province1 = "",
|
|
|
|
|
ZipCode1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ZipCode1)]?.GetValue<string>() ?? "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// payment
|
|
|
|
|
r.Payments.Add(new RecruitPayment()
|
|
|
|
|
{
|
|
|
|
|
PaymentId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PaymentID)]?.GetValue<string>() ?? "",
|
|
|
|
|
CompanyCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CompanyCode)]?.GetValue<string>() ?? "",
|
|
|
|
|
TextFile = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TextFile)]?.GetValue<string>() ?? "",
|
|
|
|
|
BankCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.BankCode)]?.GetValue<string>() ?? "",
|
|
|
|
|
AccountNumber = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.AccouontNumer)]?.GetValue<string>() ?? "",
|
|
|
|
|
TransDate = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TransDate)]?.GetValue<string>() ?? "",
|
|
|
|
|
TransTime = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TransTime)]?.GetValue<string>() ?? "",
|
|
|
|
|
CustomerName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CustomerName)]?.GetValue<string>() ?? "",
|
|
|
|
|
RefNo1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.RefNo1)]?.GetValue<string>() ?? "",
|
|
|
|
|
TermBranch = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TermBranch)]?.GetValue<string>() ?? "",
|
|
|
|
|
TellerId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TellerID)]?.GetValue<string>() ?? "",
|
|
|
|
|
CreditDebit = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CreditDebit)]?.GetValue<string>() ?? "",
|
2023-04-11 17:15:55 +07:00
|
|
|
PaymentType = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Type)]?.GetValue<string>(),
|
2023-04-06 16:38:26 +07:00
|
|
|
ChequeNo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ChequeNo)]?.GetValue<string>() ?? "",
|
|
|
|
|
Amount = (decimal)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amount)]?.GetValue<decimal>(),
|
|
|
|
|
ChqueBankCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ChqBankCode)]?.GetValue<string>() ?? ""
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// occupation
|
|
|
|
|
r.Occupations.Add(new RecruitOccupation()
|
|
|
|
|
{
|
|
|
|
|
Occupation = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Occupation)]?.GetValue<string>() ?? "",
|
2023-04-11 17:15:55 +07:00
|
|
|
Position = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Position)]?.GetValue<string>() ?? "",
|
2023-04-06 16:38:26 +07:00
|
|
|
Workplace = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Workplace)]?.GetValue<string>() ?? "",
|
|
|
|
|
Telephone = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.WorkplaceTelephone)]?.GetValue<string>() ?? "",
|
|
|
|
|
WorkAge = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.WorkAge)]?.GetValue<string>() ?? "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// certificate
|
|
|
|
|
r.Certificates.Add(new RecruitCertificate()
|
|
|
|
|
{
|
|
|
|
|
CertificateNo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateNo)]?.GetValue<string>() ?? "",
|
|
|
|
|
Description = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateDesc)]?.GetValue<string>() ?? "",
|
|
|
|
|
IssueDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateIssueDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-")),
|
|
|
|
|
ExpiredDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateExpireDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
r.Educations.Add(new RecruitEducation()
|
|
|
|
|
{
|
|
|
|
|
Degree = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Degree)]?.GetValue<string>() ?? "",
|
|
|
|
|
Major = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Major)]?.GetValue<string>() ?? "",
|
|
|
|
|
MajorGroupId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.MajorGroupID)]?.GetValue<string>() ?? "",
|
|
|
|
|
MajorGroupName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.MajorGroupName)]?.GetValue<string>() ?? "",
|
|
|
|
|
University = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.University)]?.GetValue<string>() ?? "",
|
|
|
|
|
GPA = (double)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.GPA)]?.GetValue<double>(),
|
|
|
|
|
Specialist = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.SpecialList)]?.GetValue<string>() ?? "",
|
|
|
|
|
HighDegree = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.HighDegree)]?.GetValue<string>() ?? "",
|
|
|
|
|
BachelorDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.BachelorDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
r.RecruitImport = imported;
|
|
|
|
|
_context.Recruits.Add(r);
|
|
|
|
|
|
|
|
|
|
//imported.Recruits.Add(r);
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// finally save to database
|
|
|
|
|
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await _minioService.DeleteFileAsync(Guid.Parse(import_doc_id));
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (System.IO.File.Exists(importFile))
|
|
|
|
|
System.IO.File.Delete(importFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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>
|
|
|
|
|
[HttpDelete("candidate/{id:length(36)}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> DeleteCandidateFileAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable()
|
2023-04-11 17:15:55 +07:00
|
|
|
.Include(x => x.ImportHostories)
|
2023-04-06 16:38:26 +07:00
|
|
|
.Include(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Addresses)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Occupations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Certificates)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Educations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Payments)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Documents)
|
|
|
|
|
.ThenInclude(x => x.DocumentFile)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.ScoreImport)
|
|
|
|
|
.ThenInclude(x => x.Scores)
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
if (data == null)
|
|
|
|
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
|
|
|
|
|
|
|
|
|
var rec_import_id = data.ImportFile.Id.ToString("D");
|
|
|
|
|
var score_import_id = data.ScoreImport != null ? data.ScoreImport.ImportFile.Id.ToString("D") : "-";
|
|
|
|
|
|
|
|
|
|
_context.RecruitImports.Remove(data);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
// delete upload candidate file
|
|
|
|
|
await _minioService.DeleteFileAsync(Guid.Parse(rec_import_id));
|
|
|
|
|
|
|
|
|
|
// delete score file
|
|
|
|
|
if (score_import_id != "-")
|
|
|
|
|
await _minioService.DeleteFileAsync(Guid.Parse(score_import_id));
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-11 17:15:55 +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>
|
|
|
|
|
[HttpGet("history/{id:length(36)}")]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetImportHistoryAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImportHistories.AsQueryable()
|
|
|
|
|
.Include(x => x.RecruitImport)
|
|
|
|
|
.Where(x => x.RecruitImport.Id == id)
|
|
|
|
|
.OrderByDescending(x => x.CreatedAt)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
return Success(data);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-23 12:00:07 +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>
|
|
|
|
|
[HttpPost("candidate/{id:length(36)}"), DisableRequestSizeLimit]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
|
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> ImportCandidateFileByIdAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var tmpDir = Path.Combine(_webHostEnvironment.ContentRootPath, "tmp");
|
|
|
|
|
if (!Directory.Exists(tmpDir))
|
|
|
|
|
Directory.CreateDirectory(tmpDir);
|
|
|
|
|
|
|
|
|
|
var importFile = Path.Combine(tmpDir, $"c_{DateTime.Now.ToString("ddMMyyyyHHmmss")}.xlsx");
|
|
|
|
|
var import_doc_id = "";
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return Error(GlobalMessages.NoFileToUpload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var imported = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.Include(x => x.ImportHostories)
|
|
|
|
|
.Include(x => x.ImportFile)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Addresses)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Occupations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Certificates)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Educations)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.ThenInclude(x => x.Payments)
|
|
|
|
|
.Include(x => x.Recruits)
|
|
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
if (imported == null)
|
|
|
|
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
|
|
|
|
|
|
|
|
|
if (imported.Recruits != null)
|
|
|
|
|
{
|
|
|
|
|
// remove old score data
|
|
|
|
|
_context.Recruits.RemoveRange(imported.Recruits);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
|
var doc = await _minioService.UploadFileAsync(file);
|
|
|
|
|
import_doc_id = doc.Id.ToString("D");
|
|
|
|
|
|
|
|
|
|
var fileContent = (await _minioService.DownloadFileAsync(doc.Id)).FileContent;
|
|
|
|
|
|
|
|
|
|
// สร้างรอบการบรรจุ โดยเอาเข้ามูลมาใส่จาก Request
|
|
|
|
|
imported.ImportHostories.Add(new RecruitImportHistory
|
|
|
|
|
{
|
|
|
|
|
Description = "นำเข้าข้อมูลผู้สมัครสอบแข่งขัน",
|
|
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//await _context.RecruitImports.AddAsync(imported);
|
|
|
|
|
|
|
|
|
|
// import datafile
|
|
|
|
|
System.IO.File.WriteAllBytes(importFile, fileContent);
|
|
|
|
|
|
|
|
|
|
using (var c_package = new ExcelPackage(new FileInfo(importFile)))
|
|
|
|
|
{
|
|
|
|
|
// loop from sheet2 to end
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < c_package.Workbook.Worksheets.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var workSheet = c_package.Workbook.Worksheets[i];
|
|
|
|
|
var totalRows = workSheet.Dimension.Rows;
|
|
|
|
|
var cols = workSheet.GetHeaderColumns();
|
|
|
|
|
|
|
|
|
|
int row = 2;
|
|
|
|
|
|
|
|
|
|
while (row <= totalRows)
|
|
|
|
|
{
|
|
|
|
|
var cell1 = workSheet?.Cells[row, 1]?.GetValue<string>();
|
|
|
|
|
if (cell1 == "" || cell1 == null) break;
|
|
|
|
|
|
|
|
|
|
var r = new Models.Recruits.Recruit();
|
|
|
|
|
r.ExamId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ExamID)]?.GetValue<string>();
|
|
|
|
|
r.CitizenId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalID)]?.GetValue<string>();
|
|
|
|
|
r.Prefix = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Prefix)]?.GetValue<string>();
|
|
|
|
|
r.FirstName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.FirstName)]?.GetValue<string>();
|
|
|
|
|
r.LastName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.LastName)]?.GetValue<string>();
|
|
|
|
|
r.Gendor = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Gender)]?.GetValue<string>();
|
|
|
|
|
r.National = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.National)]?.GetValue<string>().IsNull("");
|
|
|
|
|
r.Race = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Race)]?.GetValue<string>().IsNull("");
|
|
|
|
|
r.Religion = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Religion)]?.GetValue<string>().IsNull("");
|
|
|
|
|
r.DateOfBirth = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.DateOfBirth)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
|
|
|
|
|
r.Marry = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Marry)]?.GetValue<string>();
|
|
|
|
|
r.Isspecial = "N";
|
|
|
|
|
r.CitizenCardIssuer = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardIssue)]?.GetValue<string>();
|
|
|
|
|
r.CitizenCardExpireDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardExpireDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"));
|
|
|
|
|
r.ApplyDate = (DateTime)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ApplyDate)]?.GetValue<DateTime>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// address
|
|
|
|
|
r.Addresses.Add(new RecruitAddress()
|
|
|
|
|
{
|
|
|
|
|
Address = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Address)]?.GetValue<string>() ?? "",
|
|
|
|
|
Moo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Moo)]?.GetValue<string>() ?? "",
|
|
|
|
|
Soi = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Soi)]?.GetValue<string>() ?? "",
|
|
|
|
|
Road = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Road)]?.GetValue<string>() ?? "",
|
|
|
|
|
District = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.District)]?.GetValue<string>() ?? "",
|
|
|
|
|
Amphur = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amphur)]?.GetValue<string>() ?? "",
|
|
|
|
|
Province = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Province)]?.GetValue<string>() ?? "",
|
|
|
|
|
ZipCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ZipCode)]?.GetValue<string>() ?? "",
|
|
|
|
|
Telephone = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Telephone)]?.GetValue<string>() ?? "",
|
|
|
|
|
Mobile = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Mobile)]?.GetValue<string>() ?? "",
|
|
|
|
|
Address1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Address1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Moo1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Moo1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Soi1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Soi1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Road1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Road1)]?.GetValue<string>() ?? "",
|
|
|
|
|
District1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.District1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Amphur1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amphur1)]?.GetValue<string>() ?? "",
|
|
|
|
|
Province1 = "",
|
|
|
|
|
ZipCode1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ZipCode1)]?.GetValue<string>() ?? "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// payment
|
|
|
|
|
r.Payments.Add(new RecruitPayment()
|
|
|
|
|
{
|
|
|
|
|
PaymentId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PaymentID)]?.GetValue<string>() ?? "",
|
|
|
|
|
CompanyCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CompanyCode)]?.GetValue<string>() ?? "",
|
|
|
|
|
TextFile = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TextFile)]?.GetValue<string>() ?? "",
|
|
|
|
|
BankCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.BankCode)]?.GetValue<string>() ?? "",
|
|
|
|
|
AccountNumber = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.AccouontNumer)]?.GetValue<string>() ?? "",
|
|
|
|
|
TransDate = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TransDate)]?.GetValue<string>() ?? "",
|
|
|
|
|
TransTime = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TransTime)]?.GetValue<string>() ?? "",
|
|
|
|
|
CustomerName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CustomerName)]?.GetValue<string>() ?? "",
|
|
|
|
|
RefNo1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.RefNo1)]?.GetValue<string>() ?? "",
|
|
|
|
|
TermBranch = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TermBranch)]?.GetValue<string>() ?? "",
|
|
|
|
|
TellerId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TellerID)]?.GetValue<string>() ?? "",
|
|
|
|
|
CreditDebit = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CreditDebit)]?.GetValue<string>() ?? "",
|
|
|
|
|
PaymentType = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Type)]?.GetValue<string>(),
|
|
|
|
|
ChequeNo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ChequeNo)]?.GetValue<string>() ?? "",
|
|
|
|
|
Amount = (decimal)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amount)]?.GetValue<decimal>(),
|
|
|
|
|
ChqueBankCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ChqBankCode)]?.GetValue<string>() ?? ""
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// occupation
|
|
|
|
|
r.Occupations.Add(new RecruitOccupation()
|
|
|
|
|
{
|
|
|
|
|
Occupation = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Occupation)]?.GetValue<string>() ?? "",
|
|
|
|
|
Position = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Position)]?.GetValue<string>() ?? "",
|
|
|
|
|
Workplace = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Workplace)]?.GetValue<string>() ?? "",
|
|
|
|
|
Telephone = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.WorkplaceTelephone)]?.GetValue<string>() ?? "",
|
|
|
|
|
WorkAge = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.WorkAge)]?.GetValue<string>() ?? "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// certificate
|
|
|
|
|
r.Certificates.Add(new RecruitCertificate()
|
|
|
|
|
{
|
|
|
|
|
CertificateNo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateNo)]?.GetValue<string>() ?? "",
|
|
|
|
|
Description = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateDesc)]?.GetValue<string>() ?? "",
|
|
|
|
|
IssueDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateIssueDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-")),
|
|
|
|
|
ExpiredDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateExpireDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
r.Educations.Add(new RecruitEducation()
|
|
|
|
|
{
|
|
|
|
|
Degree = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Degree)]?.GetValue<string>() ?? "",
|
|
|
|
|
Major = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Major)]?.GetValue<string>() ?? "",
|
|
|
|
|
MajorGroupId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.MajorGroupID)]?.GetValue<string>() ?? "",
|
|
|
|
|
MajorGroupName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.MajorGroupName)]?.GetValue<string>() ?? "",
|
|
|
|
|
University = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.University)]?.GetValue<string>() ?? "",
|
|
|
|
|
GPA = (double)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.GPA)]?.GetValue<double>(),
|
|
|
|
|
Specialist = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.SpecialList)]?.GetValue<string>() ?? "",
|
|
|
|
|
HighDegree = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.HighDegree)]?.GetValue<string>() ?? "",
|
|
|
|
|
BachelorDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.BachelorDate)]?.GetValue<string>().ToDateTime(DateTimeFormat.Ymd, "-"))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
r.RecruitImport = imported;
|
|
|
|
|
_context.Recruits.Add(r);
|
|
|
|
|
|
|
|
|
|
//imported.Recruits.Add(r);
|
|
|
|
|
row++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// finally save to database
|
|
|
|
|
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await _minioService.DeleteFileAsync(Guid.Parse(import_doc_id));
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (System.IO.File.Exists(importFile))
|
|
|
|
|
System.IO.File.Delete(importFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-06 16:38:26 +07:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region " Score File "
|
|
|
|
|
|
|
|
|
|
[HttpPost("score/{id:length(36)}"), DisableRequestSizeLimit]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> ImportScoreFileAsync(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var tmpDir = Path.Combine(_webHostEnvironment.ContentRootPath, "tmp");
|
|
|
|
|
if (!Directory.Exists(tmpDir))
|
|
|
|
|
Directory.CreateDirectory(tmpDir);
|
|
|
|
|
|
|
|
|
|
var importFile = Path.Combine(tmpDir, $"s_{DateTime.Now.ToString("ddMMyyyyHHmmss")}.xlsx");
|
|
|
|
|
var import_doc_id = "";
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Request.Form.Files == null || Request.Form.Files.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return Error(GlobalMessages.NoFileToUpload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rec_import = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.Include(x => x.ScoreImport)
|
2023-04-23 12:00:07 +07:00
|
|
|
.ThenInclude(x => x.Scores)
|
2023-04-11 17:15:55 +07:00
|
|
|
.Include(x => x.ImportHostories)
|
2023-04-06 16:38:26 +07:00
|
|
|
.FirstOrDefaultAsync(x => x.Id == id);
|
|
|
|
|
|
|
|
|
|
if (rec_import == null)
|
|
|
|
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
|
|
|
|
|
|
|
|
|
if (rec_import.ScoreImport != null)
|
2023-04-23 12:00:07 +07:00
|
|
|
{
|
|
|
|
|
// remove old score data
|
|
|
|
|
if (rec_import.ScoreImport.Scores != null)
|
|
|
|
|
{
|
|
|
|
|
_context.RecruitScores.RemoveRange(rec_import.ScoreImport.Scores);
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-04-06 16:38:26 +07:00
|
|
|
|
|
|
|
|
var file = Request.Form.Files[0];
|
|
|
|
|
var doc = await _minioService.UploadFileAsync(file);
|
|
|
|
|
import_doc_id = doc.Id.ToString("D");
|
|
|
|
|
var fileContent = (await _minioService.DownloadFileAsync(doc.Id)).FileContent;
|
|
|
|
|
|
2023-04-11 17:15:55 +07:00
|
|
|
// create import history
|
|
|
|
|
rec_import.ImportHostories.Add(new RecruitImportHistory
|
|
|
|
|
{
|
|
|
|
|
Description = "นำเข้าข้อมูลผลคะแนนสอบ",
|
|
|
|
|
CreatedAt = DateTime.Now,
|
|
|
|
|
CreatedUserId = UserId ?? "",
|
|
|
|
|
CreatedFullName = FullName ?? "System Administrator",
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-06 16:38:26 +07:00
|
|
|
// create new file import
|
|
|
|
|
var imported = new ScoreImport
|
|
|
|
|
{
|
|
|
|
|
Year = rec_import.Year,
|
|
|
|
|
ImportFile = doc,
|
|
|
|
|
Scores = new List<RecruitScore>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// import datafile
|
|
|
|
|
System.IO.File.WriteAllBytes(importFile, fileContent);
|
|
|
|
|
|
|
|
|
|
using (var c_package = new ExcelPackage(new FileInfo(importFile)))
|
|
|
|
|
{
|
|
|
|
|
// loop from sheet2 to end
|
|
|
|
|
for (int i = 1; i < c_package.Workbook.Worksheets.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var workSheet = c_package.Workbook.Worksheets[i];
|
|
|
|
|
var totalRows = workSheet.Dimension.Rows;
|
|
|
|
|
var cols = workSheet.GetHeaderColumns();
|
|
|
|
|
|
|
|
|
|
int row = 8;
|
|
|
|
|
|
|
|
|
|
while (row <= totalRows)
|
|
|
|
|
{
|
|
|
|
|
var cell1 = workSheet?.Cells[row, 1]?.GetValue<string>();
|
|
|
|
|
if (cell1 == "" || cell1 == null) break;
|
|
|
|
|
|
|
|
|
|
var r = new RecruitScore();
|
|
|
|
|
r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>();
|
|
|
|
|
|
|
|
|
|
r.FullA = (int)workSheet?.Cells[7, 7]?.GetValue<string>().Replace("(", "").Replace(")", "").Replace("คะแนน", "").Trim().ToInteger();
|
|
|
|
|
r.SumA = workSheet?.Cells[row, 7]?.GetValue<string>() == "ขส." ? 0 : (int)workSheet?.Cells[row, 7]?.GetValue<string>().Replace(".00", "").ToInteger();
|
|
|
|
|
r.PercentageA = workSheet?.Cells[row, 8]?.GetValue<string>() == "ขส." ? 0.0 : (double)workSheet?.Cells[row, 8]?.GetValue<double>();
|
|
|
|
|
|
|
|
|
|
r.FullB = (int)workSheet?.Cells[7, 12]?.GetValue<string>().Replace("(", "").Replace(")", "").Replace("คะแนน", "").Trim().ToInteger();
|
|
|
|
|
r.SumB = workSheet?.Cells[row, 12]?.GetValue<string>() == "ขส." ? 0 : (int)workSheet?.Cells[row, 12]?.GetValue<string>().Replace(".00", "").ToInteger();
|
|
|
|
|
r.PercentageB = workSheet?.Cells[row, 13]?.GetValue<string>() == "ขส." ? 0.0 : (double)workSheet?.Cells[row, 13]?.GetValue<double>();
|
|
|
|
|
|
|
|
|
|
r.SumAB = workSheet?.Cells[row, 15]?.GetValue<string>() == "ขส." ? 0 : (int)workSheet?.Cells[row, 15]?.GetValue<string>().Replace(".00", "").ToInteger();
|
|
|
|
|
r.ABStatus = workSheet?.Cells[row, 17]?.GetValue<string>();
|
|
|
|
|
|
|
|
|
|
r.FullC = (int)workSheet?.Cells[7, 20]?.GetValue<string>().Replace("(", "").Replace(")", "").Replace("คะแนน", "").Trim().ToInteger();
|
|
|
|
|
r.SumC = workSheet?.Cells[row, 20]?.GetValue<string>() == "ขส." ? 0 : (int)workSheet?.Cells[row, 20]?.GetValue<string>().Replace(".00", "").ToInteger();
|
|
|
|
|
r.PercentageC = workSheet?.Cells[row, 21]?.GetValue<string>() == "ขส." ? 0.0 : (double)workSheet?.Cells[row, 21]?.GetValue<double>();
|
|
|
|
|
|
|
|
|
|
r.ExamStatus = workSheet?.Cells[row, 24]?.GetValue<string>();
|
|
|
|
|
r.Major = workSheet.Name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imported.Scores.Add(r);
|
|
|
|
|
row++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// finally save to database
|
|
|
|
|
rec_import.ScoreImport = imported;
|
|
|
|
|
await _context.SaveChangesAsync();
|
|
|
|
|
|
|
|
|
|
return Success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2023-04-23 12:00:07 +07:00
|
|
|
await _minioService.DeleteFileAsync(Guid.Parse(import_doc_id));
|
2023-04-06 16:38:26 +07:00
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (System.IO.File.Exists(importFile))
|
|
|
|
|
System.IO.File.Delete(importFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region " Exam Information "
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// แสดงข้อมูลสำหรับหน้าจอ : รายการข้อมูลผู้สมัครสอบ
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpGet("exam")]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetExamResultAsync()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var data = await _context.RecruitImports.AsQueryable()
|
|
|
|
|
.OrderByDescending(x => x.Year)
|
|
|
|
|
.ThenByDescending(x => x.Order)
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
ExamYear = x.Year.ToThaiYear(),
|
|
|
|
|
ExamOrder = x.Order,
|
|
|
|
|
Description = x.Name,
|
|
|
|
|
})
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
var result = new List<dynamic>();
|
|
|
|
|
|
|
|
|
|
foreach (var d in data)
|
|
|
|
|
{
|
|
|
|
|
result.Add(new
|
|
|
|
|
{
|
|
|
|
|
ExamYear = d.ExamYear,
|
|
|
|
|
Decription = d.Description,
|
|
|
|
|
ExamCount = await GetExamCount(d.Id),
|
|
|
|
|
PassCount = await GetPassExamCount(d.Id),
|
|
|
|
|
NotPassCount = (await GetExamCount(d.Id) - await GetPassExamCount(d.Id))
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Success(result);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost("exam/{id:length(36)}")]
|
|
|
|
|
public ActionResult<ResponseObject> GetExamResultById([FromBody] RecruitExamRequest req, Guid id)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var p_Id = new MySqlParameter("@id", id);
|
|
|
|
|
var data = new List<dynamic>();
|
|
|
|
|
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
|
|
|
|
{
|
|
|
|
|
cmd.CommandTimeout = 0;
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
cmd.Parameters.Clear();
|
|
|
|
|
sb.Clear();
|
|
|
|
|
sb.Append(" SELECT * ");
|
|
|
|
|
sb.Append(" FROM exam_info ");
|
|
|
|
|
sb.Append(" WHERE recruit_import_id = @id ");
|
|
|
|
|
cmd.Parameters.Add(p_Id);
|
|
|
|
|
|
|
|
|
|
if (req.ExamAttribute != null && req.ExamAttribute != "")
|
|
|
|
|
{
|
|
|
|
|
sb.Append(" AND examAttribute = @a ");
|
|
|
|
|
cmd.Parameters.Add(new MySqlParameter("@a", req.ExamAttribute));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.ExamResult != null && req.ExamResult != "")
|
|
|
|
|
{
|
|
|
|
|
sb.Append(" AND result = @r ");
|
|
|
|
|
cmd.Parameters.Add(new MySqlParameter("@r", req.ExamResult));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmd.CommandText = sb.ToString();
|
|
|
|
|
|
|
|
|
|
_context.Database.OpenConnection();
|
|
|
|
|
var da = new MySqlDataAdapter(cmd as MySqlCommand);
|
|
|
|
|
var dt = new DataTable();
|
|
|
|
|
da.Fill(dt);
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dr in dt.Rows)
|
|
|
|
|
{
|
|
|
|
|
data.Add(new
|
|
|
|
|
{
|
|
|
|
|
examID = dr["examID"].ToString(),
|
|
|
|
|
profileID = dr["profileID"].ToString(),
|
|
|
|
|
prefix = dr["prefix"].ToString(),
|
|
|
|
|
fullName = dr["fullName"].ToString(),
|
|
|
|
|
dateOfBirth = dr["dateofbirth"] == null ? "" : Convert.ToDateTime(dr["dateofbirth"]).ToThaiShortDate(),
|
|
|
|
|
gender = dr["gender"].ToString(),
|
|
|
|
|
degree = dr["degree"].ToString(),
|
|
|
|
|
major = dr["major"].ToString(),
|
|
|
|
|
majorgroup = dr["majorgroup"].ToString(),
|
|
|
|
|
certificateNo = dr["certificateno"].ToString(),
|
|
|
|
|
certificateIssueDate = dr["certificateIssueDate"] == null ? "" : Convert.ToDateTime(dr["certificateIssueDate"]).ToThaiShortDate(),
|
|
|
|
|
ExamScore = dr["score"] == null ? 0 : dr["score"].ToString().ToInteger(),
|
|
|
|
|
ExamResult = dr["result"].ToString(),
|
|
|
|
|
ExamAttribute = dr["examAttribute"].ToString(),
|
|
|
|
|
Remark = dr["remark"].ToString(),
|
|
|
|
|
IsSpecial = dr["isspecial"].ToString(),
|
|
|
|
|
applyDate = dr["applydate"] == null ? "" : Convert.ToDateTime(dr["applydate"]).ToThaiShortDate(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dynamic header = null;
|
|
|
|
|
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
cmd.CommandTimeout = 0;
|
|
|
|
|
cmd.Parameters.Clear();
|
|
|
|
|
sb.Clear();
|
|
|
|
|
sb.Append(" SELECT * ");
|
|
|
|
|
sb.Append(" FROM sum_exam_info ");
|
|
|
|
|
sb.Append(" WHERE recruit_import_id = @id ");
|
|
|
|
|
cmd.Parameters.Add(p_Id);
|
|
|
|
|
|
|
|
|
|
cmd.CommandText = sb.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_context.Database.OpenConnection();
|
|
|
|
|
MySqlDataAdapter da = new MySqlDataAdapter(cmd as MySqlCommand);
|
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
|
da.Fill(dt);
|
|
|
|
|
if (dt.Rows.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
header = new
|
|
|
|
|
{
|
|
|
|
|
count = 0,
|
|
|
|
|
pass = 0,
|
|
|
|
|
notpass = 0
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var dr = dt.Rows[0];
|
|
|
|
|
header = new
|
|
|
|
|
{
|
|
|
|
|
count = dr["count"].ToString().ToInteger(),
|
|
|
|
|
pass = dr["pass"].ToString().ToInteger(),
|
|
|
|
|
notpass = dr["notpass"].ToString().ToInteger()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Success(new
|
|
|
|
|
{
|
|
|
|
|
data = data,
|
|
|
|
|
header = header,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("exam/{id:length(36)}/{examId}")]
|
|
|
|
|
public async Task<ActionResult<ResponseObject>> GetExamResultByPersonAsync(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,
|
|
|
|
|
ProfileID = p.CitizenId,
|
|
|
|
|
p.Prefix,
|
|
|
|
|
FullName = $"{p.FirstName} {p.LastName}",
|
|
|
|
|
DateOfBirth = p.DateOfBirth.ToThaiShortDate(),
|
|
|
|
|
Gender = p.Gendor,
|
|
|
|
|
Degree = p.Educations.First().Degree,
|
|
|
|
|
Major = p.Educations.First().Major,
|
|
|
|
|
CertificateNo = p.Certificates.First().CertificateNo,
|
|
|
|
|
CertificateIssueDate = p.Certificates.First().IssueDate.ToThaiShortDate(),
|
|
|
|
|
ExamResult = sr == null ? "" : sr.ExamStatus,
|
|
|
|
|
ExamAttribute = _recruitService.CheckValidCertificate(p.Certificates.First().IssueDate, 5) ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ",
|
|
|
|
|
IsSpecial = p.Isspecial,
|
|
|
|
|
Remark = p.Remark,
|
|
|
|
|
Score = sr == null ? 0 : sr.SumA + sr.SumB + sr.SumC,
|
|
|
|
|
ScoreResult = sr == null ? null : new
|
|
|
|
|
{
|
|
|
|
|
ScoreAFull = sr.FullA,
|
|
|
|
|
ScoreA = sr.SumA,
|
|
|
|
|
ScoreBFull = sr.FullB,
|
|
|
|
|
ScoreB = sr.SumB,
|
|
|
|
|
ScoreCFull = sr.FullC,
|
|
|
|
|
ScoreC = sr.SumC,
|
|
|
|
|
ScoreSumFull = sr.FullA + sr.FullB + sr.FullC,
|
|
|
|
|
ScoreSum = sr.SumA + sr.SumB + sr.SumC,
|
|
|
|
|
ExamResult = sr.ExamStatus
|
|
|
|
|
},
|
|
|
|
|
Attachments = p.Documents.Select(a => new
|
|
|
|
|
{
|
|
|
|
|
FileName = a.DocumentFile.FileName,
|
|
|
|
|
DocumentId = a.DocumentFile.Id
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
return Success(data);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return Error(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2023-03-25 21:01:46 +07:00
|
|
|
#endregion
|
|
|
|
|
}
|
2023-03-17 14:24:43 +07:00
|
|
|
}
|