Merge branch 'develop' into adiDev
Some checks failed
release-dev / release-dev (push) Failing after 12s

This commit is contained in:
AdisakKanthawilang 2025-03-26 17:15:15 +07:00
commit 3779128e6c
26 changed files with 1912 additions and 191 deletions

View file

@ -400,9 +400,43 @@ namespace BMA.EHR.Application.Repositories.Reports
p.RemarkHorizontal,
})
.FirstOrDefaultAsync();
if (data == null)
data = await _dbContext.Set<RetirementResignEmployee>().AsQueryable()
.Where(x => x.Id == id)
.Select(p => new
{
p.Id,
p.prefix,
p.firstName,
p.lastName,
p.profileId,
p.Location,
p.SendDate,
p.ActiveDate,
p.Reason,
p.Status,
salary = p.AmountOld,
p.ApproveReason,
p.RejectReason,
p.IsActive,
p.CreatedAt,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.OligarchReject,
p.OligarchApproveReason,
p.OligarchRejectReason,
p.OligarchRejectDate,
p.CommanderReject,
p.CommanderApproveReason,
p.CommanderRejectReason,
p.CommanderRejectDate,
p.RemarkHorizontal,
})
.FirstOrDefaultAsync();
if (data == null)
return null;
var _data = new
{
data.Id,

View file

@ -69,8 +69,8 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
// use serilog
ConfigureLogs();
builder.Host.UseSerilog();
//ConfigureLogs();
//builder.Host.UseSerilog();
// Add config CORS
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
@ -154,6 +154,8 @@ var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{
Authorization = new[] { new CustomAuthorizeFilter() }

View file

@ -1,51 +1,53 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://id.frappet.synology.me/realms/hrms"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://edm-s3.frappet.synology.me/",
"AccessKey": "XxtdnJajPjp3hHuKdOMn",
"SecretKey": "rVPzB05giC7bA400cUuIThzT4T9SGCcpcmL3tBBg",
"BucketName": "bma-ehr-fpt"
},
"Mail": {
"Server": "smtp.gmail.com",
"User": "suphonchai.ph@gmail.com",
"Password": "nnjazjcnwhepkxdm",
"MailFrom": "suphonchai.ph@gmail.com",
"Port": "587"
},
"KeycloakCron": {
"Hour": "08",
"Minute": "00"
},
"Protocol": "HTTPS",
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://192.168.1.40:9200",
"IndexFormat": "bma-ehr-log-index",
"SystemName": "discipline"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"LeaveConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_leave;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://id.frappet.synology.me/realms/hrms"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://edm-s3.frappet.synology.me/",
"AccessKey": "XxtdnJajPjp3hHuKdOMn",
"SecretKey": "rVPzB05giC7bA400cUuIThzT4T9SGCcpcmL3tBBg",
"BucketName": "bma-ehr-fpt"
},
"Mail": {
"Server": "smtp.gmail.com",
"User": "suphonchai.ph@gmail.com",
"Password": "nnjazjcnwhepkxdm",
"MailFrom": "suphonchai.ph@gmail.com",
"Port": "587"
},
"KeycloakCron": {
"Hour": "08",
"Minute": "00"
},
"Protocol": "HTTPS",
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
}

View file

