Merge branch 'develop' into work

# Conflicts:
#	BMA.EHR.Application/ApplicationServicesRegistration.cs
#	BMA.EHR.Infrastructure/Migrations/ApplicationDBContextModelSnapshot.cs
#	BMA.EHR.Infrastructure/Persistence/ApplicationDBContext.cs
#	BMA.EHR.Solution.sln
This commit is contained in:
Kittapath 2023-07-13 09:57:58 +07:00
commit 8edfbc7466
70 changed files with 21946 additions and 157 deletions

View file

@ -8,11 +8,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Infrastructure.Messaging;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@ -13,6 +14,7 @@ namespace BMA.EHR.Infrastructure
IConfiguration configuration)
{
services.AddTransient<MinIOService>();
services.AddTransient<EmailSenderService>();
var connectionString = configuration.GetConnectionString("DefaultConnection");

View file

@ -0,0 +1,60 @@
using BMA.EHR.Domain.Extensions;
using Microsoft.Extensions.Configuration;
using System.Net;
using System.Net.Mail;
namespace BMA.EHR.Infrastructure.Messaging
{
public class EmailSenderService
{
#region " Fields "
private readonly IConfiguration _configuration;
#endregion
#region " Constructor and Destructor "
public EmailSenderService(IConfiguration configuration)
{
_configuration = configuration;
}
#endregion
#region " Methods "
public void SendMail(string subject, string body, string receiver)
{
try
{
var server = _configuration["Mail:Server"];
var user = _configuration["Mail:User"];
var password = _configuration["Mail:Password"];
var port = _configuration["Mail:Port"];
var from = _configuration["Mail:MailFrom"];
var client = new SmtpClient(server, port.ToInteger());
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(user, password);
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
var mail = new MailMessage();
mail.From = new MailAddress(from, "eHR Bangkok Automation System");
mail.To.Add(receiver);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
client.Send(mail);
}
catch
{
throw;
}
}
#endregion
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,57 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddMessageQueue : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "MessageQueues",
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"),
SenderSystem = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ส่งจากระบบงาน")
.Annotation("MySql:CharSet", "utf8mb4"),
Subject = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "หัวเรื่อง")
.Annotation("MySql:CharSet", "utf8mb4"),
MessageContent = table.Column<string>(type: "longtext", nullable: false, comment: "รายละเอียดข้อความ")
.Annotation("MySql:CharSet", "utf8mb4"),
MessagePayLoad = table.Column<string>(type: "longtext", nullable: false, comment: "สิ่งที่แนบมาด้วย")
.Annotation("MySql:CharSet", "utf8mb4"),
ReceiverUserId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสของผู้รับข้อความ", collation: "ascii_general_ci"),
IsSendEmail = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งอีเมลล์หรือไม่?"),
IsSendInbox = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งไปที่กล่องข้อความหรือไม่?"),
IsSendNotification = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งการแจ้งเตือนหรือไม่?"),
IsSend = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ทำการส่งข้อความแล้วหรือยัง?")
},
constraints: table =>
{
table.PrimaryKey("PK_MessageQueues", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MessageQueues");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddReceiverEmailtoMessageQueue : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ReceiverEmailAddress",
table: "MessageQueues",
type: "varchar(500)",
maxLength: 500,
nullable: false,
defaultValue: "",
comment: "อีเมล์ของผู้รับ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ReceiverEmailAddress",
table: "MessageQueues");
}
}
}

View file

