diff --git a/Models/Placement/PlacementProfile.cs b/Models/Placement/PlacementProfile.cs index 038c5a5..d66f845 100644 --- a/Models/Placement/PlacementProfile.cs +++ b/Models/Placement/PlacementProfile.cs @@ -245,6 +245,8 @@ namespace BMA.EHR.Domain.Models.Placement [Comment("หมายเหตุแนวนอน")] public string? RemarkHorizontal { get; set; } + [Comment("profileId")] + public string? profileId { get; set; } public virtual List PlacementCertificates { get; set; } = new List(); public virtual List PlacementEducations { get; set; } = new List(); } diff --git a/Request/Disables/PostDisableImportRequest.cs b/Request/Disables/PostDisableImportRequest.cs index 8c74ee5..232bc33 100644 --- a/Request/Disables/PostDisableImportRequest.cs +++ b/Request/Disables/PostDisableImportRequest.cs @@ -51,12 +51,12 @@ namespace BMA.EHR.Recurit.Exam.Service.Request.Disables /// /// วันเริ่มชำระเงิน /// - public DateTime PaymentStartDate { get; set; } + public DateTime? PaymentStartDate { get; set; } /// /// วันสิ้นสุดชำระเงิน /// - public DateTime PaymentEndDate { get; set; } + public DateTime? PaymentEndDate { get; set; } /// /// วันเริ่มสมัครสอบ diff --git a/Services/PeriodExamService.cs b/Services/PeriodExamService.cs index da0c321..0bb3926 100644 --- a/Services/PeriodExamService.cs +++ b/Services/PeriodExamService.cs @@ -15,6 +15,8 @@ using OfficeOpenXml; using BMA.EHR.Domain.Models.Placement; using OfficeOpenXml.Style; using System.Text; +using Newtonsoft.Json; +using System.Net.Http.Headers; namespace BMA.EHR.Recurit.Exam.Service.Services { @@ -27,6 +29,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services private readonly IHttpContextAccessor _httpContextAccessor; private readonly MinIOService _minioService; private readonly MailService _mailService; + private readonly IConfiguration _configuration; #endregion @@ -36,13 +39,15 @@ namespace BMA.EHR.Recurit.Exam.Service.Services MetadataDbContext contextMetadata, IHttpContextAccessor httpContextAccessor, MinIOService minioService, - MailService mailService) + MailService mailService, + IConfiguration configuration) { _context = context; _contextMetadata = contextMetadata; _httpContextAccessor = httpContextAccessor; _minioService = minioService; _mailService = mailService; + _configuration = configuration; } #endregion @@ -52,6 +57,7 @@ namespace BMA.EHR.Recurit.Exam.Service.Services private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value; + private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"]; #endregion @@ -2097,6 +2103,28 @@ namespace BMA.EHR.Recurit.Exam.Service.Services await _contextMetadata.Placements.AddAsync(placement); foreach (var candidate in periodExam.Candidate.Where(x => x.Status == "done" && x.Pass == "ได้")) { + var IsOfficer = false; + dynamic org = null; + var apiUrl = $"{_configuration["API"]}org/profile/citizenid/position/{candidate.CitizenId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + { + IsOfficer = false; + } + else + { + IsOfficer = true; + } + } + var profile = await _contextMetadata.Profiles .Include(x => x.Salaries) .FirstOrDefaultAsync(p => p.CitizenId == candidate.CitizenId); @@ -2187,6 +2215,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services LastUpdatedAt = DateTime.Now, LastUpdateUserId = UserId ?? "", LastUpdateFullName = FullName ?? "", + IsOfficer = IsOfficer, + profileId = org == null || org.result == null ? null : org.result.profileId, }; await _contextMetadata.PlacementProfiles.AddAsync(placementProfile); @@ -2254,6 +2284,27 @@ namespace BMA.EHR.Recurit.Exam.Service.Services .ToListAsync(); foreach (var candidate in candidates) { + var IsOfficer = false; + dynamic org = null; + var apiUrl = $"{_configuration["API"]}org/profile/citizenid/position/{candidate.CitizenId}"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + { + IsOfficer = false; + } + else + { + IsOfficer = true; + } + } var Address = candidate.Addresses.FirstOrDefault() == null ? null : $"{candidate.Addresses.FirstOrDefault().Address}"; var Moo = candidate.Addresses.FirstOrDefault() == null ? null : $" หมู่ {candidate.Addresses.FirstOrDefault().Moo}"; var Soi = candidate.Addresses.FirstOrDefault() == null ? null : $" ซอย {candidate.Addresses.FirstOrDefault().Soi}"; @@ -2359,6 +2410,8 @@ namespace BMA.EHR.Recurit.Exam.Service.Services LastUpdatedAt = DateTime.Now, LastUpdateUserId = UserId ?? "", LastUpdateFullName = FullName ?? "", + IsOfficer = IsOfficer, + profileId = org == null || org.result == null ? null : org.result.profileId, }; await _contextMetadata.PlacementProfiles.AddAsync(placementProfile); diff --git a/appsettings.Development.json b/appsettings.Development.json index f2e898f..952449d 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -15,13 +15,13 @@ "ConnectionStrings": { "MongoConnection": "mongodb://127.0.0.1:27017", // "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - "DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", + "DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", // "MetadataConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" - "MetadataConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + "MetadataConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" }, "Jwt": { - "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", - "Issuer": "https://identity.frappet.com/realms/bma-ehr" + "Key": "Hp3234M8rH1KjIdvhlUStayo6vIUOIeI76NKyIsiXJ8", + "Issuer": "https://id.frappet.synology.me/realms/bma-ehr" }, "EPPlus": { "ExcelPackage": { @@ -41,5 +41,7 @@ "MailFrom": "suphonchai.ph@gmail.com", "Port": "587" }, - "Domain": "http://localhost:5173" + "Domain": "https://bma-ehr-exam.frappet.synology.me", + "Protocol": "HTTPS", + "API": "https://bma-ehr.frappet.synology.me/api/v1/" } diff --git a/appsettings.json b/appsettings.json index ea8d477..813af28 100644 --- a/appsettings.json +++ b/appsettings.json @@ -15,9 +15,9 @@ "ConnectionStrings": { "MongoConnection": "mongodb://admin:adminVM123@127.0.0.1:27017", // "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - "DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", + "DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", // "MetadataConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" - "MetadataConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + "MetadataConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" }, "Jwt": { "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", @@ -41,5 +41,6 @@ "MailFrom": "suphonchai.ph@gmail.com", "Port": "587" }, - "Domain": "http://localhost:5173" + "Domain": "http://localhost:5173", + "API": "https://bma-ehr.frappet.synology.me/api/v1/" } \ No newline at end of file diff --git a/bin/Debug/net7.0/appsettings.Development.json b/bin/Debug/net7.0/appsettings.Development.json index f2e898f..952449d 100644 --- a/bin/Debug/net7.0/appsettings.Development.json +++ b/bin/Debug/net7.0/appsettings.Development.json @@ -15,13 +15,13 @@ "ConnectionStrings": { "MongoConnection": "mongodb://127.0.0.1:27017", // "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - "DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", + "DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", // "MetadataConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" - "MetadataConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + "MetadataConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" }, "Jwt": { - "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", - "Issuer": "https://identity.frappet.com/realms/bma-ehr" + "Key": "Hp3234M8rH1KjIdvhlUStayo6vIUOIeI76NKyIsiXJ8", + "Issuer": "https://id.frappet.synology.me/realms/bma-ehr" }, "EPPlus": { "ExcelPackage": { @@ -41,5 +41,7 @@ "MailFrom": "suphonchai.ph@gmail.com", "Port": "587" }, - "Domain": "http://localhost:5173" + "Domain": "https://bma-ehr-exam.frappet.synology.me", + "Protocol": "HTTPS", + "API": "https://bma-ehr.frappet.synology.me/api/v1/" } diff --git a/bin/Debug/net7.0/appsettings.json b/bin/Debug/net7.0/appsettings.json index ea8d477..813af28 100644 --- a/bin/Debug/net7.0/appsettings.json +++ b/bin/Debug/net7.0/appsettings.json @@ -15,9 +15,9 @@ "ConnectionStrings": { "MongoConnection": "mongodb://admin:adminVM123@127.0.0.1:27017", // "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", - "DefaultConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", + "DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;", // "MetadataConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" - "MetadataConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" + "MetadataConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;" }, "Jwt": { "Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI", @@ -41,5 +41,6 @@ "MailFrom": "suphonchai.ph@gmail.com", "Port": "587" }, - "Domain": "http://localhost:5173" + "Domain": "http://localhost:5173", + "API": "https://bma-ehr.frappet.synology.me/api/v1/" } \ No newline at end of file