diff --git a/Controllers/InvestmentEquipmentReport.Controller.cs b/Controllers/InvestmentEquipmentReport.Controller.cs new file mode 100644 index 0000000..b19c38a --- /dev/null +++ b/Controllers/InvestmentEquipmentReport.Controller.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +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 Swashbuckle.AspNetCore.Annotations; + +namespace rmutr_report.Controllers +{ + [SwaggerTag("สำหรับรายงาน ร.4")] + public class InvestmentEquipmentReport : Controller + { + readonly Setting _setting; + + public InvestmentEquipmentReport(Setting setting) + { + this._setting = setting; + } + + [HttpPost, Route("reports/investment_equipment_report/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetInvestmentReport([FromRoute] string type, + [FromBody] durable_articles_three durable_articles_threes) + { + //Console.WriteLine(durable_articles_threes.specification_data[0].data_detail[0].data_detail2); + var a1 = durable_articles_threes.data.Where(d => d.amount == d.amount) + .Sum(o => o.amount); + if (a1!=null) + { + durable_articles_threes.total_amount = a1; + + } + + int a = 1; + foreach (var q in durable_articles_threes.quotation) + { + + string t = "ใบเสนอราคาบริษัทที่ " + a++ +" "; + q.company = t + q.company; + //a++; + } + + + var _durable_articles_three = new List() {durable_articles_threes}; + + Report report = new Report(); + report.Load(_setting.report_path + "investment_equipment_report.frx"); + report.RegisterData(_durable_articles_three, "durable_articles_three"); + report.Prepare(); + + MemoryStream stream = new MemoryStream(); + switch (type) + { + case "view": + return File(stream, "application/pdf"); + 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; + case "doc" : case "docx": + Word2007Export word = new Word2007Export(); + report.Export(word, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "appllication/vnd.ms-word"); + break; + } + + return Ok(); + } + + } +} \ No newline at end of file diff --git a/bin/Debug/net5.0/rmutr-report.dll b/bin/Debug/net5.0/rmutr-report.dll index 17d9386..b08fc0f 100644 Binary files a/bin/Debug/net5.0/rmutr-report.dll and b/bin/Debug/net5.0/rmutr-report.dll differ diff --git a/bin/Debug/net5.0/rmutr-report.pdb b/bin/Debug/net5.0/rmutr-report.pdb index 5eec90c..b3007b0 100644 Binary files a/bin/Debug/net5.0/rmutr-report.pdb and b/bin/Debug/net5.0/rmutr-report.pdb differ diff --git a/obj/Debug/net5.0/ref/rmutr-report.dll b/obj/Debug/net5.0/ref/rmutr-report.dll index 159d3c0..fe6a101 100644 Binary files a/obj/Debug/net5.0/ref/rmutr-report.dll and b/obj/Debug/net5.0/ref/rmutr-report.dll differ diff --git a/obj/Debug/net5.0/refint/rmutr-report.dll b/obj/Debug/net5.0/refint/rmutr-report.dll index 159d3c0..fe6a101 100644 Binary files a/obj/Debug/net5.0/refint/rmutr-report.dll and b/obj/Debug/net5.0/refint/rmutr-report.dll differ diff --git a/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache b/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache index 2885292..e21add1 100644 --- a/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache +++ b/obj/Debug/net5.0/rmutr-report.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -0aa423cbcd6170f5d81cd7d9d88fda71ff7fb01c +4016abde0a942687404c1b0022dc5b31762b26b5 diff --git a/obj/Debug/net5.0/rmutr-report.dll b/obj/Debug/net5.0/rmutr-report.dll index 17d9386..b08fc0f 100644 Binary files a/obj/Debug/net5.0/rmutr-report.dll and b/obj/Debug/net5.0/rmutr-report.dll differ diff --git a/obj/Debug/net5.0/rmutr-report.pdb b/obj/Debug/net5.0/rmutr-report.pdb index 5eec90c..b3007b0 100644 Binary files a/obj/Debug/net5.0/rmutr-report.pdb and b/obj/Debug/net5.0/rmutr-report.pdb differ diff --git a/wwwroot/reports/investment_equipment_report.frx b/wwwroot/reports/investment_equipment_report.frx new file mode 100644 index 0000000..cffd342 --- /dev/null +++ b/wwwroot/reports/investment_equipment_report.frx @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +