Merge branch 'develop' into working

This commit is contained in:
suphonchai Phoonsawat 2023-07-24 09:06:48 +07:00
commit 35c0342934
38 changed files with 32780 additions and 5367 deletions

View file

@ -16,7 +16,8 @@ namespace BMA.EHR.Application
services.AddTransient<PlacementCommandRepository>();
services.AddTransient<CommandTypeRepository>();
services.AddTransient<CommandStatusRepository>();
// services.AddTransient<InsigniaPeriodsRepository>();
services.AddTransient<InsigniaPeriodsRepository>();
services.AddTransient<RetirementRepository>();
return services;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Retirement;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Repositories
{
public class RetirementRepository : GenericRepository<Guid, RetirementPeriod>
{
private readonly IApplicationDBContext _dbContext;
private readonly IHttpContextAccessor _httpContextAccessor;
public RetirementRepository(IApplicationDBContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
{
_dbContext = dbContext;
_httpContextAccessor = httpContextAccessor;
}
// public async Task<IEnumerable<Retirement>> FindByNameAsync(string name)
// {
// var data = await _dbContext.Set<Retirement>().Where(x => x.Name == name).ToListAsync();
// return data;
// }
}
}

View file

@ -9,6 +9,6 @@ namespace BMA.EHR.Application.Requests
public string Year { get; set; }
public string RequestStatus { get; set; }
public string OrganizationName { get; set; }
public List<InsigniaRequestItem> Items { get; set; }
public List<dynamic> Items { get; set; }
}
}

View file