@ -1,49 +1,122 @@
using Microsoft.AspNetCore.Http;
using BMA.EHR.Domain.Models.HR;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using Nest;
using Newtonsoft.Json;
using Serilog;
using System.Diagnostics;
using System.IO;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Text.Json;
using JsonSerializer = System.Text.Json.JsonSerializer;
namespace BMA.EHR.Domain.Middlewares
{
public class RequestLoggingMiddleware
{
private readonly RequestDelegate _next;
private readonly IConfiguration _configuration;
public RequestLoggingMiddleware(RequestDelegate next)
private string Uri = "";
private string IndexFormat = "";
private string SystemName = "";
private string APIKey = "";
public RequestLoggingMiddleware(RequestDelegate next, IConfiguration configuration)
{
_next = next;
_configuration = configuration;
Uri = _configuration["ElasticConfiguration:Uri"] ?? "http://192.168.1.40:9200";
IndexFormat = _configuration["ElasticConfiguration:IndexFormat"] ?? "bma-ehr-log-index";
SystemName = _configuration["ElasticConfiguration:SystemName"] ?? "Unknown";
}
protected async Task<string> GetExternalAPIAsync(string apiPath, string accessToken, string apiKey)
{
try
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", apiKey);
var _res = await client.GetAsync(apiPath);
if (_res.IsSuccessStatusCode)
{
var _result = await _res.Content.ReadAsStringAsync();
return _result;
}
return string.Empty;
}
}
catch
{
throw;
}
}
public async Task<GetProfileByKeycloakIdLocal?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
{
try
{
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}";
var apiKey = _configuration["API_KEY"];
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "", apiKey);
if (apiResult != null)
{
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultLocal>(apiResult);
if (raw != null)
return raw.Result;
}
return null;
}
catch
{
throw;
}
}
public async Task Invoke(HttpContext context)
{
var settings = new ConnectionSettings(new Uri("http://192.168.1.40:9200"))
.DefaultIndex("bma-ehr-log-test-net");
var settings = new ConnectionSettings(new Uri(Uri))
.DefaultIndex(IndexFormat);
var client = new ElasticClient(settings);
var startTime = DateTime.UtcNow;
var stopwatch = Stopwatch.StartNew();
string? responseBodyJson = null;
string? requestBodyJson = null;
string requestBody = await ReadRequestBodyAsync(context);
if (requestBody != "")
requestBodyJson = JsonSerializer.Serialize(JsonSerializer.Deserialize<object>(requestBody), new JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, WriteIndented = true });
var originalBodyStream = context.Response.Body;
using (var memoryStream = new MemoryStream())
{
// เปลี่ยน stream ของ Response เพื่อให้สามารถอ่านได้
context.Response.Body = memoryStream;
var keycloakId = context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? Guid.Empty.ToString("D");
var token = context.Request.Headers["Authorization"];
var pf = await GetProfileByKeycloakIdAsync(Guid.Parse(keycloakId), token);
await _next(context); // ดำเนินการต่อไปยัง Middleware อื่น ๆ
stopwatch.Stop();
var processTime = stopwatch.ElapsedMilliseconds;
var endTime = DateTime.UtcNow;
@ -55,16 +128,26 @@ namespace BMA.EHR.Domain.Middlewares
_ => "info"
};
string? message = null;
// อ่านข้อมูลจาก Response หลังจากที่ได้ถูกส่งออกไป
memoryStream.Seek(0, SeekOrigin.Begin);
var responseBody = new StreamReader(memoryStream).ReadToEnd();
if (responseBody != "")
responseBodyJson = JsonSerializer.Serialize(JsonSerializer.Deserialize<object>(responseBody), new JsonSerializerOptions { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, WriteIndented = true });
var json = JsonSerializer.Deserialize<JsonElement>(responseBody);
if (json.TryGetProperty("message", out var messageElement))
{
message = messageElement.GetString();
}
var logData = new
{
logType = logType,
ip = context.Connection.RemoteIpAddress?.ToString(),
rootId = context.Items["RootId"] ?? null,
systemName = "test",
rootId = pf == null ? null : pf.RootId,
systemName = SystemName,
startTimeStamp = startTime.ToString("o"),
endTimeStamp = endTime.ToString("o"),
processTime = processTime,
@ -72,9 +155,14 @@ namespace BMA.EHR.Domain.Middlewares
method = context.Request.Method,
endpoint = context.Request.Path + context.Request.QueryString,
responseCode = context.Response.StatusCode == 304 ? "200" : context.Response.StatusCode.ToString(),
responseDescription = context.Items["ResponseMessage"] ?? null,
input = requestBody,
output = responseBody
responseDescription = message,
input = requestBodyJson,
output = responseBodyJson,
userId = keycloakId,
userName = $"{pf?.Prefix ?? ""}{pf?.FirstName ?? ""} {pf?.LastName ?? ""}",
user = pf?.CitizenId ?? ""
};
// เขียนข้อมูลกลับไปยัง original Response body
@ -85,7 +173,7 @@ namespace BMA.EHR.Domain.Middlewares
}
//Log.Information("API Request Log: {@LogData}", logData);
}
@ -98,4 +186,47 @@ namespace BMA.EHR.Domain.Middlewares
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

