Merge branch 'develop' into working
This commit is contained in:
commit
a62e71268c
29 changed files with 914 additions and 410 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
<PackageReference Include="AWSSDK.S3" Version="3.7.107.5" />
|
<PackageReference Include="AWSSDK.S3" Version="3.7.107.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.9" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||||
|
<PackageReference Include="MimeTypeMapOfficial" Version="1.0.17" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5738,9 +5738,9 @@ namespace BMA.EHR.Application.Repositories
|
||||||
ProfileId = h.Profile.Id,
|
ProfileId = h.Profile.Id,
|
||||||
ProfileType = h.Profile.ProfileType,
|
ProfileType = h.Profile.ProfileType,
|
||||||
FullName = $"{h.Profile.Prefix?.Name}{h.Profile.FirstName} {h.Profile.LastName}",
|
FullName = $"{h.Profile.Prefix?.Name}{h.Profile.FirstName} {h.Profile.LastName}",
|
||||||
Position = h.Profile.ProfileType == " officer" ? h.Profile.Position?.Name : h.Profile.PositionEmployeePosition?.Name,
|
Position = h.Profile.ProfileType == "officer" ? h.Profile.Position?.Name : h.Profile.PositionEmployeePosition?.Name,
|
||||||
PosNo = h.Profile.ProfileType == " officer" ? h.Profile.PosNo?.Name : h.Profile.PosNoEmployee,
|
PosNo = h.Profile.ProfileType == "officer" ? h.Profile.PosNo?.Name : h.Profile.PosNoEmployee,
|
||||||
Rank = h.Profile.ProfileType == " officer" ? $"{h.Profile.PositionType?.Name}/{h.Profile.PositionLevel?.Name}" : $"-",
|
Rank = h.Profile.ProfileType == "officer" ? $"{h.Profile.PositionType?.Name}/{h.Profile.PositionLevel?.Name}" : $"-",
|
||||||
Salary = h.Salary.ToString(),
|
Salary = h.Salary.ToString(),
|
||||||
LastInsignia = h.Profile.Insignias.Count == 0 ? "" : h.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name,
|
LastInsignia = h.Profile.Insignias.Count == 0 ? "" : h.Profile.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name,
|
||||||
RequestInsignia = h.RequestInsignia.Name,
|
RequestInsignia = h.RequestInsignia.Name,
|
||||||
|
|
|
||||||
366
BMA.EHR.Application/Repositories/MinIOService.cs
Normal file
366
BMA.EHR.Application/Repositories/MinIOService.cs
Normal file
|
|
@ -0,0 +1,366 @@
|
||||||
|
using Amazon.S3;
|
||||||
|
using Amazon.S3.Model;
|
||||||
|
using BMA.EHR.Domain.Models.Documents;
|
||||||
|
using BMA.EHR.Domain.Shared;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using Amazon;
|
||||||
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
|
using MimeTypes;
|
||||||
|
using Profile = BMA.EHR.Domain.Models.HR.Profile;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Repositories
|
||||||
|
{
|
||||||
|
public class MinIOService
|
||||||
|
{
|
||||||
|
#region " Fields "
|
||||||
|
|
||||||
|
private readonly IApplicationDBContext _dbContext;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly AmazonS3Client _s3Client;
|
||||||
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
|
private string _bucketName = string.Empty;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Constructors "
|
||||||
|
|
||||||
|
public MinIOService(IApplicationDBContext dbContext,
|
||||||
|
IConfiguration configuration,
|
||||||
|
IWebHostEnvironment hostingEnvironment)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
_configuration = configuration;
|
||||||
|
_hostingEnvironment = hostingEnvironment;
|
||||||
|
|
||||||
|
var config = new AmazonS3Config
|
||||||
|
{
|
||||||
|
ServiceURL = _configuration["MinIO:Endpoint"],
|
||||||
|
ForcePathStyle = true
|
||||||
|
};
|
||||||
|
|
||||||
|
_s3Client = new AmazonS3Client(_configuration["MinIO:AccessKey"], _configuration["MinIO:SecretKey"], config);
|
||||||
|
this._bucketName = _configuration["MinIO:BucketName"] ?? "bma-recruit";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Methods "
|
||||||
|
|
||||||
|
public async Task<Document> UploadFileAsync(IFormFile file, string newFileName = "")
|
||||||
|
{
|
||||||
|
var fileName = "";
|
||||||
|
var fileExt = Path.GetExtension(file.FileName);
|
||||||
|
if (newFileName != "")
|
||||||
|
fileName = $"{newFileName}";
|
||||||
|
else
|
||||||
|
fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
|
||||||
|
|
||||||
|
|
||||||
|
var tmpDir = Path.Combine("tmp");
|
||||||
|
if (!Directory.Exists(tmpDir))
|
||||||
|
Directory.CreateDirectory(tmpDir);
|
||||||
|
|
||||||
|
var tmpFile = Path.Combine(tmpDir, $"tmp_{DateTime.Now.ToString("ddMMyyyyHHmmss")}{fileExt}");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
var id = Guid.NewGuid();
|
||||||
|
file.CopyTo(ms);
|
||||||
|
var fileBytes = ms.ToArray();
|
||||||
|
System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileBytes);
|
||||||
|
|
||||||
|
var request = new PutObjectRequest
|
||||||
|
{
|
||||||
|
BucketName = _bucketName,
|
||||||
|
Key = id.ToString("D"),
|
||||||
|
InputStream = filestream,
|
||||||
|
ContentType = file.ContentType,
|
||||||
|
CannedACL = S3CannedACL.PublicRead
|
||||||
|
};
|
||||||
|
|
||||||
|
await _s3Client.PutObjectAsync(request);
|
||||||
|
|
||||||
|
// create document object
|
||||||
|
var doc = new Document()
|
||||||
|
{
|
||||||
|
FileName = fileName,
|
||||||
|
FileType = file.ContentType,
|
||||||
|
FileSize = Convert.ToInt32(file.Length),
|
||||||
|
ObjectRefId = id,
|
||||||
|
CreatedDate = DateTime.Now
|
||||||
|
};
|
||||||
|
await _dbContext.Set<Document>().AddAsync(doc);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
File.Delete(tmpFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<FileDownloadResponse> DownloadFileAsync(Guid fileId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var doc = await _dbContext.Set<Document>().AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == fileId);
|
||||||
|
|
||||||
|
if (doc == null)
|
||||||
|
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||||
|
|
||||||
|
using (var memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
GetObjectRequest request = new GetObjectRequest
|
||||||
|
{
|
||||||
|
BucketName = _bucketName,
|
||||||
|
Key = doc.ObjectRefId.ToString("D")
|
||||||
|
};
|
||||||
|
|
||||||
|
using (GetObjectResponse response = await _s3Client.GetObjectAsync(request))
|
||||||
|
{
|
||||||
|
using (Stream responseStream = response.ResponseStream)
|
||||||
|
{
|
||||||
|
responseStream.CopyTo(memoryStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileContent = memoryStream.ToArray();
|
||||||
|
|
||||||
|
return new FileDownloadResponse
|
||||||
|
{
|
||||||
|
FileName = doc.FileName,
|
||||||
|
FileType = doc.FileType,
|
||||||
|
FileContent = fileContent
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteFileAsync(Guid fileId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var doc = await _dbContext.Set<Document>().AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == fileId);
|
||||||
|
|
||||||
|
if (doc == null)
|
||||||
|
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeleteObjectRequest request = new DeleteObjectRequest
|
||||||
|
{
|
||||||
|
BucketName = _bucketName,
|
||||||
|
Key = doc?.ObjectRefId.ToString("D")
|
||||||
|
};
|
||||||
|
|
||||||
|
// delete from minio
|
||||||
|
await _s3Client.DeleteObjectAsync(request);
|
||||||
|
|
||||||
|
_dbContext.Set<Document>().Remove(doc);
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> ImagesPath(Guid? fileId)
|
||||||
|
{
|
||||||
|
if (fileId == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
var doc = await _dbContext.Set<Document>().AsQueryable()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == fileId);
|
||||||
|
|
||||||
|
if (doc == null)
|
||||||
|
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||||
|
var config = new AmazonS3Config
|
||||||
|
{
|
||||||
|
ServiceURL = _configuration["MinIO:Endpoint"],
|
||||||
|
ForcePathStyle = true
|
||||||
|
};
|
||||||
|
|
||||||
|
DateTime expires = DateTime.UtcNow.AddHours(6);
|
||||||
|
var _protocol = _configuration["Protocol"];
|
||||||
|
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
||||||
|
{
|
||||||
|
BucketName = _bucketName,
|
||||||
|
Key = doc?.ObjectRefId.ToString("D"),
|
||||||
|
Expires = expires,
|
||||||
|
Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
|
||||||
|
};
|
||||||
|
string path = _s3Client.GetPreSignedURL(request);
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> ImagesPathByName(string fileName)
|
||||||
|
{
|
||||||
|
var config = new AmazonS3Config
|
||||||
|
{
|
||||||
|
ServiceURL = _configuration["MinIO:Endpoint"],
|
||||||
|
ForcePathStyle = true
|
||||||
|
};
|
||||||
|
|
||||||
|
DateTime expires = DateTime.UtcNow.AddHours(6);
|
||||||
|
var _protocol = _configuration["Protocol"];
|
||||||
|
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
||||||
|
{
|
||||||
|
BucketName = _bucketName,
|
||||||
|
Key = fileName,
|
||||||
|
Expires = expires,
|
||||||
|
Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
|
||||||
|
};
|
||||||
|
string path = _s3Client.GetPreSignedURL(request);
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public List<Guid> GetAllIdByRoot(Guid? id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ret = new List<Guid>();
|
||||||
|
if (id == null)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
var oc = _dbContext.Set<OrganizationEntity>().FirstOrDefault(x => x.Id == id);
|
||||||
|
if (oc != null)
|
||||||
|
ret.Add(oc.Id);
|
||||||
|
|
||||||
|
var child = _dbContext.Set<OrganizationEntity>().AsQueryable().Where(x => x.Parent != null && x.Parent.Id == id).ToList();
|
||||||
|
if (child.Any())
|
||||||
|
{
|
||||||
|
foreach (var item in child)
|
||||||
|
{
|
||||||
|
ret.AddRange(GetAllIdByRoot(item.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string?> CheckBmaOfficer(string CitizenId)
|
||||||
|
{
|
||||||
|
var data = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == CitizenId);
|
||||||
|
if (data == null)
|
||||||
|
return null;
|
||||||
|
if (data.ProfileType.Trim().ToUpper() == "OFFICER")
|
||||||
|
return "OFFICER";
|
||||||
|
if (data.EmployeeClass.Trim().ToUpper() == "PERM")
|
||||||
|
return "EMPLOYEE_PERM";
|
||||||
|
if (data.EmployeeClass.Trim().ToUpper() == "TEMP")
|
||||||
|
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);
|
||||||
|
Console.WriteLine($"{_bucketName}{subFolder}");
|
||||||
|
Console.WriteLine(fileName);
|
||||||
|
Console.WriteLine(file_name);
|
||||||
|
Console.WriteLine(filestream);
|
||||||
|
Console.WriteLine(fileType);
|
||||||
|
|
||||||
|
var request = new PutObjectRequest
|
||||||
|
{
|
||||||
|
BucketName = $"{_bucketName}",
|
||||||
|
// BucketName = $"{_bucketName}{subFolder}",
|
||||||
|
Key = file_name,
|
||||||
|
InputStream = filestream,
|
||||||
|
ContentType = fileType,
|
||||||
|
CannedACL = S3CannedACL.PublicRead
|
||||||
|
};
|
||||||
|
|
||||||
|
await _s3Client.PutObjectAsync(request);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GenerateJsonFile(string json, string path, string fileName)
|
||||||
|
{
|
||||||
|
var tmpDir = Path.Combine("tmp");
|
||||||
|
if (!Directory.Exists(tmpDir))
|
||||||
|
Directory.CreateDirectory(tmpDir);
|
||||||
|
|
||||||
|
var tmpFile = Path.Combine(tmpDir, $"{fileName}.json");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SaveToJsonFile(tmpFile, json);
|
||||||
|
await UploadFileAsyncTemp(tmpFile, path);
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
{
|
{
|
||||||
No = string.IsNullOrEmpty(evaluate_assign.data.evaluate.no.ToString()) ? string.Empty : evaluate_assign.data.evaluate.no.ToString().ToThaiNumber(),
|
No = string.IsNullOrEmpty(evaluate_assign.data.evaluate.no.ToString()) ? string.Empty : evaluate_assign.data.evaluate.no.ToString().ToThaiNumber(),
|
||||||
EvaluateDateStart = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
|
EvaluateDateStart = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||||
EvaluateDateFinish = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
|
EvaluateDateFinish = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_finish.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_finish.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||||
Name = string.IsNullOrEmpty(evaluate_assign.data.experimentee.name) ? string.Empty : evaluate_assign.data.experimentee.name,
|
Name = string.IsNullOrEmpty(evaluate_assign.data.experimentee.name) ? string.Empty : evaluate_assign.data.experimentee.name,
|
||||||
Position = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Position) ? string.Empty : evaluate_assign.data.experimentee.Position,
|
Position = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Position) ? string.Empty : evaluate_assign.data.experimentee.Position,
|
||||||
Department = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Department) ? string.Empty : evaluate_assign.data.experimentee.Department,
|
Department = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Department) ? string.Empty : evaluate_assign.data.experimentee.Department,
|
||||||
|
|
@ -206,7 +206,7 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
{
|
{
|
||||||
No = string.IsNullOrEmpty(evaluate_assign.data.evaluate.no.ToString()) ? string.Empty : evaluate_assign.data.evaluate.no.ToString().ToThaiNumber(),
|
No = string.IsNullOrEmpty(evaluate_assign.data.evaluate.no.ToString()) ? string.Empty : evaluate_assign.data.evaluate.no.ToString().ToThaiNumber(),
|
||||||
EvaluateDateStart = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
|
EvaluateDateStart = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||||
EvaluateDateFinish = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_start.ToThaiFullDate().ToString().ToThaiNumber(),
|
EvaluateDateFinish = string.IsNullOrEmpty(evaluate_assign.data.evaluate.date_finish.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.date_finish.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||||
Name = string.IsNullOrEmpty(evaluate_assign.data.experimentee.name) ? string.Empty : evaluate_assign.data.experimentee.name,
|
Name = string.IsNullOrEmpty(evaluate_assign.data.experimentee.name) ? string.Empty : evaluate_assign.data.experimentee.name,
|
||||||
Position = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Position) ? string.Empty : evaluate_assign.data.experimentee.Position,
|
Position = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Position) ? string.Empty : evaluate_assign.data.experimentee.Position,
|
||||||
Department = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Department) ? string.Empty : evaluate_assign.data.experimentee.Department,
|
Department = string.IsNullOrEmpty(evaluate_assign.data.experimentee.Department) ? string.Empty : evaluate_assign.data.experimentee.Department,
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
using System.Reflection.Metadata;
|
using System.Reflection.Metadata;
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using BMA.EHR.Application.Responses;
|
||||||
using BMA.EHR.Domain.Extensions;
|
using BMA.EHR.Domain.Extensions;
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
using BMA.EHR.Domain.Models.Organizations;
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
using BMA.EHR.Domain.Models.Retirement;
|
using BMA.EHR.Domain.Models.Retirement;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories.Reports
|
namespace BMA.EHR.Application.Repositories.Reports
|
||||||
{
|
{
|
||||||
|
|
@ -16,16 +19,19 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
|
|
||||||
private readonly IApplicationDBContext _dbContext;
|
private readonly IApplicationDBContext _dbContext;
|
||||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
|
private readonly MinIOService _documentService;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Constructor and Destructor "
|
#region " Constructor and Destructor "
|
||||||
|
|
||||||
public RetireReportRepository(IApplicationDBContext dbContext,
|
public RetireReportRepository(IApplicationDBContext dbContext,
|
||||||
|
MinIOService documentService,
|
||||||
IWebHostEnvironment hostEnvironment)
|
IWebHostEnvironment hostEnvironment)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_hostingEnvironment = hostEnvironment;
|
_hostingEnvironment = hostEnvironment;
|
||||||
|
_documentService = documentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -67,64 +73,73 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
if (retireHistorys == null)
|
if (retireHistorys == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var profile_retireHistory = await _dbContext.Set<RetirementProfile>()
|
//var profile_retireHistory = await _dbContext.Set<RetirementProfile>()
|
||||||
.Where(x => x.RetirementPeriod == retire)
|
// .Where(x => x.RetirementPeriod == retire)
|
||||||
.OrderBy(x => x.Order)
|
// .OrderBy(x => x.Order)
|
||||||
.Select(x => new
|
// .Select(x => new
|
||||||
{
|
// {
|
||||||
order = x.Order,
|
// order = x.Order,
|
||||||
id = x.Id,
|
// id = x.Id,
|
||||||
reason = x.Reason,
|
// reason = x.Reason,
|
||||||
remove = x.Remove,
|
// remove = x.Remove,
|
||||||
profileId = x.Profile.Id,
|
// profileId = x.Profile.Id,
|
||||||
citizenId = x.Profile.CitizenId,
|
// citizenId = x.Profile.CitizenId,
|
||||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
// prefix = x.Profile.Prefix == null ? string.Empty : x.Profile.Prefix.Name,
|
||||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
// fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
// organizationOrganization = x.Profile.OrganizationOrganization,
|
||||||
oc = x.Profile.Oc,
|
// oc = x.Profile.Oc,
|
||||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
// position = x.Profile.Position == null ? string.Empty : x.Profile.Position.Name,
|
||||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
// positionType = x.Profile.PositionType == null ? string.Empty : x.Profile.PositionType.Name,
|
||||||
positionExecutive = x.Profile.PositionExecutive,
|
// positionExecutive = x.Profile.PositionExecutive,
|
||||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
// posNo = x.Profile.PosNo == null ? string.Empty : x.Profile.PosNo.Name,
|
||||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
// positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
// positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
// positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||||
posNoEmployee = x.Profile.PosNoEmployee,
|
// posNoEmployee = x.Profile.PosNoEmployee,
|
||||||
})
|
// })
|
||||||
.ToListAsync();
|
// .ToListAsync();
|
||||||
|
|
||||||
return new { retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory };
|
|
||||||
|
|
||||||
|
//return new { retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profile_retireHistory };
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
var url = await _documentService.ImagesPathByName($"{retireHistorys.ProfileFile}.json");
|
||||||
|
var responseTask = client.GetAsync(url);
|
||||||
|
var results = responseTask.Result;
|
||||||
|
var json = results.Content.ReadAsStringAsync().Result;
|
||||||
|
List<ProfileJsonRequest> profiles = JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(json);
|
||||||
|
profiles = profiles.OrderBy(x => x.order).ToList();
|
||||||
|
return new { retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profiles};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var profile_retire = await _dbContext.Set<RetirementProfile>()
|
var profile_retire = await _dbContext.Set<RetirementProfile>()
|
||||||
.Where(x => x.RetirementPeriod == retire)
|
.Where(x => x.RetirementPeriod == retire)
|
||||||
.OrderBy(x => x.Order)
|
.OrderBy(x => x.Order)
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
order = x.Order,
|
order = x.Order,
|
||||||
id = x.Id,
|
id = x.Id,
|
||||||
reason = x.Reason,
|
reason = x.Reason,
|
||||||
remove = x.Remove,
|
remove = x.Remove,
|
||||||
profileId = x.Profile.Id,
|
profileId = x.Profile.Id,
|
||||||
citizenId = x.Profile.CitizenId,
|
citizenId = x.Profile.CitizenId,
|
||||||
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
prefix = x.Profile.Prefix == null ? string.Empty : x.Profile.Prefix.Name,
|
||||||
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
|
||||||
organizationOrganization = x.Profile.OrganizationOrganization,
|
organizationOrganization = x.Profile.OrganizationOrganization,
|
||||||
oc = x.Profile.Oc,
|
oc = x.Profile.Oc,
|
||||||
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
|
position = x.Profile.Position == null ? string.Empty : x.Profile.Position.Name,
|
||||||
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
|
positionType = x.Profile.PositionType == null ? string.Empty : x.Profile.PositionType.Name,
|
||||||
positionExecutive = x.Profile.PositionExecutive,
|
positionExecutive = x.Profile.PositionExecutive,
|
||||||
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
|
posNo = x.Profile.PosNo == null ? string.Empty : x.Profile.PosNo.Name,
|
||||||
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
positionEmployeePosition = x.Profile.PositionEmployeePosition,
|
||||||
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
|
||||||
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
|
||||||
posNoEmployee = x.Profile.PosNoEmployee,
|
posNoEmployee = x.Profile.PosNoEmployee,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return new { retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire };
|
return new { retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -164,12 +179,17 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
string Prefix = string.IsNullOrEmpty(data.Prefix.ToString()) ? string.Empty : data.Prefix.ToString();
|
||||||
|
string FirstName = string.IsNullOrEmpty(data.FirstName.ToString()) ? string.Empty : data.FirstName.ToString();
|
||||||
|
string LastName = string.IsNullOrEmpty(data.LastName.ToString()) ? string.Empty : data.LastName.ToString();
|
||||||
|
string FullName = $"{Prefix} {FirstName} {LastName}";
|
||||||
string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "วันที่ - เดือน - พ.ศ. -" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber();
|
string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "วันที่ - เดือน - พ.ศ. -" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber();
|
||||||
|
string CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber();
|
||||||
return new
|
return new
|
||||||
{
|
{
|
||||||
data.Prefix,
|
FullName,
|
||||||
data.FirstName,
|
Date,
|
||||||
data.LastName,
|
CurrentDate,
|
||||||
data.Position,
|
data.Position,
|
||||||
data.PositionExecutive,
|
data.PositionExecutive,
|
||||||
data.PositionType,
|
data.PositionType,
|
||||||
|
|
@ -183,7 +203,6 @@ namespace BMA.EHR.Application.Repositories.Reports
|
||||||
data.PositionLevelId,
|
data.PositionLevelId,
|
||||||
data.OrganizationId,
|
data.OrganizationId,
|
||||||
data.Number,
|
data.Number,
|
||||||
Date,
|
|
||||||
data.Location,
|
data.Location,
|
||||||
data.Reason,
|
data.Reason,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
public string? ProfileType { get; set; }
|
public string? ProfileType { get; set; }
|
||||||
public Guid ProfileId { get; set; }
|
public Guid ProfileId { get; set; }
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
public string Position { get; set; }
|
public dynamic Position { get; set; }
|
||||||
public string PosNo { get; set; }
|
public string PosNo { get; set; }
|
||||||
public string Rank { get; set; }
|
public string Rank { get; set; }
|
||||||
public string Salary { get; set; }
|
public string Salary { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ namespace BMA.EHR.Application.Responses
|
||||||
public int develop_other_training_percent { get; set; }
|
public int develop_other_training_percent { get; set; }
|
||||||
public int develop_total_percent { get; set; }
|
public int develop_total_percent { get; set; }
|
||||||
public int develop_result { get; set; }
|
public int develop_result { get; set; }
|
||||||
|
public int evaluate_result { get; set; }
|
||||||
public DateTime createdAt { get; set; }
|
public DateTime createdAt { get; set; }
|
||||||
public DateTime updatedAt { get; set; }
|
public DateTime updatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
BMA.EHR.Application/Responses/ProfileJsonRequest.cs
Normal file
24
BMA.EHR.Application/Responses/ProfileJsonRequest.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
namespace BMA.EHR.Application.Responses
|
||||||
|
{
|
||||||
|
public class ProfileJsonRequest
|
||||||
|
{
|
||||||
|
public int order { get; set; }
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public string reason { get; set; }
|
||||||
|
public string remove { get; set; }
|
||||||
|
public Guid profileId { get; set; }
|
||||||
|
public string? citizenId { get; set; }
|
||||||
|
public string? prefix { get; set; }
|
||||||
|
public string? fullName { get; set; }
|
||||||
|
public string? organizationOrganization { get; set; }
|
||||||
|
public string? oc { get; set; }
|
||||||
|
public string? position { get; set; }
|
||||||
|
public string? positionType { get; set; }
|
||||||
|
public string? positionExecutive { get; set; }
|
||||||
|
public string? posNo { get; set; }
|
||||||
|
public string? positionEmployeePosition { get; set; }
|
||||||
|
public string? positionEmployeeLevel { get; set; }
|
||||||
|
public string? positionEmployeeGroup { get; set; }
|
||||||
|
public string? posNoEmployee { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -89,6 +89,7 @@
|
||||||
public static readonly string OCNotFound = "ไม่พบหน่วยงานที่ระบุในระบบ";
|
public static readonly string OCNotFound = "ไม่พบหน่วยงานที่ระบุในระบบ";
|
||||||
public static readonly string InsigniaManageOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวน";
|
public static readonly string InsigniaManageOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวน";
|
||||||
public static readonly string InsigniaBorrowOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวนของหน่วยงานที่ได้รับ";
|
public static readonly string InsigniaBorrowOrgLimit = "จำนวนการจัดสรรเครื่องราชฯ หน่วยงานเกินจำนวนของหน่วยงานที่ได้รับ";
|
||||||
|
public static readonly string InsigniaNoBorrow = "ไม่สามารถยืมเครื่องราชฯ นี้ได้เนื่องจากสถานะรอการบันทึกข้อมูล";
|
||||||
public static readonly string InsigniaBorrowNotFound = "ไม่พบรายการยืมเครื่องราชฯ";
|
public static readonly string InsigniaBorrowNotFound = "ไม่พบรายการยืมเครื่องราชฯ";
|
||||||
public static readonly string InsigniaNotReturn = "รายการยืมเครื่องราชนี้ได้ทำการยืมไว้แล้ว";
|
public static readonly string InsigniaNotReturn = "รายการยืมเครื่องราชนี้ได้ทำการยืมไว้แล้ว";
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -1,365 +1,365 @@
|
||||||
using Amazon.S3;
|
// using Amazon.S3;
|
||||||
using Amazon.S3.Model;
|
// using Amazon.S3.Model;
|
||||||
using BMA.EHR.Domain.Models.Documents;
|
// using BMA.EHR.Domain.Models.Documents;
|
||||||
using BMA.EHR.Domain.Shared;
|
// using BMA.EHR.Domain.Shared;
|
||||||
using BMA.EHR.Infrastructure.Persistence;
|
// using BMA.EHR.Infrastructure.Persistence;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
// using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
// using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
// using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
// using Microsoft.Extensions.Configuration;
|
||||||
using MimeTypes;
|
// using MimeTypes;
|
||||||
using System.Net.Http.Headers;
|
// using System.Net.Http.Headers;
|
||||||
|
|
||||||
namespace BMA.EHR.Application.Repositories
|
// namespace BMA.EHR.Application.Repositories
|
||||||
{
|
// {
|
||||||
public class MinIOService
|
// public class MinIOService
|
||||||
{
|
// {
|
||||||
#region " Fields "
|
// #region " Fields "
|
||||||
|
|
||||||
private readonly ApplicationDBContext _context;
|
// private readonly ApplicationDBContext _context;
|
||||||
private readonly IConfiguration _configuration;
|
// private readonly IConfiguration _configuration;
|
||||||
private readonly AmazonS3Client _s3Client;
|
// private readonly AmazonS3Client _s3Client;
|
||||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
// private readonly IWebHostEnvironment _hostingEnvironment;
|
||||||
private string _bucketName = string.Empty;
|
// private string _bucketName = string.Empty;
|
||||||
|
|
||||||
#endregion
|
// #endregion
|
||||||
|
|
||||||
#region " Constructors "
|
// #region " Constructors "
|
||||||
|
|
||||||
public MinIOService(ApplicationDBContext context,
|
// public MinIOService(ApplicationDBContext context,
|
||||||
IConfiguration configuration,
|
// IConfiguration configuration,
|
||||||
IWebHostEnvironment hostingEnvironment)
|
// IWebHostEnvironment hostingEnvironment)
|
||||||
{
|
// {
|
||||||
_context = context;
|
// _context = context;
|
||||||
_configuration = configuration;
|
// _configuration = configuration;
|
||||||
_hostingEnvironment = hostingEnvironment;
|
// _hostingEnvironment = hostingEnvironment;
|
||||||
|
|
||||||
var config = new AmazonS3Config
|
// var config = new AmazonS3Config
|
||||||
{
|
// {
|
||||||
ServiceURL = _configuration["MinIO:Endpoint"],
|
// ServiceURL = _configuration["MinIO:Endpoint"],
|
||||||
ForcePathStyle = true
|
// ForcePathStyle = true
|
||||||
};
|
// };
|
||||||
|
|
||||||
_s3Client = new AmazonS3Client(_configuration["MinIO:AccessKey"], _configuration["MinIO:SecretKey"], config);
|
// _s3Client = new AmazonS3Client(_configuration["MinIO:AccessKey"], _configuration["MinIO:SecretKey"], config);
|
||||||
this._bucketName = _configuration["MinIO:BucketName"] ?? "bma-recruit";
|
// this._bucketName = _configuration["MinIO:BucketName"] ?? "bma-recruit";
|
||||||
}
|
// }
|
||||||
|
|
||||||
#endregion
|
// #endregion
|
||||||
|
|
||||||
#region " Methods "
|
// #region " Methods "
|
||||||
|
|
||||||
public async Task<Document> UploadFileAsync(IFormFile file, string newFileName = "")
|
// public async Task<Document> UploadFileAsync(IFormFile file, string newFileName = "")
|
||||||
{
|
// {
|
||||||
var fileName = "";
|
// var fileName = "";
|
||||||
var fileExt = Path.GetExtension(file.FileName);
|
// var fileExt = Path.GetExtension(file.FileName);
|
||||||
if (newFileName != "")
|
// if (newFileName != "")
|
||||||
fileName = $"{newFileName}";
|
// fileName = $"{newFileName}";
|
||||||
else
|
// else
|
||||||
fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
|
// fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
|
||||||
|
|
||||||
|
|
||||||
var tmpDir = Path.Combine("tmp");
|
// var tmpDir = Path.Combine("tmp");
|
||||||
if (!Directory.Exists(tmpDir))
|
// if (!Directory.Exists(tmpDir))
|
||||||
Directory.CreateDirectory(tmpDir);
|
// Directory.CreateDirectory(tmpDir);
|
||||||
|
|
||||||
var tmpFile = Path.Combine(tmpDir, $"tmp_{DateTime.Now.ToString("ddMMyyyyHHmmss")}{fileExt}");
|
// var tmpFile = Path.Combine(tmpDir, $"tmp_{DateTime.Now.ToString("ddMMyyyyHHmmss")}{fileExt}");
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using (var ms = new MemoryStream())
|
// using (var ms = new MemoryStream())
|
||||||
{
|
// {
|
||||||
var id = Guid.NewGuid();
|
// var id = Guid.NewGuid();
|
||||||
file.CopyTo(ms);
|
// file.CopyTo(ms);
|
||||||
var fileBytes = ms.ToArray();
|
// var fileBytes = ms.ToArray();
|
||||||
System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileBytes);
|
// System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileBytes);
|
||||||
|
|
||||||
var request = new PutObjectRequest
|
// var request = new PutObjectRequest
|
||||||
{
|
// {
|
||||||
BucketName = _bucketName,
|
// BucketName = _bucketName,
|
||||||
Key = id.ToString("D"),
|
// Key = id.ToString("D"),
|
||||||
InputStream = filestream,
|
// InputStream = filestream,
|
||||||
ContentType = file.ContentType,
|
// ContentType = file.ContentType,
|
||||||
CannedACL = S3CannedACL.PublicRead
|
// CannedACL = S3CannedACL.PublicRead
|
||||||
};
|
// };
|
||||||
|
|
||||||
await _s3Client.PutObjectAsync(request);
|
// await _s3Client.PutObjectAsync(request);
|
||||||
|
|
||||||
// create document object
|
// // create document object
|
||||||
var doc = new Document()
|
// var doc = new Document()
|
||||||
{
|
// {
|
||||||
FileName = fileName,
|
// FileName = fileName,
|
||||||
FileType = file.ContentType,
|
// FileType = file.ContentType,
|
||||||
FileSize = Convert.ToInt32(file.Length),
|
// FileSize = Convert.ToInt32(file.Length),
|
||||||
ObjectRefId = id,
|
// ObjectRefId = id,
|
||||||
CreatedDate = DateTime.Now
|
// CreatedDate = DateTime.Now
|
||||||
};
|
// };
|
||||||
|
|
||||||
await _context.Documents.AddAsync(doc);
|
// await _context.Documents.AddAsync(doc);
|
||||||
await _context.SaveChangesAsync();
|
// await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return doc;
|
// return doc;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
File.Delete(tmpFile);
|
// File.Delete(tmpFile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task<FileDownloadResponse> DownloadFileAsync(Guid fileId)
|
// public async Task<FileDownloadResponse> DownloadFileAsync(Guid fileId)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var doc = await _context.Documents.AsQueryable()
|
// var doc = await _context.Documents.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == fileId);
|
// .FirstOrDefaultAsync(x => x.Id == fileId);
|
||||||
|
|
||||||
if (doc == null)
|
// if (doc == null)
|
||||||
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
// throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||||
|
|
||||||
using (var memoryStream = new MemoryStream())
|
// using (var memoryStream = new MemoryStream())
|
||||||
{
|
// {
|
||||||
GetObjectRequest request = new GetObjectRequest
|
// GetObjectRequest request = new GetObjectRequest
|
||||||
{
|
// {
|
||||||
BucketName = _bucketName,
|
// BucketName = _bucketName,
|
||||||
Key = doc.ObjectRefId.ToString("D")
|
// Key = doc.ObjectRefId.ToString("D")
|
||||||
};
|
// };
|
||||||
|
|
||||||
using (GetObjectResponse response = await _s3Client.GetObjectAsync(request))
|
// using (GetObjectResponse response = await _s3Client.GetObjectAsync(request))
|
||||||
{
|
// {
|
||||||
using (Stream responseStream = response.ResponseStream)
|
// using (Stream responseStream = response.ResponseStream)
|
||||||
{
|
// {
|
||||||
responseStream.CopyTo(memoryStream);
|
// responseStream.CopyTo(memoryStream);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
var fileContent = memoryStream.ToArray();
|
// var fileContent = memoryStream.ToArray();
|
||||||
|
|
||||||
return new FileDownloadResponse
|
// return new FileDownloadResponse
|
||||||
{
|
// {
|
||||||
FileName = doc.FileName,
|
// FileName = doc.FileName,
|
||||||
FileType = doc.FileType,
|
// FileType = doc.FileType,
|
||||||
FileContent = fileContent
|
// FileContent = fileContent
|
||||||
};
|
// };
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task DeleteFileAsync(Guid fileId)
|
// public async Task DeleteFileAsync(Guid fileId)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var doc = await _context.Documents.AsQueryable()
|
// var doc = await _context.Documents.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == fileId);
|
// .FirstOrDefaultAsync(x => x.Id == fileId);
|
||||||
|
|
||||||
if (doc == null)
|
// if (doc == null)
|
||||||
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
// throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
DeleteObjectRequest request = new DeleteObjectRequest
|
// DeleteObjectRequest request = new DeleteObjectRequest
|
||||||
{
|
// {
|
||||||
BucketName = _bucketName,
|
// BucketName = _bucketName,
|
||||||
Key = doc?.ObjectRefId.ToString("D")
|
// Key = doc?.ObjectRefId.ToString("D")
|
||||||
};
|
// };
|
||||||
|
|
||||||
// delete from minio
|
// // delete from minio
|
||||||
await _s3Client.DeleteObjectAsync(request);
|
// await _s3Client.DeleteObjectAsync(request);
|
||||||
|
|
||||||
|
|
||||||
_context.Documents.Remove(doc);
|
// _context.Documents.Remove(doc);
|
||||||
await _context.SaveChangesAsync();
|
// await _context.SaveChangesAsync();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task<string> ImagesPath(Guid? fileId)
|
// public async Task<string> ImagesPath(Guid? fileId)
|
||||||
{
|
// {
|
||||||
if (fileId == null)
|
// if (fileId == null)
|
||||||
return "";
|
// return "";
|
||||||
|
|
||||||
var doc = await _context.Documents.AsQueryable()
|
// var doc = await _context.Documents.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Id == fileId);
|
// .FirstOrDefaultAsync(x => x.Id == fileId);
|
||||||
|
|
||||||
if (doc == null)
|
// if (doc == null)
|
||||||
throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
// throw new Exception(GlobalMessages.FileNotFoundOnServer);
|
||||||
var config = new AmazonS3Config
|
// var config = new AmazonS3Config
|
||||||
{
|
// {
|
||||||
ServiceURL = _configuration["MinIO:Endpoint"],
|
// ServiceURL = _configuration["MinIO:Endpoint"],
|
||||||
ForcePathStyle = true
|
// ForcePathStyle = true
|
||||||
};
|
// };
|
||||||
|
|
||||||
DateTime expires = DateTime.UtcNow.AddHours(6);
|
// DateTime expires = DateTime.UtcNow.AddHours(6);
|
||||||
var _protocol = _configuration["Protocol"];
|
// var _protocol = _configuration["Protocol"];
|
||||||
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
// GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
||||||
{
|
// {
|
||||||
BucketName = _bucketName,
|
// BucketName = _bucketName,
|
||||||
Key = doc?.ObjectRefId.ToString("D"),
|
// Key = doc?.ObjectRefId.ToString("D"),
|
||||||
Expires = expires,
|
// Expires = expires,
|
||||||
Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
|
// Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
|
||||||
};
|
// };
|
||||||
string path = _s3Client.GetPreSignedURL(request);
|
// string path = _s3Client.GetPreSignedURL(request);
|
||||||
|
|
||||||
return path;
|
// return path;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task<string> ImagesPathByName(string fileName)
|
// public async Task<string> ImagesPathByName(string fileName)
|
||||||
{
|
// {
|
||||||
var config = new AmazonS3Config
|
// var config = new AmazonS3Config
|
||||||
{
|
// {
|
||||||
ServiceURL = _configuration["MinIO:Endpoint"],
|
// ServiceURL = _configuration["MinIO:Endpoint"],
|
||||||
ForcePathStyle = true
|
// ForcePathStyle = true
|
||||||
};
|
// };
|
||||||
|
|
||||||
DateTime expires = DateTime.UtcNow.AddHours(6);
|
// DateTime expires = DateTime.UtcNow.AddHours(6);
|
||||||
var _protocol = _configuration["Protocol"];
|
// var _protocol = _configuration["Protocol"];
|
||||||
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
// GetPreSignedUrlRequest request = new GetPreSignedUrlRequest
|
||||||
{
|
// {
|
||||||
BucketName = _bucketName,
|
// BucketName = _bucketName,
|
||||||
Key = fileName,
|
// Key = fileName,
|
||||||
Expires = expires,
|
// Expires = expires,
|
||||||
Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
|
// Protocol = _protocol == "HTTPS" ? Protocol.HTTPS : Protocol.HTTP
|
||||||
};
|
// };
|
||||||
string path = _s3Client.GetPreSignedURL(request);
|
// string path = _s3Client.GetPreSignedURL(request);
|
||||||
|
|
||||||
return path;
|
// return path;
|
||||||
}
|
// }
|
||||||
|
|
||||||
#endregion
|
// #endregion
|
||||||
|
|
||||||
public List<Guid> GetAllIdByRoot(Guid? id)
|
// public List<Guid> GetAllIdByRoot(Guid? id)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var ret = new List<Guid>();
|
// var ret = new List<Guid>();
|
||||||
if (id == null)
|
// if (id == null)
|
||||||
return ret;
|
// return ret;
|
||||||
|
|
||||||
var oc = _context.Organizations.FirstOrDefault(x => x.Id == id);
|
// var oc = _context.Organizations.FirstOrDefault(x => x.Id == id);
|
||||||
if (oc != null)
|
// if (oc != null)
|
||||||
ret.Add(oc.Id);
|
// ret.Add(oc.Id);
|
||||||
|
|
||||||
var child = _context.Organizations.AsQueryable().Where(x => x.Parent != null && x.Parent.Id == id).ToList();
|
// var child = _context.Organizations.AsQueryable().Where(x => x.Parent != null && x.Parent.Id == id).ToList();
|
||||||
if (child.Any())
|
// if (child.Any())
|
||||||
{
|
// {
|
||||||
foreach (var item in child)
|
// foreach (var item in child)
|
||||||
{
|
// {
|
||||||
ret.AddRange(GetAllIdByRoot(item.Id));
|
// ret.AddRange(GetAllIdByRoot(item.Id));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return ret;
|
// return ret;
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task<string?> CheckBmaOfficer(string CitizenId)
|
// public async Task<string?> CheckBmaOfficer(string CitizenId)
|
||||||
{
|
// {
|
||||||
var data = await _context.Profiles.FirstOrDefaultAsync(x => x.CitizenId == CitizenId);
|
// var data = await _context.Profiles.FirstOrDefaultAsync(x => x.CitizenId == CitizenId);
|
||||||
if (data == null)
|
// if (data == null)
|
||||||
return null;
|
// return null;
|
||||||
if (data.ProfileType.Trim().ToUpper() == "OFFICER")
|
// if (data.ProfileType.Trim().ToUpper() == "OFFICER")
|
||||||
return "OFFICER";
|
// return "OFFICER";
|
||||||
if (data.EmployeeClass.Trim().ToUpper() == "PERM")
|
// if (data.EmployeeClass.Trim().ToUpper() == "PERM")
|
||||||
return "EMPLOYEE_PERM";
|
// return "EMPLOYEE_PERM";
|
||||||
if (data.EmployeeClass.Trim().ToUpper() == "TEMP")
|
// if (data.EmployeeClass.Trim().ToUpper() == "TEMP")
|
||||||
return "EMPLOYEE_TEMP";
|
// return "EMPLOYEE_TEMP";
|
||||||
return "EMPLOYEE";
|
// return "EMPLOYEE";
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task UploadFileAsyncTemp(string fileName, string subFolder)
|
// public async Task UploadFileAsyncTemp(string fileName, string subFolder)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var fileContents = File.ReadAllBytes(fileName);
|
// var fileContents = File.ReadAllBytes(fileName);
|
||||||
System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileContents);
|
// System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileContents);
|
||||||
//var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName);
|
// //var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName);
|
||||||
var fileExt = Path.GetExtension(fileName);
|
// var fileExt = Path.GetExtension(fileName);
|
||||||
var fileType = MimeTypeMap.GetMimeType(fileExt);
|
// var fileType = MimeTypeMap.GetMimeType(fileExt);
|
||||||
var file_name = Path.GetFileName(fileName);
|
// var file_name = Path.GetFileName(fileName);
|
||||||
Console.WriteLine($"{_bucketName}{subFolder}");
|
// Console.WriteLine($"{_bucketName}{subFolder}");
|
||||||
Console.WriteLine(fileName);
|
// Console.WriteLine(fileName);
|
||||||
Console.WriteLine(file_name);
|
// Console.WriteLine(file_name);
|
||||||
Console.WriteLine(filestream);
|
// Console.WriteLine(filestream);
|
||||||
Console.WriteLine(fileType);
|
// Console.WriteLine(fileType);
|
||||||
|
|
||||||
var request = new PutObjectRequest
|
// var request = new PutObjectRequest
|
||||||
{
|
// {
|
||||||
BucketName = $"{_bucketName}",
|
// BucketName = $"{_bucketName}",
|
||||||
// BucketName = $"{_bucketName}{subFolder}",
|
// // BucketName = $"{_bucketName}{subFolder}",
|
||||||
Key = file_name,
|
// Key = file_name,
|
||||||
InputStream = filestream,
|
// InputStream = filestream,
|
||||||
ContentType = fileType,
|
// ContentType = fileType,
|
||||||
CannedACL = S3CannedACL.PublicRead
|
// CannedACL = S3CannedACL.PublicRead
|
||||||
};
|
// };
|
||||||
|
|
||||||
await _s3Client.PutObjectAsync(request);
|
// await _s3Client.PutObjectAsync(request);
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public async Task GenerateJsonFile(string json, string path, string fileName)
|
// public async Task GenerateJsonFile(string json, string path, string fileName)
|
||||||
{
|
// {
|
||||||
var tmpDir = Path.Combine("tmp");
|
// var tmpDir = Path.Combine("tmp");
|
||||||
if (!Directory.Exists(tmpDir))
|
// if (!Directory.Exists(tmpDir))
|
||||||
Directory.CreateDirectory(tmpDir);
|
// Directory.CreateDirectory(tmpDir);
|
||||||
|
|
||||||
var tmpFile = Path.Combine(tmpDir, $"{fileName}.json");
|
// var tmpFile = Path.Combine(tmpDir, $"{fileName}.json");
|
||||||
|
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
SaveToJsonFile(tmpFile, json);
|
// SaveToJsonFile(tmpFile, json);
|
||||||
await UploadFileAsyncTemp(tmpFile, path);
|
// await UploadFileAsyncTemp(tmpFile, path);
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
if (tmpFile != "")
|
// if (tmpFile != "")
|
||||||
{
|
// {
|
||||||
if (System.IO.File.Exists(tmpFile))
|
// if (System.IO.File.Exists(tmpFile))
|
||||||
System.IO.File.Delete(tmpFile);
|
// System.IO.File.Delete(tmpFile);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void SaveToJsonFile(string fileName, string data)
|
// private void SaveToJsonFile(string fileName, string data)
|
||||||
{
|
// {
|
||||||
TextWriter writer = null;
|
// TextWriter writer = null;
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
writer = new StreamWriter(fileName);
|
// writer = new StreamWriter(fileName);
|
||||||
writer.Write(data);
|
// writer.Write(data);
|
||||||
}
|
// }
|
||||||
catch
|
// catch
|
||||||
{
|
// {
|
||||||
throw;
|
// throw;
|
||||||
}
|
// }
|
||||||
finally
|
// finally
|
||||||
{
|
// {
|
||||||
if (writer != null)
|
// if (writer != null)
|
||||||
writer.Close();
|
// writer.Close();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
@ -420,6 +420,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteProfileId);
|
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteProfileId);
|
||||||
if (insigniaNoteProfile == null)
|
if (insigniaNoteProfile == null)
|
||||||
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
return Error(GlobalMessages.InsigniaRequestProfileNotFound);
|
||||||
|
if (insigniaNoteProfile.Status != "DONE")
|
||||||
|
return Error(GlobalMessages.InsigniaNoBorrow);
|
||||||
|
|
||||||
var insigniaManage = await _context.InsigniaManages.AsQueryable()
|
var insigniaManage = await _context.InsigniaManages.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.Year == insigniaNoteProfile.InsigniaNote.Year && x.Insignia == insigniaNoteProfile.RequestInsignia);
|
.FirstOrDefaultAsync(x => x.Year == insigniaNoteProfile.InsigniaNote.Year && x.Insignia == insigniaNoteProfile.RequestInsignia);
|
||||||
|
|
@ -433,7 +435,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
return Error(GlobalMessages.InsigniaManageOrgNotFound);
|
||||||
|
|
||||||
var insigniaManageProfile = await _context.InsigniaManageProfiles.AsQueryable()
|
var insigniaManageProfile = await _context.InsigniaManageProfiles.AsQueryable()
|
||||||
.FirstOrDefaultAsync(x => x.InsigniaNoteProfile == insigniaNoteProfile && x.InsigniaManageOrganiation == insigniaManageOrganiation && x.Status == false);
|
.FirstOrDefaultAsync(x => x.InsigniaNoteProfile == insigniaNoteProfile && x.Status == false);
|
||||||
if (insigniaManageProfile != null)
|
if (insigniaManageProfile != null)
|
||||||
return Error(GlobalMessages.InsigniaNotReturn);
|
return Error(GlobalMessages.InsigniaNotReturn);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
|
||||||
"Issuer": "https://identity.frappet.com/realms/bma-ehr"
|
"Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
|
||||||
},
|
},
|
||||||
"EPPlus": {
|
"EPPlus": {
|
||||||
"ExcelPackage": {
|
"ExcelPackage": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"realm": "bma-ehr",
|
"realm": "bma-ehr",
|
||||||
"auth-server-url": "https://identity.frappet.com",
|
"auth-server-url": "https://id.frappet.synology.me",
|
||||||
"ssl-required": "external",
|
"ssl-required": "external",
|
||||||
"resource": "bma-ehr",
|
"resource": "bma-ehr",
|
||||||
"public-client": true
|
"public-client": true
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
|
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">id </param>
|
/// <param name="id">Id รายการบันทึกเวียนแจ้งการถึงแก่กรรม</param>
|
||||||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
|
@ -68,9 +68,25 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
|
||||||
var data = await _repository.GetRetirementDeceasedAsync(id);
|
var data = await _repository.GetRetirementDeceasedAsync(id);
|
||||||
if (data != null)
|
if (data != null || head != null)
|
||||||
{
|
{
|
||||||
|
var mergeData = new
|
||||||
|
{
|
||||||
|
Oc = head.GetType().GetProperty("Oc").GetValue(head),
|
||||||
|
Number = head.GetType().GetProperty("Number").GetValue(head),
|
||||||
|
Date = head.GetType().GetProperty("Date").GetValue(head),
|
||||||
|
Subject = head.GetType().GetProperty("Subject").GetValue(head),
|
||||||
|
Send = head.GetType().GetProperty("Send").GetValue(head),
|
||||||
|
FullName = data.GetType().GetProperty("FullName").GetValue(data),
|
||||||
|
Position = data.GetType().GetProperty("Position").GetValue(data),
|
||||||
|
Reason = data.GetType().GetProperty("Reason").GetValue(data),
|
||||||
|
DeceasedDate = data.GetType().GetProperty("Date").GetValue(data),
|
||||||
|
CurrentDate = data.GetType().GetProperty("CurrentDate").GetValue(data),
|
||||||
|
DeceasedNumber = data.GetType().GetProperty("Number").GetValue(data),
|
||||||
|
Location = data.GetType().GetProperty("Location").GetValue(data),
|
||||||
|
};
|
||||||
var mimeType = "";
|
var mimeType = "";
|
||||||
switch (exportType.Trim().ToLower())
|
switch (exportType.Trim().ToLower())
|
||||||
{
|
{
|
||||||
|
|
@ -86,7 +102,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||||
}
|
}
|
||||||
report.DataSource = data;
|
report.DataSource = mergeData;
|
||||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
{
|
{
|
||||||
|
|
@ -94,7 +110,76 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
};
|
};
|
||||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||||
return File(result.DocumentBytes, mimeType, $"deceased.{exportType.Trim().ToLower()}");
|
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 36-บันทึกเวียนแจ้งการถึงแก่กรรม
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Id รายการบันทึกเวียนแจ้งการถึงแก่กรรม</param>
|
||||||
|
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("copy/36/{exportType}/{id}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetDeceasedReportCopyAsync(Guid id, string exportType = "pdf")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var head = await _repository.GetHeadRetirementDeceasedAsync(id);
|
||||||
|
var data = await _repository.GetRetirementDeceasedAsync(id);
|
||||||
|
if (data != null || head != null)
|
||||||
|
{
|
||||||
|
var mergeData = new
|
||||||
|
{
|
||||||
|
Oc = head.GetType().GetProperty("Oc").GetValue(head),
|
||||||
|
Number = head.GetType().GetProperty("Number").GetValue(head),
|
||||||
|
Date = head.GetType().GetProperty("Date").GetValue(head),
|
||||||
|
Subject = head.GetType().GetProperty("Subject").GetValue(head),
|
||||||
|
Send = head.GetType().GetProperty("Send").GetValue(head),
|
||||||
|
FullName = data.GetType().GetProperty("FullName").GetValue(data),
|
||||||
|
Position = data.GetType().GetProperty("Position").GetValue(data),
|
||||||
|
Reason = data.GetType().GetProperty("Reason").GetValue(data),
|
||||||
|
DeceasedDate = data.GetType().GetProperty("Date").GetValue(data),
|
||||||
|
CurrentDate = data.GetType().GetProperty("CurrentDate").GetValue(data),
|
||||||
|
DeceasedNumber = data.GetType().GetProperty("Number").GetValue(data),
|
||||||
|
Location = data.GetType().GetProperty("Location").GetValue(data),
|
||||||
|
};
|
||||||
|
var mimeType = "";
|
||||||
|
switch (exportType.Trim().ToLower())
|
||||||
|
{
|
||||||
|
case "pdf": mimeType = "application/pdf"; break;
|
||||||
|
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||||
|
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"36-บันทึกเวียนแจ้งการถึงแก่กรรม.trdp");
|
||||||
|
ReportPackager reportPacker = new ReportPackager();
|
||||||
|
Telerik.Reporting.Report? report = null;
|
||||||
|
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||||
|
{
|
||||||
|
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||||
|
}
|
||||||
|
report.DataSource = mergeData;
|
||||||
|
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||||
|
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||||
|
{
|
||||||
|
ReportDocument = report,
|
||||||
|
};
|
||||||
|
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||||
|
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||||
|
return File(result.DocumentBytes, mimeType, $"รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม.{exportType.Trim().ToLower()}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,10 @@
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Extensions;
|
|
||||||
using BMA.EHR.Domain.Shared;
|
|
||||||
using BMA.EHR.Application.Repositories.Reports;
|
using BMA.EHR.Application.Repositories.Reports;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
|
||||||
using Swashbuckle.AspNetCore.Annotations;
|
using Swashbuckle.AspNetCore.Annotations;
|
||||||
using DocumentFormat.OpenXml.Drawing;
|
|
||||||
using Telerik.Reporting;
|
using Telerik.Reporting;
|
||||||
using Telerik.Reporting.Processing;
|
using Telerik.Reporting.Processing;
|
||||||
using System.IO;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using BMA.EHR.Application.Responses;
|
|
||||||
using static BMA.EHR.Application.Responses.EvaluateRecordAssignResponse;
|
|
||||||
using static BMA.EHR.Application.Responses.ProbationAssignResponse;
|
|
||||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
||||||
using DocumentFormat.OpenXml.Bibliography;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
|
|
||||||
namespace BMA.EHR.Report.Service.Controllers
|
namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -819,7 +807,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
Check_Moral2Level2 = moral2.col2,
|
Check_Moral2Level2 = moral2.col2,
|
||||||
Check_Moral2Level3 = moral2.col3,
|
Check_Moral2Level3 = moral2.col3,
|
||||||
Check_Moral2Level4 = moral2.col4,
|
Check_Moral2Level4 = moral2.col4,
|
||||||
Check_Moral2Level5 = moral2.col4,
|
Check_Moral2Level5 = moral2.col5,
|
||||||
Check_Moral3Level1 = moral3.col1,
|
Check_Moral3Level1 = moral3.col1,
|
||||||
Check_Moral3Level2 = moral3.col2,
|
Check_Moral3Level2 = moral3.col2,
|
||||||
Check_Moral3Level3 = moral3.col3,
|
Check_Moral3Level3 = moral3.col3,
|
||||||
|
|
@ -1033,7 +1021,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
Check_Moral2Level2 = moral2.col2,
|
Check_Moral2Level2 = moral2.col2,
|
||||||
Check_Moral2Level3 = moral2.col3,
|
Check_Moral2Level3 = moral2.col3,
|
||||||
Check_Moral2Level4 = moral2.col4,
|
Check_Moral2Level4 = moral2.col4,
|
||||||
Check_Moral2Level5 = moral2.col4,
|
Check_Moral2Level5 = moral2.col5,
|
||||||
Check_Moral3Level1 = moral3.col1,
|
Check_Moral3Level1 = moral3.col1,
|
||||||
Check_Moral3Level2 = moral3.col2,
|
Check_Moral3Level2 = moral3.col2,
|
||||||
Check_Moral3Level3 = moral3.col3,
|
Check_Moral3Level3 = moral3.col3,
|
||||||
|
|
@ -1091,6 +1079,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
develop_other_training_percent = evaluate.develop_other_training_percent,
|
develop_other_training_percent = evaluate.develop_other_training_percent,
|
||||||
develop_total_percent = evaluate.develop_total_percent,
|
develop_total_percent = evaluate.develop_total_percent,
|
||||||
develop_result = evaluate.develop_result,
|
develop_result = evaluate.develop_result,
|
||||||
|
evaluate_result = evaluate.evaluate_result,
|
||||||
|
|
||||||
});
|
});
|
||||||
var tblEvaluateAssign1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
|
var tblEvaluateAssign1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
|
||||||
|
|
@ -1101,7 +1090,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
tblEvaluateAssign3.DataSource = _Evaluate;
|
tblEvaluateAssign3.DataSource = _Evaluate;
|
||||||
var tblEvaluateAssign4 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table3"];
|
var tblEvaluateAssign4 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table3"];
|
||||||
tblEvaluateAssign4.DataSource = _Evaluate;
|
tblEvaluateAssign4.DataSource = _Evaluate;
|
||||||
|
report2.DataSource = _Evaluate;
|
||||||
var reportBook = new ReportBook();
|
var reportBook = new ReportBook();
|
||||||
reportBook.Reports.Add(report);
|
reportBook.Reports.Add(report);
|
||||||
reportBook.Reports.Add(report2);
|
reportBook.Reports.Add(report2);
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,10 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
public async Task<ActionResult<ResponseObject>> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf")
|
public async Task<ActionResult<ResponseObject>> GetProfileRetirement([FromRoute] Guid Id, string exportType = "pdf")
|
||||||
{
|
{
|
||||||
var retire = await _service.GetProfileRetirementdAsync(Id);
|
var retire = await _service.GetProfileRetirementdAsync(Id);
|
||||||
if (retire == null)
|
if (retire != null)
|
||||||
{
|
{
|
||||||
return NotFound();
|
var reportfile = string.Empty;
|
||||||
}
|
var returnfile = string.Empty;
|
||||||
else
|
|
||||||
{
|
|
||||||
var reportfile = "";
|
|
||||||
var returnfile = "";
|
|
||||||
exportType = exportType.Trim();
|
exportType = exportType.Trim();
|
||||||
switch (retire.GetType().GetProperty("Type").GetValue(retire))
|
switch (retire.GetType().GetProperty("Type").GetValue(retire))
|
||||||
{
|
{
|
||||||
|
|
@ -89,9 +85,10 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
{
|
{
|
||||||
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||||
}
|
}
|
||||||
//Add Parameter
|
report.DataSource = retire;
|
||||||
report.ReportParameters["Year"].Value = retire.GetType().GetProperty("Year").GetValue(retire);
|
////Add Parameter
|
||||||
report.ReportParameters["Total"].Value = retire.GetType().GetProperty("Total").GetValue(retire);
|
//report.ReportParameters["Year"].Value = retire.GetType().GetProperty("Year").GetValue(retire);
|
||||||
|
//report.ReportParameters["Total"].Value = retire.GetType().GetProperty("Total").GetValue(retire);
|
||||||
|
|
||||||
var _profileList = new List<dynamic>();
|
var _profileList = new List<dynamic>();
|
||||||
|
|
||||||
|
|
@ -123,6 +120,10 @@ namespace BMA.EHR.Report.Service.Controllers
|
||||||
var content = result.DocumentBytes;
|
var content = result.DocumentBytes;
|
||||||
return File(content, $"application/{exportType}", returnfile);
|
return File(content, $"application/{exportType}", returnfile);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -26,10 +26,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"MinIO": {
|
"MinIO": {
|
||||||
"Endpoint": "https://s3.frappet.com/",
|
"Endpoint": "https://s3cluster.frappet.com/",
|
||||||
"AccessKey": "frappet",
|
"AccessKey": "frappet",
|
||||||
"SecretKey": "P@ssw0rd",
|
"SecretKey": "FPTadmin2357",
|
||||||
"BucketName": "bma-recruit"
|
"BucketName": "bma-ehr-fpt"
|
||||||
},
|
},
|
||||||
"Protocol": "HTTPS",
|
"Protocol": "HTTPS",
|
||||||
"telerikReporting": {
|
"telerikReporting": {
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
Round = round,
|
Round = round,
|
||||||
TypeReport = null,
|
TypeReport = null,
|
||||||
|
Detail = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัตบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบัเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕",
|
||||||
Type = req.Type.Trim().ToUpper(),
|
Type = req.Type.Trim().ToUpper(),
|
||||||
Year = req.Year,
|
Year = req.Year,
|
||||||
CreatedUserId = UserId ?? "System Administrator",
|
CreatedUserId = UserId ?? "System Administrator",
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
payload_attach.Add(new PayloadAttachment
|
payload_attach.Add(new PayloadAttachment
|
||||||
{
|
{
|
||||||
name = "หนังสือเวียนถึงแก่กรรม",
|
name = "หนังสือเวียนถึงแก่กรรม",
|
||||||
url = $"{_configuration["API"]}/order/download/attachment/{retirementDeceased.DocumentForward.Id}"
|
url = $"{_configuration["API"]}/copy/36/pdf/{retirementDeceased.Id}"
|
||||||
});
|
});
|
||||||
|
|
||||||
var payload = new CommandPayload()
|
var payload = new CommandPayload()
|
||||||
|
|
|
||||||
|
|
@ -508,6 +508,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
"",
|
"",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
|
Guid.Parse("08db721d-ae22-424d-8f4a-87ba30cc3ee7"),
|
||||||
|
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
||||||
|
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ได้รับการอนุมัติจากผู้บังคับบัญชา",
|
||||||
|
"",
|
||||||
|
true
|
||||||
|
);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
|
@ -547,6 +554,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
"",
|
"",
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
await _repositoryNoti.PushNotificationAsync(
|
||||||
|
Guid.Parse("08db721d-ae22-424d-8f4a-87ba30cc3ee7"),
|
||||||
|
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
||||||
|
$"คำขอลาออกขอ {updated.Profile.Prefix?.Name}{updated.Profile.FirstName} {updated.Profile.LastName} ถูกยับยั้งจากผู้บังคับบัญชา",
|
||||||
|
"",
|
||||||
|
true
|
||||||
|
);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ namespace BMA.EHR.Retirement.Service.Requests
|
||||||
public class RetirementDeceasedAddNotiPerson
|
public class RetirementDeceasedAddNotiPerson
|
||||||
{
|
{
|
||||||
public Guid ProfileId { get; set; }
|
public Guid ProfileId { get; set; }
|
||||||
public bool IsSendMail { get; set; }
|
public bool IsSendMail { get; set; } = true;
|
||||||
public bool IsSendInbox { get; set; }
|
public bool IsSendInbox { get; set; } = true;
|
||||||
public bool IsSendNotification { get; set; }
|
public bool IsSendNotification { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue