358 lines
14 KiB
C#
358 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using FastReport;
|
|
using FastReport.Export.Csv;
|
|
using FastReport.Export.Mht;
|
|
using FastReport.Export.OoXML;
|
|
using FastReport.Export.Pdf;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using rmutr_report.Models;
|
|
using rmutr_report.Models.Hr;
|
|
using rmutr_report.Models.Hrrecruit;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
|
|
namespace rmutr_report.Controllers
|
|
{
|
|
[SwaggerTag("สำหรับรายงาน งานสรรหา")]
|
|
public class HrRecruit: Controller
|
|
{
|
|
readonly Setting _setting;
|
|
|
|
public HrRecruit(Setting setting)
|
|
{
|
|
this._setting = setting;
|
|
}
|
|
|
|
[HttpPost, Route("reports/registration_management_position/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr1Report([FromRoute] string type, [FromBody] List<registration_management_position> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "registration_management_position.frx");
|
|
report.RegisterData(_hr, "registration_management_position");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/registration_management_position_department/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr2Report([FromRoute] string type, [FromBody] List<registration_management_position> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "registration_management_position_department.frx");
|
|
report.RegisterData(_hr, "registration_management_position");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/faculty_council/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr3Report([FromRoute] string type, [FromBody] List<faculty_council> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "faculty_council.frx");
|
|
report.RegisterData(_hr, "faculty_council");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/support_personnel_qualification/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr4Report([FromRoute] string type, [FromBody] List<support_personnel_qualification> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "support_personnel_qualification.frx");
|
|
report.RegisterData(_hr, "support_personnel_qualification");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/appoint_higher_position/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr5Report([FromRoute] string type, [FromBody] List<appoint_higher_position> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "appoint_higher_position.frx");
|
|
report.RegisterData(_hr, "appoint_higher_position");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/directive_employment/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr6Report([FromRoute] string type, [FromBody] List<directive_employment> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "directive_employment.frx");
|
|
report.RegisterData(_hr, "directive_employment");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/personnel_retire/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr7Report([FromRoute] string type, [FromBody] personnel_retire _hr)
|
|
{
|
|
var hr1 = new List<personnel_retire>() {_hr};
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "personnel_retire.frx");
|
|
report.RegisterData(hr1, "personnel_retire");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
[HttpPost, Route("reports/request_salary_document/{type}")]
|
|
[ApiExplorerSettings(GroupName = "reports")]
|
|
public IActionResult GetHr8Report([FromRoute] string type, [FromBody] List<request_salary_document> _hr)
|
|
{
|
|
|
|
Report report = new Report();
|
|
report.Load(_setting.report_path + "request_salary_document.frx");
|
|
report.RegisterData(_hr, "request_salary_document");
|
|
report.Prepare();
|
|
|
|
MemoryStream stream = new MemoryStream();
|
|
switch (type)
|
|
{
|
|
case "pdf":
|
|
PDFExport pdf = new PDFExport();
|
|
report.Export(pdf, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/pdf");
|
|
|
|
case "xls":
|
|
Excel2007Export excel = new Excel2007Export();
|
|
report.Export(excel, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "application/vnd.ms-excel");
|
|
break;
|
|
case "mht":
|
|
MHTExport mht = new MHTExport();
|
|
report.Export(mht, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "multipart/related");
|
|
break;
|
|
case "csv":
|
|
CSVExport csv = new CSVExport();
|
|
report.Export(csv, stream);
|
|
stream.Seek(0, SeekOrigin.Begin);
|
|
return File(stream, "text/csv");
|
|
break;
|
|
}
|
|
|
|
return Ok();
|
|
}
|
|
}
|
|
} |