@ -0,0 +1,24 @@
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.Leave.Commons;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace BMA.EHR.Domain.Models.Leave.Requests
{
public class LeaveBeginning : EntityBase
{
[Required, Comment("รหัส Profile ในระบบทะเบียนประวัติ")]
public Guid ProfileId { get; set; } = Guid.Empty;
[Required, Comment("รหัสประเภทการลา")]
public Guid LeaveTypeId { get; set; } = Guid.Empty;
public LeaveType LeaveType { get; set; }
[Required, Comment("ปีงบประมาณ")]
public int LeaveYear { get; set; } = 0;
[Required, Comment("จำนวนวันลา")]
public double LeaveDays { get; set; } = 0.0;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,59 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
/// <inheritdoc />
public partial class AddLeaveBeginning : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LeaveBeginnings",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัส Profile ในระบบทะเบียนประวัติ", collation: "ascii_general_ci"),
LeaveTypeId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสประเภทการลา", collation: "ascii_general_ci"),
LeaveYear = table.Column<int>(type: "int", nullable: false, comment: "ปีงบประมาณ"),
LeaveDays = table.Column<double>(type: "double", nullable: false, comment: "จำนวนวันลา")
},
constraints: table =>
{
table.PrimaryKey("PK_LeaveBeginnings", x => x.Id);
table.ForeignKey(
name: "FK_LeaveBeginnings_LeaveTypes_LeaveTypeId",
column: x => x.LeaveTypeId,
principalTable: "LeaveTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_LeaveBeginnings_LeaveTypeId",
table: "LeaveBeginnings",
column: "LeaveTypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LeaveBeginnings");
}
}
}

View file

@ -119,6 +119,76 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.ToTable("LeaveTypes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<double>("LeaveDays")
.HasColumnType("double")
.HasComment("จำนวนวันลา");
b.Property<Guid>("LeaveTypeId")
.HasColumnType("char(36)")
.HasComment("รหัสประเภทการลา");
b.Property<int>("LeaveYear")
.HasColumnType("int")
.HasComment("ปีงบประมาณ");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)")
.HasComment("รหัส Profile ในระบบทะเบียนประวัติ");
b.HasKey("Id");
b.HasIndex("LeaveTypeId");
b.ToTable("LeaveBeginnings");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b =>
{
b.Property<Guid>("Id")
@ -1218,6 +1288,17 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.ToTable("UserTimeStamps");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveBeginning", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Leave.Commons.LeaveType", "LeaveType")
.WithMany()
.HasForeignKey("LeaveTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LeaveType");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.Requests.LeaveDocument", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Documents.Document", "Document")

View file

@ -32,6 +32,7 @@ namespace BMA.EHR.Infrastructure.Persistence
public DbSet<LeaveDocument> LeaveDocuments { get; set; }
public DbSet<LeaveBeginning> LeaveBeginnings { get; set; }
#endregion

View file

@ -28,6 +28,7 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="NEST" Version="7.17.5" />
<PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />

View file

@ -71,8 +71,8 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
// use serilog
ConfigureLogs();
builder.Host.UseSerilog();
//ConfigureLogs();
//builder.Host.UseSerilog();
// Add config CORS
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>

View file

@ -9,9 +9,10 @@
}
},
"ElasticConfiguration": {
"Uri": "http://192.168.1.40:9200"
"Uri": "http://192.168.1.40:9200",
"IndexFormat": "bma-ehr-log-index",
"SystemName": "insignia"
},
"LogIndex": "bma-ehr-log-index",
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",

View file

@ -162,7 +162,7 @@ app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
// Disable ก่อน เพื่อแก้ไขให้เรีบร้อยก่อนการใช้งาน
// app.UseMiddleware<RequestLoggingMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions()

View file

@ -9,7 +9,9 @@
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
"Uri": "http://192.168.1.40:9200",
"IndexFormat": "bma-ehr-log-index",
"SystemName": "leave"
},
"AllowedHosts": "*",
"ConnectionStrings": {

View file

@ -574,6 +574,7 @@ namespace BMA.EHR.Placement.Service.Controllers
uppdated.positionId = req.positionId;
uppdated.posMasterNo = req.posMasterNo;
uppdated.position = req.positionName;
uppdated.PositionExecutive = req.posExecutiveName;
uppdated.positionField = req.positionField;
uppdated.posTypeId = req.posTypeId;
uppdated.posTypeName = req.posTypeName;

View file

@ -968,6 +968,7 @@ namespace BMA.EHR.Placement.Service.Controllers
person.positionId = req.positionId;
person.posMasterNo = req.posMasterNo;
person.positionName = req.positionName;
person.PositionExecutive = req.posExecutiveName;
person.positionField = req.positionField;
person.posTypeId = req.posTypeId;
person.posTypeName = req.posTypeName;

View file

@ -673,6 +673,7 @@ namespace BMA.EHR.Placement.Service.Controllers
uppdated.positionId = req.positionId;
uppdated.posMasterNo = req.posMasterNo;
uppdated.position = req.positionName;
uppdated.PositionExecutive = req.posExecutiveName;
uppdated.positionField = req.positionField;
uppdated.posTypeId = req.posTypeId;
uppdated.posTypeName = req.posTypeName;

View file

@ -68,8 +68,8 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
// use serilog
ConfigureLogs();
builder.Host.UseSerilog();
//ConfigureLogs();
//builder.Host.UseSerilog();
// Add config CORS
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
@ -153,6 +153,8 @@ var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{
Authorization = new[] { new CustomAuthorizeFilter() }

View file

@ -29,5 +29,6 @@ namespace BMA.EHR.Placement.Service.Requests
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
public string? posExecutiveName { get; set; }
}
}

View file

@ -29,5 +29,6 @@ namespace BMA.EHR.Placement.Service.Requests
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
public string? posExecutiveName { get; set; }
}
}

View file

@ -38,5 +38,6 @@ namespace BMA.EHR.Placement.Service.Requests
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
public string? posExecutiveName { get; set; }
}
}

View file

@ -1,49 +1,51 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://id.frappet.synology.me/realms/hrms"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://edm-s3.frappet.synology.me/",
"AccessKey": "XxtdnJajPjp3hHuKdOMn",
"SecretKey": "rVPzB05giC7bA400cUuIThzT4T9SGCcpcmL3tBBg",
"BucketName": "bma-ehr-fpt"
},
"KeycloakCron": {
"Hour": "08",
"Minute": "00"
},
"Mail": {
"Server": "smtp.gmail.com",
"User": "suphonchai.ph@gmail.com",
"Password": "nnjazjcnwhepkxdm",
"MailFrom": "suphonchai.ph@gmail.com",
"Port": "587"
},
"Protocol": "HTTPS",
"APIPROBATION": "https://bma-ehr.frappet.synology.me/api/v1/probation",
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://192.168.1.40:9200",
"IndexFormat": "bma-ehr-log-index",
"SystemName": "placement"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://id.frappet.synology.me/realms/hrms"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://edm-s3.frappet.synology.me/",
"AccessKey": "XxtdnJajPjp3hHuKdOMn",
"SecretKey": "rVPzB05giC7bA400cUuIThzT4T9SGCcpcmL3tBBg",
"BucketName": "bma-ehr-fpt"
},
"KeycloakCron": {
"Hour": "08",
"Minute": "00"
},
"Mail": {
"Server": "smtp.gmail.com",
"User": "suphonchai.ph@gmail.com",
"Password": "nnjazjcnwhepkxdm",
"MailFrom": "suphonchai.ph@gmail.com",
"Port": "587"
},
"Protocol": "HTTPS",
"APIPROBATION": "https://bma-ehr.frappet.synology.me/api/v1/probation",
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
}

View file

