Merge branch 'develop' into working
This commit is contained in:
commit
7632d81a3d
17 changed files with 859 additions and 589 deletions
|
|
@ -32,6 +32,7 @@ namespace BMA.EHR.Application
|
|||
services.AddTransient<TransferReportRepository>();
|
||||
services.AddTransient<EmailSenderService>();
|
||||
services.AddTransient<CandidateReportRepository>();
|
||||
services.AddTransient<MinIOExamService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
|
|
|||
366
BMA.EHR.Application/Repositories/MinIOExamService.cs
Normal file
366
BMA.EHR.Application/Repositories/MinIOExamService.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 MinIOExamService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly IApplicationDBExamContext _dbContext;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly AmazonS3Client _s3Client;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private string _bucketName = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructors "
|
||||
|
||||
public MinIOExamService(IApplicationDBExamContext 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
|
|
@ -12,6 +13,7 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using static BMA.EHR.Domain.Extensions.DateTimeExtension;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Reports
|
||||
{
|
||||
|
|
@ -49,81 +51,125 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
#region ใบสมัครสอบ
|
||||
public async Task<dynamic> GetExamCandidateAsync(Guid id)
|
||||
{
|
||||
var careers = await _dbExamContext.Set<Career>()
|
||||
.AsQueryable()
|
||||
.Where(x => x.Candidate.Id == id)
|
||||
.ToListAsync();
|
||||
var yearDiff = 0;
|
||||
var monthDiff = 0;
|
||||
var dayDiff = 0;
|
||||
var sb = new StringBuilder();
|
||||
var zxc = new List<dynamic>();
|
||||
foreach (var career in careers)
|
||||
{
|
||||
if (career.DurationEnd < career.DurationStart)
|
||||
{
|
||||
var rangeObj = career.DurationEnd.CalculateBetweenDateV2Value(career.DurationStart);
|
||||
yearDiff = yearDiff + rangeObj.years;
|
||||
monthDiff = monthDiff + rangeObj.months;
|
||||
dayDiff = dayDiff + rangeObj.days;
|
||||
zxc.Add(rangeObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
var rangeObj = career.DurationStart.CalculateBetweenDateV2Value(career.DurationEnd);
|
||||
yearDiff = yearDiff + rangeObj.years;
|
||||
monthDiff = monthDiff + rangeObj.months;
|
||||
dayDiff = dayDiff + rangeObj.days;
|
||||
zxc.Add(rangeObj);
|
||||
}
|
||||
if (dayDiff >= 30)
|
||||
{
|
||||
monthDiff = monthDiff + (int)(dayDiff / 30);
|
||||
dayDiff = dayDiff % 30;
|
||||
}
|
||||
if (monthDiff >= 12)
|
||||
{
|
||||
yearDiff = yearDiff + (int)(monthDiff / 12);
|
||||
monthDiff = monthDiff % 12;
|
||||
}
|
||||
sb.Clear();
|
||||
sb.Append(yearDiff == 0 ? "" : $"{yearDiff} ปี ");
|
||||
sb.Append(monthDiff == 0 ? "" : $"{monthDiff} เดือน ");
|
||||
sb.Append(dayDiff == 0 ? "" : $"{dayDiff} วัน ");
|
||||
}
|
||||
var data = await _dbExamContext.Set<Candidate>().AsQueryable()
|
||||
.Where(x => x.Id == id)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
AvatarId = p.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ProfileImg.Id,
|
||||
ExamIdenNumber = p.ExamIdenNumber,
|
||||
PositionName = p.PositionExam == null ? "" : p.PositionExam.PositionName,
|
||||
PeriodExamName = p.PeriodExam == null ? "" : p.PeriodExam.Name,
|
||||
PeriodExamRound = p.PeriodExam == null ? "" : p.PeriodExam.Round.ToString(),
|
||||
PeriodExamYear = p.PeriodExam == null ? "" : p.PeriodExam.Year.ToString(),
|
||||
ExamIdenNumber = p.ExamIdenNumber == null ? "-" : p.ExamIdenNumber,
|
||||
PositionName = p.PositionExam == null ? "-" : p.PositionExam.PositionName,
|
||||
PositionLevelName = p.PositionExam == null ? "-" : p.PositionExam.PositionLevelName,
|
||||
PeriodExamName = p.PeriodExam == null ? "-" : p.PeriodExam.Name,
|
||||
PeriodExamRound = p.PeriodExam == null ? "-" : p.PeriodExam.Round.ToString(),
|
||||
PeriodExamYear = p.PeriodExam == null ? "-" : (p.PeriodExam.Year + 543).ToString(),
|
||||
|
||||
FullName = $"{p.PrefixName}{p.FirstName} {p.LastName}",
|
||||
Religion = p.ReligionName,
|
||||
Nationality = p.Nationality,
|
||||
DateOfBirth = p.DateOfBirth == null ? "" : p.DateOfBirth.Value.ToThaiShortDate2(),
|
||||
Age = p.DateOfBirth == null ? "" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
|
||||
CitizenId = p.CitizenId,
|
||||
Religion = p.ReligionName == null ? "-" : p.ReligionName,
|
||||
Nationality = p.Nationality == null ? "-" : p.Nationality,
|
||||
DateOfBirth = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.ToThaiFullDate2(),
|
||||
Age = p.DateOfBirth == null ? "-" : p.DateOfBirth.Value.CalculateAgeStrV2(0, 0),
|
||||
CitizenId = p.CitizenId == null ? "-" : p.CitizenId,
|
||||
|
||||
EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLevelExamName,
|
||||
EducationName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationName,
|
||||
EducationMajor = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationMajor,
|
||||
EducationLocation = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLocation,
|
||||
EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiShortDate2(),
|
||||
EducationScores = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationScores,
|
||||
EducationType = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationType,
|
||||
EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "" : p.Educations.FirstOrDefault().EducationLevelHighName,
|
||||
EducationLevelExamName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelExamName,
|
||||
EducationName = p.Educations.FirstOrDefault() == null ? null : (p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาตรี" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาโท" || p.Educations.FirstOrDefault().EducationLevelExamName == "ปริญญาเอก" ? null : p.Educations.FirstOrDefault().EducationName),
|
||||
EducationMajor = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationMajor,
|
||||
EducationLocation = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLocation,
|
||||
EducationEndDate = p.Educations.FirstOrDefault() == null || p.Educations.FirstOrDefault().EducationEndDate == null ? "-" : p.Educations.FirstOrDefault().EducationEndDate.Value.ToThaiFullDate2(),
|
||||
EducationScores = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationScores,
|
||||
EducationType = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationType,
|
||||
EducationLevelHighName = p.Educations.FirstOrDefault() == null ? "-" : p.Educations.FirstOrDefault().EducationLevelHighName,
|
||||
|
||||
OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "perm" ? "ลูกจ้างประจำ" : "-")),
|
||||
OccupationPosition = p.OccupationPosition,
|
||||
OccupationSalary = p.OccupationSalary,
|
||||
OccupationGroup = p.OccupationGroup,
|
||||
OccupationPile = p.OccupationPile,
|
||||
OccupationOrg = p.OccupationOrg,
|
||||
OccupationTelephone = p.OccupationTelephone,
|
||||
OccupationPositionType = p.OccupationPositionType == "other" ? "ผู้ปฏิบัติงานอื่นในกรุงเทพมหานคร" : (p.OccupationPositionType == "temp" ? "ลูกจ้างชั่วคราว" : (p.OccupationPositionType == "prem" ? "ลูกจ้างประจำ" : "-")),
|
||||
OccupationPosition = p.OccupationPosition == null ? "-" : p.OccupationPosition,
|
||||
OccupationSalary = p.OccupationSalary == null ? "-" : p.OccupationSalary.ToString(),
|
||||
OccupationGroup = p.OccupationGroup == null ? "-" : p.OccupationGroup,
|
||||
OccupationPile = p.OccupationPile == null ? "-" : p.OccupationPile,
|
||||
OccupationOrg = p.OccupationOrg == null ? "-" : p.OccupationOrg,
|
||||
OccupationTelephone = p.OccupationTelephone == null ? "-" : p.OccupationTelephone,
|
||||
|
||||
Careers = p.Careers.Select(y => new
|
||||
{
|
||||
Position = y.Position,
|
||||
Type = y.Type,
|
||||
DurationStart = y.DurationStart.ToThaiShortDate2(),
|
||||
DurationEnd = y.DurationEnd.ToThaiShortDate2(),
|
||||
RangeDate = y.RangeDate,
|
||||
}).ToList(),
|
||||
CareersTotal = sb.ToString(),
|
||||
// Careers = p.Careers.Select(y => new
|
||||
// {
|
||||
// Position = y.Position,
|
||||
// Type = y.Type,
|
||||
// DurationStart = y.DurationStart.ToThaiShortDate2(),
|
||||
// DurationEnd = y.DurationEnd.ToThaiShortDate2(),
|
||||
// RangeDate = y.RangeDate,
|
||||
// }).ToList(),
|
||||
|
||||
RegistAddress = p.RegistAddress,
|
||||
RegistProvinceName = p.RegistProvinceName,
|
||||
RegistDistrictName = p.RegistDistrictName,
|
||||
RegistSubDistrictName = p.RegistSubDistrictName,
|
||||
RegistZipCode = p.RegistZipCode,
|
||||
CurrentAddress = p.CurrentAddress,
|
||||
CurrentProvinceName = p.CurrentProvinceName,
|
||||
CurrentSubDistrictName = p.CurrentSubDistrictName,
|
||||
CurrentDistrictName = p.CurrentDistrictName,
|
||||
CurrentZipCode = p.CurrentZipCode,
|
||||
Telephone = p.Telephone,
|
||||
Email = p.Email,
|
||||
RegistAddress = p.RegistAddress == null ? "-" : p.RegistAddress,
|
||||
RegistProvinceName = p.RegistProvinceName == null ? "-" : p.RegistProvinceName,
|
||||
RegistDistrictName = p.RegistDistrictName == null ? "-" : p.RegistDistrictName,
|
||||
RegistSubDistrictName = p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName,
|
||||
RegistZipCode = p.RegistZipCode == null ? "-" : p.RegistZipCode,
|
||||
CurrentAddress = p.CurrentAddress == null ? (p.RegistAddress == null ? "-" : p.RegistAddress) : p.CurrentAddress,
|
||||
CurrentProvinceName = p.CurrentProvinceName == null ? (p.RegistProvinceName == null ? "-" : p.RegistProvinceName) : p.CurrentProvinceName,
|
||||
CurrentDistrictName = p.CurrentDistrictName == null ? (p.RegistDistrictName == null ? "-" : p.RegistDistrictName) : p.CurrentDistrictName,
|
||||
CurrentSubDistrictName = p.CurrentSubDistrictName == null ? (p.RegistSubDistrictName == null ? "-" : p.RegistSubDistrictName) : p.CurrentSubDistrictName,
|
||||
CurrentZipCode = p.CurrentZipCode == null ? (p.RegistZipCode == null ? "-" : p.RegistZipCode) : p.CurrentZipCode,
|
||||
Telephone = p.Telephone == null ? "-" : p.Telephone,
|
||||
Email = p.Email == null ? "-" : p.Email,
|
||||
|
||||
ContactFullName = $"{p.ContactPrefixName}{p.ContactFirstname} {p.ContactLastname}",
|
||||
ContactRelations = p.ContactRelations,
|
||||
ContactTel = p.ContactTel,
|
||||
ContactRelations = p.ContactRelations == null ? "-" : p.ContactRelations,
|
||||
ContactTel = p.ContactTel == null ? "-" : p.ContactTel,
|
||||
|
||||
RegisterDate = p.RegisterDate == null ? "" : p.RegisterDate.Value.ToThaiFullDate(),
|
||||
RegisterDate = p.RegisterDate == null ? "-" : p.RegisterDate.Value.ToThaiFullDate(),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (data == null)
|
||||
throw new Exception(GlobalMessages.CandidateNotFound);
|
||||
return data;
|
||||
}
|
||||
public async Task<dynamic> GetExamCareerCandidateAsync(Guid id)
|
||||
{
|
||||
var data = await _dbExamContext.Set<Career>().AsQueryable()
|
||||
var items = await _dbExamContext.Set<Career>().AsQueryable()
|
||||
.Where(x => x.Candidate != null)
|
||||
.Where(x => x.Candidate.Id == id)
|
||||
.OrderBy(x => x.DurationStart)
|
||||
.Select(p => new
|
||||
{
|
||||
Position = p.Position,
|
||||
|
|
@ -133,6 +179,22 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
RangeDate = p.RangeDate,
|
||||
})
|
||||
.ToListAsync();
|
||||
int retVal = 1;
|
||||
var data = new List<dynamic>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var _data = new
|
||||
{
|
||||
Position = item.Position,
|
||||
Type = item.Type,
|
||||
DurationStart = item.DurationStart,
|
||||
DurationEnd = item.DurationEnd,
|
||||
RangeDate = item.RangeDate,
|
||||
Index = retVal,
|
||||
};
|
||||
data.Add(_data);
|
||||
retVal++;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,6 +282,11 @@ namespace BMA.EHR.Application.Repositories.Reports
|
|||
ChairmanName = string.IsNullOrEmpty(evaluate_assign.data.chairman.name) ? string.Empty : evaluate_assign.data.chairman.name,
|
||||
ChairmanPosition = string.IsNullOrEmpty(evaluate_assign.data.chairman.Position) ? string.Empty : evaluate_assign.data.chairman.Position,
|
||||
ChairmanDate = string.IsNullOrEmpty(evaluate_assign.data.evaluate.chairman_dated.ToString()) ? "วันที่ เดือน พ.ศ." : evaluate_assign.data.evaluate.chairman_dated.ToThaiFullDate().ToString().ToThaiNumber(),
|
||||
Name = evaluate_assign.data.experimentee.name,
|
||||
RoundNo = evaluate_assign.data.assign.round_no.ToString().ToThaiNumber(),
|
||||
DateStart = string.IsNullOrEmpty(evaluate_assign.data.assign.date_start.ToString()) ? "วันที่ เดือน พ.ศ." : DateTime.Parse(evaluate_assign.data.assign.date_start).ToThaiFullDate().ToString().ToThaiNumber(),
|
||||
DateFinish = string.IsNullOrEmpty(evaluate_assign.data.assign.date_finish.ToString()) ? "วันที่ เดือน พ.ศ." : DateTime.Parse(evaluate_assign.data.assign.date_finish).ToThaiFullDate().ToString().ToThaiNumber(),
|
||||
|
||||
};
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -4,335 +4,395 @@ using System.Text;
|
|||
|
||||
namespace BMA.EHR.Domain.Extensions
|
||||
{
|
||||
public static class DateTimeExtension
|
||||
{
|
||||
private static CultureInfo _culture = new CultureInfo("th-TH");
|
||||
public static class DateTimeExtension
|
||||
{
|
||||
private static CultureInfo _culture = new CultureInfo("th-TH");
|
||||
|
||||
#region " Methods "
|
||||
#region " Methods "
|
||||
|
||||
#region " Public "
|
||||
#region " Public "
|
||||
|
||||
public static double DiffYear(this DateTime currentDate)
|
||||
{
|
||||
return (DateTime.Today - currentDate).TotalDays / 365.2425;
|
||||
}
|
||||
public static double DiffYear(this DateTime currentDate)
|
||||
{
|
||||
return (DateTime.Today - currentDate).TotalDays / 365.2425;
|
||||
}
|
||||
|
||||
public static int ToUnixTimeStamp(this DateTime value)
|
||||
{
|
||||
return (int)Math.Truncate((value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
|
||||
}
|
||||
public static int ToUnixTimeStamp(this DateTime value)
|
||||
{
|
||||
return (int)Math.Truncate((value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
|
||||
}
|
||||
|
||||
public static string ToThaiFullDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"วันที่ {value.Day} เดือน {value.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {yy}";
|
||||
}
|
||||
public static string ToThaiFullDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"วันที่ {value.Day} เดือน {value.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiFullDate2(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {yy}";
|
||||
}
|
||||
public static string ToThaiFullDate2(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiFullDate3(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMMM", _culture.DateTimeFormat)} {yy}";
|
||||
}
|
||||
public static string ToThaiFullDate3(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMMM", _culture.DateTimeFormat)} {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiShortDateTime(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy} {value.ToString("HH:mm:ss")}";
|
||||
}
|
||||
public static string ToThaiShortDateTime(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy} {value.ToString("HH:mm:ss")}";
|
||||
}
|
||||
|
||||
public static string ToThaiShortDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy}";
|
||||
}
|
||||
public static string ToThaiShortDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiShortDate2(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy.ToString().Right(2)}";
|
||||
}
|
||||
public static string ToThaiShortDate2(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day} {value.ToString("MMM", _culture.DateTimeFormat)} {yy.ToString().Right(2)}";
|
||||
}
|
||||
|
||||
public static string ToThaiDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day}/{value.Month}/{yy}";
|
||||
}
|
||||
public static string ToThaiDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day}/{value.Month}/{yy}";
|
||||
}
|
||||
|
||||
public static string ToCeDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year >= 2400 ? value.Year - 543 : value.Year;
|
||||
return $"{value.Day}/{value.Month}/{yy}";
|
||||
}
|
||||
public static string ToCeDate(this DateTime value)
|
||||
{
|
||||
var yy = value.Year >= 2400 ? value.Year - 543 : value.Year;
|
||||
return $"{value.Day}/{value.Month}/{yy}";
|
||||
}
|
||||
|
||||
public static string ToThaiDateFullDigit(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day.ToString("00")}/{value.Month.ToString("00")}/{yy.ToString("00")}";
|
||||
}
|
||||
public static string ToThaiDateFullDigit(this DateTime value)
|
||||
{
|
||||
var yy = value.Year < 2400 ? value.Year + 543 : value.Year;
|
||||
return $"{value.Day.ToString("00")}/{value.Month.ToString("00")}/{yy.ToString("00")}";
|
||||
}
|
||||
|
||||
public static string GetDay(this DateTime value)
|
||||
{
|
||||
return value.Day.ToString();
|
||||
}
|
||||
public static string GetDay(this DateTime value)
|
||||
{
|
||||
return value.Day.ToString();
|
||||
}
|
||||
|
||||
public static string GetMonth(this DateTime value)
|
||||
{
|
||||
return value.ToString("MMMM", _culture.DateTimeFormat);
|
||||
}
|
||||
public static string GetMonth(this DateTime value)
|
||||
{
|
||||
return value.ToString("MMMM", _culture.DateTimeFormat);
|
||||
}
|
||||
|
||||
public static string GetYear(this DateTime value)
|
||||
{
|
||||
return value.Year.ToThaiYear().ToString();
|
||||
}
|
||||
public static string GetYear(this DateTime value)
|
||||
{
|
||||
return value.Year.ToThaiYear().ToString();
|
||||
}
|
||||
|
||||
public static string CalculateAgeStrV2(this DateTime date, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
var age = currentDate - date;
|
||||
public static string CalculateAgeStrV2(this DateTime date, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
var age = currentDate - date;
|
||||
|
||||
|
||||
if (date > currentDate)
|
||||
{
|
||||
throw new ArgumentException("วันเกิดต้องไม่มากกว่าวันที่ปัจจุบัน");
|
||||
}
|
||||
if (date > currentDate)
|
||||
{
|
||||
throw new ArgumentException("วันเกิดต้องไม่มากกว่าวันที่ปัจจุบัน");
|
||||
}
|
||||
|
||||
int years = currentDate.Year - date.Year;
|
||||
int months = 0;
|
||||
int days = 0;
|
||||
int years = currentDate.Year - date.Year;
|
||||
int months = 0;
|
||||
int days = 0;
|
||||
|
||||
if (currentDate.Month < date.Month ||
|
||||
(currentDate.Month == date.Month && currentDate.Day < date.Day))
|
||||
{
|
||||
years--;
|
||||
months = 12 - date.Month + currentDate.Month;
|
||||
if (currentDate.Month < date.Month ||
|
||||
(currentDate.Month == date.Month && currentDate.Day < date.Day))
|
||||
{
|
||||
years--;
|
||||
months = 12 - date.Month + currentDate.Month;
|
||||
|
||||
if (currentDate.Day < date.Day)
|
||||
{
|
||||
months--;
|
||||
int lastMonthDays = DateTime.DaysInMonth(currentDate.Year, currentDate.Month - 1);
|
||||
days = lastMonthDays - date.Day + currentDate.Day;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = currentDate.Day - date.Day;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
months = currentDate.Month - date.Month;
|
||||
if (currentDate.Day < date.Day)
|
||||
{
|
||||
months--;
|
||||
int lastMonthDays = DateTime.DaysInMonth(currentDate.Year, currentDate.Month - 1);
|
||||
days = lastMonthDays - date.Day + currentDate.Day;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = currentDate.Day - date.Day;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
months = currentDate.Month - date.Month;
|
||||
|
||||
if (currentDate.Day < date.Day)
|
||||
{
|
||||
months--;
|
||||
int lastMonthDays = DateTime.DaysInMonth(currentDate.Year, currentDate.Month - 1);
|
||||
days = lastMonthDays - date.Day + currentDate.Day;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = currentDate.Day - date.Day;
|
||||
}
|
||||
}
|
||||
if (currentDate.Day < date.Day)
|
||||
{
|
||||
months--;
|
||||
int lastMonthDays = DateTime.DaysInMonth(currentDate.Year, currentDate.Month - 1);
|
||||
days = lastMonthDays - date.Day + currentDate.Day;
|
||||
}
|
||||
else
|
||||
{
|
||||
days = currentDate.Day - date.Day;
|
||||
}
|
||||
}
|
||||
|
||||
//return new Age(years, months, days);
|
||||
//return new Age(years, months, days);
|
||||
|
||||
|
||||
//// แปลงเป็นอายุในรูปแบบวันที่
|
||||
//int years = (int)(age.Days / 365.25) + plusYear - subtractYear;
|
||||
//int months = (int)((age.Days % 365.25) / 30.436875);
|
||||
//int days = (int)((age.Days % 365.25) % 30.436875);
|
||||
//// แปลงเป็นอายุในรูปแบบวันที่
|
||||
//int years = (int)(age.Days / 365.25) + plusYear - subtractYear;
|
||||
//int months = (int)((age.Days % 365.25) / 30.436875);
|
||||
//int days = (int)((age.Days % 365.25) % 30.436875);
|
||||
|
||||
return $"{years} ปี {months} เดือน {days} วัน";
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return $"{years} ปี {months} เดือน {days} วัน";
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CalculateAge(this DateTime date, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
var age = currentDate - date;
|
||||
public static int CalculateAge(this DateTime date, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentDate = DateTime.Now;
|
||||
var age = currentDate - date;
|
||||
|
||||
// แปลงเป็นอายุในรูปแบบวันที่
|
||||
int years = (int)(age.Days / 365.25) + plusYear - subtractYear;
|
||||
// แปลงเป็นอายุในรูปแบบวันที่
|
||||
int years = (int)(age.Days / 365.25) + plusYear - subtractYear;
|
||||
|
||||
return years;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return years;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CalculateGovAge(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
if (DateTime.Now.Month - appointDate.Month >= 6)
|
||||
return (DateTime.Now.Year - appointDate.Year) + 1 + plusYear - subtractYear;
|
||||
else
|
||||
return (DateTime.Now.Year - appointDate.Year) + plusYear - subtractYear;
|
||||
}
|
||||
public static int CalculateGovAge(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
if (DateTime.Now.Month - appointDate.Month >= 6)
|
||||
return (DateTime.Now.Year - appointDate.Year) + 1 + plusYear - subtractYear;
|
||||
else
|
||||
return (DateTime.Now.Year - appointDate.Year) + plusYear - subtractYear;
|
||||
}
|
||||
|
||||
|
||||
public static string CalculateGovAgeStr(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
var d2 = DateTime.Now;
|
||||
TimeSpan sp = d2.Subtract(appointDate);
|
||||
var alldays = sp.Days + ((plusYear - subtractYear) * 365);
|
||||
public static string CalculateGovAgeStr(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
var d2 = DateTime.Now;
|
||||
TimeSpan sp = d2.Subtract(appointDate);
|
||||
var alldays = sp.Days + ((plusYear - subtractYear) * 365);
|
||||
|
||||
int yy = alldays / 365;
|
||||
int mm = (alldays - (yy * 365)) / 30;
|
||||
int dd = (alldays - (yy * 365) - (mm * 30));
|
||||
int yy = alldays / 365;
|
||||
int mm = (alldays - (yy * 365)) / 30;
|
||||
int dd = (alldays - (yy * 365) - (mm * 30));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
||||
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
||||
sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
||||
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
||||
sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string CalculateGovAgeInYear(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
var d2 = DateTime.Now;
|
||||
TimeSpan sp = d2.Subtract(appointDate);
|
||||
var alldays = sp.Days + ((plusYear - subtractYear) * 365);
|
||||
public static string CalculateGovAgeInYear(this DateTime appointDate, int plusYear = 0, int subtractYear = 0)
|
||||
{
|
||||
var d2 = DateTime.Now;
|
||||
TimeSpan sp = d2.Subtract(appointDate);
|
||||
var alldays = sp.Days + ((plusYear - subtractYear) * 365);
|
||||
|
||||
int yy = alldays / 365;
|
||||
int yy = alldays / 365;
|
||||
|
||||
return yy.ToString();
|
||||
}
|
||||
return yy.ToString();
|
||||
}
|
||||
|
||||
public static int GetDifferenceInYears(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
int finalResult = 0;
|
||||
public static int GetDifferenceInYears(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
int finalResult = 0;
|
||||
|
||||
const int daysInYear = 365;
|
||||
const int daysInYear = 365;
|
||||
|
||||
//DateTime endDate = DateTime.Now;
|
||||
//DateTime endDate = DateTime.Now;
|
||||
|
||||
TimeSpan timeSpan = endDate - startDate;
|
||||
TimeSpan timeSpan = endDate - startDate;
|
||||
|
||||
if (timeSpan.TotalDays > 365)
|
||||
{
|
||||
finalResult = (int)Math.Round((timeSpan.TotalDays / daysInYear), MidpointRounding.ToEven);
|
||||
}
|
||||
if (timeSpan.TotalDays > 365)
|
||||
{
|
||||
finalResult = (int)Math.Round((timeSpan.TotalDays / daysInYear), MidpointRounding.ToEven);
|
||||
}
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
public static DateTime CalculateRetireDate(this DateTime birthDate)
|
||||
{
|
||||
var dd = birthDate.Day;
|
||||
var mm = birthDate.Month;
|
||||
var yy = birthDate.Year;
|
||||
public static DateTime CalculateRetireDate(this DateTime birthDate)
|
||||
{
|
||||
var dd = birthDate.Day;
|
||||
var mm = birthDate.Month;
|
||||
var yy = birthDate.Year;
|
||||
|
||||
var g1 = true;
|
||||
switch (mm)
|
||||
{
|
||||
case 10: if (dd >= 2) g1 = false; break;
|
||||
case 11:
|
||||
case 12: g1 = false; break;
|
||||
}
|
||||
var g1 = true;
|
||||
switch (mm)
|
||||
{
|
||||
case 10: if (dd >= 2) g1 = false; break;
|
||||
case 11:
|
||||
case 12: g1 = false; break;
|
||||
}
|
||||
|
||||
if (g1)
|
||||
return new DateTime(yy + 60, 9, 30);
|
||||
else
|
||||
return new DateTime(yy + 61, 9, 30);
|
||||
}
|
||||
if (g1)
|
||||
return new DateTime(yy + 60, 9, 30);
|
||||
else
|
||||
return new DateTime(yy + 61, 9, 30);
|
||||
}
|
||||
|
||||
public static bool IsBetween(this DateTime now, TimeSpan start, TimeSpan end)
|
||||
{
|
||||
var time = now.TimeOfDay;
|
||||
// Scenario 1: If the start time and the end time are in the same day.
|
||||
if (start <= end)
|
||||
return time >= start && time <= end;
|
||||
// Scenario 2: The start time and end time is on different days.
|
||||
return time >= start || time <= end;
|
||||
}
|
||||
public static bool IsBetween(this DateTime now, TimeSpan start, TimeSpan end)
|
||||
{
|
||||
var time = now.TimeOfDay;
|
||||
// Scenario 1: If the start time and the end time are in the same day.
|
||||
if (start <= end)
|
||||
return time >= start && time <= end;
|
||||
// Scenario 2: The start time and end time is on different days.
|
||||
return time >= start || time <= end;
|
||||
}
|
||||
|
||||
public static string CalculateBetweenDate(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
// var d2 = DateTime.Now;
|
||||
TimeSpan sp = endDate.Subtract(startDate);
|
||||
var alldays = sp.Days;
|
||||
public static string CalculateBetweenDate(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
// var d2 = DateTime.Now;
|
||||
TimeSpan sp = endDate.Subtract(startDate);
|
||||
var alldays = sp.Days;
|
||||
|
||||
int yy = alldays / 365;
|
||||
int mm = (alldays - (yy * 365)) / 30;
|
||||
int dd = (alldays - (yy * 365) - (mm * 30));
|
||||
int yy = alldays / 365;
|
||||
int mm = (alldays - (yy * 365)) / 30;
|
||||
int dd = (alldays - (yy * 365) - (mm * 30));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
||||
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
||||
sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(yy == 0 ? "" : $"{yy} ปี ");
|
||||
sb.Append(mm == 0 ? "" : $"{mm} เดือน ");
|
||||
sb.Append(dd == 0 ? "" : $"{dd} วัน ");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string CalculateBetweenDateV2(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (startDate == null || endDate == null)
|
||||
return "-";
|
||||
public static string CalculateBetweenDateV2(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
if (startDate == null || endDate == null)
|
||||
return "-";
|
||||
|
||||
DateTime today = endDate;
|
||||
DateTime birthDate = Convert.ToDateTime(startDate).AddDays(-1);
|
||||
int years = new DateTime(endDate.Subtract(birthDate).Ticks).Year - 1;
|
||||
DateTime pastYearDate = birthDate.AddYears(years);
|
||||
int months = 0;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
if (pastYearDate.AddMonths(i) == today)
|
||||
{
|
||||
months = i;
|
||||
break;
|
||||
}
|
||||
else if (pastYearDate.AddMonths(i) >= today)
|
||||
{
|
||||
months = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int days = today.Subtract(pastYearDate.AddMonths(months)).Days;
|
||||
if (today.Day < pastYearDate.Day)
|
||||
{
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) > System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days += 1;
|
||||
}
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) < System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days -= 1;
|
||||
}
|
||||
}
|
||||
// int Hours = Today.Subtract(PastYearDate).Hours;
|
||||
// int Minutes = Today.Subtract(PastYearDate).Minutes;
|
||||
// int Seconds = Today.Subtract(PastYearDate).Seconds;
|
||||
Console.WriteLine(today);
|
||||
Console.WriteLine(pastYearDate);
|
||||
Console.WriteLine(months);
|
||||
Console.WriteLine(pastYearDate.AddMonths(months));
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(years == 0 ? "" : $"{years} ปี ");
|
||||
sb.Append(months == 0 ? "" : $"{months} เดือน ");
|
||||
sb.Append(days == 0 ? "" : $"{days} วัน ");
|
||||
return sb.ToString();
|
||||
}
|
||||
DateTime today = endDate;
|
||||
DateTime birthDate = Convert.ToDateTime(startDate).AddDays(-1);
|
||||
int years = new DateTime(endDate.Subtract(birthDate).Ticks).Year - 1;
|
||||
DateTime pastYearDate = birthDate.AddYears(years);
|
||||
int months = 0;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
if (pastYearDate.AddMonths(i) == today)
|
||||
{
|
||||
months = i;
|
||||
break;
|
||||
}
|
||||
else if (pastYearDate.AddMonths(i) >= today)
|
||||
{
|
||||
months = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int days = today.Subtract(pastYearDate.AddMonths(months)).Days;
|
||||
if (today.Day < pastYearDate.Day)
|
||||
{
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) > System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days += 1;
|
||||
}
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) < System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days -= 1;
|
||||
}
|
||||
}
|
||||
// int Hours = Today.Subtract(PastYearDate).Hours;
|
||||
// int Minutes = Today.Subtract(PastYearDate).Minutes;
|
||||
// int Seconds = Today.Subtract(PastYearDate).Seconds;
|
||||
Console.WriteLine(today);
|
||||
Console.WriteLine(pastYearDate);
|
||||
Console.WriteLine(months);
|
||||
Console.WriteLine(pastYearDate.AddMonths(months));
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(years == 0 ? "" : $"{years} ปี ");
|
||||
sb.Append(months == 0 ? "" : $"{months} เดือน ");
|
||||
sb.Append(days == 0 ? "" : $"{days} วัน ");
|
||||
return sb.ToString();
|
||||
}
|
||||
public static CalculateBetweenDateV2ValueObj CalculateBetweenDateV2Value(this DateTime startDate, DateTime endDate)
|
||||
{
|
||||
// if (startDate == null || endDate == null)
|
||||
// return null;
|
||||
DateTime today = endDate.AddDays(1);
|
||||
DateTime birthDate = startDate;
|
||||
int years = new DateTime(endDate.Subtract(birthDate).Ticks).Year - 1;
|
||||
DateTime pastYearDate = birthDate.AddYears(years);
|
||||
int months = 0;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
if (pastYearDate.AddMonths(i) == today)
|
||||
{
|
||||
months = i;
|
||||
break;
|
||||
}
|
||||
else if (pastYearDate.AddMonths(i) >= today)
|
||||
{
|
||||
months = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int days = today.Subtract(pastYearDate.AddMonths(months)).Days;
|
||||
if (today.Day < pastYearDate.Day)
|
||||
{
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) > System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days += 1;
|
||||
}
|
||||
if (System.DateTime.DaysInMonth(pastYearDate.Year, pastYearDate.Month) < System.DateTime.DaysInMonth(pastYearDate.AddMonths(months).Year, pastYearDate.AddMonths(months).Month))
|
||||
{
|
||||
days -= 1;
|
||||
}
|
||||
}
|
||||
if (days >= 30)
|
||||
{
|
||||
months = months + 1;
|
||||
days = 0;
|
||||
if (months >= 12)
|
||||
{
|
||||
years = years + 1;
|
||||
months = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
var sb = new StringBuilder();
|
||||
sb.Clear();
|
||||
sb.Append(years == 0 ? "" : $"{years} ปี ");
|
||||
sb.Append(months == 0 ? "" : $"{months} เดือน ");
|
||||
sb.Append(days == 0 ? "" : $"{days} วัน ");
|
||||
return new CalculateBetweenDateV2ValueObj { years = years, months = months, days = days };
|
||||
}
|
||||
public class CalculateBetweenDateV2ValueObj
|
||||
{
|
||||
public int years { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
public int months { get; set; }
|
||||
|
||||
public int days { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -22,15 +22,15 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
private readonly CandidateReportRepository _service;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly MinIOService _minIOService;
|
||||
private readonly MinIOExamService _minIOExamService;
|
||||
|
||||
public CandidateReportController(CandidateReportRepository service, IWebHostEnvironment hostingEnvironment,
|
||||
MinIOService minIOService, IConfiguration configuration)
|
||||
MinIOExamService minIOExamService, IConfiguration configuration)
|
||||
{
|
||||
_service = service;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_configuration = configuration;
|
||||
_minIOService = minIOService;
|
||||
_minIOExamService = minIOExamService;
|
||||
}
|
||||
|
||||
#region ใบสมัคร
|
||||
|
|
@ -44,6 +44,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("{exportType}/{Id}")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetExamCandidate([FromRoute] Guid Id, string exportType = "pdf")
|
||||
{
|
||||
var candidate = await _service.GetExamCandidateAsync(Id);
|
||||
|
|
@ -71,14 +72,15 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"];
|
||||
tblData.DataSource = careers;
|
||||
|
||||
Console.WriteLine("000000");
|
||||
if (avatar != Guid.Parse("00000000-0000-0000-0000-000000000000"))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get avatar Image
|
||||
var picContent = (await _minIOService.DownloadFileAsync(avatar)).FileContent;
|
||||
var picContent = await _minIOExamService.DownloadFileAsync(avatar);
|
||||
var pictureBox = (Telerik.Reporting.PictureBox)report.Items["detailSection1"].Items["picAvatar"];
|
||||
pictureBox.Value = Image.FromStream(new MemoryStream(picContent));
|
||||
pictureBox.Value = Image.FromStream(new MemoryStream(picContent.FileContent));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา
|
||||
#region 14,15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา
|
||||
/// <summary>
|
||||
/// 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา
|
||||
/// </summary>
|
||||
|
|
@ -500,166 +500,6 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา (ยกเลิกใช้งาน)
|
||||
///// <summary>
|
||||
///// 15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
||||
///// </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("15/{exportType}/{id}")]
|
||||
//public async Task<ActionResult<ResponseObject>> GetProbation15ConvertReportAsync(Guid id, string exportType = "pdf")
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// string authorizationHeader = Request.Headers["Authorization"];
|
||||
// string token = string.Empty;
|
||||
|
||||
// if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||||
// {
|
||||
// token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||||
// var evaluateRecord = await _repository.GetEvaluateRecordAsync(id, token);
|
||||
|
||||
// if (evaluateRecord != null)
|
||||
// {
|
||||
// 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", $"15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา-1.trdp");
|
||||
// var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา-2.trdp");
|
||||
|
||||
// ReportPackager reportPacker = new ReportPackager();
|
||||
// Telerik.Reporting.Report? report = null;
|
||||
// Telerik.Reporting.Report? report2 = null;
|
||||
|
||||
// using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
// using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
|
||||
// {
|
||||
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
|
||||
// }
|
||||
|
||||
// report.ReportParameters["Name"].Value = evaluateRecord.GetType().GetProperty("Name").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["Position"].Value = evaluateRecord.GetType().GetProperty("Position").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["ExperimenteeName"].Value = evaluateRecord.GetType().GetProperty("ExperimenteeName").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["ExperimenteePosition"].Value = evaluateRecord.GetType().GetProperty("ExperimenteePosition").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["Department"].Value = evaluateRecord.GetType().GetProperty("Department").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["OrganizationOrganization"].Value = evaluateRecord.GetType().GetProperty("OrganizationOrganization").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["Oc"].Value = evaluateRecord.GetType().GetProperty("Oc").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["DateStart"].Value = evaluateRecord.GetType().GetProperty("DateStart").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["DateFinish"].Value = evaluateRecord.GetType().GetProperty("DateFinish").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["AchievementStrengthDesc1"].Value = evaluateRecord.GetType().GetProperty("AchievementStrengthDesc1").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["AchievementStrengthDesc2"].Value = evaluateRecord.GetType().GetProperty("AchievementStrengthDesc2").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["AchievementStrengthDesc3"].Value = evaluateRecord.GetType().GetProperty("AchievementStrengthDesc3").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["AchievementImproveDesc1"].Value = evaluateRecord.GetType().GetProperty("AchievementImproveDesc1").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["AchievementImproveDesc2"].Value = evaluateRecord.GetType().GetProperty("AchievementImproveDesc2").GetValue(evaluateRecord);
|
||||
// report.ReportParameters["AchievementImproveDesc3"].Value = evaluateRecord.GetType().GetProperty("AchievementImproveDesc3").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["BehaviorStrengthDesc1"].Value = evaluateRecord.GetType().GetProperty("BehaviorStrengthDesc1").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["BehaviorStrengthDesc2"].Value = evaluateRecord.GetType().GetProperty("BehaviorStrengthDesc2").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["BehaviorStrengthDesc3"].Value = evaluateRecord.GetType().GetProperty("BehaviorStrengthDesc3").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["BehaviorImproveDesc1"].Value = evaluateRecord.GetType().GetProperty("BehaviorImproveDesc1").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["BehaviorImproveDesc2"].Value = evaluateRecord.GetType().GetProperty("BehaviorImproveDesc2").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["BehaviorImproveDesc3"].Value = evaluateRecord.GetType().GetProperty("BehaviorImproveDesc3").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["Name"].Value = evaluateRecord.GetType().GetProperty("Name").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["Position"].Value = evaluateRecord.GetType().GetProperty("Position").GetValue(evaluateRecord);
|
||||
// report2.ReportParameters["MentorDate"].Value = evaluateRecord.GetType().GetProperty("MentorDate").GetValue(evaluateRecord);
|
||||
|
||||
// var _evaluateslist = new List<dynamic>();
|
||||
// dynamic evaluates = evaluateRecord.GetType().GetProperty("Evaluates").GetValue(evaluateRecord);
|
||||
// foreach (var evaluate in evaluates)
|
||||
// {
|
||||
// string Evaluate_expect_desc = string.Empty;
|
||||
// string Evaluate_output_desc = string.Empty;
|
||||
// int Evaluate_expect_level = 0;
|
||||
// int Evaluate_output_level = 0;
|
||||
// string Check_expect1 = string.Empty;
|
||||
// string Check_expect2 = string.Empty;
|
||||
// string Check_expect3 = string.Empty;
|
||||
// string Check_expect4 = string.Empty;
|
||||
// string Check_expect5 = string.Empty;
|
||||
// string Check_output1 = string.Empty;
|
||||
// string Check_output2 = string.Empty;
|
||||
// string Check_output3 = string.Empty;
|
||||
// string Check_output4 = string.Empty;
|
||||
// string Check_output5 = string.Empty;
|
||||
// var achievements = evaluate.achievements;
|
||||
// foreach (var achievement in achievements)
|
||||
// {
|
||||
// Evaluate_expect_desc = achievement.evaluate_expect_desc;
|
||||
// Evaluate_output_desc = achievement.evaluate_output_desc;
|
||||
// Evaluate_expect_level = achievement.evaluate_expect_level;
|
||||
// Evaluate_output_level = achievement.evaluate_output_level;
|
||||
// }
|
||||
// _evaluateslist.Add(new
|
||||
// {
|
||||
// No = evaluate.no,
|
||||
// Date_start = evaluate.date_start,
|
||||
// Date_finish = evaluate.date_finish,
|
||||
// Evaluate_expect_desc = $" - {Evaluate_expect_desc}",
|
||||
// Evaluate_output_desc = $" - {Evaluate_output_desc}",
|
||||
// Check_expect1 = Evaluate_expect_level == 1 ? "/" : string.Empty,
|
||||
// Check_expect2 = Evaluate_expect_level == 2 ? "/" : string.Empty,
|
||||
// Check_expect3 = Evaluate_expect_level == 3 ? "/" : string.Empty,
|
||||
// Check_expect4 = Evaluate_expect_level == 4 ? "/" : string.Empty,
|
||||
// Check_expect5 = Evaluate_expect_level == 5 ? "/" : string.Empty,
|
||||
// Check_output1 = Evaluate_output_level == 1 ? "/" : string.Empty,
|
||||
// Check_output2 = Evaluate_output_level == 2 ? "/" : string.Empty,
|
||||
// Check_output3 = Evaluate_output_level == 3 ? "/" : string.Empty,
|
||||
// Check_output4 = Evaluate_output_level == 4 ? "/" : string.Empty,
|
||||
// Check_output5 = Evaluate_output_level == 5 ? "/" : string.Empty,
|
||||
// ApplyLevel = evaluate.apply_level,
|
||||
// AchievementStrengthDesc = evaluate.achievement_strength_desc,
|
||||
// AchievementImproveDesc = evaluate.achievement_improve_desc,
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
// var tblEvaluate_1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
|
||||
// tblEvaluate_1.DataSource = _evaluateslist;
|
||||
|
||||
// var tblEvaluate_2 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||||
// tblEvaluate_2.DataSource = _evaluateslist;
|
||||
|
||||
// var reportBook = new ReportBook();
|
||||
// reportBook.Reports.Add(report);
|
||||
// reportBook.Reports.Add(report2);
|
||||
|
||||
// System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
// InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
// {
|
||||
// ReportDocument = reportBook,
|
||||
// };
|
||||
|
||||
// ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
// RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
// var content = result.DocumentBytes;
|
||||
// return File(content, mimeType, $"แบบบันทึกผล(สำหรับผู้บังคับบัญชา).{exportType.Trim().ToLower()}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return NotFound();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return Unauthorized();
|
||||
// }
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
||||
/// <summary>
|
||||
/// 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
||||
|
|
@ -1123,89 +963,7 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน (ยกเลิกใช้งาน)
|
||||
///// <summary>
|
||||
///// 18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน
|
||||
///// </summary>
|
||||
///// <param name="id">assign_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("18/{exportType}/{id}")]
|
||||
//public async Task<ActionResult<ResponseObject>> GetProbation18ConvertReportAsync(string id="9e8ec043-9f18-4f9a-bcde-3d11c909df19", string exportType = "pdf")
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// Guid Id = Guid.Parse(id);
|
||||
// string authorizationHeader = Request.Headers["Authorization"];
|
||||
// string token = string.Empty;
|
||||
|
||||
// if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||||
// {
|
||||
// token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||||
// var evaluateAssign = await _repository.GetEvaluateResultAssignAsync(Id, token);
|
||||
|
||||
// if (evaluateAssign != null)
|
||||
// {
|
||||
// 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", $"18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน-1.trdp");
|
||||
|
||||
// ReportPackager reportPacker = new ReportPackager();
|
||||
// Telerik.Reporting.Report? report = null;
|
||||
// //Telerik.Reporting.Report? report2 = null;
|
||||
|
||||
|
||||
// using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
// //using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
|
||||
// {
|
||||
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||
// //report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
|
||||
// }
|
||||
|
||||
// report.ReportParameters["Name"].Value = evaluateAssign.GetType().GetProperty("Name").GetValue(evaluateAssign);
|
||||
|
||||
// var reportBook = new ReportBook();
|
||||
// reportBook.Reports.Add(report);
|
||||
// //reportBook.Reports.Add(report2);
|
||||
|
||||
// System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
// InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
// {
|
||||
// ReportDocument = reportBook,
|
||||
// };
|
||||
|
||||
// ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
// RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
// var content = result.DocumentBytes;
|
||||
// return File(content, mimeType, $"แบบรายงานการประเมินผล(สำหรับประธาน).{exportType.Trim().ToLower()}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return NotFound();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return Unauthorized();
|
||||
// }
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// throw;
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
||||
#region 18,19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
||||
/// <summary>
|
||||
/// 19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
||||
/// </summary>
|
||||
|
|
@ -1237,29 +995,45 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
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", $"19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายเวลา.trdp");
|
||||
var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน-1.trdp");
|
||||
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายเวลา.trdp");
|
||||
ReportPackager reportPacker = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
Telerik.Reporting.Report? report1 = null;
|
||||
Telerik.Reporting.Report? report2 = null;
|
||||
using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
|
||||
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||||
report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
|
||||
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
|
||||
}
|
||||
|
||||
report.ReportParameters["EvaluateDateStart"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateStart").GetValue(evaluateAssign);
|
||||
report.ReportParameters["EvaluateDateFinish"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateFinish").GetValue(evaluateAssign);
|
||||
report.ReportParameters["Reson"].Value = evaluateAssign.GetType().GetProperty("Reson").GetValue(evaluateAssign);
|
||||
report.ReportParameters["DevelopComplete"].Value = evaluateAssign.GetType().GetProperty("DevelopComplete").GetValue(evaluateAssign);
|
||||
report.ReportParameters["PassResult"].Value = evaluateAssign.GetType().GetProperty("PassResult").GetValue(evaluateAssign);
|
||||
report.ReportParameters["ExpandMonth"].Value = evaluateAssign.GetType().GetProperty("ExpandMonth").GetValue(evaluateAssign);
|
||||
report.ReportParameters["ChairmanName"].Value = evaluateAssign.GetType().GetProperty("ChairmanName").GetValue(evaluateAssign);
|
||||
report.ReportParameters["ChairmanPosition"].Value = evaluateAssign.GetType().GetProperty("ChairmanPosition").GetValue(evaluateAssign);
|
||||
report.ReportParameters["ChairmanDate"].Value = evaluateAssign.GetType().GetProperty("ChairmanDate").GetValue(evaluateAssign);
|
||||
//สำหรับประธาน
|
||||
if((evaluateAssign.GetType().GetProperty("ExpandMonth").GetValue(evaluateAssign)).ToString() == "๐")
|
||||
{
|
||||
report1.DataSource = evaluateAssign;
|
||||
System.Collections.Hashtable deviceInfo_ = new System.Collections.Hashtable();
|
||||
InstanceReportSource instanceReportSource_ = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report1,
|
||||
};
|
||||
ReportProcessor reportProcessor_ = new ReportProcessor(_configuration);
|
||||
RenderingResult result_ = reportProcessor_.RenderReport($"{exportType}", instanceReportSource_, deviceInfo_);
|
||||
return File(result_.DocumentBytes, mimeType, $"แบบรายงานการประเมินผล.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
//กรณีขยายเวลา (ใช้รูปแบบเดิม)
|
||||
report2.ReportParameters["EvaluateDateStart"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateStart").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["EvaluateDateFinish"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateFinish").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["Reson"].Value = evaluateAssign.GetType().GetProperty("Reson").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["DevelopComplete"].Value = evaluateAssign.GetType().GetProperty("DevelopComplete").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["PassResult"].Value = evaluateAssign.GetType().GetProperty("PassResult").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["ExpandMonth"].Value = evaluateAssign.GetType().GetProperty("ExpandMonth").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["ChairmanName"].Value = evaluateAssign.GetType().GetProperty("ChairmanName").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["ChairmanPosition"].Value = evaluateAssign.GetType().GetProperty("ChairmanPosition").GetValue(evaluateAssign);
|
||||
report2.ReportParameters["ChairmanDate"].Value = evaluateAssign.GetType().GetProperty("ChairmanDate").GetValue(evaluateAssign);
|
||||
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||||
{
|
||||
ReportDocument = report,
|
||||
ReportDocument = report2,
|
||||
};
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||||
|
|
|
|||
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.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue