Merge branch 'develop' into work

This commit is contained in:
Kittapath 2023-10-12 14:37:53 +07:00
commit e3fb50932a
14 changed files with 385 additions and 41 deletions

View file

@ -340,6 +340,12 @@
<None Update="Reports\45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Reports\45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา-1.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Reports\45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา-2.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Reports\46-ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View file

@ -143,7 +143,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -262,7 +262,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -381,7 +381,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -500,7 +500,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -620,7 +620,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -741,7 +741,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -860,7 +860,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -981,7 +981,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -1105,7 +1105,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -1399,7 +1399,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -1521,7 +1521,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -1640,7 +1640,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
@ -1830,7 +1830,7 @@ namespace BMA.EHR.Report.Service.Controllers
report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName;
report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber();
report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber();
report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber();
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();

View file

@ -1,9 +1,12 @@
using BMA.EHR.Application.Repositories.Reports;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Insignias;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.EMMA;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.FileProviders;
using Swashbuckle.AspNetCore.Annotations;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
@ -441,14 +444,14 @@ namespace BMA.EHR.Report.Service.Controllers
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
}
report.ReportParameters["YearInsigniaPeriod"].Value = YearInsignalPeriod;
var tbl1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
var _Khr6List = new List<dynamic>();
foreach (var _data in data)
{
_Khr6List.Add(new
{
RowNo = _Khr6List.Count + 1,
RowNo = (_Khr6List.Count + 1).ToString().ToThaiNumber(),
DepartmentName = _data.GetType().GetProperty("DepartmentName").GetValue(_data),
G1Male = _data.GetType().GetProperty("G1Male").GetValue(_data),
G1Female = _data.GetType().GetProperty("G1Female").GetValue(_data),
@ -493,6 +496,7 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var data = await _repository.GetCoinReport(id);
var YearInsignalPeriod = await _repository.GetYearInsigniaPeriod(id);
var mimeType = "";
@ -502,35 +506,54 @@ 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", $"45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา-2.trdp");
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"45-บัญชีแสดงรายชื่อผู้ขอพระราชทานเหรียญจักรพรรดิมาลา.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["YearInsignalPeriod"].Value = YearInsignalPeriod;
//var _Khr3List = new List<dynamic>();
//int maxRows = 25;
//for (int i = 0; i < maxRows; i++)
string OCName = string.Empty;
//foreach (var info in data)
//{
// _Khr3List.Add(new
// {
// RowNo = i + 1,
// FullName = string.Empty
// });
// OCName = info.GetType().GetProperty("OCName").GetValue(info);
// break;
//}
report.ReportParameters["YearInsignalPeriod"].Value = YearInsignalPeriod;
report.ReportParameters["OCName"].Value = OCName;
var dataList = new List<dynamic>(data);
var detailList = new List<dynamic>();
//var tbl1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
//tbl1.DataSource = _Khr3List;
var ChkInsigniaName = string.IsNullOrEmpty(dataList[0].GetType().GetProperty("InsigniaName").GetValue(dataList[0]))? string.Empty: dataList[0].GetType().GetProperty("InsigniaName").GetValue(dataList[0]);
for (int i = 0; i < dataList.Count; i++)
{
detailList.Add(new
{
row = detailList.Count+1,
Number = (detailList.Count+1).ToString().ToThaiNumber(),
InsigniaName = dataList[i].GetType().GetProperty("InsigniaName").GetValue(dataList[i]),
FullName = dataList[i].GetType().GetProperty("FullName").GetValue(dataList[i]),
InsigniaInitial = dataList[i].GetType().GetProperty("InsigniaInitial").GetValue(dataList[i]),
Male = dataList[i].GetType().GetProperty("Male").GetValue(dataList[i]),
Female = dataList[i].GetType().GetProperty("Female").GetValue(dataList[i]),
}); ;
}
report.DataSource = detailList;
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 = report,
ReportDocument = reportBook,
};
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);

View file

@ -25,7 +25,7 @@ namespace BMA.EHR.Report.Service.Controllers
private readonly IWebHostEnvironment _hostingEnvironment;
private readonly IConfiguration _configuration;
//private readonly ProbationReportRepository _repository;
private readonly RetireReportRepository _service;
private readonly GenericReportGenerator _reportGenerator;
@ -33,12 +33,12 @@ namespace BMA.EHR.Report.Service.Controllers
#region " Constuctor and Destructor "
public ResignReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, /*ProbationReportRepository repository,*/ GenericReportGenerator reportGenerator)
public ResignReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, RetireReportRepository service, GenericReportGenerator reportGenerator)
{
_hostingEnvironment = hostingEnvironment;
_configuration = configuration;
//_repository = repository;
_service = service;
_reportGenerator = reportGenerator;
}
@ -57,11 +57,15 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("33/{exportType}/{id}")]
public IActionResult GetResign33ConvertReportAsync(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetResign33ConvertReportAsync(string id= "08dbca15-bb57-4b2e-8435-69116599421b", string exportType = "pdf")
{
try
{
Guid ids = Guid.Parse(id);
var resign = await _service.GetResignByUser(ids);
if (resign == null)
return NotFound();
var mimeType = "";
switch (exportType.Trim().ToLower())
{
@ -69,11 +73,38 @@ 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 FullName = resign.GetType().GetProperty("FirstName").GetValue(resign);
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
var contentData = _reportGenerator.GenerateReport(rptFile, exportType);
var rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"33-แบบฟอร์มหนังสือขอลาออกจากราชการ-2.trdp");
return File(contentData, mimeType, $"resign.{exportType.Trim().ToLower()}");
ReportPackager reportPacker = new ReportPackager();
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))
{
report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
}
report1.DataSource = resign;
var reportBook = new ReportBook();
reportBook.Reports.Add(report1);
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);
return File(result.DocumentBytes, mimeType, $"แบบฟอร์มหนังสือขอลาออกจากราชการ.{exportType.Trim().ToLower()}");
}
catch