diff --git a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs index a9894177..efcca142 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs @@ -4,6 +4,7 @@ using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Models.Commands.Core; using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.Placement; +using BMA.EHR.Domain.Models.Retirement; using BMA.EHR.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; @@ -345,6 +346,241 @@ namespace BMA.EHR.Application.Repositories.Commands } } + public async Task> GetCommandType15AttachmentAsync(Guid id) + { + try + { + var raw_data = await _dbContext.Set() + .Include(c => c.Command) + .Where(c => c.Command.Id == id) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var report_data = (from r in raw_data + join p in _dbContext.Set() + .Include(p => p.Profile) + .ThenInclude(p => p.Position) + on r.RefPlacementProfileId equals p.Id + select new CommandType15Response + { + CitizenId = r.CitizenId, + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, + Organization = p.Organization, + StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiFullDate3(), + EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiFullDate3(), + }) + .ToList(); + + return report_data; + } + catch + { + throw; + } + } + + public async Task> GetCommandType17AttachmentAsync(Guid id) + { + try + { + var raw_data = await _dbContext.Set() + .Include(c => c.Command) + .Where(c => c.Command.Id == id) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var report_data = (from r in raw_data + join p in _dbContext.Set() + .Include(p => p.Profile) + .ThenInclude(p => p.Position) + .Include(p => p.Profile) + .ThenInclude(p => p.Salaries) + on r.RefPlacementProfileId equals p.Id + select new CommandType17Response + { + CitizenId = r.CitizenId, + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, + Organization = p.OrganizationPositionOld, + PositionLevel = p.PositionLevelOld, + PositionType = p.PositionTypeOld, + PositionNumber = p.PositionNumberOld, + ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiFullDate3(), + Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? 0 : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value, + }) + .ToList(); + + return report_data; + } + catch + { + throw; + } + } + + public async Task> GetCommandType18Async(Guid id) + { + try + { + var raw_data = await _dbContext.Set() + .Include(c => c.Command) + .Where(c => c.Command.Id == id) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var report_data = (from r in raw_data + join p in _dbContext.Set() + .Include(p => p.Profile) + .ThenInclude(p => p.Position) + .Include(p => p.Profile) + .ThenInclude(p => p.Salaries) + on r.RefPlacementProfileId equals p.Id + select new CommandType18Response + { + CommandNo = r.Command.CommandNo, + CommandYear = r.Command.CommandYear, + CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(), + IssuerOrganizationName = r.Command.IssuerOrganizationName, + AuthorizedUserFullName = r.Command.AuthorizedUserFullName, + AuthorizedPosition = r.Command.AuthorizedPosition, + CitizenId = r.CitizenId, + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, + Organization = p.OrganizationPositionOld, + PositionLevel = p.PositionLevelOld, + PositionType = p.PositionTypeOld, + PositionNumber = p.PositionNumberOld, + Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? 0 : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value, + Fault = r.Command.Fault, + GuiltyBasis = r.Command.GuiltyBasis, + ConclusionFireNo = r.Command!.ConclusionFireNo, + ConclusionFireDate = r.Command.ConclusionFireDate == null ? "" : r.Command.ConclusionFireDate.Value.ToThaiFullDate3(), + ConclusionFireResolution = r.Command.ConclusionFireResolution + }) + .ToList(); + + return report_data; + } + catch + { + throw; + } + } + + public async Task> GetCommandType19Async(Guid id) + { + try + { + var raw_data = await _dbContext.Set() + .Include(c => c.Command) + .Where(c => c.Command.Id == id) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var report_data = (from r in raw_data + join p in _dbContext.Set() + .Include(p => p.Profile) + .ThenInclude(p => p.Position) + .Include(p => p.Profile) + .ThenInclude(p => p.Salaries) + on r.RefPlacementProfileId equals p.Id + select new CommandType18Response + { + CommandNo = r.Command.CommandNo, + CommandYear = r.Command.CommandYear, + CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(), + IssuerOrganizationName = r.Command.IssuerOrganizationName, + AuthorizedUserFullName = r.Command.AuthorizedUserFullName, + AuthorizedPosition = r.Command.AuthorizedPosition, + CitizenId = r.CitizenId, + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, + Organization = p.OrganizationPositionOld, + PositionLevel = p.PositionLevelOld, + PositionType = p.PositionTypeOld, + PositionNumber = p.PositionNumberOld, + Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? 0 : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value, + Fault = r.Command.Fault, + GuiltyBasis = r.Command.GuiltyBasis, + ConclusionFireNo = r.Command!.ConclusionFireNo, + ConclusionFireDate = r.Command.ConclusionFireDate == null ? "" : r.Command.ConclusionFireDate.Value.ToThaiFullDate3(), + ConclusionFireResolution = r.Command.ConclusionFireResolution + }) + .ToList(); + + return report_data; + } + catch + { + throw; + } + } + + public async Task> GetCommandType20Async(Guid id) + { + try + { + var raw_data = await _dbContext.Set() + .Include(c => c.Command) + .Where(c => c.Command.Id == id) + .ToListAsync(); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var report_data = (from r in raw_data + join p in _dbContext.Set() + .Include(p => p.Profile) + .ThenInclude(p => p.Position) + .Include(p => p.Profile) + .ThenInclude(p => p.Salaries) + on r.RefPlacementProfileId equals p.Id + select new CommandType18Response + { + CommandNo = r.Command.CommandNo, + CommandYear = r.Command.CommandYear, + CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(), + IssuerOrganizationName = r.Command.IssuerOrganizationName, + AuthorizedUserFullName = r.Command.AuthorizedUserFullName, + AuthorizedPosition = r.Command.AuthorizedPosition, + CitizenId = r.CitizenId, + FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", + PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, + Organization = p.OrganizationPositionOld, + PositionLevel = p.PositionLevelOld, + PositionType = p.PositionTypeOld, + PositionNumber = p.PositionNumberOld, + Salary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? 0 : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value, + Fault = r.Command.Fault, + GuiltyBasis = r.Command.GuiltyBasis, + ConclusionFireNo = r.Command!.ConclusionFireNo, + ConclusionFireDate = r.Command.ConclusionFireDate == null ? "" : r.Command.ConclusionFireDate.Value.ToThaiFullDate3(), + ConclusionFireResolution = r.Command.ConclusionFireResolution + }) + .ToList(); + + return report_data; + } + catch + { + throw; + } + } + #endregion } } diff --git a/BMA.EHR.Application/Responses/Reports/CommandType15Response.cs b/BMA.EHR.Application/Responses/Reports/CommandType15Response.cs new file mode 100644 index 00000000..855be88d --- /dev/null +++ b/BMA.EHR.Application/Responses/Reports/CommandType15Response.cs @@ -0,0 +1,17 @@ +namespace BMA.EHR.Application.Responses.Reports +{ + public class CommandType15Response + { + public string CitizenId { get; set; } = string.Empty; + + public string FullName { get; set; } = string.Empty; + + public string PositionName { get; set;} = string.Empty; + + public string Organization { get; set;} = string.Empty; + + public string StartDate { get; set; } = string.Empty; + + public string EndDate { get; set; } = string.Empty; + } +} diff --git a/BMA.EHR.Application/Responses/Reports/CommandType17Response.cs b/BMA.EHR.Application/Responses/Reports/CommandType17Response.cs new file mode 100644 index 00000000..f154c95f --- /dev/null +++ b/BMA.EHR.Application/Responses/Reports/CommandType17Response.cs @@ -0,0 +1,23 @@ +namespace BMA.EHR.Application.Responses.Reports +{ + public class CommandType17Response + { + public string CitizenId { get; set; } = string.Empty; + + public string FullName { get; set; } = string.Empty; + + public string Organization { get; set; } = string.Empty; + + public string PositionName { get; set; } = string.Empty; + + public string PositionLevel { get; set; } = string.Empty; + + public string PositionType { get; set; } = string.Empty; + + public string PositionNumber { get; set; } = string.Empty; + + public double Salary { get; set; } = 0; + + public string ActiveDate { get; set; } = string.Empty; + } +} diff --git a/BMA.EHR.Application/Responses/Reports/CommandType18Response.cs b/BMA.EHR.Application/Responses/Reports/CommandType18Response.cs new file mode 100644 index 00000000..f0be507f --- /dev/null +++ b/BMA.EHR.Application/Responses/Reports/CommandType18Response.cs @@ -0,0 +1,43 @@ +namespace BMA.EHR.Application.Responses.Reports +{ + public class CommandType18Response + { + public string CommandNo { get; set; } = string.Empty; + + public string CommandYear { get; set; } = string.Empty; + + public string IssuerOrganizationName { get; set; } = string.Empty; + + public string CommandAffectDate { get; set; } = string.Empty; + + public string AuthorizedUserFullName { get; set; } = string.Empty; + + public string AuthorizedPosition { get; set; } = string.Empty; + + public string CitizenId { get; set; } = string.Empty; + + public string FullName { get; set; } = string.Empty; + + public string Organization { get; set; } = string.Empty; + + public string PositionName { get; set; } = string.Empty; + + public string PositionLevel { get; set; } = string.Empty; + + public string PositionType { get; set; } = string.Empty; + + public string PositionNumber { get; set; } = string.Empty; + + public double Salary { get; set; } = 0; + + public string Fault { get; set; } = string.Empty; + + public string GuiltyBasis { get; set; } = string.Empty; + + public string ConclusionFireNo { get; set; } = string.Empty; + + public string ConclusionFireDate { get; set; } = string.Empty; + + public string ConclusionFireResolution { get; set; } = string.Empty; + } +} diff --git a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj index 0d1ad60c..d82ae1c7 100644 --- a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj +++ b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj @@ -282,6 +282,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index fb1f061e..d8ba91f2 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -875,6 +875,452 @@ namespace BMA.EHR.Report.Service.Controllers #endregion + #region " C-PM-15 " + + private async Task GenerateCommandReportType15_Cover(Guid commandId, string exportType) + { + try + { + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + //var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList(); + //var positionList = string.Empty; + + var command = new + { + CommandNo = raw_data.CommandNo, + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + ConclusionRegisterNo = raw_data.ConclusionRegisterNo, + ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3(), + ConclusionResultNo = raw_data.ConclusionResultNo, + ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3(), + PositionList = "", + Count = raw_data.Receivers.Count, + CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3(), + AuthorizedUserFullName = raw_data.AuthorizedUserFullName, + AuthorizedPosition = raw_data.AuthorizedPosition, + }; + + 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); + } + + report.DataSource = command; + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + if (exportType == "docx") + deviceInfo["OutputFormat"] = "DOCX"; + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + private async Task GenerateCommandReportType15_Attachment(Guid commandId, string exportType) + { + try + { + var command = await _repository.GetByIdAsync(commandId); + if (command == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var data = await _commandReportRepository.GetCommandType15AttachmentAsync(commandId); + + 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); + } + + var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + + tblData.DataSource = data; + + report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + report.ReportParameters["CommandNo"].Value = command.CommandNo; + report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString(); + report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3(); + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + #endregion + + #region " C-PM-16 " + + private async Task GenerateCommandReportType16_Cover(Guid commandId, string exportType) + { + try + { + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + //var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList(); + //var positionList = string.Empty; + + var command = new + { + CommandNo = raw_data.CommandNo, + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + ConclusionRegisterNo = raw_data.ConclusionRegisterNo, + ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3(), + ConclusionResultNo = raw_data.ConclusionResultNo, + ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3(), + PositionList = "", + Count = raw_data.Receivers.Count, + CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3(), + AuthorizedUserFullName = raw_data.AuthorizedUserFullName, + AuthorizedPosition = raw_data.AuthorizedPosition, + GovAidCommandNo = raw_data.GovAidCommandNo, + GovAidCommandDate = raw_data.GovAidCommandDate == null ? "" : raw_data.GovAidCommandDate.Value.ToThaiFullDate3(), + }; + + 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); + } + + report.DataSource = command; + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + if (exportType == "docx") + deviceInfo["OutputFormat"] = "DOCX"; + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + #endregion + + #region " C-PM-17 " + + private async Task GenerateCommandReportType17_Cover(Guid commandId, string exportType) + { + try + { + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + //var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList(); + //var positionList = string.Empty; + + var command = new + { + CommandNo = raw_data.CommandNo, + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + ConclusionRegisterNo = raw_data.ConclusionRegisterNo, + ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3(), + ConclusionResultNo = raw_data.ConclusionResultNo, + ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3(), + PositionList = "", + Count = raw_data.Receivers.Count, + CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3(), + AuthorizedUserFullName = raw_data.AuthorizedUserFullName, + AuthorizedPosition = raw_data.AuthorizedPosition, + }; + + 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); + } + + report.DataSource = command; + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + if (exportType == "docx") + deviceInfo["OutputFormat"] = "DOCX"; + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + private async Task GenerateCommandReportType17_Attachment(Guid commandId, string exportType) + { + try + { + var command = await _repository.GetByIdAsync(commandId); + if (command == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var data = await _commandReportRepository.GetCommandType17AttachmentAsync(commandId); + + 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); + } + + var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + + tblData.DataSource = data; + + report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + report.ReportParameters["CommandNo"].Value = command.CommandNo; + report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString(); + report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate3(); + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + #endregion + + #region " C-PM-18 " + + private async Task GenerateCommandReportType18_Cover(Guid commandId, string exportType) + { + try + { + var command = await _repository.GetByIdAsync(commandId); + if (command == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var data = await _commandReportRepository.GetCommandType18Async(commandId); + + 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); + } + + report.DataSource = data; + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + #endregion + + #region " C-PM-19 " + + private async Task GenerateCommandReportType19_Cover(Guid commandId, string exportType) + { + try + { + var command = await _repository.GetByIdAsync(commandId); + if (command == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var data = await _commandReportRepository.GetCommandType19Async(commandId); + + 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); + } + + report.DataSource = data; + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + #endregion + + #region " C-PM-20 " + + private async Task GenerateCommandReportType20_Cover(Guid commandId, string exportType) + { + try + { + var command = await _repository.GetByIdAsync(commandId); + if (command == null) + { + throw new Exception(GlobalMessages.CommandNotFound); + } + + var data = await _commandReportRepository.GetCommandType20Async(commandId); + + var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.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); + } + + report.DataSource = data; + + System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + InstanceReportSource instanceReportSource = new InstanceReportSource() + { + ReportDocument = report + }; + + ReportProcessor reportProcessor = new ReportProcessor(_configuration); + RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + var content = result.DocumentBytes; + + return content; + } + catch + { + throw; + } + } + + #endregion + #endregion #region " C-PM-01 คำสั่งบรรจุและแต่งตั้ง: สำหรับผู้สอบแข่งขันได้ " @@ -1912,7 +2358,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType15CoverReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType15CoverReport(Guid id, string exportType = "pdf") { try { @@ -1924,10 +2370,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-1.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType15_Cover(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -1949,10 +2397,14 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType15AttachmentReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType15AttachmentReport(Guid id, string exportType = "pdf") { try { + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); + var mimeType = ""; switch (exportType.Trim().ToLower()) { @@ -1961,10 +2413,8 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); - - return File(contentData, mimeType, $"command-attachment.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType15_Attachment(id, exportType); + return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -1990,7 +2440,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType16CoverReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType16CoverReportAsync(Guid id, string exportType = "pdf") { try { @@ -2002,10 +2452,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType16_Cover(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -2031,7 +2483,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType17CoverReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType17CoverReportAsync(Guid id, string exportType = "pdf") { try { @@ -2043,10 +2495,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType17_Cover(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -2068,7 +2522,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType17AttachmentReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType17AttachmentReportAsync(Guid id, string exportType = "pdf") { try { @@ -2080,10 +2534,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command-attachment.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType17_Attachment(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -2109,7 +2565,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType18CoverReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType18CoverReport(Guid id, string exportType = "pdf") { try { @@ -2121,10 +2577,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"37-คำสั่งปลดออกจากราชการ.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType18_Cover(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -2150,7 +2608,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType19CoverReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType19CoverReport(Guid id, string exportType = "pdf") { try { @@ -2162,10 +2620,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"37-คำสั่งปลดออกจากราชการ.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType19_Cover(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { @@ -2191,7 +2651,7 @@ namespace BMA.EHR.Report.Service.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public IActionResult GetCommandType20CoverReport(Guid id, string exportType = "pdf") + public async Task> GetCommandType20CoverReport(Guid id, string exportType = "pdf") { try { @@ -2203,10 +2663,12 @@ namespace BMA.EHR.Report.Service.Controllers case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; } - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.trdp"); - var contentData = _reportGenerator.GenerateReport(rptFile, exportType); + var cmd = await _repository.GetByIdAsync(id); + if (cmd == null) + throw new Exception(GlobalMessages.CommandNotFound); - return File(contentData, mimeType, $"command.{exportType.Trim().ToLower()}"); + var contentData = await GenerateCommandReportType20_Cover(id, exportType); + return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { diff --git a/BMA.EHR.Report.Service/Reports/01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp b/BMA.EHR.Report.Service/Reports/01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp index 0f29e895..b6e4d7eb 100644 Binary files a/BMA.EHR.Report.Service/Reports/01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp and b/BMA.EHR.Report.Service/Reports/01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-1.trdp b/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-1.trdp index ef347672..ff38acd5 100644 Binary files a/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-1.trdp and b/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-1.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-2.trdp b/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-2.trdp index 63fbdef5..78cfaa3c 100644 Binary files a/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-2.trdp and b/BMA.EHR.Report.Service/Reports/29-คำสั่งให้ช่วยราชการ-2.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp b/BMA.EHR.Report.Service/Reports/30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp index fc79b651..91681a24 100644 Binary files a/BMA.EHR.Report.Service/Reports/30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp and b/BMA.EHR.Report.Service/Reports/30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp b/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp index 47491558..f1b4d83a 100644 Binary files a/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp and b/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp b/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp index 0a828c29..fdba2137 100644 Binary files a/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp and b/BMA.EHR.Report.Service/Reports/34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/37-คำสั่งปลดออกจากราชการ.trdp b/BMA.EHR.Report.Service/Reports/37-คำสั่งปลดออกจากราชการ.trdp index 24e1a754..201c6328 100644 Binary files a/BMA.EHR.Report.Service/Reports/37-คำสั่งปลดออกจากราชการ.trdp and b/BMA.EHR.Report.Service/Reports/37-คำสั่งปลดออกจากราชการ.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/37-คำสั่งให้ออกจากราชการ.trdp b/BMA.EHR.Report.Service/Reports/37-คำสั่งให้ออกจากราชการ.trdp new file mode 100644 index 00000000..105de038 Binary files /dev/null and b/BMA.EHR.Report.Service/Reports/37-คำสั่งให้ออกจากราชการ.trdp differ diff --git a/BMA.EHR.Report.Service/Reports/38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.trdp b/BMA.EHR.Report.Service/Reports/38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.trdp index 26b84b16..3b632fce 100644 Binary files a/BMA.EHR.Report.Service/Reports/38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.trdp and b/BMA.EHR.Report.Service/Reports/38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.trdp differ