From 8762bcaeade6854a175600490a0009ad4c23575e Mon Sep 17 00:00:00 2001 From: Nakorn Rientrakrunchai Date: Mon, 7 Sep 2020 17:39:34 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=87=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=20=E0=B8=81=E0=B8=9E7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ApiControllers/rep_kp7Controllers.cs | 163 ++++++++++++++++++ EXCEL/eva_level_score@rep_kp7.xlsx | Bin 0 -> 10156 bytes Models/rep_kp7/Irep_kp7Service.cs | 18 ++ Models/rep_kp7/rep_kp7InputModel.cs | 24 +++ Models/rep_kp7/rep_kp7ReportRequestModel.cs | 21 +++ Models/rep_kp7/rep_kp7SearchModel.cs | 23 +++ Models/rep_kp7/rep_kp7Service.cs | 42 +++++ Models/rep_kp7/rep_kp7ViewModel.cs | 22 +++ .../rep_kp7/rep_kp7WithSelectionViewModel.cs | 13 ++ Startup.cs | 2 + ViewControllers/rep_kp7ViewControllers.cs | 48 ++++++ Views/rep_kp7View/rep_kp7_report.cshtml | 56 ++++++ tb320eva.xml | 36 ++++ wwwroot/js/rep_kp7/rep_kp7_report.js | 58 +++++++ 14 files changed, 526 insertions(+) create mode 100644 ApiControllers/rep_kp7Controllers.cs create mode 100644 EXCEL/eva_level_score@rep_kp7.xlsx create mode 100644 Models/rep_kp7/Irep_kp7Service.cs create mode 100644 Models/rep_kp7/rep_kp7InputModel.cs create mode 100644 Models/rep_kp7/rep_kp7ReportRequestModel.cs create mode 100644 Models/rep_kp7/rep_kp7SearchModel.cs create mode 100644 Models/rep_kp7/rep_kp7Service.cs create mode 100644 Models/rep_kp7/rep_kp7ViewModel.cs create mode 100644 Models/rep_kp7/rep_kp7WithSelectionViewModel.cs create mode 100644 ViewControllers/rep_kp7ViewControllers.cs create mode 100644 Views/rep_kp7View/rep_kp7_report.cshtml create mode 100644 wwwroot/js/rep_kp7/rep_kp7_report.js diff --git a/ApiControllers/rep_kp7Controllers.cs b/ApiControllers/rep_kp7Controllers.cs new file mode 100644 index 0000000..77e0631 --- /dev/null +++ b/ApiControllers/rep_kp7Controllers.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Logging; +using TTSW.Controllers; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; +using System.Data; +using Microsoft.Extensions.Configuration; +using System.IO; +using System.Net; +using iTextSharp.text; +using iTextSharp.text.pdf; + +namespace TodoAPI2.Controllers +{ + //[Authorize] + [Produces("application/json")] + [Route("api/rep_kp7")] + public class rep_kp7Controller : BaseController + { + #region Private Variables + private ILogger _logger; + private Irep_kp7Service _repository; + private IConfiguration Configuration { get; set; } + #endregion + + #region Properties + + #endregion + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public rep_kp7Controller(ILogger logger, Irep_kp7Service repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + /// + /// Get Blank Item + /// + /// + /// + /// Return a blank item + /// Returns the item + /// Error Occurred + [HttpGet("GetBlankItem")] + [ProducesResponseType(typeof(rep_kp7WithSelectionViewModel), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetBlankItem() + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.GetBlankItem(); + + return Ok(result); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetBlankItem.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Download Report + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("rep_kp7_report")] + [ProducesResponseType(typeof(FileStreamResult), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult rep_kp7_report(rep_kp7ReportRequestModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var httpclient = new WebClient(); + + var stream = new MemoryStream(); + + Document document = new Document(); + PdfCopy writer = new PdfCopy(document, stream); + document.Open(); + + // Get Main KP7 report from HR + try + { + var data = GetKP7MainReport(model.employee_id); + PdfReader reader = new PdfReader(data); + reader.ConsolidateNamedDestinations(); + for (int i = 1; i <= reader.NumberOfPages; i++) + { + PdfImportedPage page = writer.GetImportedPage(reader, i); + writer.AddPage(page); + } + reader.Close(); + } + catch (Exception ex) + { + + } + + // Get Jasper Section report + string mainurl = MyHelper.GetConfig(Configuration, "JasperReportServer:MainURL"); + string reportsite = MyHelper.GetConfig(Configuration, "JasperReportServer:reportsite"); + string username = MyHelper.GetConfig(Configuration, "JasperReportServer:username"); + string password = MyHelper.GetConfig(Configuration, "JasperReportServer:password"); + string url = $"{mainurl}{reportsite}/rep_kp7.{model.filetype}?{MyHelper.GetParameterForJasperReport(model)}&j_username={username}&j_password={password}"; + var data2 = httpclient.DownloadData(url); + PdfReader reader2 = new PdfReader(data2); + reader2.ConsolidateNamedDestinations(); + for (int i = 1; i <= reader2.NumberOfPages; i++) + { + PdfImportedPage page = writer.GetImportedPage(reader2, i); + writer.AddPage(page); + } + reader2.Close(); + + writer.Close(); + document.Close(); + + var data3 = stream.ToArray(); + var stream3 = new MemoryStream(data3); + + return File(stream3, model.contentType); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while GetReport.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + private byte[] GetKP7MainReport(int? employee_id) + { + string kp7_main_api = MyHelper.GetConfig(Configuration, "SiteInformation:hr_svc") + "/hrm/employeeReportKP/" + employee_id.ToString(); + var httpclient = new WebClient(); + return httpclient.DownloadData(kp7_main_api); + } + } +} diff --git a/EXCEL/eva_level_score@rep_kp7.xlsx b/EXCEL/eva_level_score@rep_kp7.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..841da1090400fc3a3fdfb9d6265230fba74d33b8 GIT binary patch literal 10156 zcmeHN1y>x)wjNxA2MO-(5Hz?35AN0>Rzo&5`?Z4)?tG z2kxy|t9#Yz-rscX+P+Is1_~Mr01JQz005)_VJ^QhI|u*(8U_Hs1i(XTi`v_{nA*AM ztGGLuI_omI+1ij~LqpPJ0U*Ke|9AWcbD&sdz^;=8twnuTP^?ug^hlcietjM0oD6u)K5!tspPUU}!6om+iQnt|jD1^M3 z+j}$6sR=1V`ySVb+s*$SdnncZ0u?jWogcYs!Z`$k+fJ9iVfAb#L~NilUP~0 z6&85BqQpX$#SrAqd9|e)0V> zMe?mXjcZFZT~U4h7ny+-a*3%Eu?n;?CiPbcm^lPN*l$vNwR+_=myNDVA-;HY7>I54i+#w7bFvo3tJsyR-EKD&2wA#@e>9}oD26X!33J=VV~iLXF> z(ixZ|jbJ5t1%QWevtj;2Pk{DL)<*XB*1vhPf9VVa*rkC{{5Xq#|YaK3~D7Yt+@4kzt0i4{|>m>2tl}L|KQzyy&3M55s`= zz_dBygRvhu8-ap1Iw&FXlZ3&<*x%hNIzU26b;fKEi0x;{z~cUKO+$$n{56+M?7U$z zh{I}>`ar=Uw4RK!k;$Zo5{J4T6cWCMcyJPk|8SOeDfj5g(SFNlGukf)_E&CrAhT@%|+yH zkhX2{lws)n$ZT_<@B0dPr~h4K0;CM_!@=U>2M&Kw!Eb;?=C8t1tfFf_#e(G}xh|;T zJ$5=_V*8Z}(^8q0wL@jFSCn#-O5T_=)c>HEFyv{pX38#*ltVzzW(EK5ddazzy!oH_j~Ca=p$oHe~mPJarPd(&DMc6#{bnF96ipNL%{RT-3f($po(!zwY_695km>{NcYE4&5p-m#sqErs@R_3hz;jmC zZYdYr$qK~Q#?~XAxhUe|dTcbnk$OUQHffl=`&Xe{|Mn-k(2k5m0%Rei+XiDlzay;_ zH%RgUk;=qbv4ng~)quRU-AmB=h(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zyJRl z5zhgiSMq-W@}m3>_`I(F9N>Aq;TOR7mw&A3f2$AANuMVIzes_vo-gKCTJRj@?{Ug6 z3;=+L2mtuEsO35Nb2sw~AcN%hk9g)}{?X|?2mQOH{sjs4W~6`lra$erq6`dJ1_1zM O@Q(^C#tsy}&He|deW82+ literal 0 HcmV?d00001 diff --git a/Models/rep_kp7/Irep_kp7Service.cs b/Models/rep_kp7/Irep_kp7Service.cs new file mode 100644 index 0000000..dfe7ce5 --- /dev/null +++ b/Models/rep_kp7/Irep_kp7Service.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; + +namespace TodoAPI2.Models +{ + public interface Irep_kp7Service + { + rep_kp7WithSelectionViewModel GetBlankItem(); + } +} + diff --git a/Models/rep_kp7/rep_kp7InputModel.cs b/Models/rep_kp7/rep_kp7InputModel.cs new file mode 100644 index 0000000..2880866 --- /dev/null +++ b/Models/rep_kp7/rep_kp7InputModel.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_kp7InputModel + { + + public Guid? id { get; set; } + + public int? employee_id { get; set; } + + public string active_mode { get; set; } + } +} + diff --git a/Models/rep_kp7/rep_kp7ReportRequestModel.cs b/Models/rep_kp7/rep_kp7ReportRequestModel.cs new file mode 100644 index 0000000..2b08ea0 --- /dev/null +++ b/Models/rep_kp7/rep_kp7ReportRequestModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_kp7ReportRequestModel : rep_kp7SearchModel + { + public string filetype { get; set; } + + public string contentType { get { return MyHelper.GetContentType(filetype); } } + } +} + diff --git a/Models/rep_kp7/rep_kp7SearchModel.cs b/Models/rep_kp7/rep_kp7SearchModel.cs new file mode 100644 index 0000000..e1a1a68 --- /dev/null +++ b/Models/rep_kp7/rep_kp7SearchModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_kp7SearchModel + { + + public Guid id { get; set; } + + public int? employee_id { get; set; } + + } +} + diff --git a/Models/rep_kp7/rep_kp7Service.cs b/Models/rep_kp7/rep_kp7Service.cs new file mode 100644 index 0000000..c81d06b --- /dev/null +++ b/Models/rep_kp7/rep_kp7Service.cs @@ -0,0 +1,42 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; +using System.IO; +using System.Web; +using System.Net; +using TTSW.Configure; +using Microsoft.Extensions.Options; +using System.Data; + +namespace TodoAPI2.Models +{ + public class rep_kp7Service : Irep_kp7Service + { + private IMyDatabase db; + private Iexternal_linkageService ext; + private Iexternal_employeeService emp; + + public rep_kp7Service(IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp) + { + db = mydb; + ext = inext; + emp = inemp; + } + + public rep_kp7WithSelectionViewModel GetBlankItem() + { + var i = new rep_kp7WithSelectionViewModel(); + i.item_employee_id = (from x in emp.GetAllEmployee() select x).ToList(); + + + return i; + } + } +} \ No newline at end of file diff --git a/Models/rep_kp7/rep_kp7ViewModel.cs b/Models/rep_kp7/rep_kp7ViewModel.cs new file mode 100644 index 0000000..4c82215 --- /dev/null +++ b/Models/rep_kp7/rep_kp7ViewModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_kp7ViewModel : BaseViewModel2 + { + + public int? employee_id { get; set; } + + public string employee_id_external_linkage_external_name { get; set; } + + } +} \ No newline at end of file diff --git a/Models/rep_kp7/rep_kp7WithSelectionViewModel.cs b/Models/rep_kp7/rep_kp7WithSelectionViewModel.cs new file mode 100644 index 0000000..d3a2ace --- /dev/null +++ b/Models/rep_kp7/rep_kp7WithSelectionViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace TodoAPI2.Models +{ + public class rep_kp7WithSelectionViewModel: rep_kp7ViewModel + { + public List item_employee_id { get; set; } + + } +} \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index dfacd9e..0c1f0ff 100644 --- a/Startup.cs +++ b/Startup.cs @@ -291,6 +291,8 @@ namespace Test01 services.AddScoped(); + services.AddScoped(); + #endregion services.TryAddSingleton(); diff --git a/ViewControllers/rep_kp7ViewControllers.cs b/ViewControllers/rep_kp7ViewControllers.cs new file mode 100644 index 0000000..4d34273 --- /dev/null +++ b/ViewControllers/rep_kp7ViewControllers.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using TodoAPI2.Models; +using STAFF_API.Models; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; +using TodoAPI2.Controllers; + +namespace TodoAPI2.Controllers +{ + public class rep_kp7ViewController : Controller + { + private ILogger _logger; + private Irep_kp7Service _repository; + private IConfiguration Configuration { get; set; } + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public rep_kp7ViewController(ILogger logger, Irep_kp7Service repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + public IActionResult rep_kp7_report() + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + return View(); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} + + diff --git a/Views/rep_kp7View/rep_kp7_report.cshtml b/Views/rep_kp7View/rep_kp7_report.cshtml new file mode 100644 index 0000000..d921431 --- /dev/null +++ b/Views/rep_kp7View/rep_kp7_report.cshtml @@ -0,0 +1,56 @@ +@using Microsoft.Extensions.Configuration +@inject IConfiguration Configuration +@{ + ViewData["Title"] = "rep_kp7"; +} + +
+
+
+ @Configuration["SiteInformation:modulename"] +
+
+ +
+ +
+
รายงาน rep_kp7
+
+
+
+
+ +
+ + +
+ +
+
+
+ + +
+
+
+
+
+ + +@section FooterPlaceHolder{ + + +} + diff --git a/tb320eva.xml b/tb320eva.xml index 275ba74..5f47d8a 100644 --- a/tb320eva.xml +++ b/tb320eva.xml @@ -3418,6 +3418,34 @@ Returns the item Error Occurred + + + Default constructure for dependency injection + + + + + + + + Get Blank Item + + + + Return a blank item + Returns the item + Error Occurred + + + + Download Report + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + Default constructure for dependency injection @@ -3900,6 +3928,14 @@ + + + Default constructure for dependency injection + + + + + Default constructure for dependency injection diff --git a/wwwroot/js/rep_kp7/rep_kp7_report.js b/wwwroot/js/rep_kp7/rep_kp7_report.js new file mode 100644 index 0000000..e183e44 --- /dev/null +++ b/wwwroot/js/rep_kp7/rep_kp7_report.js @@ -0,0 +1,58 @@ +var rep_kp7_API = "/api/rep_kp7/"; + +//================= Search Customizaiton ========================================= + +function rep_kp7_GetSearchParameter(fileType) { + var rep_kp7SearchObject = new Object(); +rep_kp7SearchObject.employee_id = $("#s_rep_kp7_employee_id").val(); + + + rep_kp7SearchObject.fileType = fileType; + + console.log(rep_kp7SearchObject); + + return rep_kp7SearchObject; +} + +function rep_kp7_FeedDataToSearchForm(data) { +DropDownClearFormAndFeedWithData($("#s_rep_kp7_employee_id"), data, "id", "fullname", "item_employee_id", data.employee_id); + +} + +//================= Form Data Customizaiton ========================================= + +function rep_kp7_InitialForm(s) { + var successFunc = function (result) { + rep_kp7_FeedDataToSearchForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_kp7_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Data Table ========================================= + +var s_rep_kp7_customValidation = function (group) { + return ""; +}; + + +function rep_kp7_DoSearch(fileType) { + if (!ValidateForm('s_rep_kp7', s_rep_kp7_customValidation)) { + return; + } + + var p = $.param(rep_kp7_GetSearchParameter(fileType)); + + var report_url = apisite + "/api/rep_kp7/rep_kp7_report?" + p; + + if (fileType === "pdf") { + $("#report_result").attr("src", report_url); + $("#report_result").show(); + //window.open(report_url); + } else { + $("#report_result").hide(); + window.open(report_url); + } +} +