@ -553,6 +553,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (retirementDeceased == null)
return Error(GlobalMessages.RetirementDeceasedNotFound, 404);
bool checkDup = req.Persons.Any(x => retirementDeceased.RetirementDeceasedNotis.Any(y => y.profileId == x.ProfileId));
if (checkDup)
return Error("ไม่สามารถเพิ่มรายชื่อส่งหนังสือเวียนซ้ำได้", 404);
foreach (var item in req.Persons)
{
// var profile = await _context.Profiles.AsQueryable()
@ -574,8 +578,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
if (retirementDeceased.profileType.Trim().ToUpper() == "OFFICER")
{
//if (retirementDeceased.profileType.Trim().ToUpper() == "OFFICER")
//{
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
using (var client = new HttpClient())
{
@ -602,36 +606,36 @@ namespace BMA.EHR.Retirement.Service.Controllers
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
}
}
else
{
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{item.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
//}
//else
//{
// var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{item.ProfileId}";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
// var _res = await client.SendAsync(_req);
// var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
// var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
continue;
// if (org == null || org.result == null)
// continue;
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "\n") +
(org.result.child3 == null ? "" : org.result.child3 + "\n") +
(org.result.child2 == null ? "" : org.result.child2 + "\n") +
(org.result.child1 == null ? "" : org.result.child1 + "\n") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
}
}
// retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
// retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
// retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
// retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
// retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
// retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "\n") +
// (org.result.child3 == null ? "" : org.result.child3 + "\n") +
// (org.result.child2 == null ? "" : org.result.child2 + "\n") +
// (org.result.child1 == null ? "" : org.result.child1 + "\n") +
// (org.result.root == null ? "" : org.result.root);
// retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
// }
//}
await _context.SaveChangesAsync();
}

View file

@ -149,7 +149,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.IsActive,
})
.ToListAsync();
if (status != null && status.Trim().ToUpper() != "WAITTING")
//if (status != null && status.Trim().ToUpper() != "WAITTING")
if (status != null)
retirementOuts = retirementOuts.Where(x => x.Status.Contains(status.Trim().ToUpper())).ToList();
return Success(retirementOuts);
}

View file

@ -69,8 +69,8 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
// use serilog
ConfigureLogs();
builder.Host.UseSerilog();
//ConfigureLogs();
//builder.Host.UseSerilog();
// Add config CORS
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
@ -161,6 +161,7 @@ var app = builder.Build();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
app.UseMiddleware<RequestLoggingMiddleware>();
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{

View file

@ -1,40 +1,42 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
// "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://id.frappet.synology.me/realms/hrms"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
},
"Protocol": "HTTPS",
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"APIV2": "https://bma-ehr.frappet.synology.me/api/v2",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://192.168.1.40:9200",
"IndexFormat": "bma-ehr-log-index",
"SystemName": "retirement"
},
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
// "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=hrms_discipline;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://id.frappet.synology.me/realms/hrms"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
},
"Protocol": "HTTPS",
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"APIV2": "https://bma-ehr.frappet.synology.me/api/v2",
"API_KEY": "fKRL16yyEgbyTEJdsMw2h64tGSCmkW685PRtM3CygzX1JOSdptT9UJtpgWwKM8FybRTJups3GTFwj27ZRvlPdIkv3XgCoVJaD5LmR06ozuEPvCCRSdp2WFthg08V5xHc56fTPfZLpr1VmXrhd6dvYhHIqKkQUJR02Rlkss11cLRWEQOssEFVA4xdu2J5DIRO1EM5m7wRRvEwcDB4mYRXD9HH52SMq6iYqUWEWsMwLdbk7QW9yYESUEuzMW5gWrb6vIeWZxJV5bTz1PcWUyR7eO9Fyw1F5DiQYc9JgzTC1mW7cv31fEtTtrfbJYKIb5EbWilqIEUKC6A0UKBDDek35ML0006cqRVm0pvdOH6jeq7VQyYrhdXe59dBEyhYGUIfozoVBvW7Up4QBuOMjyPjSqJPlMBKwaseptfrblxQV1AOOivSBpf1ZcQyOZ8JktRtKUDSuXsmG0lsXwFlI3JCeSHdpVdgZWFYcJPegqfrB6KotR02t9AVkpLs1ZWrixwz"
}