Gen หน้าคำสั่ง

This commit is contained in:
Suphonchai Phoonsawat 2023-09-03 18:14:07 +07:00
parent 1404ba3be5
commit cf966cd096
15 changed files with 817 additions and 33 deletions

View file

@ -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<List<CommandType15Response>> GetCommandType15AttachmentAsync(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.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<PlacementOfficer>()
.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<List<CommandType17Response>> GetCommandType17AttachmentAsync(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.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<RetirementResign>()
.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<List<CommandType18Response>> GetCommandType18Async(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.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<RetirementOut>()
.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<List<CommandType18Response>> GetCommandType19Async(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.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<RetirementDischarge>()
.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<List<CommandType18Response>> GetCommandType20Async(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.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<RetirementExpulsion>()
.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
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -282,6 +282,9 @@
<None Update="Reports\37-คำสั่งปลดออกจากราชการ.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Reports\37-คำสั่งให้ออกจากราชการ.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Reports\38-คำสั่งลงโทษไล่ข้าราชการออกจากราชการ.trdp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View file

@ -875,6 +875,452 @@ namespace BMA.EHR.Report.Service.Controllers
#endregion
#region " C-PM-15 "
private async Task<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> 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<byte[]> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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<ActionResult<ResponseObject>> 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
{