แก้บันทึกพ้นราชการ (ยังไม่เสร็จ)

This commit is contained in:
Kittapath 2023-08-03 09:35:54 +07:00
parent e55c0f746b
commit 2e7abdb60a
13 changed files with 12478 additions and 189 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,278 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updateTablepositionpathaddorder : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "PositionTypes",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อประเภทตำแหน่ง",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<bool>(
name: "IsActive",
table: "PositionTypes",
type: "tinyint(1)",
nullable: false,
comment: "สถานะการใช้งาน",
oldClrType: typeof(bool),
oldType: "tinyint(1)",
oldComment: "สถานะการใช้งาน")
.Annotation("Relational:ColumnOrder", 3)
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AddColumn<int>(
name: "Order",
table: "PositionTypes",
type: "int",
nullable: true,
comment: "ลำดับ")
.Annotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<string>(
name: "ShortName",
table: "PositionLevels",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อย่อระดับตำแหน่ง",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อย่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 3)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "PositionLevels",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อระดับตำแหน่ง",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<int>(
name: "Level",
table: "PositionLevels",
type: "int",
nullable: false,
comment: "ลำดับชั้นของระดับตำแหน่ง",
oldClrType: typeof(int),
oldType: "int",
oldComment: "ลำดับชั้นของระดับตำแหน่ง")
.Annotation("Relational:ColumnOrder", 4)
.OldAnnotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<bool>(
name: "IsActive",
table: "PositionLevels",
type: "tinyint(1)",
nullable: false,
comment: "สถานะการใช้งาน",
oldClrType: typeof(bool),
oldType: "tinyint(1)",
oldComment: "สถานะการใช้งาน")
.Annotation("Relational:ColumnOrder", 5)
.OldAnnotation("Relational:ColumnOrder", 4);
migrationBuilder.AddColumn<int>(
name: "Order",
table: "PositionLevels",
type: "int",
nullable: true,
comment: "ลำดับ")
.Annotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "PositionEmployeeLevels",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อระดับชั้นงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อระดับชั้นงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 1);
migrationBuilder.AlterColumn<bool>(
name: "IsActive",
table: "PositionEmployeeLevels",
type: "tinyint(1)",
nullable: false,
comment: "สถานะการใช้งาน",
oldClrType: typeof(bool),
oldType: "tinyint(1)",
oldComment: "สถานะการใช้งาน")
.Annotation("Relational:ColumnOrder", 3)
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AddColumn<int>(
name: "Order",
table: "PositionEmployeeLevels",
type: "int",
nullable: true,
comment: "ลำดับ")
.Annotation("Relational:ColumnOrder", 1);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Order",
table: "PositionTypes");
migrationBuilder.DropColumn(
name: "Order",
table: "PositionLevels");
migrationBuilder.DropColumn(
name: "Order",
table: "PositionEmployeeLevels");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "PositionTypes",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อประเภทตำแหน่ง",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 1)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AlterColumn<bool>(
name: "IsActive",
table: "PositionTypes",
type: "tinyint(1)",
nullable: false,
comment: "สถานะการใช้งาน",
oldClrType: typeof(bool),
oldType: "tinyint(1)",
oldComment: "สถานะการใช้งาน")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<string>(
name: "ShortName",
table: "PositionLevels",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อย่อระดับตำแหน่ง",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อย่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 3);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "PositionLevels",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อระดับตำแหน่ง",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 1)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AlterColumn<int>(
name: "Level",
table: "PositionLevels",
type: "int",
nullable: false,
comment: "ลำดับชั้นของระดับตำแหน่ง",
oldClrType: typeof(int),
oldType: "int",
oldComment: "ลำดับชั้นของระดับตำแหน่ง")
.Annotation("Relational:ColumnOrder", 3)
.OldAnnotation("Relational:ColumnOrder", 4);
migrationBuilder.AlterColumn<bool>(
name: "IsActive",
table: "PositionLevels",
type: "tinyint(1)",
nullable: false,
comment: "สถานะการใช้งาน",
oldClrType: typeof(bool),
oldType: "tinyint(1)",
oldComment: "สถานะการใช้งาน")
.Annotation("Relational:ColumnOrder", 4)
.OldAnnotation("Relational:ColumnOrder", 5);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "PositionEmployeeLevels",
type: "varchar(100)",
maxLength: 100,
nullable: false,
comment: "ชื่อระดับชั้นงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldComment: "ชื่อระดับชั้นงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ")
.Annotation("MySql:CharSet", "utf8mb4")
.Annotation("Relational:ColumnOrder", 1)
.OldAnnotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:ColumnOrder", 2);
migrationBuilder.AlterColumn<bool>(
name: "IsActive",
table: "PositionEmployeeLevels",
type: "tinyint(1)",
nullable: false,
comment: "สถานะการใช้งาน",
oldClrType: typeof(bool),
oldType: "tinyint(1)",
oldComment: "สถานะการใช้งาน")
.Annotation("Relational:ColumnOrder", 2)
.OldAnnotation("Relational:ColumnOrder", 3);
}
}
}

