change report templates (transfer, retire)

This commit is contained in:
Bright 2024-09-12 10:54:23 +07:00
parent f85c0cf636
commit d67e0450e5
5 changed files with 453 additions and 354 deletions

View file

@ -120,8 +120,21 @@ namespace BMA.EHR.Application.Repositories.Reports
{ {
profiles = profiles.OrderBy(x => x.order).ToList(); profiles = profiles.OrderBy(x => x.order).ToList();
} }
var mapProfiles = new List<ProfileRetireJsonRequest>();
if (profiles.Count > 0)
{
mapProfiles = profiles.Select((profile, index) => new ProfileRetireJsonRequest
{
order = (index + 1).ToString().ToThaiNumber(),
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
root = profile.root,
position = profile.position != "" && profile.position != null ? profile.position : "-",
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
}).ToList();
}
string SignDate = retireHistorys.SignDate != null ? DateTime.Parse(retireHistorys.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-"; string SignDate = retireHistorys.SignDate != null ? DateTime.Parse(retireHistorys.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-";
return new { SignDate, retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profile = profiles }; return new { SignDate, retireHistorys.Detail, retireHistorys.Id, retireHistorys.CreatedAt, Year = retireHistorys.Year.ToThaiYear().ToString().ToThaiNumber(), retireHistorys.Round, retireHistorys.Type, retireHistorys.TypeReport, Total = retireHistorys.Total.ToString().ToThaiNumber(), profiles = mapProfiles };
} }
} }
else else
@ -194,8 +207,21 @@ namespace BMA.EHR.Application.Repositories.Reports
// }; // };
// retires.Add(data); // retires.Add(data);
// } // }
var mapProfiles = new List<ProfileRetireJsonRequest>();
if (profile_retire.Count > 0)
{
mapProfiles = profile_retire.Select((profile, index) => new ProfileRetireJsonRequest
{
order = (index + 1).ToString().ToThaiNumber(),
fullName = $"{profile.prefix}{profile.firstName} {profile.lastName}",
root = profile.root,
position = profile.position != "" && profile.position != null ? profile.position : "-",
posNo = profile.posNo != "" && profile.posNo != null ? profile.posNo?.ToThaiNumber() : "-",
reason = profile.reason != "" && profile.reason != null ? profile.reason : "-",
}).ToList();
}
string SignDate = retire.SignDate != null ? DateTime.Parse(retire.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-"; string SignDate = retire.SignDate != null ? DateTime.Parse(retire.SignDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber() : "-";
return new { SignDate, retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profile = profile_retire }; return new { SignDate, retire.Detail, retire.Id, retire.CreatedAt, Year = retire.Year.ToThaiYear().ToString().ToThaiNumber(), retire.Round, retire.Type, retire.TypeReport, Total = profile_retire.Count.ToString().ToThaiNumber(), profiles = mapProfiles };
} }
} }
#endregion #endregion

View file

@ -70,6 +70,7 @@ namespace BMA.EHR.Application.Repositories.Reports
CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")).ToThaiFullDate().ToString().ToThaiNumber().Remove(0, 15), CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")).ToThaiFullDate().ToString().ToThaiNumber().Remove(0, 15),
Subject = $"ข้าราชการขอโอน", Subject = $"ข้าราชการขอโอน",
Name = $"{data.prefix}{data.firstName} {data.lastName}", Name = $"{data.prefix}{data.firstName} {data.lastName}",
Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร ๑๗๓ ถนนดินสอ กทม. ๑๐๒๐๐",
}; };
} }
#endregion #endregion
@ -87,7 +88,7 @@ namespace BMA.EHR.Application.Repositories.Reports
Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน", Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน",
Subject2 = $"ตรวจสอบหนี้สิน และภาระผูกพันกับกรุงเทพมหานครของข้าราชการ", Subject2 = $"ตรวจสอบหนี้สิน และภาระผูกพันกับกรุงเทพมหานครของข้าราชการ",
Subject3 = $"ตรวจสอบหนี้สินและภาระผูกพันของข้าราชการ", Subject3 = $"ตรวจสอบหนี้สินและภาระผูกพันของข้าราชการ",
Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร 173 ถนนดินสอ กทม. 10200", Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร ๑๗๓ ถนนดินสอ กทม. ๑๐๒๐๐",
Name = $"{data.prefix}{data.firstName} {data.lastName}", Name = $"{data.prefix}{data.firstName} {data.lastName}",
Position = $"{data.PositionOld}", Position = $"{data.PositionOld}",
OrganizationOrganization = $"{data.Organization}", OrganizationOrganization = $"{data.Organization}",
@ -108,7 +109,7 @@ namespace BMA.EHR.Application.Repositories.Reports
Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน", Subject = $"ข้าราชการกรุงเทพมหานครสามัญขอโอน",
Subject2 = $"ตรวจสอบพฤติการณ์ทางวินัย และภาระหนี้สิน (เงินกู้สวัสดิการข้าราชการ) ของข้าราชการ", Subject2 = $"ตรวจสอบพฤติการณ์ทางวินัย และภาระหนี้สิน (เงินกู้สวัสดิการข้าราชการ) ของข้าราชการ",
Subject3 = $"ตรวจสอบภาระผูกพันกับกรุงเทพมหานครเกี่ยวกับการลาศึกษา อบรม ของข้าราชการ", Subject3 = $"ตรวจสอบภาระผูกพันกับกรุงเทพมหานครเกี่ยวกับการลาศึกษา อบรม ของข้าราชการ",
Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร 173 ถนนดินสอ กทม. 10200", Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร ๑๗๓ ถนนดินสอ กทม. ๑๐๒๐๐",
Name = $"{data.prefix}{data.firstName} {data.lastName}", Name = $"{data.prefix}{data.firstName} {data.lastName}",
Position = $"{data.PositionOld}", Position = $"{data.PositionOld}",
OrganizationOrganization = $"{data.Organization}", OrganizationOrganization = $"{data.Organization}",
@ -131,7 +132,7 @@ namespace BMA.EHR.Application.Repositories.Reports
Subject3 = $"ตรวจสอบภาระผูกพันกับกรุงเทพมหานครเกี่ยวกับการลาศึกษา อบรม ของข้าราชการ", Subject3 = $"ตรวจสอบภาระผูกพันกับกรุงเทพมหานครเกี่ยวกับการลาศึกษา อบรม ของข้าราชการ",
Subject4 = $"ตรวจสอบหนี้สิน และภาระผูกพันกับกรุงเทพมหานครของข้าราชการ", Subject4 = $"ตรวจสอบหนี้สิน และภาระผูกพันกับกรุงเทพมหานครของข้าราชการ",
Subject5 = $"ตรวจสอบหนี้สินและภาระผูกพันของข้าราชการ", Subject5 = $"ตรวจสอบหนี้สินและภาระผูกพันของข้าราชการ",
Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร 173 ถนนดินสอ กทม. 10200", Location = $"สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร ๑๗๓ ถนนดินสอ กทม. ๑๐๒๐๐",
Name = $"{data.prefix}{data.firstName} {data.lastName}", Name = $"{data.prefix}{data.firstName} {data.lastName}",
Position = $"{data.PositionOld}", Position = $"{data.PositionOld}",
OrganizationOrganization = $"{data.Organization}", OrganizationOrganization = $"{data.Organization}",

View file

@ -0,0 +1,13 @@
namespace BMA.EHR.Application.Responses
{
public class ProfileRetireJsonRequest
{
public string? order { get; set; }
public string? fullName { get; set; }
public string? position { get; set; }
public string? posNo { get; set; }
public string? root { get; set; }
public string? reason { get; set; }
}
}

View file