@ -2,13 +2,15 @@
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
namespace BMA.EHR.Domain.Models.HR
{
public class Profile : EntityBase
{
[Key]
public Guid Id { get; set; }
// [Key]
// public Guid Id { get; set; }
[MaxLength(13), Comment("รหัสบัตรประชาชน")]
public string? CitizenId { get; set; }
[MaxLength(50)]
@ -18,7 +20,7 @@ namespace BMA.EHR.Domain.Models.HR
[MaxLength(20), Comment("ประเภทลูกจ้าง")]
public string? EmployeeClass { get; set; }
[Comment("Id คำนำหน้า")]
public Guid? PrefixId { get; set; }
public Prefix? Prefix { get; set; }
[Required, MaxLength(100), Comment("ชื่อ")]
public string? FirstName { get; set; }
[Required, MaxLength(100), Comment("นามสกุล")]
@ -32,7 +34,7 @@ namespace BMA.EHR.Domain.Models.HR
[MaxLength(100)]
public string AvatarRef { get; set; }
[Comment("Id เพศ")]
public Guid? GenderId { get; set; }
public Gender? Gender { get; set; }
[MaxLength(100), Comment("สัญชาติ")]
public string? Nationality { get; set; }
[MaxLength(100), Comment("เชื้อชาติ")]
@ -127,13 +129,13 @@ namespace BMA.EHR.Domain.Models.HR
public Guid? OrganizationOrganizationId { get; set; }
public string? OrganizationOrganization { get; set; }
[Comment("Id ตำแหน่ง")]
public Guid? PositionId { get; set; }
[Comment("ตำแหน่ง")]
public string? Position { get; set; }
public PositionPath? Position { get; set; }
// [Comment("ตำแหน่ง")]
// public string? Position { get; set; }
[Comment("Id เลขที่ตำแหน่ง")]
public Guid? PosNoId { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public string? PosNo { get; set; }
public PositionNumberEntity? PosNo { get; set; }
// [Comment("เลขที่ตำแหน่ง")]
// public string? PosNo { get; set; }
[Comment("เลขที่ตำแหน่งลูกจ้าง")]
public string? PosNoEmployee { get; set; }
[Comment("Id สายงาน")]
@ -144,14 +146,14 @@ namespace BMA.EHR.Domain.Models.HR
public Guid? PositionPathSideId { get; set; }
[Comment("ด้าน/สาขา")]
public string? PositionPathSide { get; set; }
[Comment("Id ประเภทตำแหน่ง")]
public Guid? PositionTypeId { get; set; }
// [Comment("Id ประเภทตำแหน่ง")]
// public Guid? PositionTypeId { get; set; }
[Comment("ประเภทตำแหน่ง")]
public string? PositionType { get; set; }
[Comment(" Id ระดับ")]
public Guid? PositionLevelId { get; set; }
public PositionType? PositionType { get; set; }
// [Comment(" Id ระดับ")]
// public Guid? PositionLevelId { get; set; }
[Comment("ระดับ")]
public string? PositionLevel { get; set; }
public PositionLevel? PositionLevel { get; set; }
[Comment("Id ตำแหน่งทางการบริหาร")]
public Guid? PositionExecutiveId { get; set; }
[Comment("ตำแหน่งทางการบริหาร")]

View file

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.Domain.Models.HR
{
@ -27,8 +28,8 @@ namespace BMA.EHR.Domain.Models.HR
[Comment("ประเภท")]
public string? InsigniaType { get; set; }
[Comment("ชื่อเครื่องราชฯ")]
public string? Insignia { get; set; }
public Guid? InsigniaId { get; set; }
// public string? Insignia { get; set; }
public Insignia? Insignia { get; set; }
public virtual List<ProfileInsigniaHistory> ProfileInsigniaHistorys { get; set; } = new List<ProfileInsigniaHistory>();
public virtual Profile? Profile { get; set; }
}

View file

@ -1,4 +1,5 @@
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Domain.Models.HR
@ -7,6 +8,8 @@ namespace BMA.EHR.Domain.Models.HR
{
[Comment("วัน เดือน ปี รับตำแหน่ง")]
public DateTime? Date { get; set; }
[Comment("ลำดับ")]
public int? Order { get; set; }
[Comment("เงินเดือน")]
public double? Amount { get; set; }
[Comment("เงินประจำตำแหน่ง")]
@ -30,7 +33,7 @@ namespace BMA.EHR.Domain.Models.HR
[Comment("Id ประเภทตำแหน่ง")]
public Guid? PositionTypeId { get; set; }
[Comment("Id ระดับ")]
public Guid? PositionLevelId { get; set; }
public PositionLevel? PositionLevel { get; set; }
[Comment("Id ตำแหน่งทางการบริหาร")]
public Guid? PositionExecutiveId { get; set; }
[Comment("Id ด้านทางการบริหาร")]

View file

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using System.ComponentModel.DataAnnotations.Schema;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Organizations;
namespace BMA.EHR.Domain.Models.Insignias
{
@ -16,7 +17,7 @@ namespace BMA.EHR.Domain.Models.Insignias
public InsigniaPeriod Period { get; set; }
public OrganizationOrganization OrganizationOrganization { get; set; }
public OrganizationEntity Organization { get; set; }
public virtual List<InsigniaRequestProfile> RequestProfiles { get; set; } = new List<InsigniaRequestProfile>();
}

View file

@ -20,8 +20,8 @@ namespace BMA.EHR.Domain.Models.Placement
public string? Lastname { get; set; }
[Comment("Id เพศ")]
public Gender? Gender { get; set; }
[Comment("ลำดับที่สอบได้")]
public int? Number { get; set; }
// [Comment("ลำดับที่สอบได้")]
// public int? Number { get; set; }
[Comment("Id ตำแหน่งที่สอบได้")]
public PositionPath? PositionCandidate { get; set; }

View file

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
namespace BMA.EHR.Domain.Models.Retirement
{
public class RetirementPeriod : EntityBase
{
[Comment("ครั้งที่")]
public int Round { get; set; }
[Comment("ประเภท")]
public string Type { get; set; } = string.Empty;
public virtual List<RetirementProfile> RetirementProfiles { get; set; } = new List<RetirementProfile>();
}
}

View file

@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.HR;
namespace BMA.EHR.Domain.Models.Retirement
{
public class RetirementProfile : EntityBase
{
[Comment("ลำดับที่")]
public int Order { get; set; }
[Required, Comment("เหตุผล")]
public string Reason { get; set; } = string.Empty;
[Comment("ลบออกจากเกษียญ")]
public bool Remove { get; set; } = false;
public RetirementPeriod RetirementPeriod { get; set; }
public Profile Profile { get; set; }
}
}

View file

@ -68,6 +68,14 @@
public static readonly string InvalidInsigniaRequest = "ไม่พบข้อมูลการยื่นขอพระราชทานเครื่องราชย์ของหน่วยงานที่ระบุ!!";
public static readonly string InvalidInsigniaPeriod = "ไม่พบรอบการยื่นขอพระราชทานเครื่องราชย์อิสริยาภรณ์";
public static readonly string InvalidCoinPeriod = "ไม่พบรอบการขอพระราชทานเหรียญจักรพรรดิมาลาที่ระบุ!!";
public static readonly string InvalidOC = "ไม่พบหน่วยงานที่ระบุในระบบ";
#endregion
#region " Retirement "
public static readonly string InvalidRetirementRequest = "ไม่พบข้อมูลการประกาศเกษียณอายุราชการ";
#endregion
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,578 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddTableretire : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_InsigniaRequests_OrganizationOrganizations_OrganizationOrgan~",
table: "InsigniaRequests");
migrationBuilder.DropColumn(
name: "PosNo",
table: "Profiles");
migrationBuilder.DropColumn(
name: "Position",
table: "Profiles");
migrationBuilder.DropColumn(
name: "PositionLevel",
table: "Profiles");
migrationBuilder.DropColumn(
name: "PositionType",
table: "Profiles");
migrationBuilder.DropColumn(
name: "Insignia",
table: "ProfileInsignias");
migrationBuilder.DropColumn(
name: "Number",
table: "PlacementProfiles");
migrationBuilder.RenameColumn(
name: "OrganizationOrganizationId",
table: "InsigniaRequests",
newName: "OrganizationId");
migrationBuilder.RenameIndex(
name: "IX_InsigniaRequests_OrganizationOrganizationId",
table: "InsigniaRequests",
newName: "IX_InsigniaRequests_OrganizationId");
migrationBuilder.AlterColumn<Guid>(
name: "PositionLevelId",
table: "ProfileSalaries",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ระดับ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn<int>(
name: "Order",
table: "ProfileSalaries",
type: "int",
nullable: true,
comment: "ลำดับ");
migrationBuilder.AlterColumn<Guid>(
name: "PrefixId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id คำนำหน้า")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PositionTypeId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ประเภทตำแหน่ง")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PositionLevelId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: " Id ระดับ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PositionId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ตำแหน่ง")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PosNoId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id เลขที่ตำแหน่ง")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "GenderId",
table: "Profiles",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id เพศ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "Id",
table: "Profiles",
type: "char(36)",
nullable: false,
comment: "PrimaryKey",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.Annotation("Relational:ColumnOrder", 0)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.CreateTable(
name: "Retirements",
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"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ครั้งที่"),
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภท")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Retirements", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RetirementProfiles",
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"),
Order = table.Column<int>(type: "int", nullable: false, comment: "ลำดับที่"),
Reason = table.Column<string>(type: "longtext", nullable: false, comment: "เหตุผล")
.Annotation("MySql:CharSet", "utf8mb4"),
Remove = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ลบออกจากเกษียญ"),
RetirementId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RetirementProfiles", x => x.Id);
table.ForeignKey(
name: "FK_RetirementProfiles_Profiles_ProfileId",
column: x => x.ProfileId,
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RetirementProfiles_Retirements_RetirementId",
column: x => x.RetirementId,
principalTable: "Retirements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_ProfileSalaries_PositionLevelId",
table: "ProfileSalaries",
column: "PositionLevelId");
migrationBuilder.CreateIndex(
name: "IX_Profiles_GenderId",
table: "Profiles",
column: "GenderId");
migrationBuilder.CreateIndex(
name: "IX_Profiles_PositionId",
table: "Profiles",
column: "PositionId");
migrationBuilder.CreateIndex(
name: "IX_Profiles_PositionLevelId",
table: "Profiles",
column: "PositionLevelId");
migrationBuilder.CreateIndex(
name: "IX_Profiles_PositionTypeId",
table: "Profiles",
column: "PositionTypeId");
migrationBuilder.CreateIndex(
name: "IX_Profiles_PosNoId",
table: "Profiles",
column: "PosNoId");
migrationBuilder.CreateIndex(
name: "IX_Profiles_PrefixId",
table: "Profiles",
column: "PrefixId");
migrationBuilder.CreateIndex(
name: "IX_ProfileInsignias_InsigniaId",
table: "ProfileInsignias",
column: "InsigniaId");
migrationBuilder.CreateIndex(
name: "IX_RetirementProfiles_ProfileId",
table: "RetirementProfiles",
column: "ProfileId");
migrationBuilder.CreateIndex(
name: "IX_RetirementProfiles_RetirementId",
table: "RetirementProfiles",
column: "RetirementId");
migrationBuilder.AddForeignKey(
name: "FK_InsigniaRequests_Organizations_OrganizationId",
table: "InsigniaRequests",
column: "OrganizationId",
principalTable: "Organizations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_ProfileInsignias_Insignias_InsigniaId",
table: "ProfileInsignias",
column: "InsigniaId",
principalTable: "Insignias",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Profiles_Genders_GenderId",
table: "Profiles",
column: "GenderId",
principalTable: "Genders",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Profiles_PositionLevels_PositionLevelId",
table: "Profiles",
column: "PositionLevelId",
principalTable: "PositionLevels",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Profiles_PositionNumbers_PosNoId",
table: "Profiles",
column: "PosNoId",
principalTable: "PositionNumbers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Profiles_PositionPaths_PositionId",
table: "Profiles",
column: "PositionId",
principalTable: "PositionPaths",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Profiles_PositionTypes_PositionTypeId",
table: "Profiles",
column: "PositionTypeId",
principalTable: "PositionTypes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Profiles_Prefixes_PrefixId",
table: "Profiles",
column: "PrefixId",
principalTable: "Prefixes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_ProfileSalaries_PositionLevels_PositionLevelId",
table: "ProfileSalaries",
column: "PositionLevelId",
principalTable: "PositionLevels",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_InsigniaRequests_Organizations_OrganizationId",
table: "InsigniaRequests");
migrationBuilder.DropForeignKey(
name: "FK_ProfileInsignias_Insignias_InsigniaId",
table: "ProfileInsignias");
migrationBuilder.DropForeignKey(
name: "FK_Profiles_Genders_GenderId",
table: "Profiles");
migrationBuilder.DropForeignKey(
name: "FK_Profiles_PositionLevels_PositionLevelId",
table: "Profiles");
migrationBuilder.DropForeignKey(
name: "FK_Profiles_PositionNumbers_PosNoId",
table: "Profiles");
migrationBuilder.DropForeignKey(
name: "FK_Profiles_PositionPaths_PositionId",
table: "Profiles");
migrationBuilder.DropForeignKey(
name: "FK_Profiles_PositionTypes_PositionTypeId",
table: "Profiles");
migrationBuilder.DropForeignKey(
name: "FK_Profiles_Prefixes_PrefixId",
table: "Profiles");
migrationBuilder.DropForeignKey(
name: "FK_ProfileSalaries_PositionLevels_PositionLevelId",
table: "ProfileSalaries");
migrationBuilder.DropTable(
name: "RetirementProfiles");
migrationBuilder.DropTable(
name: "Retirements");
migrationBuilder.DropIndex(
name: "IX_ProfileSalaries_PositionLevelId",
table: "ProfileSalaries");
migrationBuilder.DropIndex(
name: "IX_Profiles_GenderId",
table: "Profiles");
migrationBuilder.DropIndex(
name: "IX_Profiles_PositionId",
table: "Profiles");
migrationBuilder.DropIndex(
name: "IX_Profiles_PositionLevelId",
table: "Profiles");
migrationBuilder.DropIndex(
name: "IX_Profiles_PositionTypeId",
table: "Profiles");
migrationBuilder.DropIndex(
name: "IX_Profiles_PosNoId",
table: "Profiles");
migrationBuilder.DropIndex(
name: "IX_Profiles_PrefixId",
table: "Profiles");
migrationBuilder.DropIndex(
name: "IX_ProfileInsignias_InsigniaId",
table: "ProfileInsignias");
migrationBuilder.DropColumn(
name: "Order",
table: "ProfileSalaries");
migrationBuilder.RenameColumn(
name: "OrganizationId",
table: "InsigniaRequests",
newName: "OrganizationOrganizationId");
migrationBuilder.RenameIndex(
name: "IX_InsigniaRequests_OrganizationId",
table: "InsigniaRequests",
newName: "IX_InsigniaRequests_OrganizationOrganizationId");
migrationBuilder.AlterColumn<Guid>(
name: "PositionLevelId",
table: "ProfileSalaries",
type: "char(36)",
nullable: true,
comment: "Id ระดับ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PrefixId",
table: "Profiles",
type: "char(36)",
nullable: true,
comment: "Id คำนำหน้า",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PositionTypeId",
table: "Profiles",
type: "char(36)",
nullable: true,
comment: "Id ประเภทตำแหน่ง",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PositionLevelId",
table: "Profiles",
type: "char(36)",
nullable: true,
comment: " Id ระดับ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PositionId",
table: "Profiles",
type: "char(36)",
nullable: true,
comment: "Id ตำแหน่ง",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "PosNoId",
table: "Profiles",
type: "char(36)",
nullable: true,
comment: "Id เลขที่ตำแหน่ง",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "GenderId",
table: "Profiles",
type: "char(36)",
nullable: true,
comment: "Id เพศ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<Guid>(
name: "Id",
table: "Profiles",
type: "char(36)",
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldComment: "PrimaryKey")
.OldAnnotation("Relational:Collation", "ascii_general_ci")
.OldAnnotation("Relational:ColumnOrder", 0);
migrationBuilder.AddColumn<string>(
name: "PosNo",
table: "Profiles",
type: "longtext",
nullable: true,
comment: "เลขที่ตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Position",
table: "Profiles",
type: "longtext",
nullable: true,
comment: "ตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "PositionLevel",
table: "Profiles",
type: "longtext",
nullable: true,
comment: "ระดับ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "PositionType",
table: "Profiles",
type: "longtext",
nullable: true,
comment: "ประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "Insignia",
table: "ProfileInsignias",
type: "longtext",
nullable: true,
comment: "ชื่อเครื่องราชฯ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "Number",
table: "PlacementProfiles",
type: "int",
nullable: true,
comment: "ลำดับที่สอบได้");
migrationBuilder.AddForeignKey(
name: "FK_InsigniaRequests_OrganizationOrganizations_OrganizationOrgan~",
table: "InsigniaRequests",
column: "OrganizationOrganizationId",
principalTable: "OrganizationOrganizations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -0,0 +1,119 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updateTableretiretoRetirementPeriod : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_RetirementProfiles_Retirements_RetirementId",
table: "RetirementProfiles");
migrationBuilder.DropTable(
name: "Retirements");
migrationBuilder.RenameColumn(
name: "RetirementId",
table: "RetirementProfiles",
newName: "RetirementPeriodId");
migrationBuilder.RenameIndex(
name: "IX_RetirementProfiles_RetirementId",
table: "RetirementProfiles",
newName: "IX_RetirementProfiles_RetirementPeriodId");
migrationBuilder.CreateTable(
name: "RetirementPeriods",
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"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ครั้งที่"),
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภท")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_RetirementPeriods", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddForeignKey(
name: "FK_RetirementProfiles_RetirementPeriods_RetirementPeriodId",
table: "RetirementProfiles",
column: "RetirementPeriodId",
principalTable: "RetirementPeriods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_RetirementProfiles_RetirementPeriods_RetirementPeriodId",
table: "RetirementProfiles");
migrationBuilder.DropTable(
name: "RetirementPeriods");
migrationBuilder.RenameColumn(
name: "RetirementPeriodId",
table: "RetirementProfiles",
newName: "RetirementId");
migrationBuilder.RenameIndex(
name: "IX_RetirementProfiles_RetirementPeriodId",
table: "RetirementProfiles",
newName: "IX_RetirementProfiles_RetirementId");
migrationBuilder.CreateTable(
name: "Retirements",
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"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ครั้งที่"),
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภท")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Retirements", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddForeignKey(
name: "FK_RetirementProfiles_Retirements_RetirementId",
table: "RetirementProfiles",
column: "RetirementId",
principalTable: "Retirements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -570,7 +570,10 @@ namespace BMA.EHR.Infrastructure.Migrations
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<string>("Ability")
.IsRequired()
@ -731,8 +734,7 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("ชื่อ(เดิม)");
b.Property<Guid?>("GenderId")
.HasColumnType("char(36)")
.HasComment("Id เพศ");
.HasColumnType("char(36)");
b.Property<int>("GovAgeAbsent")
.HasColumnType("int");
@ -864,21 +866,12 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(100)")
.HasComment("สถานภาพทางกาย");
b.Property<string>("PosNo")
.HasColumnType("longtext")
.HasComment("เลขที่ตำแหน่ง");
b.Property<string>("PosNoEmployee")
.HasColumnType("longtext")
.HasComment("เลขที่ตำแหน่งลูกจ้าง");
b.Property<Guid?>("PosNoId")
.HasColumnType("char(36)")
.HasComment("Id เลขที่ตำแหน่ง");
b.Property<string>("Position")
.HasColumnType("longtext")
.HasComment("ตำแหน่ง");
.HasColumnType("char(36)");
b.Property<string>("PositionEmployeeGroup")
.HasColumnType("longtext")
@ -929,16 +922,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("Id ด้านทางการบริหาร");
b.Property<Guid?>("PositionId")
.HasColumnType("char(36)")
.HasComment("Id ตำแหน่ง");
b.Property<string>("PositionLevel")
.HasColumnType("longtext")
.HasComment("ระดับ");
.HasColumnType("char(36)");
b.Property<Guid?>("PositionLevelId")
.HasColumnType("char(36)")
.HasComment(" Id ระดับ");
.HasColumnType("char(36)");
b.Property<string>("PositionLine")
.HasColumnType("longtext")
@ -956,17 +943,11 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("char(36)")
.HasComment("Id ด้าน/สาขา");
b.Property<string>("PositionType")
.HasColumnType("longtext")
.HasComment("ประเภทตำแหน่ง");
b.Property<Guid?>("PositionTypeId")
.HasColumnType("char(36)")
.HasComment("Id ประเภทตำแหน่ง");
.HasColumnType("char(36)");
b.Property<Guid?>("PrefixId")
.HasColumnType("char(36)")
.HasComment("Id คำนำหน้า");
.HasColumnType("char(36)");
b.Property<Guid?>("PrefixOldId")
.HasColumnType("char(36)")
@ -1038,8 +1019,20 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("AvatarId");
b.HasIndex("GenderId");
b.HasIndex("LimitLeaveId");
b.HasIndex("PosNoId");
b.HasIndex("PositionId");
b.HasIndex("PositionLevelId");
b.HasIndex("PositionTypeId");
b.HasIndex("PrefixId");
b.ToTable("Profiles");
});
@ -3323,10 +3316,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("datetime(6)")
.HasComment("วันที่ประกาศในราชกิจจาฯ");
b.Property<string>("Insignia")
.HasColumnType("longtext")
.HasComment("ชื่อเครื่องราชฯ");
b.Property<Guid?>("InsigniaId")
.HasColumnType("char(36)");
@ -3396,6 +3385,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("InsigniaId");
b.HasIndex("ProfileId");
b.ToTable("ProfileInsignias");
@ -4235,6 +4226,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("char(36)")
.HasComment("Id สังกัด");
b.Property<int?>("Order")
.HasColumnType("int")
.HasComment("ลำดับ");
b.Property<Guid?>("OrganizationShortNameId")
.HasColumnType("char(36)")
.HasComment("Id ชื่อย่อหน่วยงาน");
@ -4276,8 +4271,7 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasComment("Id ตำแหน่ง");
b.Property<Guid?>("PositionLevelId")
.HasColumnType("char(36)")
.HasComment("Id ระดับ");
.HasColumnType("char(36)");
b.Property<Guid?>("PositionLineId")
.HasColumnType("char(36)")
@ -4308,6 +4302,8 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("PositionLevelId");
b.HasIndex("ProfileId");
b.ToTable("ProfileSalaries");
@ -4985,7 +4981,7 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid>("OrganizationOrganizationId")
b.Property<Guid>("OrganizationId")
.HasColumnType("char(36)");
b.Property<Guid>("PeriodId")
@ -5002,7 +4998,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasKey("Id");
b.HasIndex("OrganizationOrganizationId");
b.HasIndex("OrganizationId");
b.HasIndex("PeriodId");
@ -9989,10 +9985,6 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("varchar(40)")
.HasComment("สัญชาติ");
b.Property<int?>("Number")
.HasColumnType("int")
.HasComment("ลำดับที่สอบได้");
b.Property<string>("OccupationCompany")
.HasColumnType("longtext")
.HasComment("สำนัก/บริษัท บริษัท");
@ -10269,6 +10261,142 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("PlacementTypes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", 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<int>("Round")
.HasColumnType("int")
.HasComment("ครั้งที่");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ประเภท");
b.HasKey("Id");
b.ToTable("RetirementPeriods");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementProfile", 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<int>("Order")
.HasColumnType("int")
.HasComment("ลำดับที่");
b.Property<Guid>("ProfileId")
.HasColumnType("char(36)");
b.Property<string>("Reason")
.IsRequired()
.HasColumnType("longtext")
.HasComment("เหตุผล");
b.Property<bool>("Remove")
.HasColumnType("tinyint(1)")
.HasComment("ลบออกจากเกษียญ");
b.Property<Guid>("RetirementPeriodId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("ProfileId");
b.HasIndex("RetirementPeriodId");
b.ToTable("RetirementProfiles");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Commands.Core.CommandStatus", "CommandStatus")
@ -10328,13 +10456,49 @@ namespace BMA.EHR.Infrastructure.Migrations
.WithMany()
.HasForeignKey("AvatarId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.Gender", "Gender")
.WithMany()
.HasForeignKey("GenderId");
b.HasOne("BMA.EHR.Domain.Models.HR.LimitLeave", "LimitLeave")
.WithMany("Profiles")
.HasForeignKey("LimitLeaveId");
b.HasOne("BMA.EHR.Domain.Models.Organizations.PositionNumberEntity", "PosNo")
.WithMany()
.HasForeignKey("PosNoId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionPath", "Position")
.WithMany()
.HasForeignKey("PositionId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel")
.WithMany()
.HasForeignKey("PositionLevelId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionType", "PositionType")
.WithMany()
.HasForeignKey("PositionTypeId");
b.HasOne("BMA.EHR.Domain.Models.MetaData.Prefix", "Prefix")
.WithMany()
.HasForeignKey("PrefixId");
b.Navigation("Avatar");
b.Navigation("Gender");
b.Navigation("LimitLeave");
b.Navigation("PosNo");
b.Navigation("Position");
b.Navigation("PositionLevel");
b.Navigation("PositionType");
b.Navigation("Prefix");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileAbility", b =>
@ -10603,10 +10767,16 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileInsignia", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.Insignia", "Insignia")
.WithMany()
.HasForeignKey("InsigniaId");
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany("Insignias")
.HasForeignKey("ProfileId");
b.Navigation("Insignia");
b.Navigation("Profile");
});
@ -10728,10 +10898,16 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.HR.ProfileSalary", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.PositionLevel", "PositionLevel")
.WithMany()
.HasForeignKey("PositionLevelId");
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany("Salaries")
.HasForeignKey("ProfileId");
b.Navigation("PositionLevel");
b.Navigation("Profile");
});
@ -10775,9 +10951,9 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Insignias.InsigniaRequest", b =>
{
b.HasOne("BMA.EHR.Domain.Models.MetaData.OrganizationOrganization", "OrganizationOrganization")
b.HasOne("BMA.EHR.Domain.Models.Organizations.OrganizationEntity", "Organization")
.WithMany()
.HasForeignKey("OrganizationOrganizationId")
.HasForeignKey("OrganizationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@ -10787,7 +10963,7 @@ namespace BMA.EHR.Infrastructure.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("OrganizationOrganization");
b.Navigation("Organization");
b.Navigation("Period");
});
@ -11374,6 +11550,25 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Religion");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
.WithMany()
.HasForeignKey("ProfileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod")
.WithMany("RetirementProfiles")
.HasForeignKey("RetirementPeriodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Profile");
b.Navigation("RetirementPeriod");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Commands.Core.Command", b =>
{
b.Navigation("Documents");
@ -11574,6 +11769,11 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("PlacementEducations");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b =>
{
b.Navigation("RetirementProfiles");
});
#pragma warning restore 612, 618
}
}