View file

@ -6534,7 +6534,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)")
.HasColumnOrder(2)
.HasColumnOrder(3)
.HasComment("สถานะการใช้งาน");
b.Property<string>("LastUpdateFullName")
@ -6560,9 +6560,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasColumnOrder(1)
.HasColumnOrder(2)
.HasComment("ชื่อระดับชั้นงานข้อมูลตำแหน่งของลูกจ้างกรุงเทพ");
b.Property<int?>("Order")
.HasColumnType("int")
.HasColumnOrder(1)
.HasComment("ลำดับ");
b.HasKey("Id");
b.ToTable("PositionEmployeeLevels");
@ -7000,7 +7005,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)")
.HasColumnOrder(4)
.HasColumnOrder(5)
.HasComment("สถานะการใช้งาน");
b.Property<string>("LastUpdateFullName")
@ -7024,21 +7029,26 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<int>("Level")
.HasColumnType("int")
.HasColumnOrder(3)
.HasColumnOrder(4)
.HasComment("ลำดับชั้นของระดับตำแหน่ง");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasColumnOrder(1)
.HasColumnOrder(2)
.HasComment("ชื่อระดับตำแหน่ง");
b.Property<int?>("Order")
.HasColumnType("int")
.HasColumnOrder(1)
.HasComment("ลำดับ");
b.Property<string>("ShortName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasColumnOrder(2)
.HasColumnOrder(3)
.HasComment("ชื่อย่อระดับตำแหน่ง");
b.HasKey("Id");
@ -7344,7 +7354,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)")
.HasColumnOrder(2)
.HasColumnOrder(3)
.HasComment("สถานะการใช้งาน");
b.Property<string>("LastUpdateFullName")
@ -7370,9 +7380,14 @@ namespace BMA.EHR.Infrastructure.Migrations
.IsRequired()
.HasMaxLength(100)
.HasColumnType("varchar(100)")
.HasColumnOrder(1)
.HasColumnOrder(2)
.HasComment("ชื่อประเภทตำแหน่ง");
b.Property<int?>("Order")
.HasColumnType("int")
.HasColumnOrder(1)
.HasComment("ลำดับ");
b.HasKey("Id");
b.ToTable("PositionTypes");

View file

@ -295,6 +295,8 @@ namespace BMA.EHR.Infrastructure.Persistence
#region " Retirement "
public DbSet<RetirementPeriodHistory> RetirementPeriodHistorys { get; set; }
public DbSet<RetirementPeriod> RetirementPeriods { get; set; }
public DbSet<RetirementProfile> RetirementProfiles { get; set; }

View file

@ -18,6 +18,7 @@ namespace BMA.EHR.Application.Repositories
private readonly ApplicationDBContext _context;
private readonly IConfiguration _configuration;
private readonly AmazonS3Client _s3Client;
private readonly IWebHostEnvironment _hostingEnvironment;
private string _bucketName = string.Empty;
#endregion
@ -25,10 +26,12 @@ namespace BMA.EHR.Application.Repositories
#region " Constructors "
public MinIOService(ApplicationDBContext context,
IConfiguration configuration)
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
_context = context;
_configuration = configuration;
_hostingEnvironment = hostingEnvironment;
var config = new AmazonS3Config
{
@ -252,5 +255,84 @@ namespace BMA.EHR.Application.Repositories
return "EMPLOYEE_TEMP";
return "EMPLOYEE";
}
public async Task UploadFileAsyncTemp(string fileName, string subFolder)
{
try
{
var fileContents = File.ReadAllBytes(fileName);
System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileContents);
//var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName);
var fileExt = Path.GetExtension(fileName);
// var fileType = MimeTypeMap.GetMimeType(fileExt);
var file_name = Path.GetFileName(fileName);
var request = new PutObjectRequest
{
BucketName = $"{_bucketName}{subFolder}",
Key = file_name,
InputStream = filestream,
// ContentType = fileType,
CannedACL = S3CannedACL.PublicRead
};
await _s3Client.PutObjectAsync(request);
}
catch
{
throw;
}
}
public async Task<string> GenerateJsonFile(string json, string path, string fileName)
{
var tmpFile = "";
try
{
var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
if (!Directory.Exists(tmpDir))
Directory.CreateDirectory(tmpDir);
tmpFile = Path.Combine(tmpDir, fileName);
SaveToJsonFile(tmpFile, json);
await UploadFileAsyncTemp(tmpFile, path);
return "EMPLOYEE";
}
catch
{
throw;
}
finally
{
if (tmpFile != "")
{
if (System.IO.File.Exists(tmpFile))
System.IO.File.Delete(tmpFile);
}
}
}
private void SaveToJsonFile(string fileName, string data)
{
TextWriter writer = null;
try
{
writer = new StreamWriter(fileName);
writer.Write(data);
}
catch
{
throw;
}
finally
{
if (writer != null)
writer.Close();
}
}
}
}