@ -7485,7 +7485,7 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("OrganizationEmployees");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeeLevel", b =>
modelBuilder.Entity("BMA.EHR.Domain.Models.Notifications.MessageQueueEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@ -7532,21 +7532,85 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<Guid?>("OrganizationEmployeeId")
.HasColumnType("char(36)");
b.Property<bool>("IsSend")
.HasColumnType("tinyint(1)")
.HasComment("ทำการส่งข้อความแล้วหรือยัง?");
b.Property<Guid?>("PositionEmployeeLevelId")
.HasColumnType("char(36)");
b.Property<bool>("IsSendEmail")
.HasColumnType("tinyint(1)")
.HasComment("ส่งอีเมลล์หรือไม่?");
b.HasKey("Id");
b.Property<bool>("IsSendInbox")
.HasColumnType("tinyint(1)")
.HasComment("ส่งไปที่กล่องข้อความหรือไม่?");
b.HasIndex("OrganizationEmployeeId");
b.HasIndex("PositionEmployeeLevelId");
b.ToTable("OrganizationPositionEmployeeLevels");
b.Property<bool>("IsSendNotification")
.HasColumnType("tinyint(1)")
.HasComment("ส่งการแจ้งเตือนหรือไม่?");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeeLevel", 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<Guid?>("OrganizationEmployeeId")
.HasColumnType("char(36)");
b.Property<Guid?>("PositionEmployeeLevelId")
.HasColumnType("char(36)");
b.HasKey("Id");
b.HasIndex("OrganizationEmployeeId");
b.HasIndex("PositionEmployeeLevelId");
b.ToTable("OrganizationPositionEmployeeLevels");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.OrganizationEmployee.OrganizationPositionEmployeePositionSide", b =>
{
b.Property<Guid>("Id")
@ -7607,6 +7671,41 @@ namespace BMA.EHR.Infrastructure.Migrations
b.HasIndex("PositionEmployeePositionSideId");
b.ToTable("OrganizationPositionEmployeePositionSides");
b.Property<string>("MessageContent")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รายละเอียดข้อความ");
b.Property<string>("MessagePayLoad")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สิ่งที่แนบมาด้วย");
b.Property<string>("ReceiverEmailAddress")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("varchar(500)")
.HasComment("อีเมล์ของผู้รับ");
b.Property<Guid>("ReceiverUserId")
.HasColumnType("char(36)")
.HasComment("รหัสของผู้รับข้อความ");
b.Property<string>("SenderSystem")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasComment("ส่งจากระบบงาน");
b.Property<string>("Subject")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasComment("หัวเรื่อง");
b.HasKey("Id");
b.ToTable("MessageQueues");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Organizations.AvailablePositionLevelEntity", b =>

View file

@ -4,6 +4,7 @@ using BMA.EHR.Domain.Models.Documents;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Models.OrganizationEmployee;
using BMA.EHR.Domain.Models.Notifications;
using BMA.EHR.Domain.Models.Organizations;
using BMA.EHR.Domain.Models.Organizations.Report2;
using BMA.EHR.Domain.Models.Placement;
@ -237,6 +238,8 @@ namespace BMA.EHR.Infrastructure.Persistence
#endregion
#endregion
#region " Placements "
public DbSet<Placement> Placements { get; set; }
@ -256,14 +259,18 @@ namespace BMA.EHR.Infrastructure.Persistence
#endregion
#endregion
#region " Command "
public DbSet<DeploymentChannel> DeploymentChannels { get; set; }
#endregion
#region " Message Queue "
public DbSet<MessageQueueEntity> MessageQueues { get; set; }
#endregion
public ApplicationDBContext(DbContextOptions<ApplicationDBContext> options) : base(options)
{
}

View file

@ -202,7 +202,7 @@ namespace BMA.EHR.Application.Repositories
BucketName = _bucketName,
Key = doc?.ObjectRefId.ToString("D"),
Expires = expires,
Protocol = _protocol =="HTTPS"?Protocol.HTTPS: Protocol.HTTP
Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
};
string path = _s3Client.GetPreSignedURL(request);
@ -215,7 +215,7 @@ namespace BMA.EHR.Application.Repositories
try
{
var ret = new List<Guid>();
if(id == null)
if (id == null)
return ret;
var oc = _context.Organizations.FirstOrDefault(x => x.Id == id);
@ -245,12 +245,12 @@ namespace BMA.EHR.Application.Repositories
if (data == null)
return null;
if (data.ProfileType.Trim().ToUpper() == "OFFICER")
return "officer";
return "OFFICER";
if (data.EmployeeClass.Trim().ToUpper() == "PERM")
return "employee_perm";
return "EMPLOYEE_PERM";
if (data.EmployeeClass.Trim().ToUpper() == "TEMP")
return "employee_temp";
return "employee";
return "EMPLOYEE_TEMP";
return "EMPLOYEE";
}
}
}