test dumb

This commit is contained in:
Kittapath 2024-06-19 14:50:38 +07:00
parent 8e967a1fa8
commit 27fd503d9e
8 changed files with 342 additions and 77 deletions

View file

@ -9,6 +9,7 @@ using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
using System.Net.Http.Headers;
namespace BMA.EHR.Report.Service.Controllers
{
@ -1906,7 +1907,7 @@ namespace BMA.EHR.Report.Service.Controllers
#region " C-PM-19 "
private async Task<dynamic> GenerateCommandReportType19_Cover(Guid commandId, string exportType)
private async Task<dynamic> GenerateCommandReportType19_Cover(Guid commandId, string exportType, string token)
{
try
{
@ -1948,7 +1949,7 @@ namespace BMA.EHR.Report.Service.Controllers
throw new Exception(GlobalMessages.CommandNotFound);
}
var raw_data_profile = await _commandReportRepository.GetCommandType25AttachmentAsync(commandId);
var raw_data_profile = await _commandReportRepository.GetCommandType25AttachmentAsync(commandId, token);
var command = new
{
@ -1972,11 +1973,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 == 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(),
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(),
OrderDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
SignatoryBy = raw_data.AuthorizedUserFullName,
@ -1999,7 +2000,7 @@ namespace BMA.EHR.Report.Service.Controllers
#region " C-PM-20 "
private async Task<dynamic> GenerateCommandReportType20_Cover(Guid commandId, string exportType)
private async Task<dynamic> GenerateCommandReportType20_Cover(Guid commandId, string exportType, string token)
{
try
{
@ -2041,7 +2042,7 @@ namespace BMA.EHR.Report.Service.Controllers
throw new Exception(GlobalMessages.CommandNotFound);
}
var raw_data_profile = await _commandReportRepository.GetCommandType25AttachmentAsync(commandId);
var raw_data_profile = await _commandReportRepository.GetCommandType25AttachmentAsync(commandId, token);
var command = new
{
@ -2065,11 +2066,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 == 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(),
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(),
OrderDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
SignatoryBy = raw_data.AuthorizedUserFullName,
@ -2484,7 +2485,7 @@ namespace BMA.EHR.Report.Service.Controllers
#region " C-PM-25 "
private async Task<dynamic> GenerateCommandReportType25_Cover(Guid commandId, string exportType)
private async Task<dynamic> GenerateCommandReportType25_Cover(Guid commandId, string exportType, string token)
{
try
{
@ -2494,7 +2495,7 @@ namespace BMA.EHR.Report.Service.Controllers
throw new Exception(GlobalMessages.CommandNotFound);
}
var raw_data_profile = await _commandReportRepository.GetCommandType25AttachmentAsync(commandId);
var raw_data_profile = await _commandReportRepository.GetCommandType25AttachmentAsync(commandId, token);
var command = new
{
@ -2520,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 == 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(),
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(),
OrderDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
SignatoryBy = raw_data.AuthorizedUserFullName,
@ -3905,11 +3906,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-19/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType19CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType19CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -3924,7 +3924,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType19_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType19_Cover(id, exportType, token);
var data = new
{
template = "DP6_005",
@ -3964,11 +3970,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-20/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType20CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType20CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -3983,7 +3988,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType20_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType20_Cover(id, exportType, token);
var data = new
{
template = "DP6_008",
@ -4273,11 +4284,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-25/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType25CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType25CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4292,7 +4302,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_006",
@ -4330,11 +4346,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-26/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType26CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType26CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4349,7 +4364,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_006",
@ -4387,11 +4408,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-27/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType27CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType27CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4406,7 +4426,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_006",
@ -4444,11 +4470,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-28/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType28CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType28CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4463,7 +4488,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_004",
@ -4501,11 +4532,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-29/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType29CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType29CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4520,7 +4550,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_007",
@ -4558,11 +4594,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-30/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType30CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType30CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4577,7 +4612,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_002",
@ -4615,11 +4656,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-31/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType31CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType31CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4634,7 +4674,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_001",
@ -4672,11 +4718,10 @@ namespace BMA.EHR.Report.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("c-pm-32/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType32CoverReport(Guid id, string exportType = "pdf")
public async Task<ActionResult<ResponseObject>> GetCommandType32CoverReport([FromHeader] string authorization, Guid id, string exportType = "pdf")
{
try
{
@ -4691,7 +4736,13 @@ namespace BMA.EHR.Report.Service.Controllers
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType25_Cover(id, exportType);
var token = string.Empty;
if (AuthenticationHeaderValue.TryParse(authorization, out var headerValue))
{
var scheme = headerValue.Scheme;
token = headerValue.Parameter;
}
var contentData = await GenerateCommandReportType25_Cover(id, exportType, token);
var data = new
{
template = "DP6_003",