diff --git a/BMA.EHR.Application/Repositories/Reports/TransferReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/TransferReportRepository.cs index b7b13e28..cb50e2b6 100644 --- a/BMA.EHR.Application/Repositories/Reports/TransferReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/TransferReportRepository.cs @@ -5,6 +5,7 @@ using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Responses; using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.HR; +using BMA.EHR.Domain.Models.MetaData; using BMA.EHR.Domain.Models.Organizations; using BMA.EHR.Domain.Models.Placement; using Microsoft.AspNetCore.Hosting; @@ -71,6 +72,74 @@ namespace BMA.EHR.Application.Repositories.Reports } #endregion + #region 4 + public async Task GetData4Transfer(Guid id) + { + var data = await _dbContext.Set().AsQueryable() + .Include(x => x.Profile) + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + var currentdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber().Remove(0, 16); + return new + { + CurrentDate = currentdate, + Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน", + Subject2 = $"ตรวจสอบหนี้สิน และภาระผูกพันกับกรุงเทพมหานครของข้าราชการ", + Subject3 = $"ตรวจสอบหนี้สินและภาระผูกพันของข้าราชการ", + Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร 173 ถนนดินสอ กทม. 10200", + Name = $"{data.Profile.Prefix?.Name}{data.Profile.FirstName} {data.Profile.LastName}", + Position = $"{data.Profile.Position}", + OrganizationOrganization = $"{data.Profile.OrganizationOrganization}", + }; + } + #endregion + + #region 5 + public async Task GetData5Transfer(Guid id) + { + var data = await _dbContext.Set().AsQueryable() + .Include(x => x.Profile) + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + var currentdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber().Remove(0, 16); + return new + { + CurrentDate = currentdate, + Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน", + Subject2 = $"ตรวจสอบพฤติการณ์ทางวินัย และภาระหนี้สิน (เงินกู้สวัสดิการข้าราชการ) ของข้าราชการ", + Subject3 = $"ตรวจสอบภาระผูกพันกับกรุงเทพมหานครเกี่ยวกับการลาศึกษา อบรม ของข้าราชการ", + Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร 173 ถนนดินสอ กทม. 10200", + Name = $"{data.Profile.Prefix?.Name}{data.Profile.FirstName} {data.Profile.LastName}", + Position = $"{data.Profile.Position}", + OrganizationOrganization = $"{data.Profile.OrganizationOrganization}", + }; + } + #endregion + + #region 6 + public async Task GetData6Transfer(Guid id) + { + var data = await _dbContext.Set().AsQueryable() + .Include(x => x.Profile) + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + var currentdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber().Remove(0, 16); + return new + { + CurrentDate = currentdate, + Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน", + Subject2 = $"ตรวจสอบพฤติการณ์ทางวินัย และภาระหนี้สิน (เงินกู้สวัสดิการข้าราชการ) ของข้าราชการ", + Subject3 = $"ตรวจสอบภาระผูกพันกับกรุงเทพมหานครเกี่ยวกับการลาศึกษา อบรม ของข้าราชการ", + Subject4 = $"ตรวจสอบหนี้สิน และภาระผูกพันกับกรุงเทพมหานครของข้าราชการ", + Subject5 = $"ตรวจสอบหนี้สินและภาระผูกพันของข้าราชการ", + Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร 173 ถนนดินสอ กทม. 10200", + Name = $"{data.Profile.Prefix?.Name}{data.Profile.FirstName} {data.Profile.LastName}", + Position = $"{data.Profile.Position}", + OrganizationOrganization = $"{data.Profile.OrganizationOrganization}", + }; + } + #endregion + #endregion } } diff --git a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj index 496a674e..2702983d 100644 --- a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj +++ b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj @@ -211,6 +211,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -598,6 +601,39 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + diff --git a/BMA.EHR.Report.Service/Controllers/TransferReportController.cs b/BMA.EHR.Report.Service/Controllers/TransferReportController.cs index 48301117..c458ed7b 100644 --- a/BMA.EHR.Report.Service/Controllers/TransferReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/TransferReportController.cs @@ -233,11 +233,11 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("4/{exportType}/{id}")] - public IActionResult GetTransfer4ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task > GetTransfer4ConvertReportAsync(Guid id, string exportType = "pdf") { try { - + var data = await _service.GetData4Transfer(id); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -246,11 +246,43 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-1.trdp"); + var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-2.trdp"); + var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-3.trdp"); - return File(contentData, mimeType, $"transfer.{exportType.Trim().ToLower()}"); + ReportPackager reportPacker = new ReportPackager(); + Telerik.Reporting.Report? report = null; + Telerik.Reporting.Report? report2 = null; + Telerik.Reporting.Report? report3 = null; + using (var sourceStream = System.IO.File.OpenRead(rptFile)) + using (var sourceStream2 = System.IO.File.OpenRead(rptFile2)) + using (var sourceStream3 = System.IO.File.OpenRead(rptFile3)) + { + report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); + report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2); + report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3); + } + + report.DataSource = data; + report2.DataSource = data; + report3.DataSource = data; + + var reportBook = new ReportBook(); + reportBook.Reports.Add(report); + reportBook.Reports.Add(report2); + reportBook.Reports.Add(report3); + + 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()}"); } catch { @@ -270,11 +302,11 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("5/{exportType}/{id}")] - public IActionResult GetTransfer5ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetTransfer5ConvertReportAsync(Guid id, string exportType = "pdf") { try { - + var data = await _service.GetData5Transfer(id); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -283,11 +315,43 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-1.trdp"); + var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-2.trdp"); + var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-3.trdp"); - return File(contentData, mimeType, $"transfer.{exportType.Trim().ToLower()}"); + ReportPackager reportPacker = new ReportPackager(); + Telerik.Reporting.Report? report = null; + Telerik.Reporting.Report? report2 = null; + Telerik.Reporting.Report? report3 = null; + using (var sourceStream = System.IO.File.OpenRead(rptFile)) + using (var sourceStream2 = System.IO.File.OpenRead(rptFile2)) + using (var sourceStream3 = System.IO.File.OpenRead(rptFile3)) + { + report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); + report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2); + report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3); + } + + report.DataSource = data; + report2.DataSource = data; + report3.DataSource = data; + + var reportBook = new ReportBook(); + reportBook.Reports.Add(report); + reportBook.Reports.Add(report2); + reportBook.Reports.Add(report3); + + 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()}"); } catch { @@ -307,11 +371,11 @@ namespace BMA.EHR.Report.Service.Controllers /// ไม่ได้ Login เข้าระบบ /// เมื่อเกิดข้อผิดพลาดในการทำงาน [HttpGet("6/{exportType}/{id}")] - public IActionResult GetTransfer6ConvertReportAsync(Guid id, string exportType = "pdf") + public async Task> GetTransfer6ConvertReportAsync(Guid id, string exportType = "pdf") { try { - + var data = await _service.GetData6Transfer(id); var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -319,12 +383,55 @@ 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", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-1.trdp"); + var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-2.trdp"); + var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-3.trdp"); + var rptFile4 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-4.trdp"); + var rptFile5 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-5.trdp"); - var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + ReportPackager reportPacker = new ReportPackager(); + Telerik.Reporting.Report? report = null; + Telerik.Reporting.Report? report2 = null; + Telerik.Reporting.Report? report3 = null; + Telerik.Reporting.Report? report4 = null; + Telerik.Reporting.Report? report5 = null; - return File(contentData, mimeType, $"transfer.{exportType.Trim().ToLower()}"); + using (var sourceStream = System.IO.File.OpenRead(rptFile)) + using (var sourceStream2 = System.IO.File.OpenRead(rptFile2)) + using (var sourceStream3 = System.IO.File.OpenRead(rptFile3)) + using (var sourceStream4 = System.IO.File.OpenRead(rptFile4)) + using (var sourceStream5 = System.IO.File.OpenRead(rptFile5)) + { + report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); + report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2); + report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3); + report4 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream4); + report5 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream5); + } + report.DataSource = data; + report2.DataSource = data; + report3.DataSource = data; + report4.DataSource = data; + report5.DataSource = data; + + var reportBook = new ReportBook(); + reportBook.Reports.Add(report); + reportBook.Reports.Add(report2); + reportBook.Reports.Add(report3); + reportBook.Reports.Add(report4); + reportBook.Reports.Add(report5); + + 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()}"); } catch { diff --git a/BMA.EHR.Report.Service/Reports/22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-2.trdp b/BMA.EHR.Report.Service/Reports/22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-2.trdp index c639afb7..ba2b0a3f 100644 Binary files a/BMA.EHR.Report.Service/Reports/22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-2.trdp and b/BMA.EHR.Report.Service/Reports/22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-1.trdp b/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-1.trdp index 1ec5e612..9f436336 100644 Binary files a/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-1.trdp and b/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-1.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-2.trdp b/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-2.trdp index 8d3c5570..35b5e767 100644 Binary files a/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-2.trdp and b/BMA.EHR.Report.Service/Reports/23-หนังสือยินยอมให้โอน-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-1.trdp b/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-1.trdp new file mode 100644 index 00000000..b782ecea Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-1.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-2.trdp b/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-2.trdp new file mode 100644 index 00000000..3c9b591c Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-3.trdp b/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-3.trdp new file mode 100644 index 00000000..4081f0d7 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/24-หนังสือแจ้งสหกรณ์ออมทรัพย์-3.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-1.trdp b/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-1.trdp new file mode 100644 index 00000000..6b89db0f Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-1.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-2.trdp b/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-2.trdp new file mode 100644 index 00000000..11333af2 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-3.trdp b/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-3.trdp new file mode 100644 index 00000000..3d2c3f1f Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/25-หนังสือถึงสํานักงานการเจ้าหน้าที่-3.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-1.trdp b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-1.trdp new file mode 100644 index 00000000..43cccd37 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-1.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-2.trdp b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-2.trdp new file mode 100644 index 00000000..11333af2 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-3.trdp b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-3.trdp new file mode 100644 index 00000000..3d2c3f1f Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-3.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-4.trdp b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-4.trdp new file mode 100644 index 00000000..a4612d3c Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-4.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-5.trdp b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-5.trdp new file mode 100644 index 00000000..a49c2842 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/26-หนังสือถึงสถาบันพัฒนาข้าราชการ-5.trdp differ