แก้ไขการเรียงลำดับ บช2-3 เรียงตามเลขที่ใหม่
This commit is contained in:
parent
2940777197
commit
bd1ec56e82
2 changed files with 290 additions and 289 deletions
|
|
@ -11,135 +11,135 @@ using BMA.EHR.Report.Service.Services;
|
|||
|
||||
namespace BMA.EHR.Report.Service.Controllers
|
||||
{
|
||||
[Route("api/v{version:apiVersion}/report/organization")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
//[Authorize]
|
||||
[SwaggerTag("รายงานระบบโครงสร้าง")]
|
||||
public class OrganizationReportController : BaseController
|
||||
{
|
||||
#region " Fields "
|
||||
[Route("api/v{version:apiVersion}/report/organization")]
|
||||
[ApiVersion("1.0")]
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
//[Authorize]
|
||||
[SwaggerTag("รายงานระบบโครงสร้าง")]
|
||||
public class OrganizationReportController : BaseController
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly EHRDbContext _context;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string space = "ㅤ";
|
||||
private readonly OrganizationReportService _organizationReportService;
|
||||
private readonly EHRDbContext _context;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly string space = "ㅤ";
|
||||
private readonly OrganizationReportService _organizationReportService;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public OrganizationReportController(EHRDbContext context,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IConfiguration configuration,
|
||||
OrganizationReportService organizationReportService)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
this._organizationReportService = organizationReportService;
|
||||
}
|
||||
public OrganizationReportController(EHRDbContext context,
|
||||
IWebHostEnvironment hostingEnvironment,
|
||||
IConfiguration configuration,
|
||||
OrganizationReportService organizationReportService)
|
||||
{
|
||||
this._context = context;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
this._configuration = configuration;
|
||||
this._organizationReportService = organizationReportService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
#region " Methods "
|
||||
|
||||
[HttpGet("oc-type")]
|
||||
public async Task<ActionResult<ResponseObject>> GetOCType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Success(await _organizationReportService.GetOrganizationTypes("หน่วยงาน"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
[HttpGet("oc-type")]
|
||||
public async Task<ActionResult<ResponseObject>> GetOCType()
|
||||
{
|
||||
try
|
||||
{
|
||||
return Success(await _organizationReportService.GetOrganizationTypes("หน่วยงาน"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// รายงานบัญชี 1
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสสำนัก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
/// <summary>
|
||||
/// รายงานบัญชี 1
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสสำนัก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
|
||||
[HttpGet("account1/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetAccount1Report(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _organizationReportService.GetReport1Query(id);
|
||||
var result_data = new List<Account1ResultItem>();
|
||||
[HttpGet("account1/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetAccount1Report(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _organizationReportService.GetReport1Query(id);
|
||||
var result_data = new List<Account1ResultItem>();
|
||||
|
||||
foreach (var d in data)
|
||||
{
|
||||
result_data.Add(new Account1ResultItem
|
||||
{
|
||||
Id = d.Id,
|
||||
RootOcId = d.RootOcId,
|
||||
RootOcName = d.RootOcName,
|
||||
OcFullName = d.OcFullName.Replace($"\r\n{d.OcName}", string.Empty),
|
||||
OcId = d.OcId,
|
||||
OcName = d.OcName,
|
||||
ShortName = d.ShortName,
|
||||
PositionNumber = d.PositionNumber,
|
||||
PositionNumberInt = Convert.ToInt32(d.PositionNumber.Replace(d.ShortName, string.Empty)),
|
||||
PositionName = d.PositionName,
|
||||
PositionSide = d.PositionSide,
|
||||
PositionExecutive = d.PositionExecutive,
|
||||
PositionExecutiveSide = d.PositionExecutiveSide,
|
||||
OcOrder = d.OcOrder,
|
||||
PositionLevel = d.PositionLevel,
|
||||
Remark = d.Remark,
|
||||
PositionType = d.PositionType,
|
||||
IsDirector = d.IsDirector,
|
||||
GovernmentCode = d.GovernmentCode,
|
||||
});
|
||||
}
|
||||
foreach (var d in data)
|
||||
{
|
||||
result_data.Add(new Account1ResultItem
|
||||
{
|
||||
Id = d.Id,
|
||||
RootOcId = d.RootOcId,
|
||||
RootOcName = d.RootOcName,
|
||||
OcFullName = d.OcFullName.Replace($"\r\n{d.OcName}", string.Empty),
|
||||
OcId = d.OcId,
|
||||
OcName = d.OcName,
|
||||
ShortName = d.ShortName,
|
||||
PositionNumber = d.PositionNumber,
|
||||
PositionNumberInt = Convert.ToInt32(d.PositionNumber.Replace(d.ShortName, string.Empty)),
|
||||
PositionName = d.PositionName,
|
||||
PositionSide = d.PositionSide,
|
||||
PositionExecutive = d.PositionExecutive,
|
||||
PositionExecutiveSide = d.PositionExecutiveSide,
|
||||
OcOrder = d.OcOrder,
|
||||
PositionLevel = d.PositionLevel,
|
||||
Remark = d.Remark,
|
||||
PositionType = d.PositionType,
|
||||
IsDirector = d.IsDirector,
|
||||
GovernmentCode = d.GovernmentCode,
|
||||
});
|
||||
}
|
||||
|
||||
//var items = result_data.OrderBy(x => x.GovernmentCode).ThenBy(x => x.PositionNumberInt).ToList();
|
||||
//var items = result_data.OrderBy(x => x.GovernmentCode).ThenBy(x => x.PositionNumberInt).ToList();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Organization", $"rptAccount1.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 rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Organization", $"rptAccount1.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 = result_data;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
report.DataSource = result_data;
|
||||
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("PDF", instanceReportSource, deviceInfo);
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var first_record = result_data.FirstOrDefault();
|
||||
var first_record = result_data.FirstOrDefault();
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายงานบัญชี1_{first_record.RootOcName}_.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายงานบัญชี1_{first_record.RootOcName}_.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -153,207 +153,208 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
|
||||
[HttpGet("account2/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetAccount2Report(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _organizationReportService.GetReport2Query(id);
|
||||
var result_data = new List<Account2ResultItem>();
|
||||
foreach (var d in data)
|
||||
{
|
||||
result_data.Add(new Account2ResultItem
|
||||
{
|
||||
Id = d.Id,
|
||||
RootOcId = d.RootOcId,
|
||||
RootOcName = d.RootOcName,
|
||||
OcFullName = d.OcFullName.Replace($"\r\n{d.OcName}", string.Empty),
|
||||
OcId = d.OcId,
|
||||
OcName = d.OcName,
|
||||
ShortName = d.ShortName,
|
||||
PositionNumber = d.PositionNumber,
|
||||
PositionNumberInt = d.PositionNumber == "" ? 0 : Convert.ToInt32(d.PositionNumber.Split(".").Last()),
|
||||
PositionName = d.PositionName,
|
||||
PositionSide = d.PositionSide,
|
||||
PositionExecutive = d.PositionExecutive,
|
||||
PositionExecutiveSide = d.PositionExecutiveSide,
|
||||
OcOrder = d.OcOrder,
|
||||
PositionLevel = d.PositionLevel,
|
||||
Remark = d.Remark,
|
||||
PositionType = d.PositionType,
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetAccount2Report(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = (await _organizationReportService.GetReport2Query(id)).OrderBy(x => x.OcOrder).ThenBy(x => x.PositionNumberIntNew).ToList();
|
||||
|
||||
OcIdNew = d.OcIdNew,
|
||||
OcFullNameNew = d.OcFullNameNew.Replace($"\r\n{d.OcNameNew}", string.Empty),
|
||||
OcNameNew = d.OcNameNew,
|
||||
ShortNameNew = d.ShortNameNew,
|
||||
PositionNumberNew = d.PositionNumberNew == "" ? d.PositionNumber : d.PositionNumberNew,
|
||||
PositionNumberIntNew = d.PositionNumberNew == "" ? Convert.ToInt32(d.PositionNumber.Split(".").Last()) :
|
||||
Convert.ToInt32(d.PositionNumberNew.Split(".").Last()),
|
||||
PositionLevelNew = d.PositionLevelNew == "" ? d.PositionLevel : d.PositionLevelNew,
|
||||
PositionNameNew = d.PositionNameNew == "" ? d.PositionName : d.PositionNameNew,
|
||||
PositionSideNew = d.PositionSideNew == "" ? d.PositionSide : d.PositionSideNew,
|
||||
PositionExecutiveNew = d.PositionExecutiveNew == "" ? d.PositionExecutive : d.PositionExecutiveNew,
|
||||
PositionExecutiveSideNew = d.PositionExecutiveSideNew == "" ? d.PositionExecutiveSide : d.PositionExecutiveSideNew,
|
||||
PositionTypeNew = d.PositionTypeNew == "" ? d.PositionType : d.PositionTypeNew,
|
||||
var result_data = new List<Account2ResultItem>();
|
||||
foreach (var d in data)
|
||||
{
|
||||
result_data.Add(new Account2ResultItem
|
||||
{
|
||||
Id = d.Id,
|
||||
RootOcId = d.RootOcId,
|
||||
RootOcName = d.RootOcName,
|
||||
OcFullName = d.OcFullName.Replace($"\r\n{d.OcName}", string.Empty),
|
||||
OcId = d.OcId,
|
||||
OcName = d.OcName,
|
||||
ShortName = d.ShortName,
|
||||
PositionNumber = d.PositionNumber,
|
||||
PositionNumberInt = d.PositionNumber == "" ? 0 : Convert.ToInt32(d.PositionNumber.Split(".").Last()),
|
||||
PositionName = d.PositionName,
|
||||
PositionSide = d.PositionSide,
|
||||
PositionExecutive = d.PositionExecutive,
|
||||
PositionExecutiveSide = d.PositionExecutiveSide,
|
||||
OcOrder = d.OcOrder,
|
||||
PositionLevel = d.PositionLevel,
|
||||
Remark = d.Remark,
|
||||
PositionType = d.PositionType,
|
||||
|
||||
Prefix = d.Prefix,
|
||||
FirstName = d.FirstName,
|
||||
LastName = d.LastName,
|
||||
Degree = d.Degree,
|
||||
OcIdNew = d.OcIdNew,
|
||||
OcFullNameNew = d.OcFullNameNew.Replace($"\r\n{d.OcNameNew}", string.Empty),
|
||||
OcNameNew = d.OcNameNew,
|
||||
ShortNameNew = d.ShortNameNew,
|
||||
PositionNumberNew = d.PositionNumberNew == "" ? d.PositionNumber : d.PositionNumberNew,
|
||||
PositionNumberIntNew = d.PositionNumberNew == "" ? Convert.ToInt32(d.PositionNumber.Split(".").Last()) :
|
||||
Convert.ToInt32(d.PositionNumberNew.Split(".").Last()),
|
||||
PositionLevelNew = d.PositionLevelNew == "" ? d.PositionLevel : d.PositionLevelNew,
|
||||
PositionNameNew = d.PositionNameNew == "" ? d.PositionName : d.PositionNameNew,
|
||||
PositionSideNew = d.PositionSideNew == "" ? d.PositionSide : d.PositionSideNew,
|
||||
PositionExecutiveNew = d.PositionExecutiveNew == "" ? d.PositionExecutive : d.PositionExecutiveNew,
|
||||
PositionExecutiveSideNew = d.PositionExecutiveSideNew == "" ? d.PositionExecutiveSide : d.PositionExecutiveSideNew,
|
||||
PositionTypeNew = d.PositionTypeNew == "" ? d.PositionType : d.PositionTypeNew,
|
||||
|
||||
Salary = d.Salary,
|
||||
SalaryPosition = d.SalaryPosition,
|
||||
FullName = $"{d.Prefix}{d.FirstName} {d.LastName}".Trim()
|
||||
});
|
||||
}
|
||||
Prefix = d.Prefix,
|
||||
FirstName = d.FirstName,
|
||||
LastName = d.LastName,
|
||||
Degree = d.Degree,
|
||||
|
||||
Salary = d.Salary,
|
||||
SalaryPosition = d.SalaryPosition,
|
||||
FullName = $"{d.Prefix}{d.FirstName} {d.LastName}".Trim()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//var items = result_data.OrderBy(x => x.GovernmentCode).ThenBy(x => x.PositionNumberInt).ToList();
|
||||
//var items = result_data.OrderBy(x => x.GovernmentCode).ThenBy(x => x.PositionNumberInt).ToList();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Organization", $"rptAccount2.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 rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Organization", $"rptAccount2.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 = result_data;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
report.DataSource = result_data;
|
||||
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("PDF", instanceReportSource, deviceInfo);
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var first_record = result_data.FirstOrDefault();
|
||||
var first_record = result_data.FirstOrDefault();
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายงานบัญชี2_{first_record.RootOcName}_.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายงานบัญชี2_{first_record.RootOcName}_.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// <summary>
|
||||
/// รายงานบัญชี 3
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสสำนัก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
/// <summary>
|
||||
/// รายงานบัญชี 3
|
||||
/// </summary>
|
||||
/// <param name="id">รหัสสำนัก</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
|
||||
[HttpGet("account3/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetAccount3Report(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _organizationReportService.GetReport2Query(id);
|
||||
var result_data = new List<Account2ResultItem>();
|
||||
foreach (var d in data)
|
||||
{
|
||||
result_data.Add(new Account2ResultItem
|
||||
{
|
||||
Id = d.Id,
|
||||
RootOcId = d.RootOcId,
|
||||
RootOcName = d.RootOcName,
|
||||
OcFullName = d.OcFullName.Replace($"\r\n{d.OcName}", string.Empty),
|
||||
OcId = d.OcId,
|
||||
OcName = d.OcName,
|
||||
ShortName = d.ShortName,
|
||||
PositionNumber = d.PositionNumber,
|
||||
PositionNumberInt = d.PositionNumberInt,
|
||||
PositionName = d.PositionName,
|
||||
PositionSide = d.PositionSide,
|
||||
PositionExecutive = d.PositionExecutive,
|
||||
PositionExecutiveSide = d.PositionExecutiveSide,
|
||||
OcOrder = d.OcOrder,
|
||||
PositionLevel = d.PositionLevel,
|
||||
Remark = d.Remark,
|
||||
PositionType = d.PositionType,
|
||||
[HttpGet("account3/{id:length(36)}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> GetAccount3Report(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = (await _organizationReportService.GetReport2Query(id)).OrderBy(x => x.OcOrder).ThenBy(x => x.PositionNumberIntNew).ToList();
|
||||
var result_data = new List<Account2ResultItem>();
|
||||
foreach (var d in data)
|
||||
{
|
||||
result_data.Add(new Account2ResultItem
|
||||
{
|
||||
Id = d.Id,
|
||||
RootOcId = d.RootOcId,
|
||||
RootOcName = d.RootOcName,
|
||||
OcFullName = d.OcFullName.Replace($"\r\n{d.OcName}", string.Empty),
|
||||
OcId = d.OcId,
|
||||
OcName = d.OcName,
|
||||
ShortName = d.ShortName,
|
||||
PositionNumber = d.PositionNumber,
|
||||
PositionNumberInt = d.PositionNumberInt,
|
||||
PositionName = d.PositionName,
|
||||
PositionSide = d.PositionSide,
|
||||
PositionExecutive = d.PositionExecutive,
|
||||
PositionExecutiveSide = d.PositionExecutiveSide,
|
||||
OcOrder = d.OcOrder,
|
||||
PositionLevel = d.PositionLevel,
|
||||
Remark = d.Remark,
|
||||
PositionType = d.PositionType,
|
||||
|
||||
OcIdNew = d.OcIdNew,
|
||||
OcFullNameNew = d.OcFullNameNew.Replace($"\r\n{d.OcNameNew}", string.Empty),
|
||||
OcNameNew = d.OcNameNew,
|
||||
ShortNameNew = d.ShortNameNew,
|
||||
PositionNumberNew = d.PositionNumberNew == "" ? d.PositionNumber : d.PositionNumberNew,
|
||||
PositionNumberIntNew = d.PositionNumberNew == "" ? d.PositionNumberInt : d.PositionNumberIntNew,
|
||||
PositionLevelNew = d.PositionLevelNew == "" ? d.PositionLevel : d.PositionLevelNew,
|
||||
PositionNameNew = d.PositionNameNew == "" ? d.PositionName : d.PositionNameNew,
|
||||
PositionSideNew = d.PositionSideNew == "" ? d.PositionSide : d.PositionSideNew,
|
||||
PositionExecutiveNew = d.PositionExecutiveNew == "" ? d.PositionExecutive : d.PositionExecutiveNew,
|
||||
PositionExecutiveSideNew = d.PositionExecutiveSideNew == "" ? d.PositionExecutiveSide : d.PositionExecutiveSideNew,
|
||||
PositionTypeNew = d.PositionTypeNew == "" ? d.PositionType : d.PositionTypeNew,
|
||||
OcIdNew = d.OcIdNew,
|
||||
OcFullNameNew = d.OcFullNameNew.Replace($"\r\n{d.OcNameNew}", string.Empty),
|
||||
OcNameNew = d.OcNameNew,
|
||||
ShortNameNew = d.ShortNameNew,
|
||||
PositionNumberNew = d.PositionNumberNew == "" ? d.PositionNumber : d.PositionNumberNew,
|
||||
PositionNumberIntNew = d.PositionNumberNew == "" ? d.PositionNumberInt : d.PositionNumberIntNew,
|
||||
PositionLevelNew = d.PositionLevelNew == "" ? d.PositionLevel : d.PositionLevelNew,
|
||||
PositionNameNew = d.PositionNameNew == "" ? d.PositionName : d.PositionNameNew,
|
||||
PositionSideNew = d.PositionSideNew == "" ? d.PositionSide : d.PositionSideNew,
|
||||
PositionExecutiveNew = d.PositionExecutiveNew == "" ? d.PositionExecutive : d.PositionExecutiveNew,
|
||||
PositionExecutiveSideNew = d.PositionExecutiveSideNew == "" ? d.PositionExecutiveSide : d.PositionExecutiveSideNew,
|
||||
PositionTypeNew = d.PositionTypeNew == "" ? d.PositionType : d.PositionTypeNew,
|
||||
|
||||
Prefix = d.Prefix,
|
||||
FirstName = d.FirstName,
|
||||
LastName = d.LastName,
|
||||
Degree = d.Degree,
|
||||
Prefix = d.Prefix,
|
||||
FirstName = d.FirstName,
|
||||
LastName = d.LastName,
|
||||
Degree = d.Degree,
|
||||
|
||||
Salary = d.Salary,
|
||||
SalaryPosition = d.SalaryPosition,
|
||||
FullName = $"{d.Prefix}{d.FirstName} {d.LastName}".Trim()
|
||||
});
|
||||
}
|
||||
Salary = d.Salary,
|
||||
SalaryPosition = d.SalaryPosition,
|
||||
FullName = $"{d.Prefix}{d.FirstName} {d.LastName}".Trim()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//var items = result_data.OrderBy(x => x.GovernmentCode).ThenBy(x => x.PositionNumberInt).ToList();
|
||||
//var items = result_data.OrderBy(x => x.GovernmentCode).ThenBy(x => x.PositionNumberInt).ToList();
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Organization", $"rptAccount3.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 rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Organization", $"rptAccount3.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 = result_data;
|
||||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||||
report.DataSource = result_data;
|
||||
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("PDF", instanceReportSource, deviceInfo);
|
||||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||||
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
|
||||
|
||||
var first_record = result_data.FirstOrDefault();
|
||||
var first_record = result_data.FirstOrDefault();
|
||||
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายงานบัญชี3_{first_record.RootOcName}_.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
var content = result.DocumentBytes;
|
||||
return File(content, "application/pdf", $"รายงานบัญชี3_{first_record.RootOcName}_.pdf");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue