Merge branch 'develop' into working

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2023-08-31 11:52:39 +07:00
commit 4753e1b45e
12 changed files with 1273 additions and 82 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,7 @@
using BMA.EHR.Application.Common.Interfaces;
using Amazon.S3.Model.Internal.MarshallTransformations;
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Models.Base;
using BMA.EHR.Domain.Models.HR;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
@ -13,7 +15,7 @@ namespace BMA.EHR.Application.Repositories
private readonly IApplicationDBContext _dbContext;
private readonly DbSet<T> _dbSet;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
@ -24,7 +26,7 @@ namespace BMA.EHR.Application.Repositories
_dbContext = dbContext;
_dbSet = _dbContext.Set<T>();
_httpContextAccessor = httpContextAccessor;
}
#endregion
@ -35,12 +37,46 @@ namespace BMA.EHR.Application.Repositories
protected string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
#endregion
#region " Methods "
public async Task<Guid> GetProfileOrganizationAsync(string citizenId)
{
try
{
var pf = await _dbContext.Set<Profile>()
.Where(x => x.CitizenId == citizenId)
.Where(x => x.ProfileType.ToLower().Trim() == "officer" && x.IsActive && !x.IsLeave)
.FirstOrDefaultAsync();
return pf == null || pf.Oc == null ? Guid.Empty : pf.OcId!.Value;
}
catch
{
throw;
}
}
public async Task<bool> CheckIsActiveOfficerAsync(string citizenId)
{
try
{
var pf = await _dbContext.Set<Profile>()
.Where(x => x.CitizenId == citizenId)
.Where(x => x.ProfileType.ToLower().Trim() == "officer" && x.IsActive && !x.IsLeave)
.FirstOrDefaultAsync();
return pf != null;
}
catch
{
throw;
}
}
public virtual async Task<IReadOnlyList<T>> GetAllAsync()
{
return await _dbSet.ToListAsync();

View file

@ -2484,6 +2484,10 @@ namespace BMA.EHR.Command.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(orderId);
if (command == null)
throw new Exception(GlobalMessages.CommandNotFound);
// TODO : หาค่า Education มาแสดง
var existed = await _repository.GetReceiverByCommmandIdAsync(orderId);
@ -2500,13 +2504,25 @@ namespace BMA.EHR.Command.Service.Controllers
Education = "" // ยังหาไม่เจอว่าอยุ่ field ไหน
}).ToList();
foreach (var r in receivers)
// ให้ Update Salary เฉพาะของ Command 01-04
switch (command.CommandType.CommandCode.ToUpper())
{
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
r.SalaryAmount = salary.SalaryAmount;
r.PositionSalaryAmount = salary.PositionSalaryAmount;
r.MonthSalaryAmount = salary.MonthSalaryAmount;
case "C-PM-01":
case "C-PM-02":
case "C-PM-03":
case "c-PM-04":
{
foreach (var r in receivers)
{
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
r.SalaryAmount = salary.SalaryAmount;
r.PositionSalaryAmount = salary.PositionSalaryAmount;
r.MonthSalaryAmount = salary.MonthSalaryAmount;
}
}
break;
default:
break;
}
return Success(receivers);
@ -2534,8 +2550,12 @@ namespace BMA.EHR.Command.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(orderId);
if (command == null)
throw new Exception(GlobalMessages.CommandNotFound);
var receivers = (await _repository.GetReceiverByCommmandIdAsync(orderId))
.OrderBy(x => x.Sequence)
.OrderBy(x => x.Sequence)
.Select(r => new CommandReceiverResponse
{
RefRecordId = r.RefPlacementProfileId!.Value,
@ -2547,13 +2567,24 @@ namespace BMA.EHR.Command.Service.Controllers
Education = "" // ยังหาไม่เจอว่าอยุ่ field ไหน
}).ToList();
foreach (var r in receivers)
// ให้ Update Salary เฉพาะของ Command 01-04
switch (command.CommandType.CommandCode.ToUpper())
{
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
r.SalaryAmount = salary.SalaryAmount;
r.PositionSalaryAmount = salary.PositionSalaryAmount;
r.MonthSalaryAmount = salary.MonthSalaryAmount;
case "C-PM-01":
case "C-PM-02":
case "C-PM-03":
case "c-PM-04":
{
foreach (var r in receivers)
{
var salary = await _repository.GetPlacementSalaryAsync(r.RefRecordId);
r.SalaryAmount = salary.SalaryAmount;
r.PositionSalaryAmount = salary.PositionSalaryAmount;
r.MonthSalaryAmount = salary.MonthSalaryAmount;
}
break;
}
default: break;
}
return Success(receivers);

View file

@ -11,6 +11,10 @@
<RootNamespace>BMA.EHR.Report.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Controllers\ReportDesignerController.cs" />
</ItemGroup>
<ItemGroup>
<Content Remove="runtimeconfig.template.json" />
</ItemGroup>
@ -29,7 +33,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="NSwag.Annotations" Version="13.20.0" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Sentry.AspNetCore" Version="3.36.0" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
@ -42,6 +46,7 @@
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Telerik.Reporting" Version="17.1.23.718" />
<PackageReference Include="Telerik.Reporting.OpenXmlRendering" Version="17.1.23.718" />
</ItemGroup>
<ItemGroup>

View file

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
@ -19,6 +20,9 @@ namespace BMA.EHR.Report.Service
public void Configure(SwaggerGenOptions options)
{
// add swagger document for every API version discovered
foreach (var description in _provider.ApiVersionDescriptions)
{
options.EnableAnnotations();
@ -26,8 +30,9 @@ namespace BMA.EHR.Report.Service
options.SwaggerDoc(
description.GroupName,
CreateVersionInfo(description));
}
}
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,

View file

@ -1,15 +1,7 @@
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Application.Repositories.Reports;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Swashbuckle.AspNetCore.Annotations;
using DocumentFormat.OpenXml.Drawing;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
using System.IO;
namespace BMA.EHR.Report.Service.Controllers
{

View file

@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.OpenApi.Models;
using NSwag.Annotations;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Reflection;
namespace BMA.EHR.Report.Service
{
public class OpenApiIgnoreFilter: IDocumentFilter
{
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
foreach (var apiDescription in context.ApiDescriptions)
{
var actionDescriptor = apiDescription.ActionDescriptor as ControllerActionDescriptor;
if (actionDescriptor != null)
{
var ignoreAttribute = actionDescriptor.MethodInfo.GetCustomAttribute<OpenApiIgnoreAttribute>();
if (ignoreAttribute != null)
{
var routeKey = "/" + apiDescription.RelativePath.TrimEnd('/');
if (swaggerDoc.Paths.ContainsKey(routeKey))
{
swaggerDoc.Paths.Remove(routeKey);
}
}
}
}
}
}
}

View file

@ -88,10 +88,17 @@ var builder = WebApplication.CreateBuilder(args);
})
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(c =>
{
c.IgnoreObsoleteActions();
c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
});
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
builder.Services.AddHealthChecks();
}
var app = builder.Build();
@ -113,7 +120,7 @@ var app = builder.Build();
app.MapHealthChecks("/health");
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthentication();
@ -131,6 +138,14 @@ var app = builder.Build();
app.Run();
}
static IConfiguration ResolveSpecificReportingConfiguration(IWebHostEnvironment environment)
{
var reportingConfigFileName = Path.Combine(environment.ContentRootPath, "appsettings.json");
return new ConfigurationBuilder()
.AddJsonFile(reportingConfigFileName, true)
.Build();
}
void ConfigureLogs()
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

View file

@ -1,41 +1,51 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5156"
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5156"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7164;http://localhost:5156"
},
"report-designer": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "designer.html",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7164;http://localhost:5156"
},
"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
}
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7164;http://localhost:5156"
},
"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,

View file

@ -31,5 +31,28 @@
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
},
"Protocol": "HTTPS"
"Protocol": "HTTPS",
"telerikReporting": {
"privateFonts": [
{
"fontFamily": "TH SarabunIT๙",
"path": "Fonts/THSarabunIT.ttf"
},
{
"fontFamily": "TH SarabunIT๙",
"path": "Fonts/THSarabunITBold.ttf",
"fontStyle": "Bold"
},
{
"fontFamily": "TH SarabunPSK",
"path": "Fonts/THSarabunNew.ttf",
},
{
"fontFamily": "TH SarabunPSK",
"path": "Fonts/THSarabunNewBold.ttf",
"fontStyle": "Bold"
}
]
}
}

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Telerik Web Report Designer</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500&display=swap" rel="stylesheet">
</head>
<body>
<div id="webReportDesigner">
loading...
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2020.1.114/js/kendo.all.min.js"></script>
<script src="/api/reportdesigner/resources/js/telerikReportViewer/"></script>
<script src="/api/reportdesigner/designerresources/js/webReportDesigner/"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#webReportDesigner").telerik_WebReportDesigner({
toolboxArea: {
layout: "list" //Change to "grid" to display the contents of the Components area in a flow grid layout.
},
serviceUrl: "/api/reportdesigner",
report: "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"
}).data("telerik_WebDesigner");
});
</script>
</body>
</html>

View file

@ -19,14 +19,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Placement.Service",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.OrganizationEmployee.Service", "BMA.EHR.OrganizationEmployee.Service\BMA.EHR.OrganizationEmployee.Service.csproj", "{A54AA069-8B0E-4784-953B-5DA9F9C8285E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "BMA.EHR.Report.Service\BMA.EHR.Report.Service.csproj", "{AC4B2602-C543-4165-85D7-F6F92F553D80}"
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -57,10 +57,6 @@ Global
{A54AA069-8B0E-4784-953B-5DA9F9C8285E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A54AA069-8B0E-4784-953B-5DA9F9C8285E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A54AA069-8B0E-4784-953B-5DA9F9C8285E}.Release|Any CPU.Build.0 = Release|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Release|Any CPU.Build.0 = Release|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
@ -73,6 +69,10 @@ Global
{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
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -85,10 +85,10 @@ Global
{FA618F0C-1AF5-49AB-AE13-C020B403B64F} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
{81610EF7-AF80-44D8-9263-925C821CF45F} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{A54AA069-8B0E-4784-953B-5DA9F9C8285E} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{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}
{26FE7B1C-771B-4940-9F40-326A7AD53F1C} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}