Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop

This commit is contained in:
Kittapath 2024-07-07 10:25:41 +07:00
commit 0b6ba817f6
58 changed files with 26024 additions and 6121 deletions

View file

@ -1,12 +0,0 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.28.2",
"commands": [
"dotnet-csharpier"
]
}
}
}

View file

@ -1,88 +1,88 @@
name: release-dev
run-name: release-dev ${{ github.actor }}
on:
# push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+'
# tags-ignore:
# - '2.*'
# Allow run workflow manually from Action tab
workflow_dispatch:
# push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+'
# tags-ignore:
# - '2.*'
# Allow run workflow manually from Action tab
workflow_dispatch:
env:
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-insignia-service
DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-insignia
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-insignia-service
DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-insignia
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
# act workflow_dispatch -W .github/workflows/release_insignia.yaml --input IMAGE_VER=insignia-1.0.0 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
release-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# skip Set up QEMU because it fail on act and container
- name: Gen Version
id: gen_ver
run: |
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
else
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
fi
if [[ $IMAGE_VER == '' ]]; then
IMAGE_VER='test-vBeta'
fi
echo '::set-output name=image_ver::'$IMAGE_VER
- name: Test Version
run: |
echo $GITHUB_REF
echo ${{ steps.gen_ver.outputs.image_ver }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login in to registry
uses: docker/login-action@v2
with:
registry: ${{env.REGISTRY}}
username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_PASS}}
- name: Build and load local docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
file: BMA.EHR.Insignia.Service/Dockerfile
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
# act workflow_dispatch -W .github/workflows/release_insignia.yaml --input IMAGE_VER=insignia-1.0.0 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
release-dev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# skip Set up QEMU because it fail on act and container
- name: Gen Version
id: gen_ver
run: |
if [[ $GITHUB_REF == 'refs/tags/'* ]]; then
IMAGE_VER='${GITHUB_REF/refs\/tags\//}'
else
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
fi
if [[ $IMAGE_VER == '' ]]; then
IMAGE_VER='test-vBeta'
fi
echo '::set-output name=image_ver::'$IMAGE_VER
- name: Test Version
run: |
echo $GITHUB_REF
echo ${{ steps.gen_ver.outputs.image_ver }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login in to registry
uses: docker/login-action@v2
with:
registry: ${{env.REGISTRY}}
username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_PASS}}
- name: Build and load local docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
file: BMA.EHR.Insignia/Dockerfile
push: true
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Reload docker compose
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{env.DEPLOY_HOST}}
username: frappet
password: ${{ secrets.SSH_PASSWORD }}
port: ${{env.DEPLOY_PORT}}
script: |
cd "${{env.COMPOSE_PATH}}"
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- uses: snow-actions/line-notify@v1.1.0
if: success()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Success✅✅✅
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
- uses: snow-actions/line-notify@v1.1.0
if: failure()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Failure❌❌❌
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
- name: Reload docker compose
uses: appleboy/ssh-action@v0.1.8
with:
host: ${{env.DEPLOY_HOST}}
username: frappet
password: ${{ secrets.SSH_PASSWORD }}
port: ${{env.DEPLOY_PORT}}
script: |
cd "${{env.COMPOSE_PATH}}"
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- uses: snow-actions/line-notify@v1.1.0
if: success()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Success✅✅✅
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
- uses: snow-actions/line-notify@v1.1.0
if: failure()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Failure❌❌❌
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}

View file

@ -4,8 +4,8 @@
# Rider ignored files
/contentModel.xml
/.idea.BMA.EHR.Solution.iml
/projectSettingsUpdater.xml
/modules.xml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="accountSettings">
<option name="activeRegion" value="us-east-1" />
<option name="recentlyUsedRegions">
<list>
<option value="us-east-1" />
</list>
</option>
</component>
</project>

View file

@ -9158,11 +9158,14 @@ namespace BMA.EHR.Application.Repositories.Commands
var raw = JsonConvert.DeserializeObject<dynamic>(apiResult.Result);
if (raw != null)
{
ret.Add(new KeyValueItemResponse
if(raw.result!.rootId != null && raw.result!.root != null)
{
Id = raw.result!.rootId ?? null,
Name = raw.result!.root ?? null,
});
ret.Add(new KeyValueItemResponse
{
Id = raw.result!.rootId ?? null,
Name = raw.result!.root ?? null,
});
}
}
}
// var rootOcId = await GetRootOcIdAsync(UserOrganizationId);

File diff suppressed because it is too large Load diff

View file

@ -6,28 +6,46 @@ namespace BMA.EHR.Application.Requests
{
public Guid ProfileId { get; set; }
public string Prefix { get; set; }
public string CitizenId { get; set; } = String.Empty;
public string FullName { get; set; }
public string Prefix { get; set; } = String.Empty;
public string FirstName { get; set; } = String.Empty;
public string LastName { get; set; } = String.Empty;
public DateTime? BirthDate { get; set; }
public DateTime? DateAppoint { get; set; }
public string? ProfileType { get; set; }
public string? PosTypeName { get; set; }
public string? PosLevelName { get; set; }
public string Position { get; set; }
public string FullName { get; set; } = String.Empty;
public string Rank { get; set; }
public string Position { get; set; } = String.Empty;
public string GovAge { get; set; }
public string Rank { get; set; } = String.Empty;
public string GovAge { get; set; } = String.Empty;
public double? Salary { get; set; }
public double? PositionSalary { get; set; }
public string LastInsignia { get; set; }
public string LastInsignia { get; set; } = String.Empty;
public Guid? LastInsigniaId { get; set; }
//public Guid PosNo { get; set; }
public string PosNo { get; set; }
public string PosNo { get; set; } = String.Empty;
public InsigniaItem RequestInsignia { get; set; }
public InsigniaItem RequestInsignia { get; set; } = new();
public string Gender { get; set; }
public string Gender { get; set; } = String.Empty;
public int Seq { get; set; }
@ -40,4 +58,4 @@ namespace BMA.EHR.Application.Requests
public string Result { get; set; } = "";
}
}
}

View file

@ -71,5 +71,7 @@ namespace BMA.EHR.Domain.Models.Insignias
public string? PosNo { get; set; }
public double? Amount { get; set; }
public double? PositionSalaryAmount { get; set; }
public string? LastInsigniaName { get; set; }
}
}

View file

@ -25,6 +25,7 @@
<PackageReference Include="Oracle.EntityFrameworkCore" Version="7.21.9" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
<PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
</ItemGroup>
<ItemGroup>

View file

@ -1,5 +1,6 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Infrastructure.MessageQueue;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@ -9,6 +10,15 @@ namespace BMA.EHR.Infrastructure
{
public static class InfrastructureServiceRegistration
{
public static IServiceCollection AddMessageQueue(this IServiceCollection services)
{
services.AddTransient<RabbitMQConnection>();
services.AddTransient<RabbitMQProducer>();
services.AddTransient<RabbitMQConsumer>();
return services;
}
public static IServiceCollection AddLeavePersistence(this IServiceCollection services,
IConfiguration configuration)
{

View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BMA.EHR.Infrastructure.MessageQueue
{
public class InsigniaRequestPeriod
{
public Guid PeriodId { get; set; }
}
}

View file

@ -0,0 +1,45 @@
using Microsoft.Extensions.Configuration;
using RabbitMQ.Client;
namespace BMA.EHR.Infrastructure.MessageQueue
{
public class RabbitMQConnection
{
private readonly IConnection _connection;
private readonly IModel _channel;
private readonly IConfiguration _configuration;
/// <summary>
///
/// </summary>
/// <param name="configuration"></param>
public RabbitMQConnection(IConfiguration configuration)
{
_configuration = configuration;
var hostName = _configuration["RabbitMQ:URL"];
var userName = _configuration["RabbitMQ:UserName"];
var password = _configuration["RabbitMQ:Password"];
var factory = new ConnectionFactory() { HostName = hostName, UserName = userName, Password = password };
_connection = factory.CreateConnection();
_channel = _connection.CreateModel();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public IModel GetChannel() => _channel;
/// <summary>
///
/// </summary>
public void Dispose()
{
_channel?.Close();
_connection?.Close();
}
}
}

View file

@ -0,0 +1,104 @@
using System.Text;
using BMA.EHR.Application.Repositories;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using RabbitMQ.Client.Events;
namespace BMA.EHR.Infrastructure.MessageQueue
{
public class RabbitMQConsumer
{
private readonly RabbitMQConnection _connection;
private readonly UserProfileRepository _userProfileRepository;
private readonly InsigniaPeriodsRepository _insigniaPeriodsRepository;
private readonly IHttpContextAccessor _httpContextAccessor;
private const string INSIGNIA_QUEUE = "bma_insignia_request";
public RabbitMQConsumer(RabbitMQConnection connection,
UserProfileRepository userProfileRepository,
InsigniaPeriodsRepository insigniaPeriodsRepository,
IHttpContextAccessor httpContextAccessor)
{
_connection = connection;
_userProfileRepository = userProfileRepository;
_insigniaPeriodsRepository = insigniaPeriodsRepository;
_httpContextAccessor = httpContextAccessor;
}
#region " Properties "
private bool? RoleAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("admin");
private bool? RoleInsignia1 => _httpContextAccessor?.HttpContext?.User?.IsInRole("insignia1");
private bool? RoleInsignia2 => _httpContextAccessor?.HttpContext?.User?.IsInRole("insignia2");
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
#endregion
private async Task CalculateInsigniaAsync(Guid periodId)
{
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
foreach (var organization in organizations)
{
if (organization == null)
continue;
//if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
var result = await _insigniaPeriodsRepository.GetInsigniaRequest(periodId, organization.Id);
if (result != null)
{
Guid period = result.PeriodId;
string requestStatus = result.RequestStatus;
var candidate = await _insigniaPeriodsRepository.GetInsigniaCandidateBKK(periodId, organization.Id);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
await _insigniaPeriodsRepository.InsertCandidate(period, organization.Id, candidate);
}
}
}
}
/// <summary>
///
/// </summary>
public void StartReceiving()
{
var channel = _connection.GetChannel();
channel.QueueDeclare(queue: INSIGNIA_QUEUE,
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
var message = Encoding.UTF8.GetString(body);
//var request = JsonConvert.DeserializeObject<InsigniaRequestPeriod>(message);
Console.WriteLine(" [x] Received {0}", message);
var periodId = Guid.Parse(message);
// process insignia request while receive message
var res = CalculateInsigniaAsync(periodId);
Console.WriteLine(" [x] Success Calculate Period {0}", periodId);
};
channel.BasicConsume(queue: INSIGNIA_QUEUE,
autoAck: true,
consumer: consumer,
consumerTag: "",
noLocal: false,
exclusive: false,
arguments: null);
}
}
}

View file

@ -0,0 +1,69 @@
using System.Text;
using Newtonsoft.Json;
namespace BMA.EHR.Infrastructure.MessageQueue
{
public class RabbitMQProducer
{
private readonly RabbitMQConnection _connection;
private const string INSIGNIA_QUEUE = "bma_insignia_request";
/// <summary>
///
/// </summary>
/// <param name="connection"></param>
public RabbitMQProducer(RabbitMQConnection connection)
{
_connection = connection;
}
/// <summary>
///
/// </summary>
/// <param name="message"></param>
public void SendMessage(string message)
{
var channel = _connection.GetChannel();
channel.QueueDeclare(queue: "myqueue",
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
var body = Encoding.UTF8.GetBytes(message);
channel.BasicPublish(exchange: "",
routingKey: "myqueue",
mandatory: false,
basicProperties: null,
body: body);
}
public void CalculateInsignia(Guid periodId)
{
var channel = _connection.GetChannel();
channel.QueueDeclare(queue: INSIGNIA_QUEUE,
durable: false,
exclusive: false,
autoDelete: false,
arguments: null);
// var req = new InsigniaRequestPeriod
// {
// PeriodId = periodId
// };
// var serializedObject = JsonConvert.SerializeObject(req);
var body = Encoding.UTF8.GetBytes(periodId.ToString("D"));
channel.BasicPublish(exchange: "",
routingKey: INSIGNIA_QUEUE,
mandatory: false,
basicProperties: null,
body: body);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddLastInsigniaNametoRequest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "LastInsigniaName",
table: "InsigniaRequestProfiles",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LastInsigniaName",
table: "InsigniaRequestProfiles");
}
}
}

View file

@ -6401,6 +6401,9 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Property<bool>("IsApprove")
.HasColumnType("tinyint(1)");
b.Property<string>("LastInsigniaName")
.HasColumnType("longtext");
b.Property<string>("LastName")
.HasColumnType("longtext");

View file

@ -1,49 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>93677512-b64b-4a19-9e7d-dd283c7ec901</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Insignia.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hangfire" Version="1.8.5" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
<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.32.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>
<ItemGroup>
<None Update="Templates/PersonInsignia.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>93677512-b64b-4a19-9e7d-dd283c7ec901</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Insignia.Service</RootNamespace>
<AssemblyName>BMA.EHR.Insignia</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hangfire" Version="1.8.5" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
<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.32.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<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>
<ItemGroup>
<None Update="Templates/PersonInsignia.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load diff

View file

@ -11,17 +11,17 @@ 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.Insignia.Service/BMA.EHR.Insignia.Service.csproj", "BMA.EHR.Insignia.Service/"]
COPY ["BMA.EHR.Insignia/BMA.EHR.Insignia.csproj", "BMA.EHR.Insignia/"]
RUN dotnet restore "BMA.EHR.Insignia.Service/BMA.EHR.Insignia.Service.csproj"
RUN dotnet restore "BMA.EHR.Insignia/BMA.EHR.Insignia.csproj"
COPY . .
WORKDIR "/src/BMA.EHR.Insignia.Service"
RUN dotnet build "BMA.EHR.Insignia.Service.csproj" -c Release -o /app/build
WORKDIR "/src/BMA.EHR.Insignia"
RUN dotnet build "BMA.EHR.Insignia.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "BMA.EHR.Insignia.Service.csproj" -c Release -o /app/publish /p:UseAppHost=false
RUN dotnet publish "BMA.EHR.Insignia.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BMA.EHR.Insignia.Service.dll"]
ENTRYPOINT ["dotnet", "BMA.EHR.Insignia.dll"]

View file

@ -2,6 +2,7 @@ using BMA.EHR.Application;
using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Domain.Middlewares;
using BMA.EHR.Infrastructure;
using BMA.EHR.Infrastructure.MessageQueue;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service;
using BMA.EHR.Insignia.Service.Controllers;
@ -90,6 +91,9 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLeaveApplication();
builder.Services.AddLeavePersistence(builder.Configuration);
// RabbitMQ
builder.Services.AddMessageQueue();
builder.Services.AddControllers(options =>
{
options.SuppressAsyncSuffixInActionNames = false;
@ -172,6 +176,9 @@ var app = builder.Build();
await using var db = scope.ServiceProvider.GetRequiredService<ApplicationDBContext>();
await db.Database.MigrateAsync();
var rabbitMQConsumer = app.Services.GetRequiredService<RabbitMQConsumer>();
rabbitMQConsumer.StartReceiving();
app.Run();
}

View file

@ -43,5 +43,10 @@
"Node": {
"API": "https://bma-ehr.frappet.synology.me/api/v1/probation"
},
"API": "https://bma-ehr.frappet.synology.me/api/v1"
"API": "https://bma-ehr.frappet.synology.me/api/v1",
"RabbitMQ" :{
"URL": "localhost",
"UserName": "frappet",
"Password": "FPTadmin2357"
}
}

View file

@ -118,25 +118,33 @@ namespace BMA.EHR.Report.Service.Controllers
{
_count++;
}
string position = profile.GetType().GetProperty("position").GetValue(profile);
position = position != string.Empty && position != null ? position : "-";
string thaiOrder = profile.GetType().GetProperty("order").GetValue(profile).ToString();
thaiOrder = $"ลำดับที่ {thaiOrder.ToThaiNumber()}";
string thaiPosNo = profile.GetType().GetProperty("posNo").GetValue(profile);
thaiPosNo = thaiPosNo != null ? $"(ตำแหน่งเลขที่ {thaiPosNo.ToThaiNumber()})" : $"(ตำแหน่งเลขที่ - )";
string organizationOrganization = (profile.GetType().GetProperty("child4").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child4").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child3").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child3").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child2").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child2").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child1").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child1").GetValue(profile) + "/") +
(profile.GetType().GetProperty("root").GetValue(profile) == null ? "" : profile.GetType().GetProperty("root").GetValue(profile));
string reason = profile.GetType().GetProperty("reason").GetValue(profile);
organizationOrganization = organizationOrganization != string.Empty ? organizationOrganization : reason != string.Empty ? reason : string.Empty ;
reason = organizationOrganization == reason ? string.Empty : reason;
_profileList.Add(new
{
count = $"{_count.ToString().ToThaiNumber()}.",
no = $"{(_profileList.Count() + 1).ToString().ToThaiNumber()}.",
order = thaiOrder,
organizationOrganization = (profile.GetType().GetProperty("child4").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child4").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child3").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child3").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child2").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child2").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child1").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child1").GetValue(profile) + "/") +
(profile.GetType().GetProperty("root").GetValue(profile) == null ? "" : profile.GetType().GetProperty("root").GetValue(profile)),
organizationOrganization = organizationOrganization,
fullName = $"{profile.GetType().GetProperty("prefix").GetValue(profile)}{profile.GetType().GetProperty("firstName").GetValue(profile)} {profile.GetType().GetProperty("lastName").GetValue(profile)}",
position = profile.GetType().GetProperty("position").GetValue(profile),
posNo = profile.GetType().GetProperty("posMasterNo").GetValue(profile),
position = position,
posNo = thaiPosNo,
oc = profile.GetType().GetProperty("root").GetValue(profile),
positionEmployeePosition = profile.GetType().GetProperty("position").GetValue(profile),
posNoEmployee = profile.GetType().GetProperty("posMasterNo").GetValue(profile),
reason = profile.GetType().GetProperty("reason").GetValue(profile),
reason = reason,
});
}

