From 509a9933b024d259ad1d3a6c3d8e7b0653410f48 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 26 Jun 2024 09:56:34 +0700 Subject: [PATCH 1/8] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20comm?= =?UTF-8?q?and=20report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/CommandReportController.cs | 1114 ++++++++++------- 1 file changed, 631 insertions(+), 483 deletions(-) diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index 99245de5..1221274d 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -1011,7 +1011,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-09 " - private async Task GenerateCommandReportType09_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType09_Cover(Guid commandId, string exportType) { try { @@ -1045,34 +1045,34 @@ namespace BMA.EHR.Report.Service.Controllers MilitaryCommanDate = raw_data.MilitaryCommanDate == null ? "" : raw_data.MilitaryCommanDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-7.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-7.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1080,7 +1080,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType09_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType09_Attachment(Guid commandId, string exportType) { try { @@ -1091,39 +1091,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType09AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-8.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-8.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1135,7 +1135,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-10 " - private async Task GenerateCommandReportType10_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType10_Cover(Guid commandId, string exportType) { try { @@ -1176,34 +1176,34 @@ namespace BMA.EHR.Report.Service.Controllers Duration = raw_data.ProbationStartDate == null || raw_data.ProbationEndDate == null ? "" : raw_data.ProbationStartDate.Value.CalculateBetweenDateV2(raw_data.ProbationEndDate.Value).ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"10-แต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"10-แต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1215,7 +1215,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-11 " - private async Task GenerateCommandReportType11_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType11_Cover(Guid commandId, string exportType) { try { @@ -1226,31 +1226,31 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType11Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"11-คำสั่งให้ข้าราชการที่ผ่านการประเมิน รับราชการต่อไป.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"11-คำสั่งให้ข้าราชการที่ผ่านการประเมิน รับราชการต่อไป.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -1262,7 +1262,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-12 " - private async Task GenerateCommandReportType12_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType12_Cover(Guid commandId, string exportType) { try { @@ -1273,31 +1273,31 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType11Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"12-คำสั่งให้ข้าราชการที่ไม่ผ่านการประเมิน ออกจากราชการ.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"12-คำสั่งให้ข้าราชการที่ไม่ผ่านการประเมิน ออกจากราชการ.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -1309,7 +1309,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-13 " - private async Task GenerateCommandReportType13_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType13_Cover(Guid commandId, string exportType) { try { @@ -1339,34 +1339,34 @@ namespace BMA.EHR.Report.Service.Controllers ReceiveOrganizationName = raw_data.ReceiveOrganizationName, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1374,7 +1374,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType13_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType13_Attachment(Guid commandId, string exportType) { try { @@ -1385,39 +1385,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType13AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-2.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-2.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1429,7 +1429,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-14 " - private async Task GenerateCommandReportType14_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType14_Cover(Guid commandId, string exportType) { try { @@ -1461,34 +1461,34 @@ namespace BMA.EHR.Report.Service.Controllers ConclusionReceiveDate = raw_data.ConclusionReceiveDate == null ? "" : raw_data.ConclusionReceiveDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ-5.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ-5.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1496,7 +1496,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType14_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType14_Attachment(Guid commandId, string exportType) { try { @@ -1507,39 +1507,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType14AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1551,7 +1551,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-15 " - private async Task GenerateCommandReportType15_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType15_Cover(Guid commandId, string exportType) { try { @@ -1580,34 +1580,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-1.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-1.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1615,7 +1615,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType15_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType15_Attachment(Guid commandId, string exportType) { try { @@ -1626,39 +1626,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType15AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1670,7 +1670,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-16 " - private async Task GenerateCommandReportType16_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType16_Cover(Guid commandId, string exportType) { try { @@ -1702,34 +1702,34 @@ namespace BMA.EHR.Report.Service.Controllers //}; var data = await _commandReportRepository.GetCommandType16Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1741,7 +1741,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-17 " - private async Task GenerateCommandReportType17_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType17_Cover(Guid commandId, string exportType) { try { @@ -1770,34 +1770,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1805,7 +1805,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType17_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType17_Attachment(Guid commandId, string exportType) { try { @@ -1816,39 +1816,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType17AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1860,7 +1860,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-18 " - private async Task GenerateCommandReportType18_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType18_Cover(Guid commandId, string exportType) { try { @@ -1871,31 +1871,31 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType18Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"37-คำสั่งให้ออกจากราชการ.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"37-คำสั่งให้ออกจากราชการ.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -2093,7 +2093,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-21 " - private async Task GenerateCommandReportType21_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType21_Cover(Guid commandId, string exportType) { try { @@ -2123,40 +2123,40 @@ namespace BMA.EHR.Report.Service.Controllers Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId); - var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId); + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = receiver; - tblData.DataSource = receiver; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2168,7 +2168,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-22 " - private async Task GenerateCommandReportType22_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType22_Cover(Guid commandId, string exportType) { try { @@ -2199,34 +2199,34 @@ namespace BMA.EHR.Report.Service.Controllers // ConclusionReturnDate = raw_data.ConclusionReturnDate == null ? "" : raw_data.ConclusionReturnDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน).trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน).trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2234,7 +2234,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType22_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType22_Attachment(Guid commandId, string exportType) { try { @@ -2245,39 +2245,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType22AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน)-แนบท้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน)-แนบท้าย.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2288,7 +2288,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-23 " - private async Task GenerateCommandReportType23_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType23_Cover(Guid commandId, string exportType) { try { @@ -2318,40 +2318,40 @@ namespace BMA.EHR.Report.Service.Controllers Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var receiver = await _commandReportRepository.GetCommandType23AttachmentAsync(commandId); - var receiver = await _commandReportRepository.GetCommandType23AttachmentAsync(commandId); + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"35-คำสั่งอนุญาตให้ลูกจ้างลาออก.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"35-คำสั่งอนุญาตให้ลูกจ้างลาออก.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = receiver; - tblData.DataSource = receiver; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2363,7 +2363,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-24 " - private async Task GenerateCommandReportType24_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType24_Cover(Guid commandId, string exportType) { try { @@ -2396,34 +2396,34 @@ namespace BMA.EHR.Report.Service.Controllers // ConclusionReturnDate = raw_data.ConclusionReturnDate == null ? "" : raw_data.ConclusionReturnDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย).trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย).trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2431,7 +2431,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType24_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType24_Attachment(Guid commandId, string exportType) { try { @@ -2442,39 +2442,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType24AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)-แนบท้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)-แนบท้าย.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -3302,7 +3302,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType09_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-09", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3341,7 +3348,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType09_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + //template = "DP6_006", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3384,7 +3398,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType10_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-10", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3427,7 +3448,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType11_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-11", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3470,7 +3498,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType12_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-12", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3513,7 +3548,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType13_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-13", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3552,7 +3594,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType13_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-13", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3595,7 +3644,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType14_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-14", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3634,7 +3690,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType14_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-14", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3677,7 +3740,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType15_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-15", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3716,7 +3786,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType15_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-15", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3759,7 +3836,15 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType16_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + + var data = new + { + template = "C-PM-16", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3802,7 +3887,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType17_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-17", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3841,7 +3933,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType17_Attachment(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-17", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3884,7 +3983,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType18_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-18", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4055,7 +4161,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType21_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-21", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4098,7 +4211,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType22_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-22", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4137,7 +4257,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType22_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-22", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4180,7 +4307,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType23_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-23", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4223,7 +4357,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType24_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-24", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4262,7 +4403,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType24_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-24", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { From d7bed1516f89cc6d00f978499faf4501461dde38 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 26 Jun 2024 16:46:40 +0700 Subject: [PATCH 2/8] command report 01-09 --- .../Controllers/CommandReportController.cs | 858 ++++++++++-------- 1 file changed, 481 insertions(+), 377 deletions(-) diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index 1221274d..45fde803 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -54,7 +54,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-01 " - private async Task GenerateCommandReportType01_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType01_Cover(Guid commandId, string exportType) { try { @@ -83,34 +83,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -118,7 +118,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType01_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType01_Attachment(Guid commandId, string exportType) { try { @@ -129,39 +129,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType01AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -173,7 +173,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-02 " - private async Task GenerateCommandReportType02_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType02_Cover(Guid commandId, string exportType) { try { @@ -202,34 +202,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-3.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-3.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -237,7 +237,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType02_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType02_Attachment(Guid commandId, string exportType) { try { @@ -248,39 +248,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType02AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-4.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-4.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -292,7 +292,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-03 " - private async Task GenerateCommandReportType03_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType03_Cover(Guid commandId, string exportType) { try { @@ -321,34 +321,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน-Head.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน-Head.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -356,7 +356,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType03_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType03_Attachment(Guid commandId, string exportType) { try { @@ -367,39 +367,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType03AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -411,7 +411,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-04 " - private async Task GenerateCommandReportType04_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType04_Cover(Guid commandId, string exportType) { try { @@ -440,34 +440,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน-Head.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน-Head.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -475,7 +475,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType04_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType04_Attachment(Guid commandId, string exportType) { try { @@ -486,38 +486,38 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType03AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -529,7 +529,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-05 " - private async Task GenerateCommandReportType05_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType05_Cover(Guid commandId, string exportType) { try { @@ -560,34 +560,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -595,7 +595,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType05_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType05_Attachment(Guid commandId, string exportType) { try { @@ -606,39 +606,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -650,7 +650,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-06 " - private async Task GenerateCommandReportType06_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType06_Cover(Guid commandId, string exportType) { try { @@ -681,34 +681,34 @@ namespace BMA.EHR.Report.Service.Controllers ConclusionMeetingDate = raw_data.ConclusionMeetingDate == null ? "" : raw_data.ConclusionMeetingDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -716,7 +716,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType06_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType06_Attachment(Guid commandId, string exportType) { try { @@ -727,39 +727,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -771,7 +771,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-07 " - private async Task GenerateCommandReportType07_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType07_Cover(Guid commandId, string exportType) { try { @@ -800,34 +800,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-คำสั่งย้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-คำสั่งย้าย.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -835,7 +835,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType07_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType07_Attachment(Guid commandId, string exportType) { try { @@ -846,39 +846,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType07AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-แนบท้ายคำสั่งย้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-แนบท้ายคำสั่งย้าย.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -890,7 +890,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-08 " - private async Task GenerateCommandReportType08_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType08_Cover(Guid commandId, string exportType) { try { @@ -921,34 +921,34 @@ namespace BMA.EHR.Report.Service.Controllers ConclusionReturnDate = raw_data.ConclusionReturnDate == null ? "" : raw_data.ConclusionReturnDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-5.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-5.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //report.DataSource = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -956,7 +956,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType08_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType08_Attachment(Guid commandId, string exportType) { try { @@ -967,39 +967,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType08AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-6.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-6.trdp"); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //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.ToThaiFullDate2().ToThaiNumber(); - 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.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2640,7 +2640,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType01_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-01", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2679,7 +2686,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType01_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-01", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2722,8 +2736,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType02_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); - + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-02", + reportName = "docx-report", + data = contentData + }; + return Success(data); //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-3.trdp"); //var contentData = _reportGenerator.GenerateReport(rptFile, exportType); @@ -2767,7 +2787,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType02_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-02", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2810,7 +2837,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType03_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-03", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2849,7 +2883,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType03_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-03", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2892,7 +2933,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType04_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-04", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2931,7 +2979,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType04_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-04", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2974,7 +3029,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType05_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-05", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3013,7 +3075,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType05_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-05", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3056,7 +3125,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType06_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-06", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3095,7 +3171,7 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType06_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -3138,7 +3214,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType07_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-07", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3177,7 +3260,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType07_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-07", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3220,7 +3310,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType08_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-08", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3259,7 +3356,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType08_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-08", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { From 70f45340beae717d49c57b35b572cd5296367c76 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 26 Jun 2024 17:16:32 +0700 Subject: [PATCH 3/8] no message --- .../Controllers/CommandReportController.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index 45fde803..bccde4da 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -3172,6 +3172,13 @@ namespace BMA.EHR.Report.Service.Controllers var contentData = await GenerateCommandReportType06_Attachment(id, exportType); //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-06", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { From b3ed889433a599692220287b4f8cdb44854e9dcd Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 26 Jun 2024 18:05:12 +0700 Subject: [PATCH 4/8] =?UTF-8?q?=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B9=80?= =?UTF-8?q?=E0=B8=A5=E0=B8=B7=E0=B8=B4=E0=B8=AD=E0=B8=81=E0=B9=84=E0=B8=9B?= =?UTF-8?q?=E0=B9=81=E0=B8=A5=E0=B9=89=E0=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlacementAppointmentController.cs | 38 +++++++++---------- .../PlacementAppointmentEmployeeController.cs | 38 +++++++++---------- .../Controllers/PlacementController.cs | 30 +++++++++------ .../Controllers/PlacementReceiveController.cs | 36 +++++++++--------- .../PlacementRelocationController.cs | 19 ---------- 5 files changed, 75 insertions(+), 86 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index d21433f7..e17edde6 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -662,24 +662,24 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - // /// - // /// หน่วยงานที่ถูกเลือกไปแล้ว - // /// - // /// - // /// - // /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - // /// ไม่ได้ Login เข้าระบบ - // /// เมื่อเกิดข้อผิดพลาดในการทำงาน - // [HttpGet("use")] - // public async Task> GetAppointmentsUse() - // { - // var appointments = await _context.PlacementAppointments - // // .Where(x => x.PositionNumber != null) - // // .Where(x => x.Profile.ProfileType == "officer") - // // .Select(x => x.PositionNumber.Id) - // .ToListAsync(); - - // return Success(appointments); - // } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetAppointmentsUse() + { + var appointments = await _context.PlacementAppointments + .Where(x => x.posmasterId != null) + .Where(x => x.Status != "DONE") + .Where(x => x.type == "OFFICER") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(appointments); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs index aa1c5ed3..7f7e9afe 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs @@ -648,24 +648,24 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - // /// - // /// หน่วยงานที่ถูกเลือกไปแล้ว - // /// - // /// - // /// - // /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - // /// ไม่ได้ Login เข้าระบบ - // /// เมื่อเกิดข้อผิดพลาดในการทำงาน - // [HttpGet("use")] - // public async Task> GetAppointmentsUse() - // { - // var appointments = await _context.PlacementAppointments - // .Where(x => x.PositionNumber != null) - // .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") - // .Select(x => x.PositionNumber.Id) - // .ToListAsync(); - - // return Success(appointments); - // } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetAppointmentsUse() + { + var appointments = await _context.PlacementAppointments + .Where(x => x.posmasterId != null) + .Where(x => x.Status != "DONE") + .Where(x => x.type == "EMPLOYEE") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(appointments); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index b141ebbb..14bd46aa 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1045,17 +1045,6 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - [HttpGet("position/use")] - public async Task> GetPositionUse() - { - var position = await _context.PlacementProfiles - .Where(x => x.PositionNumber != null) - .Select(x => x.PositionNumber) - .ToListAsync(); - - return Success(position); - } - [HttpPut("position/{personalId:length(36)}")] public async Task> UpdatePositionDraft([FromBody] List items, Guid personalId) { @@ -1283,5 +1272,24 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetPositionUse() + { + var position = await _context.PlacementProfiles + .Where(x => x.posmasterId != null) + .Where(x => x.PlacementStatus != "CONTAIN") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(position); + } + } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 8f9c2df5..42eb09e7 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -794,23 +794,23 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - // /// - // /// หน่วยงานที่ถูกเลือกไปแล้ว - // /// - // /// - // /// - // /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - // /// ไม่ได้ Login เข้าระบบ - // /// เมื่อเกิดข้อผิดพลาดในการทำงาน - // [HttpGet("use")] - // public async Task> GetReceiveUse() - // { - // var receives = await _context.PlacementReceives - // .Where(x => x.PositionNumber != null) - // .Select(x => x.PositionNumber.Id) - // .ToListAsync(); - - // return Success(receives); - // } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetPositionUse() + { + var position = await _context.PlacementReceives + .Where(x => x.posmasterId != null) + .Where(x => x.Status != "DONE") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(position); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs index 183e242f..81ca987b 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs @@ -525,24 +525,5 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - - /// - /// หน่วยงานที่ถูกเลือกไปแล้ว - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("use")] - public async Task> GetRelocationUse() - { - var relocation = await _context.PlacementRelocations - .Where(x => x.PositionNumber != null) - .Select(x => x.PositionNumber.Id) - .ToListAsync(); - - return Success(relocation); - } } } From 88f627a2c6427dc8d6d7290986fb60f63283b9c3 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 26 Jun 2024 22:57:50 +0700 Subject: [PATCH 5/8] array --- .../Controllers/CommandReportController.cs | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index bccde4da..fbb36e33 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -2521,11 +2521,11 @@ namespace BMA.EHR.Report.Service.Controllers RefRaw = raw_data.RefRaw == null ? "" : raw_data.RefRaw.ToThaiNumber(), Result = raw_data.Result == null ? "" : raw_data.Result.ToThaiNumber(), - Fullname = raw_data_profile == null ? "" : raw_data_profile.fullName, - Positionname = raw_data_profile == null ? "" : raw_data_profile.positionname, - Positionno = raw_data_profile == null ? "" : raw_data_profile.positionno.ToThaiNumber(), - Organizationname = raw_data_profile == null ? "" : raw_data_profile.organizationname.ToThaiNumber(), - Salary = raw_data_profile == null ? "" : raw_data_profile.salary.ToThaiNumber(), + Fullname = raw_data_profile == null ? "" : raw_data_profile.fullName != null ? raw_data_profile.fullName : "-", + Positionname = raw_data_profile == null ? "" : raw_data_profile.positionname != null ? raw_data_profile.positionname : "-", + Positionno = raw_data_profile == null ? "" : raw_data_profile.positionno != null ? raw_data_profile.positionno.ToThaiNumber() : "-", + Organizationname = raw_data_profile == null ? "" : raw_data_profile.organizationname != null ? raw_data_profile.organizationname.ToThaiNumber() : "-", + Salary = raw_data_profile == null ? "" : raw_data_profile.salary != null ? raw_data_profile.salary.ToThaiNumber() : "-", OrderDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(), SignatoryBy = raw_data.AuthorizedUserFullName, @@ -2543,6 +2543,7 @@ namespace BMA.EHR.Report.Service.Controllers } #endregion + #region " C-PM-33 " private async Task GenerateCommandReportType33_Cover(Guid commandId, string exportType) @@ -3564,7 +3565,10 @@ namespace BMA.EHR.Report.Service.Controllers { template = "C-PM-11", reportName = "docx-report", - data = contentData + data = new + { + data = contentData + } }; return Success(data); } @@ -3614,7 +3618,10 @@ namespace BMA.EHR.Report.Service.Controllers { template = "C-PM-12", reportName = "docx-report", - data = contentData + data = new + { + data = contentData + } }; return Success(data); } @@ -3953,7 +3960,10 @@ namespace BMA.EHR.Report.Service.Controllers { template = "C-PM-16", reportName = "docx-report", - data = contentData + data = new + { + data = contentData + } }; return Success(data); } @@ -4099,7 +4109,10 @@ namespace BMA.EHR.Report.Service.Controllers { template = "C-PM-18", reportName = "docx-report", - data = contentData + data = new + { + data = contentData + } }; return Success(data); } @@ -4593,6 +4606,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-26 คำสั่งให้ออกจากราชการไว้ก่อนxxxx " /// @@ -4655,6 +4669,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-27 คำสั่งลงโทษ ภาคทัณฑ์ " /// @@ -4717,6 +4732,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-28 คำสั่งลงโทษ ตัดเงินเดือน " /// @@ -4779,6 +4795,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-29 คำสั่งลงโทษ ลดขั้นเงินเดือน " /// @@ -4841,6 +4858,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-30 คำสั่งเพิ่มโทษ " /// @@ -4903,6 +4921,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-31 คำสั่งงดโทษ " /// @@ -4965,6 +4984,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-32 คำสั่งยุติเรื่อง " /// @@ -5027,6 +5047,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-33 คำสั่งยุติเรื่อง " /// @@ -5073,6 +5094,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-34 คำสั่งยุติเรื่อง " /// @@ -5119,6 +5141,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-35 คำสั่งยุติเรื่อง " /// @@ -5165,6 +5188,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-36 คำสั่งยุติเรื่อง " /// @@ -5211,6 +5235,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-37 คำสั่งยุติเรื่อง " /// @@ -5257,6 +5282,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #endregion } } From 410db008125d2be3946b61bfe51167f0935bb475 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 26 Jun 2024 23:28:27 +0700 Subject: [PATCH 6/8] =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87=E0=B8=A7=E0=B8=B4=E0=B8=99=E0=B8=B1=E0=B8=A2?= =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B8=A5?= =?UTF-8?q?=E0=B8=87=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=A2=E0=B8=B5?= =?UTF-8?q?=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 42 ++++++- .../Controllers/DisciplineResultController.cs | 113 +++++++++++++++++- .../Requests/PassDisciplineResponse.cs | 5 + 3 files changed, 155 insertions(+), 5 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index daf17ebb..bc0482e2 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -2764,7 +2764,7 @@ namespace BMA.EHR.Application.Repositories.Commands isProbation = true, isLeave = false, dateRetire = (DateTime?)null, - dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate, + dateAppoint = command.CommandAffectDate == null ? null : command.CommandAffectDate, dateStart = command.CommandAffectDate == null ? null : command.CommandAffectDate, govAgeAbsent = 0, govAgePlus = 0, @@ -5562,6 +5562,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var _baseAPI = _configuration["API"]; @@ -5710,6 +5714,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var _baseAPI = _configuration["API"]; @@ -6346,6 +6354,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6475,6 +6487,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6605,6 +6621,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6735,6 +6755,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6865,6 +6889,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ลดขั้นเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6995,6 +7023,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งเพิ่มโทษ" }); var baseAPI = _configuration["API"]; @@ -7125,6 +7157,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งงดโทษ" }); var baseAPI = _configuration["API"]; @@ -7255,6 +7291,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งยุติเรื่อง" }); var baseAPI = _configuration["API"]; diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 2bc4032c..ade28dd0 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -11,6 +11,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Swashbuckle.AspNetCore.Annotations; +using System.Configuration; +using System.Net.Http.Headers; using System.Security.Claims; namespace BMA.EHR.DisciplineResult.Service.Controllers @@ -26,15 +28,18 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers private readonly DisciplineDbContext _context; private readonly MinIODisciplineService _documentService; private readonly IHttpContextAccessor _httpContextAccessor; + private readonly IConfiguration _configuration; public DisciplineResultController(DisciplineDbContext context, MinIODisciplineService documentService, - IHttpContextAccessor httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + IConfiguration configuration) { // _repository = repository; _context = context; _documentService = documentService; _httpContextAccessor = httpContextAccessor; + _configuration = configuration; } #region " Properties " @@ -42,6 +47,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value; + private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"]; #endregion @@ -465,6 +471,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x=>x.DisciplineDisciplinary) .Where(x => x.Status == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); @@ -472,6 +479,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data.Status = "NEW"; data.CommandTypeId = null; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data.DisciplineDisciplinary.Title, + level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } } await _context.SaveChangesAsync(); } @@ -492,6 +517,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) .Where(x => x.StatusDiscard == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); @@ -499,6 +525,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data.StatusDiscard = "NEW"; data.CommandTypeDiscardId = null; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data.DisciplineDisciplinary.Title, + level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } } await _context.SaveChangesAsync(); } @@ -519,17 +563,58 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data1 = await _context.DisciplineInvestigate_ProfileComplaints + .Include(x => x.DisciplineInvestigate) .Where(x => x.IsReport == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); if (data1 != null) + { data1.IsReport = "NEW"; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data1.DisciplineInvestigate.Title, + level = "", + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) .Where(x => x.IsReport == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); - if (data2 != null) - data2.IsReport = "NEW"; + if (data2 != null) { + data2.IsReport = "NEW"; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data2.DisciplineDisciplinary.Title, + level = data2.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } await _context.SaveChangesAsync(); } return Success(); @@ -549,11 +634,31 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data = await _context.DisciplineReport_Profiles + .Include(x => x.DisciplineDisciplinary) .Where(x => x.Status == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); - if (data != null) + if (data != null) { data.Status = "DONE"; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data.DisciplineDisciplinary.Title, + level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } await _context.SaveChangesAsync(); } return Success(); diff --git a/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs b/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs index 8e237ccc..c95f888c 100644 --- a/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs +++ b/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs @@ -13,5 +13,10 @@ namespace BMA.EHR.Discipline.Service.Requests public Guid id { get; set; } = Guid.Empty; public Guid personId { get; set; } = Guid.Empty; public Guid? commandId { get; set; } = Guid.Empty; + + public DateTime? commandAffectDate { get; set; } + public string? commandNo { get; set; } + public string? commandYear { get; set; } + public string? detail { get; set; } } } From 417c7b0071e7d8e21bdc70b14bddb52501fe02f8 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 27 Jun 2024 18:02:07 +0700 Subject: [PATCH 7/8] =?UTF-8?q?=E0=B9=81=E0=B8=99=E0=B8=9A=E0=B8=97?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=A2=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B9=88=E0=B8=87=20(5,6,=207,=208,=209,13,=2014,=2015)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandReportRepository.cs | 54 ++--- .../Controllers/CommandReportController.cs | 225 +++++++++++++++--- 2 files changed, 214 insertions(+), 65 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs index 6046d317..89a83e31 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs @@ -92,7 +92,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Oc = p.root == null ? "" : p.root, PositionName = p.positionName == null ? "" : p.positionName, @@ -151,7 +151,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Oc = p.root == null ? "" : p.root, PositionName = p.positionName == null ? "" : p.positionName, @@ -215,7 +215,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "), Probation = pf.IsProbation ? "(อยู่ระหว่างปฏิบัติหน้าที่ราชการ)" : "", @@ -285,7 +285,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "), OldPositionName = pf.Position == null ? "" : pf.Position.Name, @@ -351,13 +351,13 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.root == null ? "" : p.root, @@ -421,13 +421,13 @@ namespace BMA.EHR.Application.Repositories.Commands // pf.Educations.OrderByDescending(x => x.StartDate).FirstOrDefault().Degree, Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.root == null ? "" : p.root, @@ -475,20 +475,20 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.rootOld == null ? "" : p.rootOld, NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), @@ -525,20 +525,20 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.rootOld == null ? "" : p.rootOld, NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), @@ -570,7 +570,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PlacementCommandIssuer = r.Command.PlacementCommandIssuer ?? "", PlacementCommandNo = r.Command.PlacementCommandNo == null ? "" : r.Command.PlacementCommandNo.ToThaiNumber(), @@ -606,7 +606,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PlacementCommandIssuer = r.Command.PlacementCommandIssuer ?? "", PlacementCommandNo = r.Command.PlacementCommandNo == null ? "" : r.Command.PlacementCommandNo.ToThaiNumber(), @@ -647,13 +647,13 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType13Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, PositionName = p.PositionOld == null ? "" : p.PositionOld, PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), //Salary = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), @@ -695,7 +695,7 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.OrganizationPositionOld ?? "", OldPositionName = p.OrganizationPositionOld ?? "", @@ -744,7 +744,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType15Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, // PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, @@ -836,7 +836,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType17Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.PositionOld ?? "", Organization = p.OrganizationPositionOld ?? "", @@ -888,7 +888,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", // PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, @@ -943,7 +943,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, Organization = p.OrganizationPositionOld ?? "", @@ -997,7 +997,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, Organization = p.OrganizationPositionOld ?? "", @@ -1060,7 +1060,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType21Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId.ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Organization = r.Organization == null ? "" : r.Organization.ToThaiNumber(), PositionName = r.PositionName == null ? "" : r.PositionName.ToThaiNumber(), @@ -1192,7 +1192,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType21Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId.ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Organization = p.OrganizationPositionOld ?? "", PositionName = p.PositionOld ?? "", @@ -1311,7 +1311,7 @@ namespace BMA.EHR.Application.Repositories.Commands { fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}", positionname = org.result.position, - positionno = org.result.posNo, + positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), organizationname = org.result.organization, salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(), }; diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index fbb36e33..3daa078d 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -599,14 +599,33 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -720,14 +739,34 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -839,14 +878,33 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType07AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-แนบท้ายคำสั่งย้าย.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -908,7 +966,6 @@ namespace BMA.EHR.Report.Service.Controllers CommandNo = raw_data.CommandNo.ToThaiNumber(), CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), IssuerOrganizationName = raw_data.IssuerOrganizationName, - ConclusionRegisterNo = raw_data.ConclusionRegisterNo == null ? "" : raw_data.ConclusionRegisterNo.ToThaiNumber(), ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3().ToThaiNumber(), ConclusionResultNo = raw_data.ConclusionResultNo == null ? "" : raw_data.ConclusionResultNo.ToThaiNumber(), ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3().ToThaiNumber(), @@ -960,14 +1017,31 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType08AttachmentAsync(commandId); - return data; + return new { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-6.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -1084,14 +1158,32 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType09AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-8.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -1378,14 +1470,32 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType13AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-2.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -1500,14 +1610,33 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType14AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -1619,14 +1748,34 @@ namespace BMA.EHR.Report.Service.Controllers { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType15AttachmentAsync(commandId); - return data; + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp"); //ReportPackager reportPackager = new ReportPackager(); @@ -3079,7 +3228,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-05", + template = "C-PM-05-attachment", reportName = "docx-report", data = contentData }; @@ -3175,7 +3324,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-06", + template = "C-PM-06-attachment", reportName = "docx-report", data = contentData }; @@ -3271,7 +3420,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-07", + template = "C-PM-07-attachment", reportName = "docx-report", data = contentData }; @@ -3367,7 +3516,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-08", + template = "C-PM-08-attachment", reportName = "docx-report", data = contentData }; @@ -3463,7 +3612,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - //template = "DP6_006", + template = "C-PM-09-attachment", reportName = "docx-report", data = contentData }; @@ -3715,7 +3864,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-13", + template = "C-PM-13-attachment", reportName = "docx-report", data = contentData }; @@ -3811,7 +3960,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-14", + template = "C-PM-14-attachment", reportName = "docx-report", data = contentData }; @@ -3907,7 +4056,7 @@ namespace BMA.EHR.Report.Service.Controllers //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); var data = new { - template = "C-PM-15", + template = "C-PM-15-attachment", reportName = "docx-report", data = contentData }; From 8b10a65d2a2d979e70d7117080fdb5af17665df7 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 27 Jun 2024 18:02:48 +0700 Subject: [PATCH 8/8] =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97?= =?UTF-8?q?=E0=B8=B6=E0=B8=81=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=E0=B8=A5=E0=B8=87=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LeaveRequests/LeaveRequestRepository.cs | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs index 4a9731f3..578c700e 100644 --- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs @@ -1,4 +1,6 @@ using System.Drawing; +using System.Net.Http.Headers; +using System.Net.Http.Json; using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Messaging; using BMA.EHR.Domain.Models.HR; @@ -404,7 +406,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้"); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId,AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -421,19 +423,38 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests // insert to profile leave - var profileLeave = new ProfileLeave + // var profileLeave = new ProfileLeave + // { + // DateStartLeave = rawData.LeaveStartDate, + // DateEndLeave = rawData.LeaveEndDate, + + // TotalLeave = rawData.LeaveTotal, + // Status = "approve", + // Reason = rawData.LeaveDetail, + + // ProfileId = profile.Id, // change from profile object to id + // TypeLeave = leaveType + // }; + // _appDbContext.Set().Add(profileLeave); + var _baseAPI = _configuration["API"]; + var apiUrlSalary = $"{_baseAPI}/org/profile/leave"; + using (var client = new HttpClient()) { - DateStartLeave = rawData.LeaveStartDate, - DateEndLeave = rawData.LeaveEndDate, - - TotalLeave = rawData.LeaveTotal, - Status = "approve", - Reason = rawData.LeaveDetail, - - ProfileId = profile.Id, // change from profile object to id - TypeLeave = leaveType - }; - _appDbContext.Set().Add(profileLeave); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = profile.Id, + leaveTypeId = leaveType?.Id ?? null, + dateLeaveStart = rawData.LeaveStartDate, + dateLeaveEnd = rawData.LeaveEndDate, + leaveDays = 0,//หน้า fe ไม่ได้ใช้ + leaveCount = 0,//หน้า fe ไม่ได้ใช้ + totalLeave = rawData.LeaveTotal, + status = "approve", + reason = rawData.LeaveDetail, + }); + // var _result = await _res.Content.ReadAsStringAsync(); + } await _appDbContext.SaveChangesAsync(); // insert to process timestamp