Compare commits

..

No commits in common. "dev" and "v1.0.0" have entirely different histories.
dev ... v1.0.0

13 changed files with 154 additions and 6668 deletions

View file

@ -1365,7 +1365,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
District = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "", District = workSheet?.Cells[row, 54]?.GetValue<string>() ?? "",
Amphur = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "", Amphur = workSheet?.Cells[row, 55]?.GetValue<string>() ?? "",
Province = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "", Province = workSheet?.Cells[row, 56]?.GetValue<string>() ?? "",
ZipCode = (workSheet?.Cells[row, 57]?.GetValue<string>() ?? "").Trim(), ZipCode = workSheet?.Cells[row, 57]?.GetValue<string>() ?? "",
Telephone = workSheet?.Cells[row, 58]?.GetValue<string>() ?? "", Telephone = workSheet?.Cells[row, 58]?.GetValue<string>() ?? "",
Mobile = "", Mobile = "",
Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue<string>() ?? "")}", Address1 = $"{(workSheet?.Cells[row, 61]?.GetValue<string>() ?? "")} {(workSheet?.Cells[row, 62]?.GetValue<string>() ?? "")}",
@ -1375,7 +1375,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
District1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "", District1 = workSheet?.Cells[row, 66]?.GetValue<string>() ?? "",
Amphur1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "", Amphur1 = workSheet?.Cells[row, 67]?.GetValue<string>() ?? "",
Province1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "", Province1 = workSheet?.Cells[row, 68]?.GetValue<string>() ?? "",
ZipCode1 = (workSheet?.Cells[row, 69]?.GetValue<string>() ?? "").Trim(), ZipCode1 = workSheet?.Cells[row, 69]?.GetValue<string>() ?? "",
CreatedAt = DateTime.Now, CreatedAt = DateTime.Now,
CreatedUserId = UserId ?? "", CreatedUserId = UserId ?? "",
CreatedFullName = FullName ?? "System Administrator", CreatedFullName = FullName ?? "System Administrator",
@ -1399,7 +1399,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
TermBranch = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "", TermBranch = workSheet?.Cells[row, 113]?.GetValue<string>() ?? "",
TellerId = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "", TellerId = workSheet?.Cells[row, 114]?.GetValue<string>() ?? "",
CreditDebit = workSheet?.Cells[row, 115]?.GetValue<string>() ?? "", CreditDebit = workSheet?.Cells[row, 115]?.GetValue<string>() ?? "",
PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>() ?? "", PaymentType = workSheet?.Cells[row, 116]?.GetValue<string>(),
ChequeNo = workSheet?.Cells[row, 117]?.GetValue<string>() ?? "", ChequeNo = workSheet?.Cells[row, 117]?.GetValue<string>() ?? "",
Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue<decimal>(), Amount = (decimal)workSheet?.Cells[row, 118]?.GetValue<decimal>(),
ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue<string>() ?? "", ChqueBankCode = workSheet?.Cells[row, 119]?.GetValue<string>() ?? "",
@ -1604,10 +1604,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>(); r.ExamId = workSheet?.Cells[row, 2]?.GetValue<string>();
//var recruit = await _context.Disables.AsQueryable()
// .Include(x => x.PeriodExam)
// .Where(x => x.PeriodExam == rec_import && x.ExamId == r.ExamId)
// .FirstOrDefaultAsync();
// ใช้ dictionary lookup แทน query DB ทีละรอบ // ใช้ dictionary lookup แทน query DB ทีละรอบ
if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit)) if (!string.IsNullOrEmpty(r.ExamId) && recruitsDict.TryGetValue(r.ExamId, out var recruit))
{ {
r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>()?.Trim(); r.CitizenId = workSheet?.Cells[row, 3]?.GetValue<string>();
// ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง // ภาคความรู้ความสามารถที่ใช้เฉพาะตำแหน่ง
r.FullA = 200; r.FullA = 200;
@ -1628,20 +1633,24 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
r.FullScore = 300; r.FullScore = 300;
r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue<string>()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue<double>(), 2); r.TotalScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 13]?.GetValue<string>()) ? 0.00 : Math.Round(workSheet.Cells[row, 13].GetValue<double>(), 2);
var examStatusCol7 = workSheet?.Cells[row, 7]?.GetValue<string>()?.Trim(); if (workSheet?.Cells[row, 7]?.GetValue<string>() == "ขาดสอบ")
var examStatusCol14 = workSheet?.Cells[row, 14]?.GetValue<string>()?.Trim(); {
r.ExamStatus = r.ExamStatus = "ขส.";
examStatusCol7 == "ขาดสอบ" ? "ขส." : }
examStatusCol14 == "ได้" ? "ผ่าน" : else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ได้")
examStatusCol14 == "ตก" ? "ไม่ผ่าน" : "-"; {
r.ExamStatus = "ผ่าน";
}
else if (workSheet?.Cells[row, 14]?.GetValue<string>() == "ตก")
{
r.ExamStatus = "ไม่ผ่าน";
}
else
{
r.ExamStatus = "-";
}
r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue<string>()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue<string>(); r.RemarkScore = string.IsNullOrWhiteSpace(workSheet?.Cells[row, 15]?.GetValue<string>()) ? string.Empty : workSheet?.Cells[row, 15]?.GetValue<string>();
var examAttr = workSheet?.Cells[row, 16]?.GetValue<string>()?.Trim();
r.ExamAttribute =
examAttr == "ผ่าน" ? "มีคุณสมบัติ" :
examAttr == "ไม่ผ่าน" ? "ไม่มีคุณสมบัติ" : "";
r.Major = workSheet.Name; r.Major = workSheet.Name;
r.CreatedAt = DateTime.Now; r.CreatedAt = DateTime.Now;
@ -2082,15 +2091,10 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
: "", : "",
examScore = x.score == null ? 0.0 : x.score.TotalScore, examScore = x.score == null ? 0.0 : x.score.TotalScore,
examResult = x.score == null ? "" : x.score.ExamStatus, examResult = x.score == null ? "" : x.score.ExamStatus,
//examAttribute = x.disable.Certificates.Any() && x.disable.Certificates.First().IssueDate != null examAttribute = x.disable.Certificates.Any() && x.disable.Certificates.First().IssueDate != null
// ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5) ? _disableService.CheckValidCertificate(x.disable.Certificates.First().IssueDate, 5)
// ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ" ? "มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ", : "ไม่มีคุณสมบัติ",
examAttribute = x.score != null && !string.IsNullOrEmpty(x.score.ExamAttribute) &&
(x.score.ExamAttribute == "มีคุณสมบัติ" || x.score.ExamAttribute == "ไม่มีคุณสมบัติ")
? x.score.ExamAttribute : "",
remark = x.disable.Remark, remark = x.disable.Remark,
isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "", isSpecial = x.disable.Isspecial == "Y" ? x.disable.Isspecial : "",
applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue applyDate = x.disable.ApplyDate.HasValue && x.disable.ApplyDate.Value != DateTime.MinValue
@ -2187,8 +2191,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
.Where(x => x.ExamId == examId) .Where(x => x.ExamId == examId)
.Join(_context.DisableScores.AsQueryable() .Join(_context.DisableScores.AsQueryable()
.Include(x => x.ScoreImport), .Include(x => x.ScoreImport),
rc => new { PeriodExamId = rc.PeriodExam.Id, rc.ExamId }, rc => new { /*rc.PeriodExam.Year,*/ rc.ExamId },
sc => new { PeriodExamId = sc.ScoreImport.PeriodExamId, sc.ExamId }, sc => new { /*sc.ScoreImport.Year,*/ sc.ExamId },
(p, sr) => new (p, sr) => new
{ {
ExamID = p.ExamId, ExamID = p.ExamId,
@ -2210,16 +2214,11 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
: "" : ""
: "", : "",
ExamResult = sr == null ? "" : sr.ExamStatus, ExamResult = sr == null ? "" : sr.ExamStatus,
// ExamAttribute = p.Certificates.Count > 0 ? ExamAttribute = p.Certificates.Count > 0 ?
// _disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5) _disableService.CheckValidCertificate(p.Certificates.First().IssueDate, 5)
// ? "มีคุณสมบัติ" ? "มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ" : "ไม่มีคุณสมบัติ"
// : "ไม่มีคุณสมบัติ", : "ไม่มีคุณสมบัติ",
ExamAttribute = sr != null && !string.IsNullOrEmpty(sr.ExamAttribute) &&
(sr.ExamAttribute == "มีคุณสมบัติ" || sr.ExamAttribute == "ไม่มีคุณสมบัติ")
? sr.ExamAttribute : "",
IsSpecial = p.Isspecial, IsSpecial = p.Isspecial,
Remark = p.Remark, Remark = p.Remark,
University = p.Educations.First().University, University = p.Educations.First().University,

View file

@ -749,56 +749,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Controllers
} }
} }
/// <summary>
/// ดาวน์โหลดรายชื่อผู้มีสิทธิ์สอบ
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("download/candidate-exam/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DownloadCandidateExamAsync(string examId)
{
try
{
var data = await _periodExamService.DownloadCandidateExamAsync(examId);
return Success(data);
}
catch (Exception ex)
{
return Error(ex);
}
}
/// <summary>
/// ดาวน์โหลดรายชื่อผู้สอบคัดเลือกได้
/// </summary>
/// <param name="examId">รหัสรอบสมัคร</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านโหลดผู้สมัครสอบสำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("download/pass-exam/{examId:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> DownloadPassExamAsync(string examId)
{
try
{
var data = await _periodExamService.DownloadPassExamAsync(examId);
return Success(data);
}
catch (Exception ex)
{
return Error(ex, "เกิดข้อผิดพลาดในการแสดงรายงาน");
}
}
/// <summary> /// <summary>
/// โหลดผู้สมัครสอบ /// โหลดผู้สมัครสอบ
/// </summary> /// </summary>

View file

@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Nest; using Nest;
using Newtonsoft.Json;
using System.Diagnostics; using System.Diagnostics;
using System.IdentityModel.Tokens.Jwt; using System.Net.Http.Headers;
using System.Security.Claims; using System.Security.Claims;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
@ -18,6 +19,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
private string Uri = ""; private string Uri = "";
private string IndexFormat = ""; private string IndexFormat = "";
private string SystemName = ""; private string SystemName = "";
private string APIKey = "";
public RequestLoggingMiddleware(RequestDelegate next, IConfiguration configuration) public RequestLoggingMiddleware(RequestDelegate next, IConfiguration configuration)
{ {
@ -30,48 +32,65 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
SystemName = "recruiting"; SystemName = "recruiting";
} }
/// <summary> protected async Task<string> GetExternalAPIAsync(string apiPath, string accessToken, string apiKey)
/// แกะ JWT token เพื่อดึง claims ต่างๆ
/// </summary>
private JwtSecurityToken? ParseToken(string token)
{ {
try try
{ {
var tokenHandler = new JwtSecurityTokenHandler(); using (var client = new HttpClient())
var jwtToken = tokenHandler.ReadJwtToken(token.Replace("Bearer ", "")); {
return jwtToken; // Set timeout to 30 seconds instead of default 100 seconds
client.Timeout = TimeSpan.FromSeconds(30);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", apiKey);
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var _res = await client.GetAsync(apiPath, cts.Token);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
return _result;
}
return string.Empty;
}
} }
catch catch (TaskCanceledException)
{ {
// Log timeout but don't throw - return empty result instead
Console.WriteLine($"API call timed out: {apiPath}");
return string.Empty;
}
catch (Exception ex)
{
// Log other exceptions but don't throw - return empty result instead
Console.WriteLine($"API call failed: {apiPath}, Error: {ex.Message}");
return string.Empty;
}
}
public async Task<GetProfileByKeycloakIdLocal?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
{
try
{
//var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}";
var apiPath = $"{_configuration["API"]}/org/dotnet/user-logs/{keycloakId}";
var apiKey = _configuration["API_KEY"] ?? "";
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
if (!string.IsNullOrEmpty(apiResult))
{
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultLocal>(apiResult);
if (raw != null)
return raw.Result;
}
return null; return null;
} }
} catch (Exception ex)
/// <summary>
/// ดึงค่า claim จาก token โดยลองชื่อหลายแบบ
/// </summary>
private string? GetClaimValue(JwtSecurityToken? token, params string[] claimNames)
{
if (token == null) return null;
foreach (var name in claimNames)
{ {
var claim = token.Claims.FirstOrDefault(c => c.Type == name); // Log exception but don't throw - return null instead
if (claim != null) Console.WriteLine($"GetProfileByKeycloakIdAsync failed for {keycloakId}: {ex.Message}");
return claim.Value; return null;
} }
return null;
}
/// <summary>
/// ดึงค่า Guid claim จาก token
/// </summary>
private Guid? GetGuidClaim(JwtSecurityToken? token, params string[] claimNames)
{
var value = GetClaimValue(token, claimNames);
if (Guid.TryParse(value, out var guid))
return guid;
return null;
} }
public async Task Invoke(HttpContext context) public async Task Invoke(HttpContext context)
@ -136,22 +155,19 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
// เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้ // เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้
context.Response.Body = memoryStream; context.Response.Body = memoryStream;
var keycloakId = context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? Guid.Empty.ToString("D"); var keycloakId = context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? Guid.Empty.ToString("D");
var tokenHeader = context.Request.Headers["Authorization"].ToString(); var token = context.Request.Headers["Authorization"];
// แกะ JWT token เพื่อดึง claims ต่างๆ var pf = await GetProfileByKeycloakIdAsync(Guid.Parse(keycloakId), token);
var jwtToken = ParseToken(tokenHeader); var _userFullname = string.Empty;
var _userName = string.Empty;
// ดึงข้อมูลจาก claims โดยลองชื่อหลายแบบ (camelCase, snake_case, ฯลฯ) if (keycloakId != "00000000-0000-0000-0000-000000000000" && pf == null)
var prefix = GetClaimValue(jwtToken, "prefix", "Prefix", "PREFIX"); {
var firstName = GetClaimValue(jwtToken, "given_name", "firstname", "firstName", "FirstName", "FIRSTNAME"); _userFullname = context.User?.FindFirst("name")?.Value;
var lastName = GetClaimValue(jwtToken, "family_name", "lastname", "lastName", "LastName", "LASTNAME"); _userName = context.User?.FindFirst("preferred_username")?.Value;
var preferredUsername = GetClaimValue(jwtToken, "preferred_username", "preferred_username", "PreferredUsername"); }
var orgRootDnaId = GetGuidClaim(jwtToken, "orgRootDnaId", "org_root_dna_id", "OrgRootDnaId", "rootDnaId");
var orgChild1DnaId = GetGuidClaim(jwtToken, "orgChild1DnaId", "org_child1_dna", "OrgChild1Dna", "child1DnaId");
var orgChild2DnaId = GetGuidClaim(jwtToken, "orgChild2DnaId", "org_child2_dna", "OrgChild2Dna", "child2DnaId");
var orgChild3DnaId = GetGuidClaim(jwtToken, "orgChild3DnaId", "org_child3_dna", "OrgChild3Dna", "child3DnaId");
var orgChild4DnaId = GetGuidClaim(jwtToken, "orgChild4DnaId", "org_child4_dna", "OrgChild4Dna", "child4DnaId");
await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ
@ -238,7 +254,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
{ {
logType = logType, logType = logType,
ip = context.Connection.RemoteIpAddress?.ToString(), ip = context.Connection.RemoteIpAddress?.ToString(),
rootId = orgRootDnaId?.ToString("D"), //rootId = pf == null ? null : pf.RootId,
rootId = pf == null ? null : pf.RootDnaId,
systemName = SystemName, systemName = SystemName,
startTimeStamp = startTime.ToString("o"), startTimeStamp = startTime.ToString("o"),
endTimeStamp = endTime.ToString("o"), endTimeStamp = endTime.ToString("o"),
@ -252,8 +269,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
output = responseBodyJson, output = responseBodyJson,
userId = keycloakId, userId = keycloakId,
userName = $"{prefix ?? ""}{firstName ?? ""} {lastName ?? ""}".Trim(), userName = pf != null ? $"{pf?.Prefix ?? ""}{pf?.FirstName ?? ""} {pf?.LastName ?? ""}" : _userFullname ?? "",
user = preferredUsername ?? "" user = pf != null ? pf?.CitizenId ?? "" : _userName ?? ""
}; };
@ -278,4 +295,47 @@ namespace BMA.EHR.Recurit.Exam.Service.Core
return body; return body;
} }
} }
public class GetProfileByKeycloakIdLocal
{
public Guid Id { get; set; }
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? CitizenId { get; set; }
public string? Root { get; set; }
public string? Child1 { get; set; }
public string? Child2 { get; set; }
public string? Child3 { get; set; }
public string? Child4 { get; set; }
public Guid? RootId { get; set; }
public Guid? Child1Id { get; set; }
public Guid? Child2Id { get; set; }
public Guid? Child3Id { get; set; }
public Guid? Child4Id { get; set; }
public Guid? RootDnaId { get; set; }
public Guid? Child1DnaId { get; set; }
public Guid? Child2DnaId { get; set; }
public Guid? Child3DnaId { get; set; }
public Guid? Child4DnaId { get; set; }
public double? Amount { get; set; }
public double? PositionSalaryAmount { get; set; }
public string? Commander { get; set; }
public Guid? CommanderId { get; set; }
public Guid? CommanderKeycloak { get; set; }
}
public class GetProfileByKeycloakIdResultLocal
{
public string Message { get; set; } = string.Empty;
public int Status { get; set; } = -1;
public GetProfileByKeycloakIdLocal? Result { get; set; }
}
} }

View file

@ -1296,13 +1296,13 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
b.Property<string>("ZipCode") b.Property<string>("ZipCode")
.IsRequired() .IsRequired()
.HasMaxLength(10) .HasMaxLength(5)
.HasColumnType("varchar(10)"); .HasColumnType("varchar(5)");
b.Property<string>("ZipCode1") b.Property<string>("ZipCode1")
.IsRequired() .IsRequired()
.HasMaxLength(10) .HasMaxLength(5)
.HasColumnType("varchar(10)"); .HasColumnType("varchar(5)");
b.HasKey("Id"); b.HasKey("Id");
@ -1883,12 +1883,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Data.Migrations
.HasColumnOrder(101) .HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล"); .HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("ExamAttribute")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("สถานะคัดกรองคุณสมบัติ");
b.Property<string>("ExamId") b.Property<string>("ExamId")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(50)

View file

@ -1,32 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_table_DisableScore_add_field_ExamAttribute : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ExamAttribute",
table: "DisableScores",
type: "varchar(50)",
maxLength: 50,
nullable: false,
defaultValue: "",
comment: "สถานะคัดกรองคุณสมบัติ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ExamAttribute",
table: "DisableScores");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,66 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
/// <inheritdoc />
public partial class update_DisableAddress : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ZipCode1",
table: "DisableAddresses",
type: "varchar(10)",
maxLength: 10,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(5)",
oldMaxLength: 5)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ZipCode",
table: "DisableAddresses",
type: "varchar(10)",
maxLength: 10,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(5)",
oldMaxLength: 5)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ZipCode1",
table: "DisableAddresses",
type: "varchar(5)",
maxLength: 5,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(10)",
oldMaxLength: 10)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ZipCode",
table: "DisableAddresses",
type: "varchar(5)",
maxLength: 5,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(10)",
oldMaxLength: 10)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}

View file

@ -25,7 +25,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
[MaxLength(200)] [MaxLength(200)]
public string Province { get; set; }// public string Province { get; set; }//
[MaxLength(10)] [MaxLength(5)]
public string ZipCode { get; set; }// public string ZipCode { get; set; }//
[MaxLength(200)] [MaxLength(200)]
@ -55,7 +55,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
[MaxLength(200)] [MaxLength(200)]
public string Province1 { get; set; }// public string Province1 { get; set; }//
[MaxLength(10)] [MaxLength(5)]
public string ZipCode1 { get; set; }// public string ZipCode1 { get; set; }//
public Disable Disable { get; set; } public Disable Disable { get; set; }

View file

@ -80,9 +80,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Models.Disables
[Comment("หมายเหตุจากลำดับที่สอบได้")] [Comment("หมายเหตุจากลำดับที่สอบได้")]
public string RemarkExamOrder { get; set; } = string.Empty; public string RemarkExamOrder { get; set; } = string.Empty;
[MaxLength(50), Comment("สถานะคัดกรองคุณสมบัติ")]
public string ExamAttribute { get; set; } = string.Empty;
public ScoreImport ScoreImport { get; set; } public ScoreImport ScoreImport { get; set; }
} }
} }

View file

@ -9,8 +9,5 @@ namespace BMA.EHR.Recurit.Exam.Service.Response
public string? RejectDetail { get; set; } public string? RejectDetail { get; set; }
public bool? IsShowExamInfo { get; set; } public bool? IsShowExamInfo { get; set; }
public bool? IsShowResult { get; set; }
} }
} }

