diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index 3729ff0..0000000
--- a/.dockerignore
+++ /dev/null
@@ -1,25 +0,0 @@
-**/.classpath
-**/.dockerignore
-**/.env
-**/.git
-**/.gitignore
-**/.project
-**/.settings
-**/.toolstarget
-**/.vs
-**/.vscode
-**/*.*proj.user
-**/*.dbmdl
-**/*.jfm
-**/azds.yaml
-**/bin
-**/charts
-**/docker-compose*
-**/Dockerfile*
-**/node_modules
-**/npm-debug.log
-**/obj
-**/secrets.dev.yaml
-**/values.dev.yaml
-LICENSE
-README.md
\ No newline at end of file
diff --git a/.github/workflows/build-local.yaml b/.github/workflows/build-local.yaml
new file mode 100644
index 0000000..3a06de7
--- /dev/null
+++ b/.github/workflows/build-local.yaml
@@ -0,0 +1,46 @@
+# use for local build with act
+name: build-local
+run-name: build-local ${{ github.actor }}
+on:
+ workflow_dispatch:
+env:
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: demo/bma-ehr-metadata-service
+jobs:
+ # act workflow_dispatch -W .github/workflows/build-local.yaml --input IMAGE_VER=test-v6.1
+ build-local:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ # skip Set up QEMU because it fail on act and container
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Test Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ # - name: Login in to registry
+ # uses: docker/login-action@v2
+ # with:
+ # registry: ${{env.REGISTRY}}
+ # username: ${{secrets.DOCKER_USER}}
+ # password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ load: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
new file mode 100644
index 0000000..ed8d1dc
--- /dev/null
+++ b/.github/workflows/release.yaml
@@ -0,0 +1,67 @@
+name: release-dev
+run-name: release-dev ${{ github.actor }}
+on:
+ # push:
+ # tags:
+ # - 'v[0-9]+.[0-9]+.[0-9]+'
+ # tags-ignore:
+ # - '2.*'
+ # Allow run workflow manually from Action tab
+ workflow_dispatch:
+env:
+ REGISTRY: docker.frappet.com
+ IMAGE_NAME: ehr/bma-ehr-recruit-service
+ DEPLOY_HOST: frappet.com
+ COMPOSE_PATH: /home/frappet/docker/bma-ehr-recruit
+
+jobs:
+ # act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
+ release-dev:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ # skip Set up QEMU because it fail on act and container
+ - name: Gen Version
+ id: gen_ver
+ run: |
+ if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
+ IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
+ else
+ IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
+ fi
+ if [[ $IMAGE_VER == '' ]]; then
+ IMAGE_VER='test-vBeta'
+ fi
+ echo '::set-output name=image_ver::'$IMAGE_VER
+ - name: Test Version
+ run: |
+ echo $GITHUB_REF
+ echo ${{ steps.gen_ver.outputs.image_ver }}
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login in to registry
+ uses: docker/login-action@v2
+ with:
+ registry: ${{env.REGISTRY}}
+ username: ${{secrets.DOCKER_USER}}
+ password: ${{secrets.DOCKER_PASS}}
+ - name: Build and load local docker image
+ uses: docker/build-push-action@v3
+ with:
+ context: .
+ platforms: linux/amd64
+ push: true
+ tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
+
+ - name: Reload docker compose
+ uses: appleboy/ssh-action@v0.1.8
+ with:
+ host: ${{env.DEPLOY_HOST}}
+ username: frappet
+ password: ${{ secrets.SSH_PASSWORD }}
+ port: 22
+ script: |
+ cd "${{env.COMPOSE_PATH}}"
+ docker-compose pull
+ docker-compose up -d
+ echo "${{ steps.gen_ver.outputs.image_ver }}"> success
\ No newline at end of file
diff --git a/Controllers/RecruitController.cs b/Controllers/RecruitController.cs
index 065ffc0..73be880 100644
--- a/Controllers/RecruitController.cs
+++ b/Controllers/RecruitController.cs
@@ -1,5 +1,8 @@
+using Amazon.S3.Model;
+using BMA.EHR.Extensions;
using BMA.EHR.Recruit.Service.Core;
using BMA.EHR.Recruit.Service.Data;
+using BMA.EHR.Recruit.Service.Extensions;
using BMA.EHR.Recruit.Service.Models.Recruits;
using BMA.EHR.Recruit.Service.Requests.Recruits;
using BMA.EHR.Recruit.Service.Responses;
@@ -7,7 +10,12 @@ using BMA.EHR.Recruit.Service.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
+using MySqlConnector;
+using OfficeOpenXml;
+using Org.BouncyCastle.Ocsp;
+using Sentry;
using Swashbuckle.AspNetCore.Annotations;
+using System.Data;
using System.Net;
using System.Text;
@@ -256,8 +264,32 @@ namespace BMA.EHR.Recruit.Service.Controllers
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);
@@ -384,6 +416,10 @@ namespace BMA.EHR.Recruit.Service.Controllers
.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);
_context.RecruitImports.Remove(data);
@@ -399,6 +435,649 @@ namespace BMA.EHR.Recruit.Service.Controllers
#endregion
+ #region " Candidate Files "
+
+ ///
+ /// แสดงข้อมูลสำหรับหน้าจอ รายการนำเข้าข้อมูลผู้สมัครสอบแข่งขัน
+ ///
+ ///
+ /// เมื่อแสดงรายการข้อมูลสำเร็จ
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpGet("candidate")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> 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);
+ }
+ }
+
+
+ ///
+ /// นำเข้ารายชื่อผู้สมัครสอบแข่งขัน
+ ///
+ ///
+ /// เมื่อทำนำเข้าข้อมูลสำเร็จ
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("candidate"), DisableRequestSizeLimit]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> 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,
+ //Recruits = new List(),
+ };
+
+ 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();
+ if (cell1 == "" || cell1 == null) break;
+
+ var r = new Models.Recruits.Recruit();
+ r.ExamId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ExamID)]?.GetValue();
+ r.CitizenId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalID)]?.GetValue();
+ r.Prefix = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Prefix)]?.GetValue();
+ r.FirstName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.FirstName)]?.GetValue();
+ r.LastName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.LastName)]?.GetValue();
+ r.Gendor = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Gender)]?.GetValue();
+ r.National = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.National)]?.GetValue().IsNull("");
+ r.Race = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Race)]?.GetValue().IsNull("");
+ r.Religion = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Religion)]?.GetValue().IsNull("");
+ r.DateOfBirth = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.DateOfBirth)]?.GetValue().ToDateTime(DateTimeFormat.Ymd, "-"));
+ r.Marry = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Marry)]?.GetValue();
+ r.Isspecial = "N";
+ r.CitizenCardIssuer = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardIssue)]?.GetValue();
+ r.CitizenCardExpireDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PersonalCardExpireDate)]?.GetValue().ToDateTime(DateTimeFormat.Ymd, "-"));
+ r.ApplyDate = (DateTime)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ApplyDate)]?.GetValue();
+
+
+ // address
+ r.Addresses.Add(new RecruitAddress()
+ {
+ Address = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Address)]?.GetValue() ?? "",
+ Moo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Moo)]?.GetValue() ?? "",
+ Soi = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Soi)]?.GetValue() ?? "",
+ Road = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Road)]?.GetValue() ?? "",
+ District = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.District)]?.GetValue() ?? "",
+ Amphur = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amphur)]?.GetValue() ?? "",
+ Province = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Province)]?.GetValue() ?? "",
+ ZipCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ZipCode)]?.GetValue() ?? "",
+ Telephone = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Telephone)]?.GetValue() ?? "",
+ Mobile = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Mobile)]?.GetValue() ?? "",
+ Address1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Address1)]?.GetValue()??"",
+ Moo1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Moo1)]?.GetValue() ?? "",
+ Soi1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Soi1)]?.GetValue() ?? "",
+ Road1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Road1)]?.GetValue() ?? "",
+ District1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.District1)]?.GetValue() ?? "",
+ Amphur1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amphur1)]?.GetValue() ?? "",
+ Province1 = "",
+ ZipCode1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ZipCode1)]?.GetValue() ?? "",
+ });
+
+ // payment
+ r.Payments.Add(new RecruitPayment()
+ {
+ PaymentId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.PaymentID)]?.GetValue() ?? "",
+ CompanyCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CompanyCode)]?.GetValue() ?? "",
+ TextFile = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TextFile)]?.GetValue() ?? "",
+ BankCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.BankCode)]?.GetValue() ?? "",
+ AccountNumber = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.AccouontNumer)]?.GetValue() ?? "",
+ TransDate = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TransDate)]?.GetValue() ?? "",
+ TransTime = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TransTime)]?.GetValue() ?? "",
+ CustomerName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CustomerName)]?.GetValue() ?? "",
+ RefNo1 = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.RefNo1)]?.GetValue() ?? "",
+ TermBranch = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TermBranch)]?.GetValue() ?? "",
+ TellerId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.TellerID)]?.GetValue() ?? "",
+ CreditDebit = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CreditDebit)]?.GetValue() ?? "",
+ PaymentType = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Type)]?.GetValue() ,
+ ChequeNo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ChequeNo)]?.GetValue() ?? "",
+ Amount = (decimal)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Amount)]?.GetValue(),
+ ChqueBankCode = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.ChqBankCode)]?.GetValue() ?? ""
+ });
+
+ // occupation
+ r.Occupations.Add(new RecruitOccupation()
+ {
+ Occupation = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Occupation)]?.GetValue() ?? "",
+ Position = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Position)]?.GetValue()??"",
+ Workplace = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Workplace)]?.GetValue() ?? "",
+ Telephone = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.WorkplaceTelephone)]?.GetValue() ?? "",
+ WorkAge = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.WorkAge)]?.GetValue() ?? "",
+ });
+
+ // certificate
+ r.Certificates.Add(new RecruitCertificate()
+ {
+ CertificateNo = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateNo)]?.GetValue() ?? "",
+ Description = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateDesc)]?.GetValue() ?? "",
+ IssueDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateIssueDate)]?.GetValue().ToDateTime(DateTimeFormat.Ymd, "-")),
+ ExpiredDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.CertificateExpireDate)]?.GetValue().ToDateTime(DateTimeFormat.Ymd, "-"))
+ });
+
+ r.Educations.Add(new RecruitEducation()
+ {
+ Degree = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Degree)]?.GetValue() ?? "",
+ Major = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.Major)]?.GetValue() ?? "",
+ MajorGroupId = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.MajorGroupID)]?.GetValue() ?? "",
+ MajorGroupName = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.MajorGroupName)]?.GetValue() ?? "",
+ University = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.University)]?.GetValue() ?? "",
+ GPA = (double)workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.GPA)]?.GetValue(),
+ Specialist = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.SpecialList)]?.GetValue() ?? "",
+ HighDegree = workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.HighDegree)]?.GetValue() ?? "",
+ BachelorDate = Convert.ToDateTime(workSheet?.Cells[row, GetColumnIndex(cols, CandidateFileHeader.BachelorDate)]?.GetValue().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);
+ }
+ }
+
+ ///
+ /// ลบข้อมูลนำข้อมูลผู้สมัครสอบแข่งขัน
+ ///
+ /// รหัสรอบการสอบแข่งขัน
+ ///
+ /// เมื่อทำนำเข้าข้อมูลสำเร็จ
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpDelete("candidate/{id:length(36)}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
+ [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+ [ProducesResponseType(StatusCodes.Status500InternalServerError)]
+ public async Task> DeleteCandidateFileAsync(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)
+ .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);
+ }
+ }
+
+ #endregion
+
+ #region " Score File "
+
+ [HttpPost("score/{id:length(36)}"), DisableRequestSizeLimit]
+ public async Task> 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)
+ .FirstOrDefaultAsync(x => x.Id == id);
+
+ if (rec_import == null)
+ return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
+
+ if (rec_import.ScoreImport != null)
+ return Error($"มีการนำเข้าข้อมูลเอาไว้ก่อนหน้านี้แล้ว ไม่สามารถนำเข้าได้!!");
+
+ 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;
+
+ // create new file import
+ var imported = new ScoreImport
+ {
+ Year = rec_import.Year,
+ ImportFile = doc,
+ Scores = new List()
+ };
+
+ // 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();
+ if (cell1 == "" || cell1 == null) break;
+
+ var r = new RecruitScore();
+ r.ExamId = workSheet?.Cells[row, 2]?.GetValue();
+
+ r.FullA = (int)workSheet?.Cells[7, 7]?.GetValue().Replace("(", "").Replace(")", "").Replace("คะแนน", "").Trim().ToInteger();
+ r.SumA = workSheet?.Cells[row, 7]?.GetValue() == "ขส." ? 0 : (int)workSheet?.Cells[row, 7]?.GetValue().Replace(".00", "").ToInteger();
+ r.PercentageA = workSheet?.Cells[row, 8]?.GetValue() == "ขส." ? 0.0 : (double)workSheet?.Cells[row, 8]?.GetValue();
+
+ r.FullB = (int)workSheet?.Cells[7, 12]?.GetValue().Replace("(", "").Replace(")", "").Replace("คะแนน", "").Trim().ToInteger();
+ r.SumB = workSheet?.Cells[row, 12]?.GetValue() == "ขส." ? 0 : (int)workSheet?.Cells[row, 12]?.GetValue().Replace(".00", "").ToInteger();
+ r.PercentageB = workSheet?.Cells[row, 13]?.GetValue() == "ขส." ? 0.0 : (double)workSheet?.Cells[row, 13]?.GetValue();
+
+ r.SumAB = workSheet?.Cells[row, 15]?.GetValue() == "ขส." ? 0 : (int)workSheet?.Cells[row, 15]?.GetValue().Replace(".00", "").ToInteger();
+ r.ABStatus = workSheet?.Cells[row, 17]?.GetValue();
+
+ r.FullC = (int)workSheet?.Cells[7, 20]?.GetValue().Replace("(", "").Replace(")", "").Replace("คะแนน", "").Trim().ToInteger();
+ r.SumC = workSheet?.Cells[row, 20]?.GetValue() == "ขส." ? 0 : (int)workSheet?.Cells[row, 20]?.GetValue().Replace(".00", "").ToInteger();
+ r.PercentageC = workSheet?.Cells[row, 21]?.GetValue() == "ขส." ? 0.0 : (double)workSheet?.Cells[row, 21]?.GetValue();
+
+ r.ExamStatus = workSheet?.Cells[row, 24]?.GetValue();
+ 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)
+ {
+ return Error(ex);
+ }
+ finally
+ {
+ if (System.IO.File.Exists(importFile))
+ System.IO.File.Delete(importFile);
+ }
+ }
+
+ #endregion
+
+ #region " Exam Information "
+
+ ///
+ /// แสดงข้อมูลสำหรับหน้าจอ : รายการข้อมูลผู้สมัครสอบ
+ ///
+ [HttpGet("exam")]
+ public async Task> 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();
+
+ 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 GetExamResultById([FromBody] RecruitExamRequest req, Guid id)
+ {
+ try
+ {
+ var p_Id = new MySqlParameter("@id", id);
+ var data = new List();
+ 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> 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
+
#endregion
}
}
\ No newline at end of file
diff --git a/Core/GlobalMessages.cs b/Core/GlobalMessages.cs
index 806dd44..30057cf 100644
--- a/Core/GlobalMessages.cs
+++ b/Core/GlobalMessages.cs
@@ -1,10 +1,11 @@
namespace BMA.EHR.Recruit.Service.Core
{
- public class GlobalMessages
- {
- public const string FileNotFoundOnServer = "ไม่พบไฟล์ในระบบ!!";
- public const string CannotInsertToDatabase = "ไม่สามารถบันทึกลงฐานข้อมูลได้!!";
- public const string InvalidRequestParam = "Request parameter ไม่ถูกต้อง!!";
- public const string NoFileToUpload = "ไม่พบไฟล์เพื่อทำการอัพโหลด";
- }
+ public class GlobalMessages
+ {
+ public const string FileNotFoundOnServer = "ไม่พบไฟล์ในระบบ!!";
+ public const string CannotInsertToDatabase = "ไม่สามารถบันทึกลงฐานข้อมูลได้!!";
+ public const string InvalidRequestParam = "Request parameter ไม่ถูกต้อง!!";
+ public const string NoFileToUpload = "ไม่พบไฟล์เพื่อทำการอัพโหลด";
+ public const string DataNotFound = "ไม่พบข้อมูลในระบบ";
+ }
}
diff --git a/Dockerfile b/Dockerfile
index 5f71a60..e45a6f8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,10 +7,11 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
-COPY ["BMA.EHR.Recruit.Service/BMA.EHR.Recruit.Service.csproj", "BMA.EHR.Recruit.Service/"]
-RUN dotnet restore "BMA.EHR.Recruit.Service/BMA.EHR.Recruit.Service.csproj"
+COPY ["nuget.config", "."]
+COPY ["BMA.EHR.Recruit.Service.csproj", "."]
+RUN dotnet restore "./BMA.EHR.Recruit.Service.csproj"
COPY . .
-WORKDIR "/src/BMA.EHR.Recruit.Service"
+WORKDIR "/src/."
RUN dotnet build "BMA.EHR.Recruit.Service.csproj" -c Release -o /app/build
FROM build AS publish
diff --git a/Extensions/ExcelWorksheetExtension.cs b/Extensions/ExcelWorksheetExtension.cs
new file mode 100644
index 0000000..4d30d04
--- /dev/null
+++ b/Extensions/ExcelWorksheetExtension.cs
@@ -0,0 +1,19 @@
+using OfficeOpenXml;
+using System;
+using System.Collections.Generic;
+
+namespace BMA.EHR.Recruit.Service.Extensions
+{
+ public static class ExcelWorksheetExtension
+ {
+ public static string[] GetHeaderColumns(this ExcelWorksheet sheet, int row = 1)
+ {
+ List columnNames = new List();
+ foreach (var firstRowCell in sheet.Cells[row, sheet.Dimension.Start.Column, 1, sheet.Dimension.End.Column])
+ columnNames.Add(firstRowCell.Text);
+ return columnNames.ToArray();
+ }
+
+
+ }
+}
diff --git a/Migrations/20230403104559_Update Recruit Score Relationship.Designer.cs b/Migrations/20230403104559_Update Recruit Score Relationship.Designer.cs
new file mode 100644
index 0000000..a596d94
--- /dev/null
+++ b/Migrations/20230403104559_Update Recruit Score Relationship.Designer.cs
@@ -0,0 +1,1196 @@
+//
+using System;
+using BMA.EHR.Recruit.Service.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace BMA.EHR.Recruit.Service.Migrations
+{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20230403104559_Update Recruit Score Relationship")]
+ partial class UpdateRecruitScoreRelationship
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Documents.Document", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CreatedDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("Detail")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("varchar(255)");
+
+ b.Property("FileSize")
+ .HasColumnType("int");
+
+ b.Property("FileType")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("varchar(128)");
+
+ b.Property("ObjectRefId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Documents");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.Recruit", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("CitizenCardExpireDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CitizenCardIssuer")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("CitizenId")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("varchar(13)")
+ .HasComment("เลขประจำตัวประชาชน");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("DateOfBirth")
+ .HasColumnType("datetime(6)");
+
+ b.Property("ExamId")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("FirstName")
+ .IsRequired()
+ .HasMaxLength(150)
+ .HasColumnType("varchar(150)");
+
+ b.Property("Gendor")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("varchar(20)");
+
+ b.Property("Isspecial")
+ .IsRequired()
+ .HasMaxLength(1)
+ .HasColumnType("varchar(1)");
+
+ b.Property("LastName")
+ .IsRequired()
+ .HasMaxLength(150)
+ .HasColumnType("varchar(150)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("Marry")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("varchar(20)");
+
+ b.Property("National")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Prefix")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("Qualified")
+ .IsRequired()
+ .HasMaxLength(1)
+ .HasColumnType("varchar(1)");
+
+ b.Property("Race")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("RecruitImportId")
+ .HasColumnType("char(36)");
+
+ b.Property("RefNo")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("varchar(20)");
+
+ b.Property("Religion")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Remark")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RecruitImportId");
+
+ b.ToTable("Recruits");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitAddress", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("Address")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Address1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Amphur")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Amphur1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("District")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("District1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("Mobile")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Moo")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Moo1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Province")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Province1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("RecruitId")
+ .HasColumnType("char(36)");
+
+ b.Property("Road")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Road1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Soi")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Soi1")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Telephone")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("ZipCode")
+ .IsRequired()
+ .HasMaxLength(5)
+ .HasColumnType("varchar(5)");
+
+ b.Property("ZipCode1")
+ .IsRequired()
+ .HasMaxLength(5)
+ .HasColumnType("varchar(5)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RecruitId");
+
+ b.ToTable("RecruitAddresses");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitCertificate", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("CertificateNo")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("ExpiredDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("IssueDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("RecruitId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RecruitId");
+
+ b.ToTable("RecruitCertificates");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitDocument", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("DocumentFileId")
+ .HasColumnType("char(36)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("RecruitId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DocumentFileId");
+
+ b.HasIndex("RecruitId");
+
+ b.ToTable("RecruitDocuments");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitEducation", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("BachelorDate")
+ .HasColumnType("datetime(6)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("Degree")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("GPA")
+ .HasColumnType("double");
+
+ b.Property("HighDegree")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("Major")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("MajorGroupId")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("varchar(20)");
+
+ b.Property("MajorGroupName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("RecruitId")
+ .HasColumnType("char(36)");
+
+ b.Property("Specialist")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("varchar(1000)");
+
+ b.Property("University")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RecruitId");
+
+ b.ToTable("RecruitEducations");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitImport", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("ImportFileId")
+ .HasColumnType("char(36)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(250)
+ .HasColumnType("varchar(250)")
+ .HasColumnOrder(2)
+ .HasComment("ชื่อการสอบ");
+
+ b.Property("Order")
+ .HasColumnType("int")
+ .HasColumnOrder(3)
+ .HasComment("ครั้งที่");
+
+ b.Property("ScoreImportId")
+ .HasColumnType("char(36)");
+
+ b.Property("Year")
+ .HasColumnType("int")
+ .HasColumnOrder(1)
+ .HasComment("ปีที่จัดการสอบ");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ImportFileId");
+
+ b.HasIndex("ScoreImportId");
+
+ b.ToTable("RecruitImports");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitOccupation", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("Occupation")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Position")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("RecruitId")
+ .HasColumnType("char(36)");
+
+ b.Property("Telephone")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("WorkAge")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("Workplace")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RecruitId");
+
+ b.ToTable("RecruitOccupations");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitPayment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("AccountNumber")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("Amount")
+ .HasColumnType("decimal(65,30)");
+
+ b.Property("BankCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("ChequeNo")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("ChqueBankCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("CompanyCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("CreditDebit")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("CustomerName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)");
+
+ b.Property("LastUpdateFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(105)
+ .HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdateUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(103)
+ .HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
+
+ b.Property("LastUpdatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(102)
+ .HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
+
+ b.Property("PaymentId")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("PaymentType")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("RecruitId")
+ .HasColumnType("char(36)");
+
+ b.Property("RefNo1")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("TellerId")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("TermBranch")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("TextFile")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("TransDate")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("TransTime")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RecruitId");
+
+ b.ToTable("RecruitPayments");
+ });
+
+ modelBuilder.Entity("BMA.EHR.Recruit.Service.Models.Recruits.RecruitScore", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)")
+ .HasColumnOrder(0)
+ .HasComment("PrimaryKey")
+ .HasAnnotation("Relational:JsonPropertyName", "id");
+
+ b.Property("ABStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("CreatedAt")
+ .HasColumnType("datetime(6)")
+ .HasColumnOrder(100)
+ .HasComment("สร้างข้อมูลเมื่อ");
+
+ b.Property("CreatedFullName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("varchar(200)")
+ .HasColumnOrder(104)
+ .HasComment("ชื่อ User ที่สร้างข้อมูล");
+
+ b.Property("CreatedUserId")
+ .IsRequired()
+ .HasMaxLength(40)
+ .HasColumnType("varchar(40)")
+ .HasColumnOrder(101)
+ .HasComment("User Id ที่สร้างข้อมูล");
+
+ b.Property("ExamId")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("ExamStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("varchar(50)");
+
+ b.Property("FullA")
+ .HasColumnType("int");
+
+ b.Property