@ -1,5 +1,6 @@
using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Extensions;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.Reports; using BMA.EHR.Application.Repositories.Reports;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -20,12 +21,14 @@ namespace BMA.EHR.Report.Service.Controllers
private readonly RetireReportRepository _service; private readonly RetireReportRepository _service;
private readonly IWebHostEnvironment _hostingEnvironment; private readonly IWebHostEnvironment _hostingEnvironment;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
public RetireReportController(RetireReportRepository service, IWebHostEnvironment hostingEnvironment, IConfiguration configuration) public RetireReportController(RetireReportRepository service, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, PermissionRepository permission)
{ {
_service = service; _service = service;
_hostingEnvironment = hostingEnvironment; _hostingEnvironment = hostingEnvironment;
_configuration = configuration; _configuration = configuration;
_permission = permission;
} }
#region 31- & 32- #region 31- & 32-
@ -45,25 +48,28 @@ namespace BMA.EHR.Report.Service.Controllers
if (retire != null) if (retire != null)
{ {
var reportfile = string.Empty; var reportfile = string.Empty;
var returnfile = string.Empty; //var returnfile = string.Empty;
exportType = exportType.Trim(); exportType = exportType.Trim();
switch (retire.GetType().GetProperty("Type").GetValue(retire)) switch (retire.GetType().GetProperty("Type").GetValue(retire))
{ {
case "OFFICER": case "OFFICER":
if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire))) if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire)))
{ {
reportfile = $"31-ประกาศเกษียณข้าราชการ-1.trdp"; //reportfile = $"31-ประกาศเกษียณข้าราชการ-1.trdp";
returnfile = $"ประกาศเกษียณข้าราชการ.{exportType}"; //returnfile = $"ประกาศเกษียณข้าราชการ.{exportType}";
reportfile = $"retire-1";
} }
else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT") else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT")
{ {
reportfile = $"31-ประกาศเกษียณข้าราชการ-2.trdp"; //reportfile = $"31-ประกาศเกษียณข้าราชการ-2.trdp";
returnfile = $"แก้ไขประกาศเกษียณข้าราชการ.{exportType}"; //returnfile = $"แก้ไขประกาศเกษียณข้าราชการ.{exportType}";
reportfile = $"retire-2";
} }
else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE") else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE")
{ {
reportfile = $"31-ประกาศเกษียณข้าราชการ-3.trdp"; //reportfile = $"31-ประกาศเกษียณข้าราชการ-3.trdp";
returnfile = $"ยกเลิกประกาศเกษียณข้าราชการ.{exportType}"; //returnfile = $"ยกเลิกประกาศเกษียณข้าราชการ.{exportType}";
reportfile = $"retire-3";
} }
else else
{ {
@ -73,18 +79,21 @@ namespace BMA.EHR.Report.Service.Controllers
case "EMPLOYEE": case "EMPLOYEE":
if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire))) if (string.IsNullOrEmpty(retire.GetType().GetProperty("TypeReport").GetValue(retire)))
{ {
reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ-1.trdp"; //reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ-1.trdp";
returnfile = $"ประกาศเกษียณลูกจ้างประจำ.{exportType}"; //returnfile = $"ประกาศเกษียณลูกจ้างประจำ.{exportType}";
reportfile = $"retire-emp-1";
} }
else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT") else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "ADD" || retire.GetType().GetProperty("TypeReport").GetValue(retire) == "EDIT")
{ {
reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ-2.trdp"; //reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ-2.trdp";
returnfile = $"แก้ไขประกาศเกษียณลูกจ้างประจำ.{exportType}"; //returnfile = $"แก้ไขประกาศเกษียณลูกจ้างประจำ.{exportType}";
reportfile = $"retire-emp-2";
} }
else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE") else if (retire.GetType().GetProperty("TypeReport").GetValue(retire) == "REMOVE")
{ {
reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ-3.trdp"; //reportfile = $"32-ประกาศเกษียณลูกจ้างประจำ-3.trdp";
returnfile = $"ยกเลิกประกาศเกษียณลูกจ้างประจำ.{exportType}"; //returnfile = $"ยกเลิกประกาศเกษียณลูกจ้างประจำ.{exportType}";
reportfile = $"retire-emp-3";
} }
else else
{ {
@ -95,86 +104,94 @@ namespace BMA.EHR.Report.Service.Controllers
return Error(retire.GetType().GetProperty("Type").GetValue(retire)); return Error(retire.GetType().GetProperty("Type").GetValue(retire));
} }
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", reportfile); //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", reportfile);
ReportPackager reportPacker = new ReportPackager(); //ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null; //Telerik.Reporting.Report? report = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile)) //using (var sourceStream = System.IO.File.OpenRead(rptFile))
{ //{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream); // report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
} //}
report.ReportParameters["Type"].Value = (returnfile != "ยกเลิกประกาศเกษียณข้าราชการ.pdf" && returnfile != "ยกเลิกประกาศเกษียณข้าราชการ.docx") && (returnfile != "แก้ไขประกาศเกษียณข้าราชการ.pdf" && returnfile != "แก้ไขประกาศเกษียณข้าราชการ.docx") && (returnfile != "ยกเลิกประกาศเกษียณลูกจ้างประจำ.pdf" && returnfile != "ยกเลิกประกาศเกษียณลูกจ้างประจำ.docx") && (returnfile != "แก้ไขประกาศเกษียณลูกจ้างประจำ.pdf" && returnfile != "แก้ไขประกาศเกษียณลูกจ้างประจำ.docx") ? "1" : "0"; //report.ReportParameters["Type"].Value = (returnfile != "ยกเลิกประกาศเกษียณข้าราชการ.pdf" && returnfile != "ยกเลิกประกาศเกษียณข้าราชการ.docx") && (returnfile != "แก้ไขประกาศเกษียณข้าราชการ.pdf" && returnfile != "แก้ไขประกาศเกษียณข้าราชการ.docx") && (returnfile != "ยกเลิกประกาศเกษียณลูกจ้างประจำ.pdf" && returnfile != "ยกเลิกประกาศเกษียณลูกจ้างประจำ.docx") && (returnfile != "แก้ไขประกาศเกษียณลูกจ้างประจำ.pdf" && returnfile != "แก้ไขประกาศเกษียณลูกจ้างประจำ.docx") ? "1" : "0";
var _profileList = new List<dynamic>(); //var _profileList = new List<dynamic>();
var _count = 0; //var _count = 0;
var tmpOc1 = string.Empty; //var tmpOc1 = string.Empty;
foreach (var profile in retire.GetType().GetProperty("profile").GetValue(retire)) //foreach (var profile in retire.GetType().GetProperty("profile").GetValue(retire))
{ //{
var tmpOc2 = profile.GetType().GetProperty("root").GetValue(profile); // var tmpOc2 = profile.GetType().GetProperty("root").GetValue(profile);
if (tmpOc1 != tmpOc2) // if (tmpOc1 != tmpOc2)
{ // {
_count = 1; // _count = 1;
tmpOc1 = tmpOc2; // tmpOc1 = tmpOc2;
} // }
else // else
{ // {
_count++; // _count++;
} // }
string position = profile.GetType().GetProperty("position").GetValue(profile); // string position = profile.GetType().GetProperty("position").GetValue(profile);
position = position != string.Empty && position != null ? position : "-"; // position = position != string.Empty && position != null ? position : "-";
string thaiOrder = profile.GetType().GetProperty("order").GetValue(profile).ToString(); // string thaiOrder = profile.GetType().GetProperty("order").GetValue(profile).ToString();
thaiOrder = $"ลำดับที่ {thaiOrder.ToThaiNumber()}"; // thaiOrder = $"ลำดับที่ {thaiOrder.ToThaiNumber()}";
string thaiPosNo = profile.GetType().GetProperty("posNo").GetValue(profile); // string thaiPosNo = profile.GetType().GetProperty("posNo").GetValue(profile);
thaiPosNo = thaiPosNo != null ? $"(ตำแหน่งเลขที่ {thaiPosNo.ToThaiNumber()})" : $"(ตำแหน่งเลขที่ - )"; // thaiPosNo = thaiPosNo != null ? $"(ตำแหน่งเลขที่ {thaiPosNo.ToThaiNumber()})" : $"(ตำแหน่งเลขที่ - )";
string organizationOrganization = (profile.GetType().GetProperty("child4").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child4").GetValue(profile) + "/") + // string organizationOrganization = (profile.GetType().GetProperty("child4").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child4").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child3").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child3").GetValue(profile) + "/") + // (profile.GetType().GetProperty("child3").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child3").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child2").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child2").GetValue(profile) + "/") + // (profile.GetType().GetProperty("child2").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child2").GetValue(profile) + "/") +
(profile.GetType().GetProperty("child1").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child1").GetValue(profile) + "/") + // (profile.GetType().GetProperty("child1").GetValue(profile) == null ? "" : profile.GetType().GetProperty("child1").GetValue(profile) + "/") +
(profile.GetType().GetProperty("root").GetValue(profile) == null ? "" : profile.GetType().GetProperty("root").GetValue(profile)); // (profile.GetType().GetProperty("root").GetValue(profile) == null ? "" : profile.GetType().GetProperty("root").GetValue(profile));
string reason = profile.GetType().GetProperty("reason").GetValue(profile); // string reason = profile.GetType().GetProperty("reason").GetValue(profile);
organizationOrganization = organizationOrganization != string.Empty ? organizationOrganization : reason != string.Empty ? reason : string.Empty ; // organizationOrganization = organizationOrganization != string.Empty ? organizationOrganization : reason != string.Empty ? reason : string.Empty ;
reason = organizationOrganization == reason ? string.Empty : reason; // reason = organizationOrganization == reason ? string.Empty : reason;
_profileList.Add(new // _profileList.Add(new
{ // {
count = $"{_count.ToString().ToThaiNumber()}.", // count = $"{_count.ToString().ToThaiNumber()}.",
no = $"{(_profileList.Count() + 1).ToString().ToThaiNumber()}.", // no = $"{(_profileList.Count() + 1).ToString().ToThaiNumber()}.",
order = thaiOrder, // order = thaiOrder,
organizationOrganization = organizationOrganization, // organizationOrganization = organizationOrganization,
fullName = $"{profile.GetType().GetProperty("prefix").GetValue(profile)}{profile.GetType().GetProperty("firstName").GetValue(profile)} {profile.GetType().GetProperty("lastName").GetValue(profile)}", // fullName = $"{profile.GetType().GetProperty("prefix").GetValue(profile)}{profile.GetType().GetProperty("firstName").GetValue(profile)} {profile.GetType().GetProperty("lastName").GetValue(profile)}",
position = position, // position = position,
posNo = thaiPosNo, // posNo = thaiPosNo,
oc = profile.GetType().GetProperty("root").GetValue(profile), // oc = profile.GetType().GetProperty("root").GetValue(profile),
positionEmployeePosition = profile.GetType().GetProperty("position").GetValue(profile), // positionEmployeePosition = profile.GetType().GetProperty("position").GetValue(profile),
posNoEmployee = profile.GetType().GetProperty("posMasterNo").GetValue(profile), // posNoEmployee = profile.GetType().GetProperty("posMasterNo").GetValue(profile),
reason = reason, // reason = reason,
}); // });
} //}
//Binding Data ////Binding Data
if (report.ReportParameters["Type"].Value == "1") //if (report.ReportParameters["Type"].Value == "1")
//{
// // report.ReportParameters["Year"].Value = retire.GetType().GetProperty("year").GetValue(retire);
// // report.ReportParameters["Total"].Value = retire.GetType().GetProperty("total").GetValue(retire);
// // report.ReportParameters["Detail"].Value = retire.GetType().GetProperty("detail").GetValue(retire);
// // report.DataSource = _profileList;
// report.DataSource = retire;
// var tblProfile = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
// tblProfile.DataSource = _profileList;
//}
//else
//{
// report.DataSource = retire;
// var tblProfile = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
// tblProfile.DataSource = _profileList;
//}
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = report,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, $"application/{exportType}", returnfile);
var data = new
{ {
// report.ReportParameters["Year"].Value = retire.GetType().GetProperty("year").GetValue(retire); template = reportfile,
// report.ReportParameters["Total"].Value = retire.GetType().GetProperty("total").GetValue(retire); reportName = "docx-report",
// report.ReportParameters["Detail"].Value = retire.GetType().GetProperty("detail").GetValue(retire); data = retire
// report.DataSource = _profileList;
report.DataSource = retire;
var tblProfile = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
tblProfile.DataSource = _profileList;
}
else
{
report.DataSource = retire;
var tblProfile = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
tblProfile.DataSource = _profileList;
}
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = report,
}; };
return Success(data);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, $"application/{exportType}", returnfile);
} }
else else
{ {

View file

@ -61,54 +61,61 @@ namespace BMA.EHR.Report.Service.Controllers
try try
{ {
var data = await _service.GetData1Transfer(id); var data = await _service.GetData1Transfer(id);
var mimeType = ""; //var mimeType = "";
switch (exportType.Trim().ToLower()) //switch (exportType.Trim().ToLower())
//{
// case "pdf": mimeType = "application/pdf"; break;
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
//}
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-2.trdp");
//var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-3.trdp");
//var rptFile4 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-4.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//Telerik.Reporting.Report? report2 = null;
//Telerik.Reporting.Report? report3 = null;
//Telerik.Reporting.Report? report4 = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
//using (var sourceStream4 = System.IO.File.OpenRead(rptFile4))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
// report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
// report4 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream4);
//}
//report.DataSource = data;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report);
//reportBook.Reports.Add(report2);
//reportBook.Reports.Add(report3);
//reportBook.Reports.Add(report4);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, mimeType, $"แบบคำร้องขอโอน.{exportType.Trim().ToLower()}");
var result = new
{ {
case "pdf": mimeType = "application/pdf"; break; template = "transfer1",
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; reportName = "docx-report",
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; data = data
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-2.trdp");
var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-3.trdp");
var rptFile4 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"21-คำร้องขอโอน-4.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
Telerik.Reporting.Report? report2 = null;
Telerik.Reporting.Report? report3 = null;
Telerik.Reporting.Report? report4 = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
using (var sourceStream4 = System.IO.File.OpenRead(rptFile4))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
report4 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream4);
}
report.DataSource = data;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);
reportBook.Reports.Add(report3);
reportBook.Reports.Add(report4);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
}; };
return Success(result);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, mimeType, $"แบบคำร้องขอโอน.{exportType.Trim().ToLower()}");
} }
catch catch
{ {
@ -133,44 +140,51 @@ namespace BMA.EHR.Report.Service.Controllers
try try
{ {
var data = await _service.GetData2Transfer(id); var data = await _service.GetData2Transfer(id);
var mimeType = ""; //var mimeType = "";
switch (exportType.Trim().ToLower()) //switch (exportType.Trim().ToLower())
//{
// case "pdf": mimeType = "application/pdf"; break;
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
//}
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-2.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//Telerik.Reporting.Report? report2 = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
//}
//report.DataSource = data;
//report2.DataSource = data;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report);
//reportBook.Reports.Add(report2);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, mimeType, $"หนังสือแจ้งสำนักงานการเจ้าหน้าที่.{exportType.Trim().ToLower()}");
var result = new
{ {
case "pdf": mimeType = "application/pdf"; break; template = "transfer2",
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; reportName = "docx-report",
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; data = data
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"22-หนังสือแจ้งสำนักงานการเจ้าหน้าที่-2.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
Telerik.Reporting.Report? report2 = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
}
report.DataSource = data;
report2.DataSource = data;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
}; };
return Success(result);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, mimeType, $"หนังสือแจ้งสำนักงานการเจ้าหน้าที่.{exportType.Trim().ToLower()}");
} }
catch catch
{ {
@ -195,44 +209,51 @@ namespace BMA.EHR.Report.Service.Controllers
try try
{ {
var data = await _service.GetData3Transfer(id); var data = await _service.GetData3Transfer(id);
var mimeType = ""; //var mimeType = "";
switch (exportType.Trim().ToLower()) //switch (exportType.Trim().ToLower())
//{
// case "pdf": mimeType = "application/pdf"; break;
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
//}
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"23-หนังสือยินยอมให้โอน-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"23-หนังสือยินยอมให้โอน-2.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//Telerik.Reporting.Report? report2 = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
//}
//report.DataSource = data;
//report2.DataSource = data;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report);
//reportBook.Reports.Add(report2);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, mimeType, $"หนังสือยินยอมให้โอน.{exportType.Trim().ToLower()}");
var result = new
{ {
case "pdf": mimeType = "application/pdf"; break; template = "transfer3",
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; reportName = "docx-report",
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; data = data
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"23-หนังสือยินยอมให้โอน-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"23-หนังสือยินยอมให้โอน-2.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
Telerik.Reporting.Report? report2 = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
}
report.DataSource = data;
report2.DataSource = data;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
}; };
return Success(result);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, mimeType, $"หนังสือยินยอมให้โอน.{exportType.Trim().ToLower()}");
} }
catch catch
{ {
@ -257,51 +278,58 @@ namespace BMA.EHR.Report.Service.Controllers
try try
{ {
var data = await _service.GetData4Transfer(id); var data = await _service.GetData4Transfer(id);
var mimeType = ""; //var mimeType = "";
switch (exportType.Trim().ToLower()) //switch (exportType.Trim().ToLower())
//{
// case "pdf": mimeType = "application/pdf"; break;
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
//}
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-2.trdp");
//var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-3.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//Telerik.Reporting.Report? report2 = null;
//Telerik.Reporting.Report? report3 = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
// report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
//}
//report.DataSource = data;
//report2.DataSource = data;
//report3.DataSource = data;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report);
//reportBook.Reports.Add(report2);
//reportBook.Reports.Add(report3);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, mimeType, $"หนังสือแจ้งสหกรณ์ออมทรัพย์.{exportType.Trim().ToLower()}");
var result = new
{ {
case "pdf": mimeType = "application/pdf"; break; template = "transfer4",
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; reportName = "docx-report",
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; data = data
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-2.trdp");
var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"24-หนังสือแจ้งสหกรณ์ออมทรัพย์-3.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
Telerik.Reporting.Report? report2 = null;
Telerik.Reporting.Report? report3 = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
}
report.DataSource = data;
report2.DataSource = data;
report3.DataSource = data;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);
reportBook.Reports.Add(report3);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
}; };
return Success(result);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, mimeType, $"หนังสือแจ้งสหกรณ์ออมทรัพย์.{exportType.Trim().ToLower()}");
} }
catch catch
{ {
@ -326,51 +354,58 @@ namespace BMA.EHR.Report.Service.Controllers
try try
{ {
var data = await _service.GetData5Transfer(id); var data = await _service.GetData5Transfer(id);
var mimeType = ""; //var mimeType = "";
switch (exportType.Trim().ToLower()) //switch (exportType.Trim().ToLower())
//{
// case "pdf": mimeType = "application/pdf"; break;
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
//}
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-2.trdp");
//var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-3.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//Telerik.Reporting.Report? report2 = null;
//Telerik.Reporting.Report? report3 = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
// report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
//}
//report.DataSource = data;
//report2.DataSource = data;
//report3.DataSource = data;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report);
//reportBook.Reports.Add(report2);
//reportBook.Reports.Add(report3);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, mimeType, $"หนังสือถึงสํานักงานการเจ้าหน้าที่.{exportType.Trim().ToLower()}");
var result = new
{ {
case "pdf": mimeType = "application/pdf"; break; template = "transfer5",
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; reportName = "docx-report",
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; data = data
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-2.trdp");
var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"25-หนังสือถึงสํานักงานการเจ้าหน้าที่-3.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
Telerik.Reporting.Report? report2 = null;
Telerik.Reporting.Report? report3 = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
}
report.DataSource = data;
report2.DataSource = data;
report3.DataSource = data;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);
reportBook.Reports.Add(report3);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
}; };
return Success(result);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, mimeType, $"หนังสือถึงสํานักงานการเจ้าหน้าที่.{exportType.Trim().ToLower()}");
} }
catch catch
{ {
@ -395,62 +430,69 @@ namespace BMA.EHR.Report.Service.Controllers
try try
{ {
var data = await _service.GetData6Transfer(id); var data = await _service.GetData6Transfer(id);
var mimeType = ""; //var mimeType = "";
switch (exportType.Trim().ToLower()) //switch (exportType.Trim().ToLower())
//{
// case "pdf": mimeType = "application/pdf"; break;
// case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
// case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
//}
//var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-1.trdp");
//var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-2.trdp");
//var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-3.trdp");
//var rptFile4 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-4.trdp");
//var rptFile5 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-5.trdp");
//ReportPackager reportPacker = new ReportPackager();
//Telerik.Reporting.Report? report = null;
//Telerik.Reporting.Report? report2 = null;
//Telerik.Reporting.Report? report3 = null;
//Telerik.Reporting.Report? report4 = null;
//Telerik.Reporting.Report? report5 = null;
//using (var sourceStream = System.IO.File.OpenRead(rptFile))
//using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
//using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
//using (var sourceStream4 = System.IO.File.OpenRead(rptFile4))
//using (var sourceStream5 = System.IO.File.OpenRead(rptFile5))
//{
// report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
// report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
// report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
// report4 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream4);
// report5 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream5);
//}
//report.DataSource = data;
//report2.DataSource = data;
//report3.DataSource = data;
//report4.DataSource = data;
//report5.DataSource = data;
//var reportBook = new ReportBook();
//reportBook.Reports.Add(report);
//reportBook.Reports.Add(report2);
//reportBook.Reports.Add(report3);
//reportBook.Reports.Add(report4);
//reportBook.Reports.Add(report5);
//System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//InstanceReportSource instanceReportSource = new InstanceReportSource()
//{
// ReportDocument = reportBook,
//};
//ReportProcessor reportProcessor = new ReportProcessor(_configuration);
//RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
//var content = result.DocumentBytes;
//return File(content, mimeType, $"หนังสือถึงสถาบันพัฒนาข้าราชการ.{exportType.Trim().ToLower()}");
var result = new
{ {
case "pdf": mimeType = "application/pdf"; break; template = "transfer6",
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; reportName = "docx-report",
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; data = data
}
var rptFile = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-1.trdp");
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-2.trdp");
var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-3.trdp");
var rptFile4 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-4.trdp");
var rptFile5 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"26-หนังสือถึงสถาบันพัฒนาข้าราชการ-5.trdp");
ReportPackager reportPacker = new ReportPackager();
Telerik.Reporting.Report? report = null;
Telerik.Reporting.Report? report2 = null;
Telerik.Reporting.Report? report3 = null;
Telerik.Reporting.Report? report4 = null;
Telerik.Reporting.Report? report5 = null;
using (var sourceStream = System.IO.File.OpenRead(rptFile))
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
using (var sourceStream3 = System.IO.File.OpenRead(rptFile3))
using (var sourceStream4 = System.IO.File.OpenRead(rptFile4))
using (var sourceStream5 = System.IO.File.OpenRead(rptFile5))
{
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
report3 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream3);
report4 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream4);
report5 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream5);
}
report.DataSource = data;
report2.DataSource = data;
report3.DataSource = data;
report4.DataSource = data;
report5.DataSource = data;
var reportBook = new ReportBook();
reportBook.Reports.Add(report);
reportBook.Reports.Add(report2);
reportBook.Reports.Add(report3);
reportBook.Reports.Add(report4);
reportBook.Reports.Add(report5);
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
{
ReportDocument = reportBook,
}; };
return Success(result);
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, mimeType, $"หนังสือถึงสถาบันพัฒนาข้าราชการ.{exportType.Trim().ToLower()}");
} }
catch catch
{ {