View file

@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Models.Commands;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.Retirement;
namespace BMA.EHR.Infrastructure.Persistence
{
@ -292,6 +293,14 @@ namespace BMA.EHR.Infrastructure.Persistence
#endregion
#region " Retirement "
public DbSet<RetirementPeriod> RetirementPeriods { get; set; }
public DbSet<RetirementProfile> RetirementProfiles { get; set; }
#endregion
public ApplicationDBContext(DbContextOptions<ApplicationDBContext> options) : base(options)
{
}

View file

@ -94,9 +94,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
Items = new List<InsigniaRequestItem>()
Items = new List<dynamic>()
};
var candidate = _repository.GetInsigniaCandidate(period, ocId);
var candidate = await _repository.GetInsigniaCandidate(period, ocId);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
@ -106,15 +106,15 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
if (role == "officer")
{
resend.Items = _repository.InsigniaHasProfile(period, ocId);
resend.Items = await _repository.InsigniaHasProfile(period, ocId);
return Success(resend);
}
else
{
var passData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Organization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
@ -122,8 +122,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
// fkDivisionId = ir.Organization.Id,
// fkDivision = ir.Organization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
@ -169,9 +169,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
.FirstOrDefault();
var failData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Organization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
@ -179,8 +179,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
// fkDivisionId = ir.Organization.Id,
// fkDivision = ir.Organization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
@ -256,28 +256,28 @@ namespace BMA.EHR.Insignia.Service.Controllers
Name = periodName,
RequestStatus = requestStatus,
OrganizationName = result.OrganizationName,
Items = new List<InsigniaRequestItem>()
Items = new List<dynamic>()
};
var candidate = _repository.GetInsigniaCandidateBKK(period, ocId);
var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
_repository.InsertCandidate(period, ocId, candidate);
await _repository.InsertCandidate(period, ocId, candidate);
}
if (role == "officer")
{
resend.Items = _repository.InsigniaHasProfile(period, ocId);
resend.Items = await _repository.InsigniaHasProfile(period, ocId);
return Success(resend);
}
else
{
var passData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Organization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
@ -285,8 +285,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
// fkDivisionId = ir.Organization.Id,
// fkDivision = ir.Organization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
@ -333,9 +333,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
.FirstOrDefault();
var failData = _context.InsigniaRequests.AsQueryable()
.Include(x => x.OrganizationOrganization)
.Include(x => x.Organization)
.Include(x => x.RequestProfiles)
.Where(x => x.OrganizationOrganization.Id == ocId)
.Where(x => x.Organization.Id == ocId)
.Where(x => x.Period.Id == period)
.Select(ir => new
{
@ -343,8 +343,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
requstStatus = ir.RequestStatus,
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
fkInstituteId = -1,
fkDivisionId = ir.OrganizationOrganization.Id,
fkDivision = ir.OrganizationOrganization.Name,
// fkDivisionId = ir.Organization.Id,
// fkDivision = ir.Organization.Name,
fkInstitute = "",
fkPeriodId = ir.Period.Id,
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()

View file

@ -14,7 +14,8 @@
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "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;"
"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.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",

View file

@ -116,9 +116,21 @@ namespace BMA.EHR.Placement.Service.Controllers
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Draft = x.Draft,
Number = x.Number,
ExamNumber = x.ExamNumber,
Deferment = x.IsRelief,
}).ToListAsync();
ContainDate = x.RecruitDate,
OrganizationPositionId = x.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationPosition.Id,
PosNoId = x.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionNumber.Id,
PositionId = x.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPath.Id,
PositionLevelId = x.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLevel.Id,
PositionLineId = x.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLine.Id,
PositionPathSideId = x.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPathSide.Id,
PositionTypeId = x.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionType.Id,
SalaryAmount = x.Amount,
MouthSalaryAmount = x.MouthSalaryAmount,
PositionSalaryAmount = x.PositionSalaryAmount,
}).OrderBy(x => x.ExamNumber).ToListAsync();
var result = new List<dynamic>();
foreach (var p in data)
@ -139,8 +151,20 @@ namespace BMA.EHR.Placement.Service.Controllers
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
p.StatusId,
p.Draft,
p.Number,
p.ExamNumber,
p.Deferment,
p.ContainDate,
p.OrganizationPositionId,
p.PosNoId,
p.PositionId,
p.PositionLevelId,
p.PositionLineId,
p.PositionPathSideId,
p.PositionTypeId,
p.SalaryAmount,
p.MouthSalaryAmount,
p.PositionSalaryAmount,
};
result.Add(_data);
}
@ -157,6 +181,7 @@ namespace BMA.EHR.Placement.Service.Controllers
.Where(x => x.Placement.Id == examId)
.Where(x => x.OrganizationPosition != null)
.Where(x => x.OrganizationPosition.Organization != null)
.Where(x => x.Draft == true)
.Where(x => ocIdList.Contains(x.OrganizationPosition.Organization.Id))
.Select(x => new
{
@ -174,9 +199,21 @@ namespace BMA.EHR.Placement.Service.Controllers
BmaOfficer = x.IsOfficer,
StatusId = x.PlacementStatus,
Draft = x.Draft,
Number = x.Number,
ExamNumber = x.ExamNumber,
Deferment = x.IsRelief,
}).OrderBy(x => x.Number).ToListAsync();
ContainDate = x.RecruitDate,
OrganizationPositionId = x.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationPosition.Id,
PosNoId = x.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionNumber.Id,
PositionId = x.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPath.Id,
PositionLevelId = x.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLevel.Id,
PositionLineId = x.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionLine.Id,
PositionPathSideId = x.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionPathSide.Id,
PositionTypeId = x.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionType.Id,
SalaryAmount = x.Amount,
MouthSalaryAmount = x.MouthSalaryAmount,
PositionSalaryAmount = x.PositionSalaryAmount,
}).OrderBy(x => x.ExamNumber).ToListAsync();
var result = new List<dynamic>();
foreach (var p in data)
@ -197,8 +234,20 @@ namespace BMA.EHR.Placement.Service.Controllers
BmaOfficer = await _documentService.CheckBmaOfficer(p.IdCard),
p.StatusId,
p.Draft,
p.Number,
p.ExamNumber,
p.Deferment,
p.ContainDate,
p.OrganizationPositionId,
p.PosNoId,
p.PositionId,
p.PositionLevelId,
p.PositionLineId,
p.PositionPathSideId,
p.PositionTypeId,
p.SalaryAmount,
p.MouthSalaryAmount,
p.PositionSalaryAmount,
};
result.Add(_data);
}
@ -550,6 +599,8 @@ namespace BMA.EHR.Placement.Service.Controllers
var person = await _context.PlacementProfiles.FindAsync(req.PersonalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
if (person.Draft == true)
return Error("ไม่สามารถแก้ไขข้อมูลนี้ได้เนื่องจากเผยแพร่ไปแล้ว");
if (req.PosNoId != null)
{

View file

@ -0,0 +1,25 @@
**/.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

View file

@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>7be0011e-a539-4e0e-a300-ed7f11163989</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.31.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>7be0011e-a539-4e0e-a300-ed7f11163989</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Retirement.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.31.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,84 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Reflection;
namespace BMA.EHR.Retirement.Service
{
public class ConfigureSwaggerOptions : IConfigureNamedOptions<SwaggerGenOptions>
{
private readonly IApiVersionDescriptionProvider _provider;
public ConfigureSwaggerOptions(
IApiVersionDescriptionProvider provider)
{
_provider = provider;
}
public void Configure(SwaggerGenOptions options)
{
// add swagger document for every API version discovered
foreach (var description in _provider.ApiVersionDescriptions)
{
options.EnableAnnotations();
options.SwaggerDoc(
description.GroupName,
CreateVersionInfo(description));
}
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please enter a valid token",
Name = "Authorization",
Type = SecuritySchemeType.Http,
BearerFormat = "JWT",
Scheme = "Bearer"
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[]{}
}
});
// generate the XML docs that'll drive the swagger docs
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
options.IncludeXmlComments(xmlPath);
}
public void Configure(string name, SwaggerGenOptions options)
{
Configure(options);
}
private OpenApiInfo CreateVersionInfo(
ApiVersionDescription desc)
{
var info = new OpenApiInfo()
{
Title = "BMA EHR Retirement Service Document",
Version = desc.ApiVersion.ToString()
};
if (desc.IsDeprecated)
{
info.Description += " This API version has been deprecated. Please use one of the new APIs available from the explorer.";
}
return info;
}
}
}