View file

@ -1978,19 +1978,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
if (candidate == null) if (candidate == null)
throw new Exception(GlobalMessages.CandidateNotFound); throw new Exception(GlobalMessages.CandidateNotFound);
bool IsShowResult = true; return new CandidateStatusResponse { Status = candidate.Status, RejectDetail = candidate.RejectDetail, IsShowExamInfo = candidate.IsShowExamInfo };
if (exam.AnnouncementDate != null)
{
var showResultEndDate = exam.AnnouncementDate.Value.Date.AddDays(15);
IsShowResult = DateTime.Now.Date <= showResultEndDate;
}
return new CandidateStatusResponse {
Status = candidate.Status,
RejectDetail = candidate.RejectDetail,
IsShowExamInfo = candidate.IsShowExamInfo,
IsShowResult = IsShowResult,
};
} }
public async Task UserCheckCandidateService(string examId, string positionId, string status) public async Task UserCheckCandidateService(string examId, string positionId, string status)

View file

@ -1625,101 +1625,6 @@ namespace BMA.EHR.Recurit.Exam.Service.Services
}; };
} }
public async Task<dynamic> DownloadCandidateExamAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Where(x => x.CheckDisability == false)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var data = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "register")
.Where(x => x.ExamIdenNumber != null && x.ExamIdenNumber != "")
.OrderBy(x => x.ExamIdenNumber)
.Select(p => new
{
ExamId = p.ExamIdenNumber == null ? null : (p.ExamIdenNumber.ToThaiNumber()),
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
PositionName = "",
ExamName =
($"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}").ToThaiNumber(),
}).ToListAsync();
if (data.Count == 0)
throw new Exception("ไม่พบข้อมูลในระบบ");
var examName = data[0].ExamName;
return new
{
template = "rptCandidateList",
reportName = $"รายชื่อผู้มีสิทธิ์สอบ_{data.First().ExamName}",
data = new
{
examName = examName,
data = data
}
};
}
public async Task<dynamic> DownloadPassExamAsync(string examId)
{
var periodExam = await _context.PeriodExams.AsQueryable()
.Where(x => x.CheckDisability == false)
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(examId));
if (periodExam == null)
throw new Exception(GlobalMessages.ExamNotFound);
var candidates = await _context.Candidates.AsQueryable()
.Include(x => x.PeriodExam)
.ThenInclude(x => x.ScoreImport)
.Where(x => x.PeriodExam == periodExam)
.Where(x => x.Status != "register")
.ToListAsync();
var data = candidates.Select((p, idx) => new
{
SeatNumber = p.SeatNumber == null ? "-" : (p.SeatNumber.ToThaiNumber()),
CitizenId = p.CitizenId == null ? "-" : (p.CitizenId.ToThaiNumber()),
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
DateOfBirth = p.DateOfBirth == null ? "-" : (p.DateOfBirth.Value.ToThaiShortDate()),
ExamName = ($"{p.PeriodExam.Name} ครั้งที่ {p.PeriodExam.Round}/{p.PeriodExam.Year.Value.ToThaiYear()}").ToThaiNumber(),
Number = p.Number == null ? (idx + 1).ToString().ToThaiNumber() : p.Number.ToThaiNumber(),
FullA = "",
SumA = "",
FullB = p.PointTotalB == null ? "-" : p.PointTotalB.ToString(),
SumB = p.PointB == null ? "-" : p.PointB.ToString(),
FullC = p.PointTotalC == null ? "-" : p.PointTotalC.ToString(),
SumC = p.PointC == null ? "-" : p.PointC.ToString(),
SumScore = ((Convert.ToInt32(p.PointB ?? "0") + Convert.ToInt32(p.PointC ?? "0")).ToString()).ToThaiNumber(),
ExamResult = p.Pass,
ExamThaiId = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber.ToThaiNumber(),
ExamId = p.ExamIdenNumber,
})
.OrderBy(x => x.ExamId)
.Where(x => x.ExamResult?.Trim() == "ได้")
.ToList();
if (data.Count == 0)
throw new Exception("ไม่พบข้อมูลในระบบ");
var examName = data[0].ExamName;
return new
{
template = "rptPassExamList",
reportName = $"รายชื่อผู้สอบแข่งขันได้_{periodExam.Name} ครั้งที่ {periodExam.Round}/{periodExam.Year.Value.ToThaiYear()}",
data = new
{
examName = examName,
data = data
}
};
}
public async Task<PeriodExam> GetsPaymentExamAsync(string examId) public async Task<PeriodExam> GetsPaymentExamAsync(string examId)
{ {
var periodExam = await _context.PeriodExams.AsQueryable() var periodExam = await _context.PeriodExams.AsQueryable()