1067 lines
75 KiB
C#
1067 lines
75 KiB
C#
using BMA.EHR.Domain.Common;
|
||
using BMA.EHR.Application.Repositories.Reports;
|
||
using Microsoft.AspNetCore.Authorization;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using Swashbuckle.AspNetCore.Annotations;
|
||
using Telerik.Reporting;
|
||
using Telerik.Reporting.Processing;
|
||
using System.Text.RegularExpressions;
|
||
|
||
namespace BMA.EHR.Report.Service.Controllers
|
||
{
|
||
[Route("api/v{version:apiVersion}/report/probation")]
|
||
[ApiVersion("2.0")]
|
||
[ApiController]
|
||
[Produces("application/json")]
|
||
[Authorize]
|
||
[SwaggerTag("API รายงานระบทดลองงาน")]
|
||
public class ProbationReportController : BaseController
|
||
{
|
||
#region " Fields "
|
||
|
||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||
private readonly IConfiguration _configuration;
|
||
private readonly ProbationReportRepository _repository;
|
||
private readonly GenericReportGenerator _reportGenerator;
|
||
|
||
#endregion
|
||
|
||
#region " Constuctor and Destructor "
|
||
|
||
public ProbationReportController(IWebHostEnvironment hostingEnvironment, IConfiguration configuration, ProbationReportRepository repository, GenericReportGenerator reportGenerator)
|
||
{
|
||
|
||
_hostingEnvironment = hostingEnvironment;
|
||
_configuration = configuration;
|
||
_repository = repository;
|
||
_reportGenerator = reportGenerator;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region " Methods "
|
||
|
||
#region 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ
|
||
/// <summary>
|
||
/// 13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ
|
||
/// </summary>
|
||
/// <param name="id">assign id แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ</param>
|
||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||
/// <returns></returns>
|
||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||
[HttpGet("13/{exportType}/{id}")]
|
||
public async Task<ActionResult<ResponseObject>> GetProbationReportAsync(Guid id, string exportType = "pdf")
|
||
{
|
||
try
|
||
{
|
||
|
||
string authorizationHeader = Request.Headers["Authorization"];
|
||
string token = string.Empty;
|
||
|
||
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||
{
|
||
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||
var probation = await _repository.GetProbationAssignAsync(id, token);
|
||
|
||
if(probation != null)
|
||
{
|
||
var mimeType = "";
|
||
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", $"13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ-1.trdp");
|
||
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ-2.trdp");
|
||
var rptFile3 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"13-แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ-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.ReportParameters["Name"].Value = probation.GetType().GetProperty("Name").GetValue(probation);
|
||
report.ReportParameters["Position"].Value = probation.GetType().GetProperty("Position").GetValue(probation);
|
||
report.ReportParameters["Department"].Value = probation.GetType().GetProperty("Department").GetValue(probation);
|
||
report.ReportParameters["OrganizationOrganization"].Value = probation.GetType().GetProperty("OrganizationOrganization").GetValue(probation);
|
||
report.ReportParameters["Oc"].Value = probation.GetType().GetProperty("Oc").GetValue(probation);
|
||
report.ReportParameters["DateStart"].Value = probation.GetType().GetProperty("DateStart").GetValue(probation);
|
||
report.ReportParameters["DateFinish"].Value = probation.GetType().GetProperty("DateFinish").GetValue(probation);
|
||
report.ReportParameters["NameMentor1"].Value = probation.GetType().GetProperty("NameMentor1").GetValue(probation);
|
||
report.ReportParameters["DateMentor1"].Value = probation.GetType().GetProperty("DateMentor1").GetValue(probation);
|
||
report.ReportParameters["PositionMentor1"].Value = probation.GetType().GetProperty("PositionMentor1").GetValue(probation);
|
||
report.ReportParameters["NameMentor2"].Value = probation.GetType().GetProperty("NameMentor2").GetValue(probation);
|
||
report.ReportParameters["DateMentor2"].Value = probation.GetType().GetProperty("DateMentor2").GetValue(probation);
|
||
report.ReportParameters["PositionMentor2"].Value = probation.GetType().GetProperty("PositionMentor2").GetValue(probation);
|
||
report2.ReportParameters["Behave"].Value =
|
||
"ความประพฤติ\n" +
|
||
" • ให้บริการประชาชนหรือผู้รับบริการด้วยอัธยาศัยดี\n" +
|
||
" • มีความรับผิดชอบในการปฏิบัติงาน\n" +
|
||
" • ให้บริการประชาชนหรือผู้รับบริการด้วยความรวดเร็ว เอาใจใส่เป็นมาตรฐานเดียวกัน\n" +
|
||
" • ตั้งใจปฏิบัติหน้าที่ราชการด้วยความอุตสาหะ ขยันหมั่นเพียร\n" +
|
||
"ความมีคุณธรรมจริยธรรม ได้แก่\n" +
|
||
" • อุทิศตนและเสียสละเวลาในการปฏิบัติงานอย่างเต็มกำลังความสามารถ\n" +
|
||
" • มีจิตสำนึกที่ดี ปฏิบัติงานด้วยความซื่อสัตย์ สุจริต\n" +
|
||
" • ยึดมั่นในสถาบันพระมหากษัตริย์ และไม่กระทำการใด ๆ อันจะก่อให้เกิดความเสียหายต่อประเทศชาติ ศาสนา และพระมหากษัตริย์\n" +
|
||
"การรักษาวินัย ได้แก่\n" +
|
||
" • มีความรับผิดชอบในการรักษาเวลาทำงาน\n" +
|
||
" • แต่งกายในการปฏิบัติงานได้อย่างเหมาะสมกับการเป็นข้าราชการ\n" +
|
||
" • ไม่กระทำการใด ๆ อันเป็นการเสื่อมเกียรติและศักดิ์ศรีของความเป็นข้าราชการ\n" +
|
||
" • ไม่กระทำการใด ๆ อันอาจก่อให้เกิดความเสียหายแก่ชื่อเสียงของหน่วยงาน\n" +
|
||
" • ปฏิบัติหน้าที่อย่างตรงไปตรงมาโดยยึดหลักจรรยาบรรณวิชาชีพ\n";
|
||
report2.ReportParameters["OtherDesc"].Value = probation.GetType().GetProperty("OtherDesc").GetValue(probation);
|
||
report2.ReportParameters["Other4Desc"].Value = probation.GetType().GetProperty("Other4Desc").GetValue(probation);
|
||
report2.ReportParameters["Other5No1Desc"].Value = probation.GetType().GetProperty("Other5No1Desc").GetValue(probation);
|
||
report3.ReportParameters["Name"].Value = probation.GetType().GetProperty("Name").GetValue(probation);
|
||
report3.ReportParameters["Position"].Value = probation.GetType().GetProperty("Position").GetValue(probation);
|
||
report3.ReportParameters["DateStart"].Value = probation.GetType().GetProperty("DateStart").GetValue(probation);
|
||
report3.ReportParameters["NameMentor1"].Value = probation.GetType().GetProperty("NameMentor1").GetValue(probation);
|
||
report3.ReportParameters["PositionMentor1"].Value = probation.GetType().GetProperty("PositionMentor1").GetValue(probation);
|
||
report3.ReportParameters["DateMentor1"].Value = probation.GetType().GetProperty("DateMentor1").GetValue(probation);
|
||
report3.ReportParameters["NameCommander"].Value = probation.GetType().GetProperty("NameCommander").GetValue(probation);
|
||
report3.ReportParameters["PositionCommander"].Value = probation.GetType().GetProperty("PositionCommander").GetValue(probation);
|
||
report3.ReportParameters["DateCommander"].Value = probation.GetType().GetProperty("DateCommander").GetValue(probation);
|
||
report3.ReportParameters["Other5No2Desc"].Value = probation.GetType().GetProperty("Other5No2Desc").GetValue(probation);
|
||
report3.ReportParameters["NameMentor2"].Value = probation.GetType().GetProperty("NameMentor2").GetValue(probation);
|
||
report3.ReportParameters["DateMentor2"].Value = probation.GetType().GetProperty("DateMentor2").GetValue(probation);
|
||
report3.ReportParameters["PositionMentor2"].Value = probation.GetType().GetProperty("PositionMentor2").GetValue(probation);
|
||
|
||
var _jobsList = new List<dynamic>();
|
||
dynamic jobs = probation.GetType().GetProperty("Jobs").GetValue(probation);
|
||
foreach (var job in jobs)
|
||
{
|
||
_jobsList.Add(new
|
||
{
|
||
Id = "-",
|
||
Activity_desc = job.activity_desc,
|
||
Goal_desc = job.goal_desc,
|
||
});
|
||
}
|
||
var tblJobsActivity = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||
tblJobsActivity.DataSource = _jobsList;
|
||
var tblJobsGoal = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
|
||
tblJobsGoal.DataSource = _jobsList;
|
||
|
||
var _knowledgeList = new List<dynamic>();
|
||
dynamic knowledges = probation.GetType().GetProperty("Knowledge").GetValue(probation);
|
||
foreach (var knowledge in knowledges)
|
||
{
|
||
string output = Regex.Replace(knowledge.description, "<.*?>", string.Empty);
|
||
output = output.Replace(" ", " ");
|
||
_knowledgeList.Add(new
|
||
{
|
||
Title = knowledge.title,
|
||
Description = output
|
||
});
|
||
}
|
||
var tblKnowledges = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table3"];
|
||
tblKnowledges.DataSource = _knowledgeList;
|
||
|
||
var _competencysList = new List<dynamic>();
|
||
dynamic competencys = probation.GetType().GetProperty("Competency").GetValue(probation);
|
||
foreach (var competency in competencys)
|
||
{
|
||
string output = Regex.Replace(competency.description, "<.*?>", string.Empty);
|
||
output = output.Replace(" ", " ");
|
||
_competencysList.Add(new
|
||
{
|
||
Id = competency.id,
|
||
Title = competency.title,
|
||
Description = output
|
||
});
|
||
}
|
||
var tblCompetencys = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table4"];
|
||
tblCompetencys.DataSource = _competencysList;
|
||
|
||
var _OutputsList = new List<dynamic>();
|
||
dynamic Outputs = probation.GetType().GetProperty("Outputs").GetValue(probation);
|
||
foreach (var Output in Outputs)
|
||
{
|
||
_OutputsList.Add(new
|
||
{
|
||
Output_desc = Output.output_desc,
|
||
Indicator_desc = Output.indicator_desc,
|
||
});
|
||
}
|
||
var tblOutputs = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table1"];
|
||
tblOutputs.DataSource = _OutputsList;
|
||
|
||
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()}");
|
||
}
|
||
else
|
||
{
|
||
return NotFound();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Unauthorized();
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 14,15-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา
|
||
/// <summary>
|
||
/// 14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา
|
||
/// </summary>
|
||
/// <param name="id">evaluate id</param>
|
||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||
/// <returns></returns>
|
||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||
[HttpGet("14/{exportType}/{id}")]
|
||
public async Task<ActionResult<ResponseObject>> GetProbation14ConvertReportAsync(Guid id, string exportType = "pdf")
|
||
{
|
||
try
|
||
{
|
||
string authorizationHeader = Request.Headers["Authorization"];
|
||
string token = string.Empty;
|
||
|
||
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||
{
|
||
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||
var evaluateRecord = await _repository.GetEvaluateRecordAsync(id, token);
|
||
|
||
if (evaluateRecord != null)
|
||
{
|
||
var mimeType = "";
|
||
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", $"14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา-1.trdp");
|
||
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"14-แบบบันทึกผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้ดูแล และ ผู้บังคับบัญชา-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.ReportParameters["DirectorName"].Value = evaluateRecord.GetType().GetProperty("DirectorName").GetValue(evaluateRecord);
|
||
report.ReportParameters["DirectorPosition"].Value = evaluateRecord.GetType().GetProperty("DirectorPosition").GetValue(evaluateRecord);
|
||
report.ReportParameters["Name"].Value = evaluateRecord.GetType().GetProperty("Name").GetValue(evaluateRecord);
|
||
report.ReportParameters["Position"].Value = evaluateRecord.GetType().GetProperty("Position").GetValue(evaluateRecord);
|
||
report.ReportParameters["Department"].Value = evaluateRecord.GetType().GetProperty("Department").GetValue(evaluateRecord);
|
||
report.ReportParameters["OrganizationOrganization"].Value = evaluateRecord.GetType().GetProperty("Organizationorganization").GetValue(evaluateRecord);
|
||
report.ReportParameters["Oc"].Value = evaluateRecord.GetType().GetProperty("Oc").GetValue(evaluateRecord);
|
||
report.ReportParameters["DateStart"].Value = evaluateRecord.GetType().GetProperty("DateStart").GetValue(evaluateRecord);
|
||
report.ReportParameters["DateFinish"].Value = evaluateRecord.GetType().GetProperty("DateFinish").GetValue(evaluateRecord);
|
||
report.ReportParameters["No"].Value = evaluateRecord.GetType().GetProperty("No").GetValue(evaluateRecord);
|
||
report.ReportParameters["EvaluateDateStart"].Value = evaluateRecord.GetType().GetProperty("EvaluateDateStart").GetValue(evaluateRecord);
|
||
report.ReportParameters["EvaluateDateFinish"].Value = evaluateRecord.GetType().GetProperty("EvaluateDateFinish").GetValue(evaluateRecord);
|
||
report.ReportParameters["Role"].Value = evaluateRecord.GetType().GetProperty("Role").GetValue(evaluateRecord);
|
||
report2.ReportParameters["Role"].Value = evaluateRecord.GetType().GetProperty("Role").GetValue(evaluateRecord);
|
||
report2.ReportParameters["DirectorName"].Value = evaluateRecord.GetType().GetProperty("DirectorName").GetValue(evaluateRecord);
|
||
report2.ReportParameters["DirectorPosition"].Value = evaluateRecord.GetType().GetProperty("DirectorPosition").GetValue(evaluateRecord);
|
||
report2.ReportParameters["DirectorDated"].Value = evaluateRecord.GetType().GetProperty("DirectorDated").GetValue(evaluateRecord);
|
||
//1.1
|
||
var _Achievementslist = new List<dynamic>();
|
||
dynamic Achievements = evaluateRecord.GetType().GetProperty("Achievements").GetValue(evaluateRecord);
|
||
foreach (var achievements in Achievements)
|
||
{
|
||
_Achievementslist.Add(new
|
||
{
|
||
evaluate_expect_desc = achievements.evaluate_expect_desc,
|
||
expectCol1 = achievements.evaluate_expect_level.col1,
|
||
expectCol2 = achievements.evaluate_expect_level.col2,
|
||
expectCol3 = achievements.evaluate_expect_level.col3,
|
||
expectCol4 = achievements.evaluate_expect_level.col4,
|
||
expectCol5 = achievements.evaluate_expect_level.col5,
|
||
evaluate_output_desc = achievements.evaluate_output_desc,
|
||
outputCol1 = achievements.evaluate_output_level.col1,
|
||
outputCol2 = achievements.evaluate_output_level.col2,
|
||
outputCol3 = achievements.evaluate_output_level.col3,
|
||
outputCol4 = achievements.evaluate_output_level.col4,
|
||
outputCol5 = achievements.evaluate_output_level.col5,
|
||
});
|
||
}
|
||
var tblEvaluate1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||
tblEvaluate1.DataSource = _Achievementslist;
|
||
//1.2 ... 1.7
|
||
var _Evaluatelist = new List<dynamic>();
|
||
dynamic evaluate = evaluateRecord.GetType().GetProperty("Evaluate").GetValue(evaluateRecord);
|
||
dynamic knowledge = evaluate.knowledge_level;
|
||
dynamic skill = evaluate.skill_level;
|
||
dynamic competency = evaluate.competency_level;
|
||
dynamic learn = evaluate.learn_level;
|
||
dynamic apply = evaluate.apply_level;
|
||
dynamic achievement = evaluate.achievement_other_level;
|
||
string achievement_other_desc = evaluate.achievement_other_desc;
|
||
string achievement_strength_desc = evaluate.achievement_strength_desc;
|
||
string achievement_improve_desc = evaluate.achievement_improve_desc;
|
||
//2.1 ... 2.4
|
||
dynamic conduct1 = evaluate.conduct1_level;
|
||
dynamic conduct2 = evaluate.conduct2_level;
|
||
dynamic conduct3 = evaluate.conduct3_level;
|
||
dynamic conduct4 = evaluate.conduct4_level;
|
||
dynamic moral1 = evaluate.moral1_level;
|
||
dynamic moral2 = evaluate.moral2_level;
|
||
dynamic moral3 = evaluate.moral3_level;
|
||
dynamic discipline1 = evaluate.discipline1_level;
|
||
dynamic discipline2 = evaluate.discipline2_level;
|
||
dynamic discipline3 = evaluate.discipline3_level;
|
||
dynamic discipline4 = evaluate.discipline4_level;
|
||
dynamic discipline5 = evaluate.discipline5_level;
|
||
dynamic behavior = evaluate.behavior_other_level;
|
||
string behavior_other_desc = evaluate.behavior_other_desc;
|
||
string behavior_strength_desc = evaluate.behavior_strength_desc;
|
||
string behavior_improve_desc = evaluate.behavior_improve_desc;
|
||
string orientation = evaluate.orientation;
|
||
string self_learning = evaluate.self_learning;
|
||
string training_seminar = evaluate.training_seminar;
|
||
string other_training = evaluate.other_training;
|
||
_Evaluatelist.Add(new
|
||
{
|
||
knowledge_col1 = knowledge.col1,
|
||
knowledge_col2 = knowledge.col2,
|
||
knowledge_col3 = knowledge.col3,
|
||
knowledge_col4 = knowledge.col4,
|
||
knowledge_col5 = knowledge.col5,
|
||
skill_col1 = skill.col1,
|
||
skill_col2 = skill.col2,
|
||
skill_col3 = skill.col3,
|
||
skill_col4 = skill.col4,
|
||
skill_col5 = skill.col5,
|
||
competency_col1 = competency.col1,
|
||
competency_col2 = competency.col2,
|
||
competency_col3 = competency.col3,
|
||
competency_col4 = competency.col4,
|
||
competency_col5 = competency.col5,
|
||
learn_col1 = learn.col1,
|
||
learn_col2 = learn.col2,
|
||
learn_col3 = learn.col3,
|
||
learn_col4 = learn.col4,
|
||
learn_col5 = learn.col5,
|
||
apply_col1 = apply.col1,
|
||
apply_col2 = apply.col2,
|
||
apply_col3 = apply.col3,
|
||
apply_col4 = apply.col4,
|
||
apply_col5 = apply.col5,
|
||
achievement_col1 = achievement.col1,
|
||
achievement_col2 = achievement.col2,
|
||
achievement_col3 = achievement.col3,
|
||
achievement_col4 = achievement.col4,
|
||
achievement_col5 = achievement.col5,
|
||
achievement_other_desc,
|
||
achievement_strength_desc,
|
||
achievement_improve_desc,
|
||
conduct1_col1 = conduct1.col1,
|
||
conduct1_col2 = conduct1.col2,
|
||
conduct1_col3 = conduct1.col3,
|
||
conduct1_col4 = conduct1.col4,
|
||
conduct1_col5 = conduct1.col5,
|
||
conduct2_col1 = conduct2.col1,
|
||
conduct2_col2 = conduct2.col2,
|
||
conduct2_col3 = conduct2.col3,
|
||
conduct2_col4 = conduct2.col4,
|
||
conduct2_col5 = conduct2.col5,
|
||
conduct3_col1 = conduct3.col1,
|
||
conduct3_col2 = conduct3.col2,
|
||
conduct3_col3 = conduct3.col3,
|
||
conduct3_col4 = conduct3.col4,
|
||
conduct3_col5 = conduct3.col5,
|
||
conduct4_col1 = conduct4.col1,
|
||
conduct4_col2 = conduct4.col2,
|
||
conduct4_col3 = conduct4.col3,
|
||
conduct4_col4 = conduct4.col4,
|
||
conduct4_col5 = conduct4.col5,
|
||
moral1_col1 = moral1.col1,
|
||
moral1_col2 = moral1.col2,
|
||
moral1_col3 = moral1.col3,
|
||
moral1_col4 = moral1.col4,
|
||
moral1_col5 = moral1.col5,
|
||
moral2_col1 = moral2.col1,
|
||
moral2_col2 = moral2.col2,
|
||
moral2_col3 = moral2.col3,
|
||
moral2_col4 = moral2.col4,
|
||
moral2_col5 = moral2.col5,
|
||
moral3_col1 = moral3.col1,
|
||
moral3_col2 = moral3.col2,
|
||
moral3_col3 = moral3.col3,
|
||
moral3_col4 = moral3.col4,
|
||
moral3_col5 = moral3.col5,
|
||
discipline1_col1 = discipline1.col1,
|
||
discipline1_col2 = discipline1.col2,
|
||
discipline1_col3 = discipline1.col3,
|
||
discipline1_col4 = discipline1.col4,
|
||
discipline1_col5 = discipline1.col5,
|
||
discipline2_col1 = discipline2.col1,
|
||
discipline2_col2 = discipline2.col2,
|
||
discipline2_col3 = discipline2.col3,
|
||
discipline2_col4 = discipline2.col4,
|
||
discipline2_col5 = discipline2.col5,
|
||
discipline3_col1 = discipline3.col1,
|
||
discipline3_col2 = discipline3.col2,
|
||
discipline3_col3 = discipline3.col3,
|
||
discipline3_col4 = discipline3.col4,
|
||
discipline3_col5 = discipline3.col5,
|
||
discipline4_col1 = discipline4.col1,
|
||
discipline4_col2 = discipline4.col2,
|
||
discipline4_col3 = discipline4.col3,
|
||
discipline4_col4 = discipline4.col4,
|
||
discipline4_col5 = discipline4.col5,
|
||
discipline5_col1 = discipline5.col1,
|
||
discipline5_col2 = discipline5.col2,
|
||
discipline5_col3 = discipline5.col3,
|
||
discipline5_col4 = discipline5.col4,
|
||
discipline5_col5 = discipline5.col5,
|
||
behavior_col1 = behavior.col1,
|
||
behavior_col2 = behavior.col2,
|
||
behavior_col3 = behavior.col3,
|
||
behavior_col4 = behavior.col4,
|
||
behavior_col5 = behavior.col5,
|
||
behavior_other_desc,
|
||
behavior_strength_desc,
|
||
behavior_improve_desc,
|
||
orientation,
|
||
self_learning,
|
||
training_seminar,
|
||
other_training,
|
||
});
|
||
|
||
var tblEvaluate2 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table3"];
|
||
tblEvaluate2.DataSource = _Evaluatelist;
|
||
var tblEvaluate3 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table4"];
|
||
tblEvaluate3.DataSource = _Evaluatelist;
|
||
var tblEvaluate4 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table1"];
|
||
tblEvaluate4.DataSource = _Evaluatelist;
|
||
var tblEvaluate5 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table4"];
|
||
tblEvaluate5.DataSource = _Evaluatelist;
|
||
var tblEvaluate6 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table2"];
|
||
tblEvaluate6.DataSource = _Evaluatelist;
|
||
|
||
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()}");
|
||
}
|
||
else
|
||
{
|
||
return NotFound();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Unauthorized();
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
||
/// <summary>
|
||
/// 16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา
|
||
/// </summary>
|
||
/// <param name="id">evaluate id</param>
|
||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||
/// <returns></returns>
|
||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||
[HttpGet("16/{exportType}/{id}")]
|
||
public async Task<ActionResult<ResponseObject>> GetProbation16ConvertReportAsync(Guid id, string exportType = "pdf")
|
||
{
|
||
try
|
||
{
|
||
string authorizationHeader = Request.Headers["Authorization"];
|
||
string token = string.Empty;
|
||
|
||
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||
{
|
||
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||
var evaluateAssign = await _repository.GetEvaluateAssignAsync(id, token);
|
||
|
||
if (evaluateAssign != null)
|
||
{
|
||
var mimeType = "";
|
||
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", $"16-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับผู้บังคับบัญชา-1.trdp");
|
||
|
||
ReportPackager reportPacker = new ReportPackager();
|
||
Telerik.Reporting.Report? report = null;
|
||
|
||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||
{
|
||
report = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream);
|
||
}
|
||
report.ReportParameters["No"].Value = evaluateAssign.GetType().GetProperty("No").GetValue(evaluateAssign);
|
||
report.ReportParameters["EvaluateDateStart"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateStart").GetValue(evaluateAssign);
|
||
report.ReportParameters["EvaluateDateFinish"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateFinish").GetValue(evaluateAssign);
|
||
report.ReportParameters["Name"].Value = evaluateAssign.GetType().GetProperty("Name").GetValue(evaluateAssign);
|
||
report.ReportParameters["Position"].Value = evaluateAssign.GetType().GetProperty("Position").GetValue(evaluateAssign);
|
||
report.ReportParameters["Department"].Value = evaluateAssign.GetType().GetProperty("Department").GetValue(evaluateAssign);
|
||
report.ReportParameters["OrganizationOrganization"].Value = evaluateAssign.GetType().GetProperty("OrganizationOrganization").GetValue(evaluateAssign);
|
||
report.ReportParameters["Oc"].Value = evaluateAssign.GetType().GetProperty("Oc").GetValue(evaluateAssign);
|
||
report.ReportParameters["DateStart"].Value = evaluateAssign.GetType().GetProperty("DateStart").GetValue(evaluateAssign);
|
||
report.ReportParameters["DateFinish"].Value = evaluateAssign.GetType().GetProperty("DateFinish").GetValue(evaluateAssign);
|
||
report.ReportParameters["BehaviorStrengthDesc"].Value = evaluateAssign.GetType().GetProperty("BehaviorStrengthDesc").GetValue(evaluateAssign);
|
||
report.ReportParameters["BehaviorImproveDesc"].Value = evaluateAssign.GetType().GetProperty("BehaviorImproveDesc").GetValue(evaluateAssign);
|
||
report.ReportParameters["CommanderName"].Value = evaluateAssign.GetType().GetProperty("CommanderName").GetValue(evaluateAssign);
|
||
report.ReportParameters["CommanderPosition"].Value = evaluateAssign.GetType().GetProperty("CommanderPosition").GetValue(evaluateAssign);
|
||
report.ReportParameters["CommanderDated"].Value = evaluateAssign.GetType().GetProperty("CommanderDated").GetValue(evaluateAssign);
|
||
|
||
dynamic evaluate = evaluateAssign.GetType().GetProperty("Evaluate").GetValue(evaluateAssign);
|
||
dynamic knowledge = evaluate.knowledge_level;
|
||
dynamic skill = evaluate.skill_level;
|
||
dynamic competency = evaluate.competency_level;
|
||
dynamic learn = evaluate.learn_level;
|
||
dynamic apply = evaluate.apply_level;
|
||
dynamic success = evaluate.success_level;
|
||
dynamic achievement = evaluate.achievement_other_level;
|
||
dynamic conduct1 = evaluate.conduct1_level;
|
||
dynamic conduct2 = evaluate.conduct2_level;
|
||
dynamic conduct3 = evaluate.conduct3_level;
|
||
dynamic conduct4 = evaluate.conduct4_level;
|
||
dynamic moral1 = evaluate.moral1_level;
|
||
dynamic moral2 = evaluate.moral2_level;
|
||
dynamic moral3 = evaluate.moral3_level;
|
||
dynamic discipline1 = evaluate.discipline1_level;
|
||
dynamic discipline2 = evaluate.discipline2_level;
|
||
dynamic discipline3 = evaluate.discipline3_level;
|
||
dynamic discipline4 = evaluate.discipline4_level;
|
||
dynamic discipline5 = evaluate.discipline5_level;
|
||
dynamic behavior = evaluate.behavior_other_level;
|
||
var _Evaluate= new List<dynamic>();
|
||
_Evaluate.Add(new
|
||
{
|
||
Check_Knowledge1 = knowledge.col1,
|
||
Check_Knowledge2 = knowledge.col2,
|
||
Check_Knowledge3 = knowledge.col3,
|
||
Check_Knowledge4 = knowledge.col4,
|
||
Check_Knowledge5 = knowledge.col5,
|
||
Check_SkillLevel1 = skill.col1,
|
||
Check_SkillLevel2 = skill.col2,
|
||
Check_SkillLevel3 = skill.col3,
|
||
Check_SkillLevel4 = skill.col4,
|
||
Check_SkillLevel5 = skill.col5,
|
||
Check_CompetencyLevel1 = competency.col1,
|
||
Check_CompetencyLevel2 = competency.col2,
|
||
Check_CompetencyLevel3 = competency.col3,
|
||
Check_CompetencyLevel4 = competency.col4,
|
||
Check_CompetencyLevel5 = competency.col5,
|
||
Check_LearnLevel1 = learn.col1,
|
||
Check_LearnLevel2 = learn.col2,
|
||
Check_LearnLevel3 = learn.col3,
|
||
Check_LearnLevel4 = learn.col4,
|
||
Check_LearnLevel5 = learn.col5,
|
||
Check_ApplyLevel1 = apply.col1,
|
||
Check_ApplyLevel2 = apply.col2,
|
||
Check_ApplyLevel3 = apply.col3,
|
||
Check_ApplyLevel4 = apply.col4,
|
||
Check_ApplyLevel5 = apply.col5,
|
||
Check_Success_level1 = success.col1,
|
||
Check_Success_level2 = success.col2,
|
||
Check_Success_level3 = success.col3,
|
||
Check_Success_level4 = success.col4,
|
||
Check_Success_level5 = success.col5,
|
||
AchievementOtherDesc = evaluate.achievement_other_desc,
|
||
Check_AchievementOtherLevel1 = achievement.col1,
|
||
Check_AchievementOtherLevel2 = achievement.col2,
|
||
Check_AchievementOtherLevel3 = achievement.col3,
|
||
Check_AchievementOtherLevel4 = achievement.col4,
|
||
Check_AchievementOtherLevel5 = achievement.col5,
|
||
Check_Conduct1Level1 = conduct1.col1,
|
||
Check_Conduct1Level2 = conduct1.col2,
|
||
Check_Conduct1Level3 = conduct1.col3,
|
||
Check_Conduct1Level4 = conduct1.col4,
|
||
Check_Conduct1Level5 = conduct1.col5,
|
||
Check_Conduct2Level1 = conduct2.col1,
|
||
Check_Conduct2Level2 = conduct2.col2,
|
||
Check_Conduct2Level3 = conduct2.col3,
|
||
Check_Conduct2Level4 = conduct2.col4,
|
||
Check_Conduct2Level5 = conduct2.col5,
|
||
Check_Conduct3Level1 = conduct3.col1,
|
||
Check_Conduct3Level2 = conduct3.col2,
|
||
Check_Conduct3Level3 = conduct3.col3,
|
||
Check_Conduct3Level4 = conduct3.col4,
|
||
Check_Conduct3Level5 = conduct3.col5,
|
||
Check_Conduct4Level1 = conduct4.col1,
|
||
Check_Conduct4Level2 = conduct4.col2,
|
||
Check_Conduct4Level3 = conduct4.col3,
|
||
Check_Conduct4Level4 = conduct4.col4,
|
||
Check_Conduct4Level5 = conduct4.col5,
|
||
Check_Moral1Level1 = moral1.col1,
|
||
Check_Moral1Level2 = moral1.col2,
|
||
Check_Moral1Level3 = moral1.col3,
|
||
Check_Moral1Level4 = moral1.col4,
|
||
Check_Moral1Level5 = moral1.col5,
|
||
Check_Moral2Level1 = moral2.col1,
|
||
Check_Moral2Level2 = moral2.col2,
|
||
Check_Moral2Level3 = moral2.col3,
|
||
Check_Moral2Level4 = moral2.col4,
|
||
Check_Moral2Level5 = moral2.col5,
|
||
Check_Moral3Level1 = moral3.col1,
|
||
Check_Moral3Level2 = moral3.col2,
|
||
Check_Moral3Level3 = moral3.col3,
|
||
Check_Moral3Level4 = moral3.col4,
|
||
Check_Moral3Level5 = moral3.col5,
|
||
Check_Discipline1Level1 = discipline1.col1,
|
||
Check_Discipline1Level2 = discipline1.col2,
|
||
Check_Discipline1Level3 = discipline1.col3,
|
||
Check_Discipline1Level4 = discipline1.col4,
|
||
Check_Discipline1Level5 = discipline1.col5,
|
||
Check_Discipline2Level1 = discipline2.col1,
|
||
Check_Discipline2Level2 = discipline2.col2,
|
||
Check_Discipline2Level3 = discipline2.col3,
|
||
Check_Discipline2Level4 = discipline2.col4,
|
||
Check_Discipline2Level5 = discipline2.col5,
|
||
Check_Discipline3Level1 = discipline3.col1,
|
||
Check_Discipline3Level2 = discipline3.col2,
|
||
Check_Discipline3Level3 = discipline3.col3,
|
||
Check_Discipline3Level4 = discipline3.col4,
|
||
Check_Discipline3Level5 = discipline3.col5,
|
||
Check_Discipline4Level1 = discipline4.col1,
|
||
Check_Discipline4Level2 = discipline4.col2,
|
||
Check_Discipline4Level3 = discipline4.col3,
|
||
Check_Discipline4Level4 = discipline4.col4,
|
||
Check_Discipline4Level5 = discipline4.col5,
|
||
Check_Discipline5Level1 = discipline5.col1,
|
||
Check_Discipline5Level2 = discipline5.col2,
|
||
Check_Discipline5Level3 = discipline5.col3,
|
||
Check_Discipline5Level4 = discipline5.col4,
|
||
Check_Discipline5Level5 = discipline5.col5,
|
||
BehaviorOtherDesc = evaluate.behavior_other_desc,
|
||
Check_BehaviorOtherLevel1 = behavior.col1,
|
||
Check_BehaviorOtherLevel2 = behavior.col2,
|
||
Check_BehaviorOtherLevel3 = behavior.col3,
|
||
Check_BehaviorOtherLevel4 = behavior.col4,
|
||
Check_BehaviorOtherLevel5 = behavior.col5,
|
||
});
|
||
var tblEvaluateAssign1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||
tblEvaluateAssign1.DataSource = _Evaluate;
|
||
|
||
var tblEvaluateAssign2 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
|
||
tblEvaluateAssign2.DataSource = _Evaluate;
|
||
|
||
var tblEvaluateAssign3 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table3"];
|
||
tblEvaluateAssign3.DataSource = evaluate;
|
||
|
||
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, mimeType, $"แบบประเมินผล(สำหรับผู้บังคับบัญชา).{exportType.Trim().ToLower()}");
|
||
}
|
||
else
|
||
{
|
||
return NotFound();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Unauthorized();
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ
|
||
/// <summary>
|
||
/// 17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ
|
||
/// </summary>
|
||
/// <param name="id">evaluate id</param>
|
||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||
/// <returns></returns>
|
||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||
[HttpGet("17/{exportType}/{id}")]
|
||
public async Task<ActionResult<ResponseObject>> GetProbation17ConvertReportAsync(Guid id, string exportType = "pdf")
|
||
{
|
||
try
|
||
{
|
||
string authorizationHeader = Request.Headers["Authorization"];
|
||
string token = string.Empty;
|
||
|
||
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||
{
|
||
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||
var evaluateAssign = await _repository.GetEvaluateChairmanAssignAsync(id, token);
|
||
|
||
if (evaluateAssign != null)
|
||
{
|
||
var mimeType = "";
|
||
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", $"17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ-1.trdp");
|
||
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"17-แบบประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับคณะกรรมการ-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.ReportParameters["No"].Value = evaluateAssign.GetType().GetProperty("No").GetValue(evaluateAssign);
|
||
report.ReportParameters["EvaluateDateStart"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateStart").GetValue(evaluateAssign);
|
||
report.ReportParameters["EvaluateDateFinish"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateFinish").GetValue(evaluateAssign);
|
||
report.ReportParameters["Name"].Value = evaluateAssign.GetType().GetProperty("Name").GetValue(evaluateAssign);
|
||
report.ReportParameters["Position"].Value = evaluateAssign.GetType().GetProperty("Position").GetValue(evaluateAssign);
|
||
report.ReportParameters["Department"].Value = evaluateAssign.GetType().GetProperty("Department").GetValue(evaluateAssign);
|
||
report.ReportParameters["OrganizationOrganization"].Value = evaluateAssign.GetType().GetProperty("OrganizationOrganization").GetValue(evaluateAssign);
|
||
report.ReportParameters["Oc"].Value = evaluateAssign.GetType().GetProperty("Oc").GetValue(evaluateAssign);
|
||
report.ReportParameters["DateStart"].Value = evaluateAssign.GetType().GetProperty("DateStart").GetValue(evaluateAssign);
|
||
report.ReportParameters["DateFinish"].Value = evaluateAssign.GetType().GetProperty("DateFinish").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ChairmanName"].Value = evaluateAssign.GetType().GetProperty("ChairmanName").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ChairmanPosition"].Value = evaluateAssign.GetType().GetProperty("ChairmanPosition").GetValue(evaluateAssign);
|
||
report2.ReportParameters["MentorName1"].Value = evaluateAssign.GetType().GetProperty("Director1Name").GetValue(evaluateAssign);
|
||
report2.ReportParameters["MentorPosition1"].Value = evaluateAssign.GetType().GetProperty("Director1Position").GetValue(evaluateAssign);
|
||
report2.ReportParameters["MentorName2"].Value = evaluateAssign.GetType().GetProperty("Director2Name").GetValue(evaluateAssign);
|
||
report2.ReportParameters["MentorPosition2"].Value = evaluateAssign.GetType().GetProperty("Director2Position").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ChairmanDated"].Value = evaluateAssign.GetType().GetProperty("ChairmanDated").GetValue(evaluateAssign);
|
||
report2.ReportParameters["Director1Dated"].Value = evaluateAssign.GetType().GetProperty("Director1Dated").GetValue(evaluateAssign);
|
||
report2.ReportParameters["Director2Dated"].Value = evaluateAssign.GetType().GetProperty("Director2Dated").GetValue(evaluateAssign);
|
||
|
||
dynamic evaluate = evaluateAssign.GetType().GetProperty("Evaluate").GetValue(evaluateAssign);
|
||
dynamic knowledge = evaluate.knowledge_level;
|
||
dynamic apply = evaluate.apply_level;
|
||
dynamic success = evaluate.success_level;
|
||
dynamic achievement = evaluate.achievement_other_level;
|
||
dynamic conduct1 = evaluate.conduct1_level;
|
||
dynamic conduct2 = evaluate.conduct2_level;
|
||
dynamic conduct3 = evaluate.conduct3_level;
|
||
dynamic conduct4 = evaluate.conduct4_level;
|
||
dynamic moral1 = evaluate.moral1_level;
|
||
dynamic moral2 = evaluate.moral2_level;
|
||
dynamic moral3 = evaluate.moral3_level;
|
||
dynamic discipline1 = evaluate.discipline1_level;
|
||
dynamic discipline2 = evaluate.discipline2_level;
|
||
dynamic discipline3 = evaluate.discipline3_level;
|
||
dynamic discipline4 = evaluate.discipline4_level;
|
||
dynamic discipline5 = evaluate.discipline5_level;
|
||
dynamic behavior = evaluate.behavior_other_level;
|
||
string behavior_other_desc = evaluate.behavior_other_desc;
|
||
var _Evaluate = new List<dynamic>();
|
||
_Evaluate.Add(new
|
||
{
|
||
Check_Knowledge1 = knowledge.col1,
|
||
Check_Knowledge2 = knowledge.col2,
|
||
Check_Knowledge3 = knowledge.col3,
|
||
Check_Knowledge4 = knowledge.col4,
|
||
Check_Knowledge5 = knowledge.col5,
|
||
Check_ApplyLevel1 = apply.col1,
|
||
Check_ApplyLevel2 = apply.col2,
|
||
Check_ApplyLevel3 = apply.col3,
|
||
Check_ApplyLevel4 = apply.col4,
|
||
Check_ApplyLevel5 = apply.col5,
|
||
Check_Success_level1 = success.col1,
|
||
Check_Success_level2 = success.col2,
|
||
Check_Success_level3 = success.col3,
|
||
Check_Success_level4 = success.col4,
|
||
Check_Success_level5 = success.col5,
|
||
AchievementOtherDesc = evaluate.achievement_other_desc,
|
||
Check_AchievementOtherLevel1 = achievement.col1,
|
||
Check_AchievementOtherLevel2 = achievement.col2,
|
||
Check_AchievementOtherLevel3 = achievement.col3,
|
||
Check_AchievementOtherLevel4 = achievement.col4,
|
||
Check_AchievementOtherLevel5 = achievement.col5,
|
||
Check_Conduct1Level1 = conduct1.col1,
|
||
Check_Conduct1Level2 = conduct1.col2,
|
||
Check_Conduct1Level3 = conduct1.col3,
|
||
Check_Conduct1Level4 = conduct1.col4,
|
||
Check_Conduct1Level5 = conduct1.col5,
|
||
Check_Conduct2Level1 = conduct2.col1,
|
||
Check_Conduct2Level2 = conduct2.col2,
|
||
Check_Conduct2Level3 = conduct2.col3,
|
||
Check_Conduct2Level4 = conduct2.col4,
|
||
Check_Conduct2Level5 = conduct2.col5,
|
||
Check_Conduct3Level1 = conduct3.col1,
|
||
Check_Conduct3Level2 = conduct3.col2,
|
||
Check_Conduct3Level3 = conduct3.col3,
|
||
Check_Conduct3Level4 = conduct3.col4,
|
||
Check_Conduct3Level5 = conduct3.col5,
|
||
Check_Conduct4Level1 = conduct4.col1,
|
||
Check_Conduct4Level2 = conduct4.col2,
|
||
Check_Conduct4Level3 = conduct4.col3,
|
||
Check_Conduct4Level4 = conduct4.col4,
|
||
Check_Conduct4Level5 = conduct4.col5,
|
||
Check_Moral1Level1 = moral1.col1,
|
||
Check_Moral1Level2 = moral1.col2,
|
||
Check_Moral1Level3 = moral1.col3,
|
||
Check_Moral1Level4 = moral1.col4,
|
||
Check_Moral1Level5 = moral1.col5,
|
||
Check_Moral2Level1 = moral2.col1,
|
||
Check_Moral2Level2 = moral2.col2,
|
||
Check_Moral2Level3 = moral2.col3,
|
||
Check_Moral2Level4 = moral2.col4,
|
||
Check_Moral2Level5 = moral2.col5,
|
||
Check_Moral3Level1 = moral3.col1,
|
||
Check_Moral3Level2 = moral3.col2,
|
||
Check_Moral3Level3 = moral3.col3,
|
||
Check_Moral3Level4 = moral3.col4,
|
||
Check_Moral3Level5 = moral3.col5,
|
||
Check_Discipline1Level1 = discipline1.col1,
|
||
Check_Discipline1Level2 = discipline1.col2,
|
||
Check_Discipline1Level3 = discipline1.col3,
|
||
Check_Discipline1Level4 = discipline1.col4,
|
||
Check_Discipline1Level5 = discipline1.col5,
|
||
Check_Discipline2Level1 = discipline2.col1,
|
||
Check_Discipline2Level2 = discipline2.col2,
|
||
Check_Discipline2Level3 = discipline2.col3,
|
||
Check_Discipline2Level4 = discipline2.col4,
|
||
Check_Discipline2Level5 = discipline2.col5,
|
||
Check_Discipline3Level1 = discipline3.col1,
|
||
Check_Discipline3Level2 = discipline3.col2,
|
||
Check_Discipline3Level3 = discipline3.col3,
|
||
Check_Discipline3Level4 = discipline3.col4,
|
||
Check_Discipline3Level5 = discipline3.col5,
|
||
Check_Discipline4Level1 = discipline4.col1,
|
||
Check_Discipline4Level2 = discipline4.col2,
|
||
Check_Discipline4Level3 = discipline4.col3,
|
||
Check_Discipline4Level4 = discipline4.col4,
|
||
Check_Discipline4Level5 = discipline4.col5,
|
||
Check_Discipline5Level1 = discipline5.col1,
|
||
Check_Discipline5Level2 = discipline5.col2,
|
||
Check_Discipline5Level3 = discipline5.col3,
|
||
Check_Discipline5Level4 = discipline5.col4,
|
||
Check_Discipline5Level5 = discipline5.col5,
|
||
BehaviorOtherDesc = evaluate.behavior_other_desc,
|
||
Check_BehaviorOtherLevel1 = behavior.col1,
|
||
Check_BehaviorOtherLevel2 = behavior.col2,
|
||
Check_BehaviorOtherLevel3 = behavior.col3,
|
||
Check_BehaviorOtherLevel4 = behavior.col4,
|
||
Check_BehaviorOtherLevel5 = behavior.col5,
|
||
achievement_score = evaluate.achievement_score,
|
||
achievement_score_total = evaluate.achievement_score_total,
|
||
achievement_percent = evaluate.achievement_percent,
|
||
achievement_result = evaluate.achievement_result,
|
||
behavior_score = evaluate.behavior_score,
|
||
behavior_score_total = evaluate.behavior_score_total,
|
||
behavior_percent = evaluate.behavior_percent,
|
||
behavior_result = evaluate.behavior_result,
|
||
sum_score = evaluate.sum_score,
|
||
sum_percent = evaluate.sum_percent,
|
||
develop_orientation_score = evaluate.develop_orientation_score,
|
||
develop_self_learning_score = evaluate.develop_self_learning_score,
|
||
develop_training_seminar_score = evaluate.develop_training_seminar_score,
|
||
develop_other_training_score = evaluate.develop_other_training_score,
|
||
develop_total_score = evaluate.develop_total_score,
|
||
develop_orientation_percent = evaluate.develop_orientation_percent,
|
||
develop_self_learning_percent = evaluate.develop_self_learning_percent,
|
||
develop_training_seminar_percent = evaluate.develop_training_seminar_percent,
|
||
develop_other_training_percent = evaluate.develop_other_training_percent,
|
||
develop_total_percent = evaluate.develop_total_percent,
|
||
develop_result = evaluate.develop_result,
|
||
evaluate_result = evaluate.evaluate_result,
|
||
|
||
});
|
||
var tblEvaluateAssign1 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table2"];
|
||
tblEvaluateAssign1.DataSource = _Evaluate;
|
||
var tblEvaluateAssign2 = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||
tblEvaluateAssign2.DataSource = _Evaluate;
|
||
var tblEvaluateAssign3 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table2"];
|
||
tblEvaluateAssign3.DataSource = _Evaluate;
|
||
var tblEvaluateAssign4 = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["table3"];
|
||
tblEvaluateAssign4.DataSource = _Evaluate;
|
||
report2.DataSource = _Evaluate;
|
||
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()}");
|
||
}
|
||
else
|
||
{
|
||
return NotFound();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Unauthorized();
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 18,19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
||
/// <summary>
|
||
/// 19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน และ กรณีขยายเวลา
|
||
/// </summary>
|
||
/// <param name="id">assign id แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ</param>
|
||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||
/// <returns></returns>
|
||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||
[HttpGet("19/{exportType}/{id}")]
|
||
public async Task<ActionResult<ResponseObject>> GetProbation19ConvertReportAsync(Guid id, string exportType = "pdf")
|
||
{
|
||
try
|
||
{
|
||
string authorizationHeader = Request.Headers["Authorization"];
|
||
string token = string.Empty;
|
||
|
||
if (!string.IsNullOrEmpty(authorizationHeader) && authorizationHeader.StartsWith("Bearer "))
|
||
{
|
||
token = authorizationHeader.Substring("Bearer ".Length).Trim();
|
||
var evaluateAssign = await _repository.GetEvaluateResultAssignAsync(id, token);
|
||
|
||
if (evaluateAssign != null)
|
||
{
|
||
var mimeType = "";
|
||
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 rptFile1 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"18-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ สำหรับประธาน-1.trdp");
|
||
var rptFile2 = System.IO.Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"19-แบบรายงานการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ กรณีขยายเวลา.trdp");
|
||
ReportPackager reportPacker = new ReportPackager();
|
||
Telerik.Reporting.Report? report1 = null;
|
||
Telerik.Reporting.Report? report2 = null;
|
||
using (var sourceStream1 = System.IO.File.OpenRead(rptFile1))
|
||
using (var sourceStream2 = System.IO.File.OpenRead(rptFile2))
|
||
{
|
||
report1 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream1);
|
||
report2 = (Telerik.Reporting.Report)reportPacker.UnpackageDocument(sourceStream2);
|
||
}
|
||
//สำหรับประธาน
|
||
if((evaluateAssign.GetType().GetProperty("ExpandMonth").GetValue(evaluateAssign)).ToString() == "๐")
|
||
{
|
||
report1.DataSource = evaluateAssign;
|
||
System.Collections.Hashtable deviceInfo_ = new System.Collections.Hashtable();
|
||
InstanceReportSource instanceReportSource_ = new InstanceReportSource()
|
||
{
|
||
ReportDocument = report1,
|
||
};
|
||
ReportProcessor reportProcessor_ = new ReportProcessor(_configuration);
|
||
RenderingResult result_ = reportProcessor_.RenderReport($"{exportType}", instanceReportSource_, deviceInfo_);
|
||
return File(result_.DocumentBytes, mimeType, $"แบบรายงานการประเมินผล.{exportType.Trim().ToLower()}");
|
||
}
|
||
//กรณีขยายเวลา (ใช้รูปแบบเดิม)
|
||
report2.ReportParameters["EvaluateDateStart"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateStart").GetValue(evaluateAssign);
|
||
report2.ReportParameters["EvaluateDateFinish"].Value = evaluateAssign.GetType().GetProperty("EvaluateDateFinish").GetValue(evaluateAssign);
|
||
report2.ReportParameters["Reson"].Value = evaluateAssign.GetType().GetProperty("Reson").GetValue(evaluateAssign);
|
||
report2.ReportParameters["DevelopComplete"].Value = evaluateAssign.GetType().GetProperty("DevelopComplete").GetValue(evaluateAssign);
|
||
report2.ReportParameters["PassResult"].Value = evaluateAssign.GetType().GetProperty("PassResult").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ExpandMonth"].Value = evaluateAssign.GetType().GetProperty("ExpandMonth").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ChairmanName"].Value = evaluateAssign.GetType().GetProperty("ChairmanName").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ChairmanPosition"].Value = evaluateAssign.GetType().GetProperty("ChairmanPosition").GetValue(evaluateAssign);
|
||
report2.ReportParameters["ChairmanDate"].Value = evaluateAssign.GetType().GetProperty("ChairmanDate").GetValue(evaluateAssign);
|
||
report2.ReportParameters["CommanderName"].Value = evaluateAssign.GetType().GetProperty("CommanderName").GetValue(evaluateAssign);
|
||
report2.ReportParameters["CommanderPosition"].Value = evaluateAssign.GetType().GetProperty("CommanderPosition").GetValue(evaluateAssign);
|
||
report2.ReportParameters["CommanderDate"].Value = evaluateAssign.GetType().GetProperty("CommanderDate").GetValue(evaluateAssign);
|
||
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
|
||
InstanceReportSource instanceReportSource = new InstanceReportSource()
|
||
{
|
||
ReportDocument = report2,
|
||
};
|
||
ReportProcessor reportProcessor = new ReportProcessor(_configuration);
|
||
RenderingResult result = reportProcessor.RenderReport($"{exportType}", instanceReportSource, deviceInfo);
|
||
return File(result.DocumentBytes, mimeType, $"แบบรายงานการประเมินผล.{exportType.Trim().ToLower()}");
|
||
}
|
||
else
|
||
{
|
||
return NotFound();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return Unauthorized();
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
throw;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
}
|
||
}
|