View file

@ -0,0 +1,447 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.Placement;
using BMA.EHR.Domain.Models.Retirement;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Retirement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Swashbuckle.AspNetCore.Annotations;
using System.Drawing;
using System.Linq;
using System.Security.Claims;
using System.Security.Cryptography;
namespace BMA.EHR.Retirement.Service.Controllers
{
[Route("api/v{version:apiVersion}/retirement")]
[ApiVersion("1.0")]
[ApiController]
[Produces("application/json")]
[Authorize]
[SwaggerTag("ระบบพ้นราชการ")]
public class RetirementController : BaseController
{
private readonly RetirementRepository _repository;
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
public RetirementController(RetirementRepository repository,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
{
_repository = repository;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
}
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " จัดลำดับเกษียณ "
private async Task GenOrderByYear(string type, int year)
{
if (type.Trim().ToUpper().Contains("OFFICER"))
{
var profiles = await _context.RetirementProfiles
.Where(x => x.CreatedAt.Year == year)
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.OrderBy(x => x.Profile.OrganizationOrganization)
.ThenBy(x => x.Profile.PositionType == null ? null : x.Profile.PositionType.Name)
.ThenBy(x => x.Profile.PositionLevel == null ? null : x.Profile.PositionLevel.Name)
.ToListAsync();
var order = 1;
foreach (var profile in profiles)
{
profile.Order = order;
profile.LastUpdateFullName = FullName ?? "System Administrator";
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
order++;
}
}
if (type.Trim().ToUpper().Contains("EMPLOYEE"))
{
var profiles = await _context.RetirementProfiles
.Where(x => x.CreatedAt.Year == year)
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.OrderBy(x => x.Profile.OrganizationOrganization)
.ThenBy(x => x.Profile.EmployeeType)
.ThenBy(x => x.Profile.PositionEmployeeLevel)
.ToListAsync();
var order = 1;
foreach (var profile in profiles)
{
profile.Order = order;
profile.LastUpdateFullName = FullName ?? "System Administrator";
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
order++;
}
}
_context.SaveChanges();
}
#endregion
/// <summary>
/// list ประกาศเกษียณอายุราชการ
/// </summary>
/// <param name="type">ประเภทUser(officer,employee)(ตัวใหญ่หรือเล็กก็ได้)</param>
/// <param name="year">ปีงบประมาณ(ค.ศ.)</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{type}/{year}")]
public async Task<ActionResult<ResponseObject>> GetRetirement(string type, int year)
{
if (type.Trim().ToUpper().Contains("OFFICER") || type.Trim().ToUpper().Contains("EMPLOYEE"))
{
var retire_old = await _context.RetirementPeriods
.Include(x => x.RetirementProfiles)
.Where(x => x.CreatedAt.Year == year)
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.OrderByDescending(x => x.Round)
.FirstOrDefaultAsync();
if (retire_old != null)
{
var data = await _context.RetirementPeriods
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.Where(x => year > 0 ? (x.CreatedAt.Year == year) : (x.CreatedAt.Year > 0))
.Select(x => new
{
Id = x.Id,
CreatedAt = x.CreatedAt,
Round = x.Round,
Total = retire_old.Id == x.Id ? retire_old.RetirementProfiles.Count() : retire_old.RetirementProfiles.Count() - x.RetirementProfiles.Where(x => x.Remove == true).Count(),
}).OrderByDescending(x => x.CreatedAt)
.ToListAsync();
return Success(data);
}
}
return Success();
}
/// <summary>
/// สร้างประกาศเกษียณใหม่
/// </summary>
/// <param name="type">ประเภทUser(officer,employee)(ตัวใหญ่หรือเล็กก็ได้)</param>
/// <param name="year">ปีงบประมาณ(ค.ศ.)</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("profile/{type}/{year}")]
public async Task<ActionResult<ResponseObject>> CreateProfileRetirement(string type, int year)
{
var round = 1;
var retire_old = await _context.RetirementPeriods
.Include(x => x.RetirementProfiles)
.Where(x => x.CreatedAt.Year == year)
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.OrderByDescending(x => x.Round)
.FirstOrDefaultAsync();
if (retire_old != null)
round = retire_old.Round + 1;
var retire = new RetirementPeriod
{
Round = round,
Type = type.Trim().ToUpper(),
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.RetirementPeriods.AddAsync(retire);
if (retire_old != null)
{
var profiles = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire_old)
.Where(x => x.Remove == false)
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.ToListAsync();
foreach (var profile in profiles)
{
profile.RetirementPeriod = retire;
profile.LastUpdateFullName = FullName ?? "System Administrator";
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
}
}
else
{
var profiles = await _context.Profiles.AsQueryable()
// .Where(x => x.BirthDate.CalculateRetireDate().Year == year)
.Where(x => x.ProfileType.Trim().ToUpper().Contains(type.Trim().ToUpper()))
// .Where(x => x.CitizenId == "0000000000001")
.ToListAsync();
// var profiles = await (from p in _context.Profiles
// where p.BirthDate.CalculateRetireDate().Year == year
// select p)
// .ToListAsync();
profiles = profiles.Where(x=>x.BirthDate.CalculateRetireDate().Year == year).ToList();
var order = 1;
foreach (var profile in profiles)
{
var data = new RetirementProfile
{
Order = order,
Remove = false,
RetirementPeriod = retire,
Profile = profile,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.RetirementProfiles.AddAsync(data);
order++;
}
}
_context.SaveChanges();
var retire_all_year = await _context.RetirementPeriods
.Where(x => x.CreatedAt.Year == year)
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.CountAsync();
if (retire_all_year <= 1)
{
await GenOrderByYear(type.Trim().ToUpper(), year);
}
_context.SaveChanges();
var profile_new = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire)
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
.Select(x => new
{
Order = x.Order,
Id = x.Id,
Reason = x.Reason,
Remove = x.Remove,
ProfileId = x.Profile.Id,
CitizenId = x.Profile.CitizenId,
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
FullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
OrganizationOrganization = x.Profile.OrganizationOrganization,
Oc = x.Profile.Oc,
Position = x.Profile.Position == null ? null : x.Profile.Position.Name,
PositionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
PositionExecutive = x.Profile.PositionExecutive,
PosNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
PositionEmployeePosition = x.Profile.PositionEmployeePosition,
PositionEmployeeLevel = x.Profile.PositionEmployeeLevel,
PositionEmployeeGroup = x.Profile.PositionEmployeeGroup,
PosNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return Success(new { retire.Id, retire.CreatedAt, retire.Round, retire.Type, profile = profile_new });
}
/// <summary>
/// View รายชื่อผู้เกษียณอายุราชการในประกาศ
/// </summary>
/// <param name="retireId">Id ประกาศ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetProfileRetirement(Guid retireId)
{
var retire = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.InvalidRetirementRequest, 404);
var retire_old = await _context.RetirementPeriods
.Where(x => x.CreatedAt < retire.CreatedAt)
.Where(x => x.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
.ToListAsync();
var profile = await _context.RetirementProfiles
.Where(x => !retire_old.Contains(x.RetirementPeriod))
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
.Select(x => new
{
Order = x.Order,
Id = x.Id,
Reason = x.Reason,
Remove = x.Remove,
ProfileId = x.Profile.Id,
CitizenId = x.Profile.CitizenId,
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
FullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
OrganizationOrganization = x.Profile.OrganizationOrganization,
Oc = x.Profile.Oc,
Position = x.Profile.Position == null ? null : x.Profile.Position.Name,
PositionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
PositionExecutive = x.Profile.PositionExecutive,
PosNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
PositionEmployeePosition = x.Profile.PositionEmployeePosition,
PositionEmployeeLevel = x.Profile.PositionEmployeeLevel,
PositionEmployeeGroup = x.Profile.PositionEmployeeGroup,
PosNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return Success(profile);
}
/// <summary>
/// Delete รายชื่อผู้เกษียณอายุราชการในประกาศ
/// </summary>
/// <param name="retireProfileId">Id ผู้ใช้งานในประกาศ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpDelete("profile/{retireProfileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> DeleteProfileRetirement(Guid retireProfileId)
{
var profile = await _context.RetirementProfiles
.FirstOrDefaultAsync(x => x.Id == retireProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
_context.RetirementProfiles.Remove(profile);
_context.SaveChanges();
return Success();
}
/// <summary>
/// Add รายชื่อผู้เกษียณอายุราชการในประกาศ
/// </summary>
/// <param name="retireId">Id ประกาศ</param>
/// <param name="profileId">Id ผู้ใช้งาน</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("profile/{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> AddProfileRetirement([FromBody] ProfileRequest req, Guid retireId)
{
var profile = await _context.Profiles
.FirstOrDefaultAsync(x => x.Id == req.ProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var retire = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.InvalidRetirementRequest, 404);
var order = 1;
var retire_old = await _context.RetirementPeriods
.Where(x => x.CreatedAt.Year == retire.CreatedAt.Year)
.Where(x => x.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
.ToListAsync();
var last_order = await _context.RetirementProfiles
.Where(x => retire_old.Contains(x.RetirementPeriod))
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
.OrderByDescending(x => x.Order)
.FirstOrDefaultAsync();
if (last_order != null)
order = last_order.Order + 1;
var data = new RetirementProfile
{
Order = order,
Remove = false,
RetirementPeriod = retire,
Profile = profile,
CreatedUserId = FullName ?? "",
CreatedFullName = UserId ?? "System Administrator",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
if (retire_old.Count() <= 1)
{
await GenOrderByYear(retire.Type.Trim().ToUpper(), retire.CreatedAt.Year);
}
_context.RetirementProfiles.Add(data);
_context.SaveChanges();
return Success();
}
/// <summary>
/// ใส่เหตุผลไม่เกษียณ
/// </summary>
/// <param name="retireProfileId">Id ผู้ใช้งานในประกาศ</param>
/// <param name="reason">เหตุผล</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("reason")]
public async Task<ActionResult<ResponseObject>> EditReasonProfileRetirement([FromBody] ProfileRetireRequest req)
{
var profile = await _context.RetirementProfiles
.FirstOrDefaultAsync(x => x.Id == req.RetireProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
profile.Remove = true;
profile.Reason = req.Reason;
profile.LastUpdateFullName = FullName ?? "System Administrator";
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
/// <summary>
/// View เหตุผลไม่เกษียณ
/// </summary>
/// <param name="retireProfileId">Id ผู้ใช้งานในประกาศ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("reason/{retireProfileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> ViewReasonProfileRetirement(Guid retireProfileId)
{
var profile = await _context.RetirementProfiles
.Select(x => new
{
Id = x.Id,
Reason = x.Reason,
})
.FirstOrDefaultAsync(x => x.Id == retireProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
return Success(profile);
}
}
}

View file

@ -0,0 +1,27 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["BMA.EHR.Domain/BMA.EHR.Domain.csproj", "BMA.EHR.Domain/"]
COPY ["BMA.EHR.Application/BMA.EHR.Application.csproj", "BMA.EHR.Application/"]
COPY ["BMA.EHR.Infrastructure/BMA.EHR.Infrastructure.csproj", "BMA.EHR.Infrastructure/"]
COPY ["BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj", "BMA.EHR.Retirement.Service/"]
RUN dotnet restore "BMA.EHR.Retirement.Service/BMA.EHR.Retirement.Service.csproj"
COPY . .
WORKDIR "/src/BMA.EHR.Retirement.Service"
RUN dotnet build "BMA.EHR.Retirement.Service.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "BMA.EHR.Retirement.Service.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BMA.EHR.Retirement.Service.dll"]

View file

@ -0,0 +1,161 @@
using BMA.EHR.Application;
using BMA.EHR.Domain.Middlewares;
using BMA.EHR.Infrastructure;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Retirement.Service;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Logging;
using Microsoft.IdentityModel.Tokens;
using Serilog;
using Serilog.Exceptions;
using Serilog.Sinks.Elasticsearch;
using System.Reflection;
using System.Text;
var builder = WebApplication.CreateBuilder(args);
{
var issuer = builder.Configuration["Jwt:Issuer"];
var key = builder.Configuration["Jwt:Key"];
IdentityModelEventSource.ShowPII = true;
builder.Services.AddHttpContextAccessor();
builder.Services.AddApiVersioning(opt =>
{
opt.DefaultApiVersion = new ApiVersion(1, 0);
opt.AssumeDefaultVersionWhenUnspecified = true;
opt.ReportApiVersions = true;
opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
new HeaderApiVersionReader("x-api-version"),
new MediaTypeApiVersionReader("x-api-version"));
});
builder.Services.AddVersionedApiExplorer(setup =>
{
setup.GroupNameFormat = "'v'VVV";
setup.SubstituteApiVersionInUrl = true;
});
builder.Services.AddEndpointsApiExplorer();
// Authorization
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(opt =>
{
opt.RequireHttpsMetadata = false; //false for dev
opt.Authority = issuer;
opt.TokenValidationParameters = new()
{
ValidateIssuer = true,
ValidateAudience = false,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = issuer,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key))
};
});
builder.Services.AddAuthorization();
// use serilog
ConfigureLogs();
builder.Host.UseSerilog();
// Add config CORS
builder.Services.AddCors(options => options.AddDefaultPolicy(builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowedToAllowWildcardSubdomains();
}));
// Add services to the container.
builder.Services.AddApplication();
builder.Services.AddPersistence(builder.Configuration);
builder.Services.AddControllers(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
})
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
builder.Services.AddSwaggerGen();
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
builder.Services.AddHealthChecks();
}
var app = builder.Build();
{
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
{
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
description.GroupName.ToUpperInvariant());
}
});
}
app.MapHealthChecks("/health");
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthentication();
app.UseAuthorization();
app.UseDefaultFiles();
app.UseStaticFiles();
app.MapControllers();
app.UseMiddleware<ErrorHandlerMiddleware>();
// apply migrations
await using var scope = app.Services.CreateAsyncScope();
await using var db = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
await db.Database.MigrateAsync();
app.Run();
}
void ConfigureLogs()
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile(
$"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json",
optional: true)
.Build();
Log.Logger = new LoggerConfiguration()
.Enrich.FromLogContext()
.MinimumLevel.Error()
.WriteTo.Console()
.Enrich.WithExceptionDetails()
.WriteTo.Elasticsearch(ConfigureElasticSink(configuration, environment ?? ""))
.Enrich.WithProperty("Environment", environment)
.ReadFrom.Configuration(configuration)
.CreateLogger();
}
ElasticsearchSinkOptions ConfigureElasticSink(IConfigurationRoot configuration, string environment)
{
return new ElasticsearchSinkOptions(new Uri(configuration["ElasticConfiguration:Uri"] ?? ""))
{
AutoRegisterTemplate = true,
IndexFormat = $"{Assembly.GetExecutingAssembly()?.GetName()?.Name?.ToLower().Replace(".", "-")}-{environment?.ToLower().Replace(".", "-")}"
};
}

View file

@ -0,0 +1,48 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5039"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7120;http://localhost:5039"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:35013",
"sslPort": 44374
}
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class ProfileRequest
{
public Guid ProfileId { get; set; }
}
}

View file

@ -0,0 +1,11 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class ProfileRetireRequest
{
public Guid RetireProfileId { get; set; }
public string Reason { get; set; }
}
}

View file

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View file

@ -0,0 +1,36 @@
{
"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.9;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"
},
"EPPlus": {
"ExcelPackage": {
"LicenseContext": "NonCommercial"
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
},
"Protocol": "HTTPS"
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="private_nuget" value="https://nuget.frappet.synology.me/v3/index.json" />
</packageSources>
</configuration>

View file

@ -0,0 +1,184 @@
<!--
~ Copyright 2016 Red Hat, Inc. and/or its affiliates
~ and other contributors as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<html>
<head>
<script src="./keycloak.js"></script>
</head>
<body>
<div>
<button onclick="keycloak.login()">Login</button>
<button onclick="keycloak.login({ action: 'UPDATE_PASSWORD' })">Update Password</button>
<button onclick="keycloak.logout()">Logout</button>
<button onclick="keycloak.register()">Register</button>
<button onclick="keycloak.accountManagement()">Account</button>
<button onclick="refreshToken(9999)">Refresh Token</button>
<button onclick="refreshToken(30)">Refresh Token (if <30s validity)</button>
<button onclick="loadProfile()">Get Profile</button>
<button onclick="updateProfile()">Update profile</button>
<button onclick="loadUserInfo()">Get User Info</button>
<button onclick="output(keycloak.tokenParsed)">Show Token</button>
<button onclick="output(keycloak.refreshTokenParsed)">Show Refresh Token</button>
<button onclick="output(keycloak.idTokenParsed)">Show ID Token</button>
<button onclick="showExpires()">Show Expires</button>
<button onclick="output(keycloak)">Show Details</button>
<button onclick="output(keycloak.createLoginUrl())">Show Login URL</button>
<button onclick="output(keycloak.createLogoutUrl())">Show Logout URL</button>
<button onclick="output(keycloak.createRegisterUrl())">Show Register URL</button>
<button onclick="output(keycloak.createAccountUrl())">Show Account URL</button>
</div>
<h2>Result</h2>
<pre style="background-color: #ddd; border: 1px solid #ccc; padding: 10px; word-wrap: break-word; white-space: pre-wrap;" id="output"></pre>
<h2>Events</h2>
<pre style="background-color: #ddd; border: 1px solid #ccc; padding: 10px; word-wrap: break-word; white-space: pre-wrap;" id="events"></pre>
<script>
function loadProfile() {
keycloak.loadUserProfile().success(function(profile) {
output(profile);
}).error(function() {
output('Failed to load profile');
});
}
function updateProfile() {
var url = keycloak.createAccountUrl().split('?')[0];
var req = new XMLHttpRequest();
req.open('POST', url, true);
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader('Content-Type', 'application/json');
req.setRequestHeader('Authorization', 'bearer ' + keycloak.token);
req.onreadystatechange = function () {
if (req.readyState == 4) {
if (req.status == 200) {
output('Success');
} else {
output('Failed');
}
}
}
req.send('{"email":"myemail@foo.bar","firstName":"test","lastName":"bar"}');
}
function loadUserInfo() {
keycloak.loadUserInfo().success(function(userInfo) {
output(userInfo);
}).error(function() {
output('Failed to load user info');
});
}
function refreshToken(minValidity) {
keycloak.updateToken(minValidity).then(function(refreshed) {
if (refreshed) {
output(keycloak.tokenParsed);
} else {
output('Token not refreshed, valid for ' + Math.round(keycloak.tokenParsed.exp + keycloak.timeSkew - new Date().getTime() / 1000) + ' seconds');
}
}).catch(function() {
output('Failed to refresh token');
});
}
function showExpires() {
if (!keycloak.tokenParsed) {
output("Not authenticated");
return;
}
var o = 'Token Expires:\t\t' + new Date((keycloak.tokenParsed.exp + keycloak.timeSkew) * 1000).toLocaleString() + '\n';
o += 'Token Expires in:\t' + Math.round(keycloak.tokenParsed.exp + keycloak.timeSkew - new Date().getTime() / 1000) + ' seconds\n';
if (keycloak.refreshTokenParsed) {
o += 'Refresh Token Expires:\t' + new Date((keycloak.refreshTokenParsed.exp + keycloak.timeSkew) * 1000).toLocaleString() + '\n';
o += 'Refresh Expires in:\t' + Math.round(keycloak.refreshTokenParsed.exp + keycloak.timeSkew - new Date().getTime() / 1000) + ' seconds';
}
output(o);
}
function output(data) {
if (typeof data === 'object') {
data = JSON.stringify(data, null, ' ');
}
document.getElementById('output').innerHTML = data;
}
function event(event) {
var e = document.getElementById('events').innerHTML;
document.getElementById('events').innerHTML = new Date().toLocaleString() + "\t" + event + "\n" + e;
}
var keycloak = Keycloak();
keycloak.onAuthSuccess = function () {
event('Auth Success');
};
keycloak.onAuthError = function (errorData) {
event("Auth Error: " + JSON.stringify(errorData) );
};
keycloak.onAuthRefreshSuccess = function () {
event('Auth Refresh Success');
};
keycloak.onAuthRefreshError = function () {
event('Auth Refresh Error');
};
keycloak.onAuthLogout = function () {
event('Auth Logout');
};
keycloak.onTokenExpired = function () {
event('Access token expired.');
};
keycloak.onActionUpdate = function (status) {
switch (status) {
case 'success':
event('Action completed successfully'); break;
case 'cancelled':
event('Action cancelled by user'); break;
case 'error':
event('Action failed'); break;
}
};
// Flow can be changed to 'implicit' or 'hybrid', but then client must enable implicit flow in admin console too
var initOptions = {
responseMode: 'fragment',
flow: 'standard'
};
keycloak.init(initOptions).then(function(authenticated) {
output('Init Success (' + (authenticated ? 'Authenticated' : 'Not Authenticated') + ')');
}).catch(function() {
output('Init Error');
});
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
{
"realm": "bma-ehr",
"auth-server-url": "https://identity.frappet.com",
"ssl-required": "external",
"resource": "bma-ehr",
"public-client": true
}

View file

@ -23,7 +23,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Command.Service", "BMA.EHR.Command.Service\BMA.EHR.Command.Service.csproj", "{E4E905EE-61DF-4451-B063-5C86BC7574CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Insignia.Service", "BMA.EHR.Insignia.Service\BMA.EHR.Insignia.Service.csproj", "{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Insignia.Service", "BMA.EHR.Insignia.Service\BMA.EHR.Insignia.Service.csproj", "{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Retirement.Service", "BMA.EHR.Retirement.Service\BMA.EHR.Retirement.Service.csproj", "{3FFE378C-387F-42EA-96E2-68E63BB295F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -67,6 +69,10 @@ Global
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Release|Any CPU.Build.0 = Release|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -82,6 +88,7 @@ Global
{AC4B2602-C543-4165-85D7-F6F92F553D80} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{E4E905EE-61DF-4451-B063-5C86BC7574CE} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{3FFE378C-387F-42EA-96E2-68E63BB295F9} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}