View file

@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.OrganizationEmploye
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("{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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Retirement.Service", "BMA.EHR.Retirement.Service\BMA.EHR.Retirement.Service.csproj", "{3FFE378C-387F-42EA-96E2-68E63BB295F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "BMA.EHR.Report.Service\BMA.EHR.Report.Service.csproj", "{26FE7B1C-771B-4940-9F40-326A7AD53F1C}"
@ -31,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Leave.Service", "BM
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Discipline.Service", "BMA.EHR.Discipline.Service\BMA.EHR.Discipline.Service.csproj", "{0145A11E-7780-437B-A86F-CBDDB50BC3D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BMA.EHR.Insignia", "BMA.EHR.Insignia\BMA.EHR.Insignia.csproj", "{03AB740F-AF31-423E-8546-198B914AF76F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -65,10 +65,6 @@ Global
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.Build.0 = Release|Any CPU
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
@ -85,6 +81,10 @@ Global
{0145A11E-7780-437B-A86F-CBDDB50BC3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0145A11E-7780-437B-A86F-CBDDB50BC3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0145A11E-7780-437B-A86F-CBDDB50BC3D1}.Release|Any CPU.Build.0 = Release|Any CPU
{03AB740F-AF31-423E-8546-198B914AF76F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03AB740F-AF31-423E-8546-198B914AF76F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03AB740F-AF31-423E-8546-198B914AF76F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03AB740F-AF31-423E-8546-198B914AF76F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -98,11 +98,11 @@ Global
{81610EF7-AF80-44D8-9263-925C821CF45F} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{A54AA069-8B0E-4784-953B-5DA9F9C8285E} = {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}
{26FE7B1C-771B-4940-9F40-326A7AD53F1C} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{0F15B902-82D7-4878-B12D-B36C14E8EDBC} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{0145A11E-7780-437B-A86F-CBDDB50BC3D1} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{03AB740F-AF31-423E-8546-198B914AF76F} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}