add ง.5-2.2
This commit is contained in:
92
Controllers/project_request_thailand.Controller.cs
Normal file
92
Controllers/project_request_thailand.Controller.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ClosedXML.Excel;
|
||||
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 Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
namespace rmutr_report.Controllers
|
||||
{
|
||||
[SwaggerTag("สำหรับรายงานคำขอโครงการ Thailand 4.0 (ง.5-2.2)")]
|
||||
public class project_request_thailand: Controller
|
||||
{
|
||||
readonly Setting _setting;
|
||||
|
||||
public project_request_thailand(Setting setting)
|
||||
{
|
||||
this._setting = setting;
|
||||
}
|
||||
[HttpPost, Route("reports/project_request_thailand/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetRequestProjectReport([FromRoute] string type, [FromBody] project_request_thai project)
|
||||
{
|
||||
|
||||
foreach (var v in project.five)
|
||||
{
|
||||
string na = "ประเด็นยุทธศาสตร์ที่ " ;
|
||||
v.strategic_issues = na + v.strategic_issues;
|
||||
string na2 = "กลยุทธ์ที่ " ;
|
||||
v.measure = na2 + v.measure;
|
||||
}
|
||||
foreach (var v in project.eleventh)
|
||||
{
|
||||
foreach (var vv in v.elevenths)
|
||||
{
|
||||
string na = "ครั้งที่ ";
|
||||
vv.the_time = na + vv.the_time;
|
||||
// string na2 = " จำนวน ";
|
||||
// // vv.count_day = na2 + vv.count_day + " วัน";
|
||||
// // if (project.count_day != null)
|
||||
// // {
|
||||
// // project.text3 = "จำนวน " + project.count_day + " วัน";
|
||||
// // }
|
||||
}
|
||||
}
|
||||
|
||||
var _project = new List<project_request_thai>() {project};
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "project_request_thailands.frx");
|
||||
report.RegisterData(_project, "project_request_thai");
|
||||
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":
|
||||
case "xlsx":
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user