diff --git a/ApiControllers/eva_create_evaluation_detail_historyControllers.cs b/ApiControllers/eva_create_evaluation_detail_historyControllers.cs new file mode 100644 index 0000000..a354ddb --- /dev/null +++ b/ApiControllers/eva_create_evaluation_detail_historyControllers.cs @@ -0,0 +1,403 @@ +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; + +namespace TodoAPI2.Controllers +{ + //[Authorize] + [Produces("application/json")] + [Route("api/eva_create_evaluation_detail_history")] + public class eva_create_evaluation_detail_historyController : BaseController + { + #region Private Variables + private ILogger _logger; + private Ieva_create_evaluation_detail_historyService _repository; + private IConfiguration Configuration { get; set; } + #endregion + + #region Properties + + #endregion + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public eva_create_evaluation_detail_historyController(ILogger logger, Ieva_create_evaluation_detail_historyService repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + /// + /// Get specific item by id + /// + /// + /// + /// Return Get specific item by id + /// Returns the item + /// Error Occurred + [HttpGet("{id}")] + [ProducesResponseType(typeof(eva_create_evaluation_detail_historyWithSelectionViewModel), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Get(int id) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.GetWithSelection(id); + + return Ok(result); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult Get.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get Blank Item + /// + /// + /// + /// Return a blank item + /// Returns the item + /// Error Occurred + [HttpGet("GetBlankItem")] + [ProducesResponseType(typeof(eva_create_evaluation_detail_historyWithSelectionViewModel), 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}"); + } + } + + /// + /// Get list items by evaluation_detail_id + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("")] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetList(int? evaluation_detail_id) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + return Ok(_repository.GetListByevaluation_detail_id(evaluation_detail_id)); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetList.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get list items by search + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("GetListBySearch")] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetListBySearch(eva_create_evaluation_detail_historySearchModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + return Ok(_repository.GetListBySearch(model)); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetListBySearch.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Download Report + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("eva_create_evaluation_detail_history_report")] + [ProducesResponseType(typeof(FileStreamResult), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult eva_create_evaluation_detail_history_report(eva_create_evaluation_detail_historyReportRequestModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var httpclient = new WebClient(); + 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}/xxใส่ชื่อรายงานตรงนี้xx.{model.filetype}?{MyHelper.GetParameterForJasperReport(model)}&j_username={username}&j_password={password}"; + + if (model.filetype == "xlsx") + { + url += "&ignorePagination=true"; + } + + var data = httpclient.DownloadData(url); + var stream = new MemoryStream(data); + + return File(stream, model.contentType); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while GetReport.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Create new item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPost("")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Insert([FromBody] eva_create_evaluation_detail_historyInputModel model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.Insert(model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"เพิ่มข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while insert.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Update item + /// + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("{id}")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Update(int id, [FromBody] eva_create_evaluation_detail_historyInputModel model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.Update(id, model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"แก้ไขข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while update {id.ToString()}.", ex); + return StatusCode(500, $"{id.ToString()}. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Delete item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpDelete("{id}")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Delete(int id) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + _repository.Delete(id); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"ลบข้อมูล เรียบร้อย"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while delete {id.ToString()}.", ex); + return StatusCode(500, $"{id.ToString()}. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Update multiple item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("UpdateMultiple")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult UpdateMultiple([FromBody] List model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + string rowCount = _repository.UpdateMultiple(model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = "ปรับปรุงข้อมูลเรียบร้อย จำนวน "+rowCount+" รายการ"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while UpdateMultiple.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Refresh AutoField of all items + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("RefreshAutoField")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult RefreshAutoField() + { + if (ModelState.IsValid) + { + try + { + //if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + _repository.RefreshAutoFieldOfAllData(); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"ปรับปรุง Auto Field ของทุก record เรียบร้อย"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while RefreshAutoField.", ex); + return StatusCode(500, $"มีปัญหาระหว่างการปรับปรุง Auto Field. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + + + } +} diff --git a/ApiControllers/eva_create_evaluation_detail_statusControllers.cs b/ApiControllers/eva_create_evaluation_detail_statusControllers.cs index c7ea76f..29b445d 100644 --- a/ApiControllers/eva_create_evaluation_detail_statusControllers.cs +++ b/ApiControllers/eva_create_evaluation_detail_statusControllers.cs @@ -27,6 +27,7 @@ namespace TodoAPI2.Controllers private ILogger _logger; private Ieva_create_evaluation_detail_statusService _repository; private IConfiguration Configuration { get; set; } + private Iexternal_employeeService emp; #endregion #region Properties @@ -37,13 +38,17 @@ namespace TodoAPI2.Controllers /// Default constructure for dependency injection /// /// - /// + /// + /// /// - public eva_create_evaluation_detail_statusController(ILogger logger, Ieva_create_evaluation_detail_statusService repository, IConfiguration configuration) + public eva_create_evaluation_detail_statusController(ILogger logger, + Ieva_create_evaluation_detail_statusService repository, IConfiguration configuration, + Iexternal_employeeService inemp) { _logger = logger; _repository = repository; Configuration = configuration; + emp = inemp; } /// @@ -220,12 +225,25 @@ namespace TodoAPI2.Controllers try { if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); - var result = _repository.Update(id, model); - var message = new CommonResponseMessage(); - message.code = "200"; - message.message = $"แก้ไขข้อมูล เรียบร้อย"; - message.data = result; - return Ok(message); + + if (!string.IsNullOrEmpty(HttpContext.Request.Cookies["user_id"])) + { + var loginid = Convert.ToInt32(HttpContext.Request.Cookies["user_id"]); + var e = emp.GetEmployeeForLogin(Convert.ToInt32(loginid)); + model.employee_id = e.id; + var result = _repository.Update(id, model); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"แก้ไขข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + else + { + return Unauthorized(); + } + + } catch (Exception ex) { diff --git a/EF/DataContext.cs b/EF/DataContext.cs index 2a374d9..f4dd0b9 100644 --- a/EF/DataContext.cs +++ b/EF/DataContext.cs @@ -41,8 +41,8 @@ namespace TTSW.EF { public DbSet eva_limit_frame_employee { get; set; } public DbSet eva_limit_frame_group { get; set; } public DbSet eva_limit_frame_plan { get; set; } - public DbSet eva_idp_plan { get; set; } + public DbSet eva_create_evaluation_detail_history { get; set; } public DbSet eva_evaluation_achievement_attach { get; set; } protected override void OnModelCreating (ModelBuilder modelBuilder) { diff --git a/EXCEL/eva_create_evaluation_detail_history.xlsx b/EXCEL/eva_create_evaluation_detail_history.xlsx new file mode 100644 index 0000000..b634e6e Binary files /dev/null and b/EXCEL/eva_create_evaluation_detail_history.xlsx differ diff --git a/Migrations/20210413072130_AddEvaLog.Designer.cs b/Migrations/20210413072130_AddEvaLog.Designer.cs new file mode 100644 index 0000000..ed93980 --- /dev/null +++ b/Migrations/20210413072130_AddEvaLog.Designer.cs @@ -0,0 +1,1032 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TTSW.EF; + +namespace tb320eva.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20210413072130_AddEvaLog")] + partial class AddEvaLog + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("TodoAPI2.Models.eva_adjust_postponementEntity", b => + { + b.Property("id"); + + b.Property("command_no") + .HasMaxLength(4000); + + b.Property("create_evaluation_id"); + + b.Property("created"); + + b.Property("fiscal_year"); + + b.Property("imported_date"); + + b.Property("imported_file") + .HasMaxLength(1000); + + b.Property("isActive"); + + b.Property("limit"); + + b.Property("limit_frame"); + + b.Property("limit_frame_quota"); + + b.Property("limit_quota"); + + b.Property("managed_by"); + + b.Property("percentage"); + + b.Property("report_type") + .HasMaxLength(1000); + + b.Property("theDate"); + + b.Property("theRound"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("create_evaluation_id"); + + b.ToTable("eva_adjust_postponement"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_adjust_postponement_detailEntity", b => + { + b.Property("id"); + + b.Property("achievement_final"); + + b.Property("adjust_postponement_id"); + + b.Property("adjust_postponement_quota_id"); + + b.Property("competency_final"); + + b.Property("cost_living"); + + b.Property("created"); + + b.Property("employee_id"); + + b.Property("employee_no_at_this_time") + .HasMaxLength(1000); + + b.Property("fullname_at_this_time") + .HasMaxLength(1000); + + b.Property("isActive"); + + b.Property("is_for_postponement"); + + b.Property("level_score_final") + .HasMaxLength(255); + + b.Property("level_this_time") + .HasMaxLength(1000); + + b.Property("middle"); + + b.Property("migration_eva_result") + .HasMaxLength(1000); + + b.Property("migration_total_score"); + + b.Property("new_cost_living"); + + b.Property("new_sarary"); + + b.Property("new_sarary_with_quota"); + + b.Property("order_at_this_time"); + + b.Property("org_at_this_time"); + + b.Property("other_money_at_this_time"); + + b.Property("position_allowance_at_this_time"); + + b.Property("position_this_time") + .HasMaxLength(1000); + + b.Property("promoted_percentage"); + + b.Property("receive_quota"); + + b.Property("remark") + .HasMaxLength(1000); + + b.Property("sarary"); + + b.Property("score_final"); + + b.Property("total_promote"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("adjust_postponement_id"); + + b.HasIndex("adjust_postponement_quota_id"); + + b.ToTable("eva_adjust_postponement_detail"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluationEntity", b => + { + b.Property("id"); + + b.Property("created"); + + b.Property("employee_id"); + + b.Property("evaluation_group_id"); + + b.Property("isActive"); + + b.Property("performance_plan_id"); + + b.Property("score1"); + + b.Property("score2"); + + b.Property("supervisor1_id"); + + b.Property("supervisor2_id"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("evaluation_group_id"); + + b.HasIndex("performance_plan_id"); + + b.ToTable("eva_create_evaluation"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluation_detailEntity", b => + { + b.Property("id"); + + b.Property("Final_summary_chief"); + + b.Property("Final_summary_competency_chief"); + + b.Property("Final_summary_competency_supervisor"); + + b.Property("Final_summary_competency_supervisor1A"); + + b.Property("Final_summary_competency_supervisor2A"); + + b.Property("Final_summary_supervisor"); + + b.Property("Final_summary_supervisor1A"); + + b.Property("Final_summary_supervisor2A"); + + b.Property("achievement_chief"); + + b.Property("achievement_supervisor"); + + b.Property("achievement_supervisor1A"); + + b.Property("achievement_supervisor2A"); + + b.Property("chief"); + + b.Property("chief_a"); + + b.Property("chief_a_date"); + + b.Property("chief_a_reject_reason") + .HasMaxLength(1000); + + b.Property("chief_a_remark") + .HasMaxLength(1000); + + b.Property("chief_a_result") + .HasMaxLength(1); + + b.Property("competency_chief"); + + b.Property("competency_supervisor"); + + b.Property("competency_supervisor1A"); + + b.Property("competency_supervisor2A"); + + b.Property("create_evaluation_id"); + + b.Property("created"); + + b.Property("employee_id"); + + b.Property("eva_employee_id"); + + b.Property("help_org_id"); + + b.Property("isActive"); + + b.Property("level_score_chief") + .HasMaxLength(255); + + b.Property("level_score_supervisor") + .HasMaxLength(255); + + b.Property("level_score_supervisor1A") + .HasMaxLength(255); + + b.Property("level_score_supervisor2A") + .HasMaxLength(255); + + b.Property("order_of_data"); + + b.Property("score_chief"); + + b.Property("score_supervisor"); + + b.Property("score_supervisor1A"); + + b.Property("score_supervisor2A"); + + b.Property("status_chief") + .HasMaxLength(1); + + b.Property("status_chief_a") + .HasMaxLength(1); + + b.Property("status_chief_a_click_date"); + + b.Property("status_chief_click_date"); + + b.Property("status_self") + .HasMaxLength(1); + + b.Property("status_self_a") + .HasMaxLength(1); + + b.Property("status_self_a_click_date"); + + b.Property("status_self_click_date"); + + b.Property("status_supervisor") + .HasMaxLength(1); + + b.Property("status_supervisor1A") + .HasMaxLength(1); + + b.Property("status_supervisor1A_click_date"); + + b.Property("status_supervisor2A") + .HasMaxLength(1); + + b.Property("status_supervisor2A_click_date"); + + b.Property("status_supervisor_click_date"); + + b.Property("supervisor1"); + + b.Property("supervisor1A"); + + b.Property("supervisor1A_date"); + + b.Property("supervisor1A_remark") + .HasMaxLength(1000); + + b.Property("supervisor1A_result") + .HasMaxLength(1); + + b.Property("supervisor1_date"); + + b.Property("supervisor1_id"); + + b.Property("supervisor1_remark") + .HasMaxLength(1000); + + b.Property("supervisor1_result") + .HasMaxLength(1); + + b.Property("supervisor2"); + + b.Property("supervisor2A"); + + b.Property("supervisor2A_date"); + + b.Property("supervisor2A_remark") + .HasMaxLength(1000); + + b.Property("supervisor2A_result") + .HasMaxLength(1); + + b.Property("supervisor2_date"); + + b.Property("supervisor2_id"); + + b.Property("supervisor2_remark") + .HasMaxLength(1000); + + b.Property("supervisor2_result") + .HasMaxLength(1); + + b.Property("total_summary_chief"); + + b.Property("total_summary_competency_chief"); + + b.Property("total_summary_competency_supervisor"); + + b.Property("total_summary_competency_supervisor1A"); + + b.Property("total_summary_competency_supervisor2A"); + + b.Property("total_summary_supervisor"); + + b.Property("total_summary_supervisor1A"); + + b.Property("total_summary_supervisor2A"); + + b.Property("updated"); + + b.Property("work_period"); + + b.HasKey("id"); + + b.HasIndex("create_evaluation_id"); + + b.ToTable("eva_create_evaluation_detail"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluation_detail_historyEntity", b => + { + b.Property("id"); + + b.Property("action_detail") + .HasMaxLength(4000); + + b.Property("action_dt"); + + b.Property("action_emp_id"); + + b.Property("created"); + + b.Property("evaluation_detail_id"); + + b.Property("isActive"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("evaluation_detail_id"); + + b.ToTable("eva_create_evaluation_detail_history"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_achievementEntity", b => + { + b.Property("id"); + + b.Property("achievement") + .HasMaxLength(8000); + + b.Property("create_evaluation_detail_id"); + + b.Property("created"); + + b.Property("isActive"); + + b.Property("score"); + + b.Property("score2"); + + b.Property("score3"); + + b.Property("score4"); + + b.Property("sumary"); + + b.Property("sumary2"); + + b.Property("sumary3"); + + b.Property("sumary4"); + + b.Property("target_score1") + .HasMaxLength(255); + + b.Property("target_score2") + .HasMaxLength(255); + + b.Property("target_score3") + .HasMaxLength(255); + + b.Property("target_score4") + .HasMaxLength(255); + + b.Property("target_score5") + .HasMaxLength(255); + + b.Property("thefile") + .HasMaxLength(1000); + + b.Property("updated"); + + b.Property("weight"); + + b.HasKey("id"); + + b.HasIndex("create_evaluation_detail_id"); + + b.ToTable("eva_evaluation_achievement"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_achievement_attachEntity", b => + { + b.Property("id"); + + b.Property("achievement_id"); + + b.Property("created"); + + b.Property("isActive"); + + b.Property("the_file") + .HasMaxLength(1000); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("achievement_id"); + + b.ToTable("eva_evaluation_achievement_attach"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_behaviorEntity", b => + { + b.Property("id"); + + b.Property("behavior") + .HasMaxLength(1000); + + b.Property("create_evaluation_detail_id"); + + b.Property("created"); + + b.Property("isActive"); + + b.Property("score"); + + b.Property("score2"); + + b.Property("score3"); + + b.Property("score4"); + + b.Property("sumary"); + + b.Property("sumary2"); + + b.Property("sumary3"); + + b.Property("sumary4"); + + b.Property("target_score1") + .HasMaxLength(255); + + b.Property("target_score2") + .HasMaxLength(255); + + b.Property("target_score3") + .HasMaxLength(255); + + b.Property("target_score4") + .HasMaxLength(255); + + b.Property("target_score5") + .HasMaxLength(255); + + b.Property("updated"); + + b.Property("weight"); + + b.HasKey("id"); + + b.HasIndex("create_evaluation_detail_id"); + + b.ToTable("eva_evaluation_behavior"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_groupEntity", b => + { + b.Property("id") + .ValueGeneratedOnAdd(); + + b.Property("code") + .HasMaxLength(255); + + b.Property("created"); + + b.Property("isActive"); + + b.Property("main_dept_id"); + + b.Property("percentage"); + + b.Property("thegroup") + .HasMaxLength(255); + + b.Property("updated"); + + b.HasKey("id"); + + b.ToTable("eva_evaluation_group"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_group_detailEntity", b => + { + b.Property("id") + .ValueGeneratedOnAdd(); + + b.Property("created"); + + b.Property("employee_id"); + + b.Property("evaluation_group_id"); + + b.Property("isActive"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("evaluation_group_id"); + + b.ToTable("eva_evaluation_group_detail"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_operating_agreementEntity", b => + { + b.Property("id"); + + b.Property("create_evaluation_detail_id"); + + b.Property("created"); + + b.Property("indicators") + .HasMaxLength(4000); + + b.Property("isActive"); + + b.Property("mission_detail") + .HasMaxLength(4000); + + b.Property("mission_no"); + + b.Property("target") + .HasMaxLength(4000); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("create_evaluation_detail_id"); + + b.ToTable("eva_evaluation_operating_agreement"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_idp_planEntity", b => + { + b.Property("id"); + + b.Property("create_evaluation_detail_id"); + + b.Property("created"); + + b.Property("develop") + .HasMaxLength(1000); + + b.Property("development_method") + .HasMaxLength(1000); + + b.Property("end_date"); + + b.Property("isActive"); + + b.Property("period_text") + .HasMaxLength(1000); + + b.Property("start_date"); + + b.Property("updated"); + + b.HasKey("id"); + + b.ToTable("eva_idp_plan"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_level_scoreEntity", b => + { + b.Property("id") + .ValueGeneratedOnAdd(); + + b.Property("code") + .HasMaxLength(255); + + b.Property("created"); + + b.Property("detail") + .HasMaxLength(1000); + + b.Property("isActive"); + + b.Property("max_score"); + + b.Property("min_score"); + + b.Property("updated"); + + b.HasKey("id"); + + b.ToTable("eva_level_score"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_limit_frame_employeeEntity", b => + { + b.Property("id"); + + b.Property("cost_of_living"); + + b.Property("created"); + + b.Property("employee_id"); + + b.Property("frame_group_guid"); + + b.Property("help_org_id"); + + b.Property("isActive"); + + b.Property("level_text") + .HasMaxLength(1000); + + b.Property("monthly_remuneration"); + + b.Property("order_of_data"); + + b.Property("org_id"); + + b.Property("position_allowance"); + + b.Property("position_text") + .HasMaxLength(1000); + + b.Property("salary"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("frame_group_guid"); + + b.ToTable("eva_limit_frame_employee"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_limit_frame_groupEntity", b => + { + b.Property("id"); + + b.Property("created"); + + b.Property("frame_plan_guid"); + + b.Property("group_guid"); + + b.Property("isActive"); + + b.Property("limit_frame_295"); + + b.Property("main_dept_id"); + + b.Property("remark") + .HasMaxLength(4000); + + b.Property("total_salary"); + + b.Property("total_salary_limit"); + + b.Property("total_salary_limit_rounded"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("frame_plan_guid"); + + b.HasIndex("group_guid"); + + b.ToTable("eva_limit_frame_group"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_limit_frame_planEntity", b => + { + b.Property("id"); + + b.Property("created"); + + b.Property("executed_date"); + + b.Property("isActive"); + + b.Property("limit_frame_005"); + + b.Property("limit_frame_005_total"); + + b.Property("limit_frame_005_total_rounded"); + + b.Property("plan_guid"); + + b.Property("salary_adjustment_date"); + + b.Property("status_chief") + .HasMaxLength(1); + + b.Property("status_self") + .HasMaxLength(1); + + b.Property("supervisor1"); + + b.Property("supervisor1_date"); + + b.Property("supervisor1_remark") + .HasMaxLength(1000); + + b.Property("supervisor1_result") + .HasMaxLength(1); + + b.Property("total_salary"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("plan_guid"); + + b.ToTable("eva_limit_frame_plan"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_performance_planEntity", b => + { + b.Property("id") + .ValueGeneratedOnAdd(); + + b.Property("created"); + + b.Property("fiscal_year"); + + b.Property("isActive"); + + b.Property("percent"); + + b.Property("theTime"); + + b.Property("updated"); + + b.HasKey("id"); + + b.ToTable("eva_performance_plan"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_performance_plan_detailEntity", b => + { + b.Property("id") + .ValueGeneratedOnAdd(); + + b.Property("created"); + + b.Property("end_date"); + + b.Property("isActive"); + + b.Property("list_no"); + + b.Property("performance_plan_id"); + + b.Property("remark") + .HasMaxLength(1000); + + b.Property("start_date"); + + b.Property("step") + .HasMaxLength(1000); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("performance_plan_id"); + + b.ToTable("eva_performance_plan_detail"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_promoted_percentageEntity", b => + { + b.Property("id") + .ValueGeneratedOnAdd(); + + b.Property("code") + .HasMaxLength(255); + + b.Property("created"); + + b.Property("detail") + .HasMaxLength(1000); + + b.Property("isActive"); + + b.Property("level_score_id"); + + b.Property("max_score"); + + b.Property("min_score"); + + b.Property("promoted_percentage"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("level_score_id"); + + b.ToTable("eva_promoted_percentage"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_salary_cylinderEntity", b => + { + b.Property("id"); + + b.Property("cost_living"); + + b.Property("created"); + + b.Property("isActive"); + + b.Property("middle"); + + b.Property("position_level"); + + b.Property("position_type"); + + b.Property("temporary_min"); + + b.Property("themax"); + + b.Property("themin"); + + b.Property("updated"); + + b.HasKey("id"); + + b.ToTable("eva_salary_cylinder"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_adjust_postponementEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluationEntity", "eva_create_evaluation") + .WithMany() + .HasForeignKey("create_evaluation_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_adjust_postponement_detailEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_adjust_postponementEntity", "eva_adjust_postponement") + .WithMany() + .HasForeignKey("adjust_postponement_id"); + + b.HasOne("TodoAPI2.Models.eva_adjust_postponementEntity", "eva_adjust_postponement_quota") + .WithMany() + .HasForeignKey("adjust_postponement_quota_id") + .HasConstraintName("FK_eva_adjust_postponement_detail_eva_adjust_postponement_adj~1"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluationEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_evaluation_groupEntity", "eva_evaluation_group") + .WithMany() + .HasForeignKey("evaluation_group_id"); + + b.HasOne("TodoAPI2.Models.eva_performance_planEntity", "eva_performance_plan") + .WithMany() + .HasForeignKey("performance_plan_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluation_detailEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluationEntity", "eva_create_evaluation_create_evaluation_id") + .WithMany() + .HasForeignKey("create_evaluation_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluation_detail_historyEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluation_detailEntity", "eva_create_evaluation_detail_evaluation_detail_id") + .WithMany() + .HasForeignKey("evaluation_detail_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_achievementEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluation_detailEntity", "eva_create_evaluation_detail") + .WithMany() + .HasForeignKey("create_evaluation_detail_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_achievement_attachEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_evaluation_achievementEntity", "eva_evaluation_achievement_achievement_id") + .WithMany() + .HasForeignKey("achievement_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_behaviorEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluation_detailEntity", "eva_create_evaluation_detail") + .WithMany() + .HasForeignKey("create_evaluation_detail_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_group_detailEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_evaluation_groupEntity", "eva_evaluation_group") + .WithMany() + .HasForeignKey("evaluation_group_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_operating_agreementEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluation_detailEntity", "eva_create_evaluation_detail_create_evaluation_detail_id") + .WithMany() + .HasForeignKey("create_evaluation_detail_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_limit_frame_employeeEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_limit_frame_groupEntity", "eva_limit_frame_group_frame_group_guid") + .WithMany() + .HasForeignKey("frame_group_guid"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_limit_frame_groupEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_limit_frame_planEntity", "eva_limit_frame_plan_frame_plan_guid") + .WithMany() + .HasForeignKey("frame_plan_guid"); + + b.HasOne("TodoAPI2.Models.eva_evaluation_groupEntity", "eva_evaluation_group_group_guid") + .WithMany() + .HasForeignKey("group_guid"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_limit_frame_planEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_performance_planEntity", "eva_performance_plan_plan_guid") + .WithMany() + .HasForeignKey("plan_guid"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_performance_plan_detailEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_performance_planEntity", "eva_performance_plan") + .WithMany() + .HasForeignKey("performance_plan_id"); + }); + + modelBuilder.Entity("TodoAPI2.Models.eva_promoted_percentageEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_level_scoreEntity", "eva_level_score") + .WithMany() + .HasForeignKey("level_score_id"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20210413072130_AddEvaLog.cs b/Migrations/20210413072130_AddEvaLog.cs new file mode 100644 index 0000000..932de5d --- /dev/null +++ b/Migrations/20210413072130_AddEvaLog.cs @@ -0,0 +1,46 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace tb320eva.Migrations +{ + public partial class AddEvaLog : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "eva_create_evaluation_detail_history", + columns: table => new + { + id = table.Column(nullable: false), + created = table.Column(nullable: false), + updated = table.Column(nullable: false), + isActive = table.Column(nullable: false), + evaluation_detail_id = table.Column(nullable: true), + action_dt = table.Column(nullable: true), + action_detail = table.Column(maxLength: 4000, nullable: true), + action_emp_id = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_eva_create_evaluation_detail_history", x => x.id); + table.ForeignKey( + name: "FK_eva_create_evaluation_detail_history_eva_create_evaluation_~", + column: x => x.evaluation_detail_id, + principalTable: "eva_create_evaluation_detail", + principalColumn: "id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_eva_create_evaluation_detail_history_evaluation_detail_id", + table: "eva_create_evaluation_detail_history", + column: "evaluation_detail_id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "eva_create_evaluation_detail_history"); + } + } +} diff --git a/Migrations/DataContextModelSnapshot.cs b/Migrations/DataContextModelSnapshot.cs index 4832bab..4a9b151 100644 --- a/Migrations/DataContextModelSnapshot.cs +++ b/Migrations/DataContextModelSnapshot.cs @@ -373,6 +373,32 @@ namespace tb320eva.Migrations b.ToTable("eva_create_evaluation_detail"); }); + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluation_detail_historyEntity", b => + { + b.Property("id"); + + b.Property("action_detail") + .HasMaxLength(4000); + + b.Property("action_dt"); + + b.Property("action_emp_id"); + + b.Property("created"); + + b.Property("evaluation_detail_id"); + + b.Property("isActive"); + + b.Property("updated"); + + b.HasKey("id"); + + b.HasIndex("evaluation_detail_id"); + + b.ToTable("eva_create_evaluation_detail_history"); + }); + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_achievementEntity", b => { b.Property("id"); @@ -918,6 +944,13 @@ namespace tb320eva.Migrations .HasForeignKey("create_evaluation_id"); }); + modelBuilder.Entity("TodoAPI2.Models.eva_create_evaluation_detail_historyEntity", b => + { + b.HasOne("TodoAPI2.Models.eva_create_evaluation_detailEntity", "eva_create_evaluation_detail_evaluation_detail_id") + .WithMany() + .HasForeignKey("evaluation_detail_id"); + }); + modelBuilder.Entity("TodoAPI2.Models.eva_evaluation_achievementEntity", b => { b.HasOne("TodoAPI2.Models.eva_create_evaluation_detailEntity", "eva_create_evaluation_detail") diff --git a/Models/eva_create_evaluation_detail_agreement/eva_create_evaluation_detail_agreementViewModel.cs b/Models/eva_create_evaluation_detail_agreement/eva_create_evaluation_detail_agreementViewModel.cs index be64814..b53171c 100644 --- a/Models/eva_create_evaluation_detail_agreement/eva_create_evaluation_detail_agreementViewModel.cs +++ b/Models/eva_create_evaluation_detail_agreement/eva_create_evaluation_detail_agreementViewModel.cs @@ -60,9 +60,9 @@ namespace TodoAPI2.Models public decimal? score2 { get; set; } - public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date); } } - public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date); } } - public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date); } } + public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date) + " " + MyHelper.GetTimeStringFromDate(status_self_click_date) + getHistoryLink(status_self); } } + public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date) + " " + MyHelper.GetTimeStringFromDate(status_chief_click_date) + getHistoryLink(status_chief); } } + public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date) + " " + MyHelper.GetTimeStringFromDate(status_supervisor_click_date) + getHistoryLink(status_supervisor); } } private string getStatusText(string s) { @@ -80,5 +80,15 @@ namespace TodoAPI2.Models return " "; } + private string getHistoryLink(string s) + { + if (!string.IsNullOrEmpty(s)) + { + return ("
ดูประวัติ").Replace("{0}", '"'.ToString()); + } + return ""; + } + } -} \ No newline at end of file +} + diff --git a/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocViewModel.cs b/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocViewModel.cs index e64f18f..3e78561 100644 --- a/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocViewModel.cs +++ b/Models/eva_create_evaluation_detail_firstdoc/eva_create_evaluation_detail_firstdocViewModel.cs @@ -68,19 +68,28 @@ namespace TodoAPI2.Models public decimal? score2 { get; set; } - public string txt_status_self_a { get { return getStatusText2(status_self_a) + MyHelper.GetDateStringForReport(status_self_a_click_date); } } + public string txt_status_self_a { get { return getStatusText2(status_self_a) + MyHelper.GetDateStringForReport(status_self_a_click_date) + " " + MyHelper.GetTimeStringFromDate(status_self_a_click_date) + getHistoryLink(status_self_a); } } - public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date); } } + public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date) + " " + MyHelper.GetTimeStringFromDate(status_self_click_date) + getHistoryLink(status_self); } } - public string txt_status_chief_a { get { return getStatusText2(status_chief_a) + MyHelper.GetDateStringForReport(status_chief_a_click_date); } } + public string txt_status_chief_a { get { return getStatusText2(status_chief_a) + MyHelper.GetDateStringForReport(status_chief_a_click_date) + " " + MyHelper.GetTimeStringFromDate(status_chief_a_click_date) + getHistoryLink(status_chief_a); } } - public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date); } } - public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date); } } + public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date) + " " + MyHelper.GetTimeStringFromDate(status_chief_click_date) + getHistoryLink(status_chief); } } + public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date) + " " + MyHelper.GetTimeStringFromDate(status_supervisor_click_date) + getHistoryLink(status_supervisor); } } public string role_desc { get; set; } public string role_code { get; set; } + private string getHistoryLink(string s) + { + if (!string.IsNullOrEmpty(s)) + { + return ("
ดูประวัติ").Replace("{0}", '"'.ToString()); + } + return ""; + } + private string getStatusText(string s) { if (!string.IsNullOrEmpty(s)) diff --git a/Models/eva_create_evaluation_detail_history/Ieva_create_evaluation_detail_historyService.cs b/Models/eva_create_evaluation_detail_history/Ieva_create_evaluation_detail_historyService.cs new file mode 100644 index 0000000..1746352 --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/Ieva_create_evaluation_detail_historyService.cs @@ -0,0 +1,32 @@ +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 Ieva_create_evaluation_detail_historyService : IBaseService2 + { + new eva_create_evaluation_detail_historyViewModel Insert(eva_create_evaluation_detail_historyInputModel model, bool is_force_save); + new eva_create_evaluation_detail_historyViewModel Update(int id, eva_create_evaluation_detail_historyInputModel model, bool is_force_save); + List GetListByevaluation_detail_id(int? evaluation_detail_id); + List GetListBySearch(eva_create_evaluation_detail_historySearchModel model); + + string UpdateMultiple(List model, bool is_force_save); + eva_create_evaluation_detail_historyWithSelectionViewModel GetWithSelection(int id); + eva_create_evaluation_detail_historyWithSelectionViewModel GetBlankItem(); + + void RefreshAutoFieldOfAllData(); + eva_create_evaluation_detail_historyEntity GetEntity(int id); + DataContext GetContext(); + + + + } +} + diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyEntity.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyEntity.cs new file mode 100644 index 0000000..17e0e37 --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyEntity.cs @@ -0,0 +1,42 @@ +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; +using System.IO; + +namespace TodoAPI2.Models +{ + public class eva_create_evaluation_detail_historyEntity : BaseEntity2 + { + + + [ForeignKey("evaluation_detail_id")] + public eva_create_evaluation_detailEntity eva_create_evaluation_detail_evaluation_detail_id { get; set; } + public int? evaluation_detail_id { get; set; } + + public DateTime? action_dt { get; set; } + + [MaxLength(4000)] + public string action_detail { get; set; } + + public int? action_emp_id { get; set; } + + + public void SetAutoField(DataContext context) + { + + } + + public void DoAfterInsertUpdate(DataContext context) + { + + } + + } +} diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyInputModel.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyInputModel.cs new file mode 100644 index 0000000..461d2ff --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyInputModel.cs @@ -0,0 +1,30 @@ +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 eva_create_evaluation_detail_historyInputModel + { + + public int? id { get; set; } + + public int? evaluation_detail_id { get; set; } + + public DateTime? action_dt { get; set; } + + public string action_detail { get; set; } + + public int? action_emp_id { get; set; } + + public string active_mode { get; set; } + } +} + diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyReportRequestModel.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyReportRequestModel.cs new file mode 100644 index 0000000..e3c8f5a --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyReportRequestModel.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 eva_create_evaluation_detail_historyReportRequestModel : eva_create_evaluation_detail_historySearchModel + { + public string filetype { get; set; } + + public string contentType { get { return MyHelper.GetContentType(filetype); } } + } +} + diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historySearchModel.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historySearchModel.cs new file mode 100644 index 0000000..385381f --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historySearchModel.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 eva_create_evaluation_detail_historySearchModel + { + + public int id { get; set; } + + public int? evaluation_detail_id { get; set; } + + } +} + diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyService.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyService.cs new file mode 100644 index 0000000..4129a92 --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyService.cs @@ -0,0 +1,310 @@ +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 eva_create_evaluation_detail_historyService : Ieva_create_evaluation_detail_historyService + { + private IBaseRepository2 _repository; + private IMyDatabase db; + private Iexternal_linkageService ext; + private Iexternal_employeeService emp; + + public eva_create_evaluation_detail_historyService(IBaseRepository2 repository, IMyDatabase mydb, + Iexternal_linkageService inext, Iexternal_employeeService inemp) + { + _repository = repository; + db = mydb; + ext = inext; + emp = inemp; + } + + #region Private Functions + private eva_create_evaluation_detail_historyEntity GetEntity(eva_create_evaluation_detail_historyInputModel model) + { + return Mapper.Map(model); + } + private List GetEntityList(List models) + { + return Mapper.Map>(models); + } + private eva_create_evaluation_detail_historyViewModel GetDto(eva_create_evaluation_detail_historyEntity entity) + { + return Mapper.Map(entity); + } + private List GetDtoList(List entities) + { + return Mapper.Map>(entities); + } + + #endregion + + #region Public Functions + #region Query Functions + + public eva_create_evaluation_detail_historyViewModel Get(int id) + { + var entity = _repository.Get(id); + + return GetDto(entity); + } + + public eva_create_evaluation_detail_historyEntity GetEntity(int id) + { + var entity = _repository.Get(id); + + return entity; + } + + public DataContext GetContext() + { + return _repository.Context; + } + + public eva_create_evaluation_detail_historyWithSelectionViewModel GetWithSelection(int id) + { + var entity = _repository.Get(id); + var i = Mapper.Map(entity); + i.item_action_emp_id = emp.GetAllEmployee(); + + + return i; + } + public eva_create_evaluation_detail_historyWithSelectionViewModel GetBlankItem() + { + var i = new eva_create_evaluation_detail_historyWithSelectionViewModel(); + i.item_action_emp_id = emp.GetAllEmployee(); + + + return i; + } + + public List GetListByevaluation_detail_id(int? evaluation_detail_id) + { + var model = new eva_create_evaluation_detail_historySearchModel(); + model.evaluation_detail_id = evaluation_detail_id; + return GetListBySearch(model); + } + + public List GetListBySearch(eva_create_evaluation_detail_historySearchModel model) + { + var data = ( + from m_eva_create_evaluation_detail_history in _repository.Context.eva_create_evaluation_detail_history + + join fk_eva_create_evaluation_detail1 in _repository.Context.eva_create_evaluation_detail on m_eva_create_evaluation_detail_history.evaluation_detail_id equals fk_eva_create_evaluation_detail1.id + into eva_create_evaluation_detailResult1 + from fk_eva_create_evaluation_detailResult1 in eva_create_evaluation_detailResult1.DefaultIfEmpty() + + join fk_external_employee4 in emp.GetAllEmployee() on m_eva_create_evaluation_detail_history.action_emp_id equals fk_external_employee4.id + into external_employeeResult4 + from fk_external_employeeResult4 in external_employeeResult4.DefaultIfEmpty() + + where + 1 == 1 + && (!model.evaluation_detail_id.HasValue || m_eva_create_evaluation_detail_history.evaluation_detail_id == model.evaluation_detail_id) + + orderby m_eva_create_evaluation_detail_history.action_dt + select new eva_create_evaluation_detail_historyViewModel() + { + id = m_eva_create_evaluation_detail_history.id, + evaluation_detail_id = m_eva_create_evaluation_detail_history.evaluation_detail_id, + action_dt = m_eva_create_evaluation_detail_history.action_dt, + action_detail = m_eva_create_evaluation_detail_history.action_detail, + action_emp_id = m_eva_create_evaluation_detail_history.action_emp_id, + + evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id = fk_eva_create_evaluation_detailResult1.create_evaluation_id, + action_emp_id_external_employee_fullname = fk_external_employeeResult4.fullname, + + isActive = m_eva_create_evaluation_detail_history.isActive, + Created = m_eva_create_evaluation_detail_history.created, + Updated = m_eva_create_evaluation_detail_history.updated + } + ).Take(1000).ToList(); + + return data; + } + + #endregion + + #region Manipulation Functions + + + public int GetNewPrimaryKey() + { + int? newkey = 0; + + var x = (from i in _repository.Context.eva_create_evaluation_detail_history + orderby i.id descending + select i).Take(1).ToList(); + + if(x.Count > 0) + { + newkey = x[0].id + 1; + } + + return newkey.Value; + } + + + public eva_create_evaluation_detail_historyViewModel Insert(eva_create_evaluation_detail_historyInputModel model, bool is_force_save) + { + var entity = GetEntity(model); + entity.id = GetNewPrimaryKey(); + + + entity.SetAutoField(_repository.Context); + + if (is_force_save) + { + var inserted = _repository.Insert(entity); + entity.DoAfterInsertUpdate(_repository.Context); + return Get(inserted.id); + } + else + { + _repository.InsertWithoutCommit(entity); + entity.DoAfterInsertUpdate(_repository.Context); + return Mapper.Map(entity); + } + } + + public eva_create_evaluation_detail_historyViewModel Update(int id, eva_create_evaluation_detail_historyInputModel model, bool is_force_save) + { + var existingEntity = _repository.Get(id); + if (existingEntity != null) + { + existingEntity.evaluation_detail_id = model.evaluation_detail_id; + existingEntity.action_dt = model.action_dt; + existingEntity.action_detail = model.action_detail; + existingEntity.action_emp_id = model.action_emp_id; + + existingEntity.SetAutoField(_repository.Context); + + if (is_force_save) + { + var updated = _repository.Update(id, existingEntity); + existingEntity.DoAfterInsertUpdate(_repository.Context); + return Get(updated.id); + } + else + { + _repository.UpdateWithoutCommit(id, existingEntity); + existingEntity.DoAfterInsertUpdate(_repository.Context); + return Mapper.Map(existingEntity); + } + } + else + throw new NotificationException("No data to update"); + } + + public string UpdateMultiple(List model, bool is_force_save) + { + foreach(var i in model) + { + if (i.active_mode == "1" && i.id.HasValue) // update + { + var existingEntity = _repository.Get(i.id.Value); + if (existingEntity != null) + { + existingEntity.evaluation_detail_id = i.evaluation_detail_id; + existingEntity.action_dt = i.action_dt; + existingEntity.action_detail = i.action_detail; + existingEntity.action_emp_id = i.action_emp_id; + + existingEntity.SetAutoField(_repository.Context); + _repository.UpdateWithoutCommit(i.id.Value, existingEntity); + } + } + else if (i.active_mode == "1" && !i.id.HasValue) // add + { + var entity = GetEntity(i); + entity.id = GetNewPrimaryKey(); + entity.SetAutoField(_repository.Context); + _repository.InsertWithoutCommit(entity); + } + else if (i.active_mode == "0" && i.id.HasValue) // remove + { + _repository.DeleteWithoutCommit(i.id.Value); + } + else if (i.active_mode == "0" && !i.id.HasValue) + { + // nothing to do + } + } + if (is_force_save) + { + _repository.Context.SaveChanges(); + } + + return model.Count().ToString(); + } + + public eva_create_evaluation_detail_historyViewModel SetAsActive(int id) + { + var updated = _repository.SetAsActive(id); + + return Get(updated.id); + } + public eva_create_evaluation_detail_historyViewModel SetAsInactive(int id) + { + var updated = _repository.SetAsInActive(id); + + return Get(updated.id); + } + public void Delete(int id) + { + _repository.Delete(id); + + return; + } + + public void RefreshAutoFieldOfAllData() + { + var all_items = from i in _repository.Context.eva_create_evaluation_detail_history + select i; + foreach (var item in all_items) + { + item.SetAutoField(_repository.Context); + } + _repository.Context.SaveChanges(); + } + + private Dictionary GetLookupForLog() + { + var i = new Dictionary(); + + + i.Add("evaluation_detail_id", "การประเมิน"); + i.Add("evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id", "การประเมิน"); + i.Add("action_dt", "วันที่/เวลา"); + i.Add("txt_action_dt", "วันที่/เวลา"); + i.Add("action_detail", "รายละเอียด"); + i.Add("action_emp_id", "ผู้ดำเนินการ"); + i.Add("action_emp_id_external_employee_employee_type", "ผู้ดำเนินการ"); + + return i; + } + + #endregion + + #region Match Item + + #endregion + + #endregion + } +} \ No newline at end of file diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyViewModel.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyViewModel.cs new file mode 100644 index 0000000..61a5215 --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyViewModel.cs @@ -0,0 +1,31 @@ +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 eva_create_evaluation_detail_historyViewModel : BaseViewModel2 + { + + public int? evaluation_detail_id { get; set; } + + public DateTime? action_dt { get; set; } + + public string txt_action_dt { get { return MyHelper.GetDateStringForReport(this.action_dt); } } + + public string action_detail { get; set; } + + public int? action_emp_id { get; set; } + + public int? evaluation_detail_id_eva_create_evaluation_detail_create_evaluation_id { get; set; } + public string action_emp_id_external_employee_fullname { get; set; } + + } +} \ No newline at end of file diff --git a/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyWithSelectionViewModel.cs b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyWithSelectionViewModel.cs new file mode 100644 index 0000000..85ce478 --- /dev/null +++ b/Models/eva_create_evaluation_detail_history/eva_create_evaluation_detail_historyWithSelectionViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace TodoAPI2.Models +{ + public class eva_create_evaluation_detail_historyWithSelectionViewModel: eva_create_evaluation_detail_historyViewModel + { + public List item_action_emp_id { get; set; } + + } +} \ No newline at end of file diff --git a/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processViewModel.cs b/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processViewModel.cs index be97079..8af11e3 100644 --- a/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processViewModel.cs +++ b/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processViewModel.cs @@ -88,11 +88,20 @@ namespace TodoAPI2.Models public DateTime? status_supervisor1A_click_date { get; set; } public DateTime? status_supervisor2A_click_date { get; set; } - public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date); } } - public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date); } } - public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date); } } - public string txt_status_supervisor1A { get { return getStatusText(status_supervisor1A) + MyHelper.GetDateStringForReport(status_supervisor1A_click_date); } } - public string txt_status_supervisor2A { get { return getStatusText(status_supervisor2A) + MyHelper.GetDateStringForReport(status_supervisor2A_click_date); } } + public string txt_status_self { get { return getStatusText(status_self) + MyHelper.GetDateStringForReport(status_self_click_date) + " " + MyHelper.GetTimeStringFromDate(status_self_click_date) + getHistoryLink(status_self); } } + public string txt_status_chief { get { return getStatusText(status_chief) + MyHelper.GetDateStringForReport(status_chief_click_date) + " " + MyHelper.GetTimeStringFromDate(status_chief_click_date) + getHistoryLink(status_chief); } } + public string txt_status_supervisor { get { return getStatusText(status_supervisor) + MyHelper.GetDateStringForReport(status_supervisor_click_date) + " " + MyHelper.GetTimeStringFromDate(status_supervisor_click_date) + getHistoryLink(status_supervisor); } } + public string txt_status_supervisor1A { get { return getStatusText(status_supervisor1A) + MyHelper.GetDateStringForReport(status_supervisor1A_click_date) + " " + MyHelper.GetTimeStringFromDate(status_supervisor1A_click_date) + getHistoryLink(status_supervisor1A); } } + public string txt_status_supervisor2A { get { return getStatusText(status_supervisor2A) + MyHelper.GetDateStringForReport(status_supervisor2A_click_date) + " " + MyHelper.GetTimeStringFromDate(status_supervisor2A_click_date) + getHistoryLink(status_supervisor2A); } } + + private string getHistoryLink(string s) + { + if (!string.IsNullOrEmpty(s)) + { + return ("
ดูประวัติ").Replace("{0}", '"'.ToString()); + } + return ""; + } private string getStatusText(string s) { @@ -110,8 +119,8 @@ namespace TodoAPI2.Models return " "; } - public string txt_status_self_a_click_date { get { return MyHelper.GetDateStringForReport(status_self_a_click_date); } } - public string txt_status_chief_a_click_date { get { return MyHelper.GetDateStringForReport(status_chief_a_click_date); } } + public string txt_status_self_a_click_date { get { return MyHelper.GetDateStringForReport(status_self_a_click_date) + " " + MyHelper.GetTimeStringFromDate(status_self_a_click_date); } } + public string txt_status_chief_a_click_date { get { return MyHelper.GetDateStringForReport(status_chief_a_click_date) + " " + MyHelper.GetTimeStringFromDate(status_chief_a_click_date); } } } } diff --git a/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusInputModel.cs b/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusInputModel.cs index 75bd35e..47aca51 100644 --- a/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusInputModel.cs +++ b/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusInputModel.cs @@ -34,6 +34,8 @@ namespace TodoAPI2.Models public string status_mode { get; set; } + public int? employee_id { get; set; } + public string active_mode { get; set; } } } diff --git a/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs b/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs index 8f2ab33..7e0d3f4 100644 --- a/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs +++ b/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs @@ -28,16 +28,18 @@ namespace TodoAPI2.Models private IMyDatabase db; private Iexternal_linkageService ext; private Iexternal_employeeService emp; + private Ieva_create_evaluation_detail_historyService his; private IConfiguration Configuration { get; set; } public eva_create_evaluation_detail_statusService(IBaseRepository2 repository, - IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp, IConfiguration configuration) + IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp, IConfiguration configuration, Ieva_create_evaluation_detail_historyService inhis) { _repository = repository; db = mydb; ext = inext; emp = inemp; Configuration = configuration; + his = inhis; } #region Private Functions @@ -155,13 +157,33 @@ namespace TodoAPI2.Models var entity = GetEntity(model); entity.id = GetNewPrimaryKey(); - - var inserted = _repository.Insert(entity); return Get(inserted.id); } + private void add_history(DateTime? dt, string action, int? action_user_id, int? detail_id) + { + int? newkey = 0; + + var x = (from i in _repository.Context.eva_create_evaluation_detail_history + orderby i.id descending + select i).Take(1).ToList(); + + if (x.Count > 0) + { + newkey = x[0].id + 1; + } + + var n = new eva_create_evaluation_detail_historyEntity(); + n.id = newkey.Value; + n.action_detail = action; + n.action_dt = dt; + n.action_emp_id = action_user_id; + n.evaluation_detail_id = detail_id; + _repository.Context.Add(n); + } + public eva_create_evaluation_detail_statusViewModel Update(int id, eva_create_evaluation_detail_statusInputModel model) { var existingEntity = _repository.Get(id); @@ -198,23 +220,25 @@ namespace TodoAPI2.Models if (model.status_mode == "nextA") { - existingEntity.status_self_a_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_self_a_click_date = DateTime.Now; existingEntity.status_chief_a_click_date = null; noti_to_employee_id = existingEntity.chief; noti_message = "กรุณาตรวจสอบ ข้อตกลงการประเมิน ของ {0}"; noti_url = "/eva/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ส่งข้อตกลงการประเมิน", model.employee_id, existingEntity.id); } else if (model.status_mode == "backB") { - existingEntity.status_chief_a_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_chief_a_click_date = DateTime.Now; existingEntity.status_self_a_click_date = null; noti_to_employee_id = existingEntity.employee_id; noti_message = "ข้อตกลงการประเมินของคุณ ({0}) ถูกตีกลับ"; noti_url = "/eva/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ข้อตกลงการประเมิน ถูกตีกลับ", model.employee_id, existingEntity.id); } else if (model.status_mode == "nextB") { - existingEntity.status_chief_a_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_chief_a_click_date = DateTime.Now; if (current_eva.employee_id == existingEntity.chief) // หัวหน้าและผู้ประเมินสูงสุด เป็นคนคนเดียวกัน { noti_to_employee_id = current_eva.supervisor1_id; @@ -224,10 +248,11 @@ namespace TodoAPI2.Models noti_to_employee_id = current_eva.employee_id; } need_noti = false; + add_history(DateTime.Now, "อนุมัติ ข้อตกลงการประเมิน", existingEntity.chief, existingEntity.id); } else if (model.status_mode == "next0") { - existingEntity.status_self_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_self_click_date = DateTime.Now; noti_to_employee_id = existingEntity.chief; noti_message = "กรุณาตรวจสอบแบบประเมินของ {0}"; noti_url = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d?id=" + existingEntity.id.ToString(); @@ -235,10 +260,11 @@ namespace TodoAPI2.Models noti_to_employee_id2 = owner_eva_employee_id; noti_message2 = "แบบประเมินของ {0} ได้ถูกส่งต่อไปยังขั้นตอนถัดไปแล้ว"; noti_url2 = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ส่งแบบประเมิน", model.employee_id, existingEntity.id); } else if (model.status_mode == "next1") { - existingEntity.status_chief_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_chief_click_date = DateTime.Now; if (current_eva.employee_id == existingEntity.chief) // หัวหน้าและผู้ประเมินสูงสุด เป็นคนคนเดียวกัน { noti_to_employee_id = current_eva.supervisor1_id; @@ -250,61 +276,68 @@ namespace TodoAPI2.Models } else if (model.status_mode == "back1") { - existingEntity.status_chief_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_chief_click_date = DateTime.Now; existingEntity.status_self_click_date = null; noti_to_employee_id = existingEntity.employee_id; noti_message = "ข้อตกลงการประเมินของคุณ ({0}) ถูกตีกลับ"; noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ข้อตกลงการประเมิน ถูกตีกลับ โดยผู้ประเมิน", model.employee_id, existingEntity.id); } else if (model.status_mode == "next2") { - existingEntity.status_supervisor_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_supervisor_click_date = DateTime.Now; noti_to_employee_id = current_eva.supervisor1_id; noti_to_employee_id2 = owner_eva_employee_id; noti_message2 = "แบบประเมินของ {0} ได้ถูกส่งต่อไปยังขั้นตอนถัดไปแล้ว"; noti_url2 = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ผู้ประเมินสูงสุด อนุมัติแบบประเมินแล้ว", model.employee_id, existingEntity.id); } else if (model.status_mode == "back2") { - existingEntity.status_supervisor_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_supervisor_click_date = DateTime.Now; existingEntity.status_chief_click_date = null; noti_to_employee_id = existingEntity.chief; noti_message = "แบบประเมินของ {0} ถูกตีกลับ"; noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "แบบประเมิน ถูกตีกลับ โดยผู้ประเมินสูงสุด", model.employee_id, existingEntity.id); } else if (model.status_mode == "next3") { - existingEntity.status_supervisor1A_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_supervisor1A_click_date = DateTime.Now; noti_to_employee_id = current_eva.supervisor2_id; noti_to_employee_id2 = owner_eva_employee_id; noti_message2 = "แบบประเมินของ {0} ได้ถูกส่งต่อไปยังขั้นตอนถัดไปแล้ว"; noti_url2 = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง อนุมัติแบบประเมินแล้ว", model.employee_id, existingEntity.id); } else if (model.status_mode == "back3") { - existingEntity.status_supervisor1A_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_supervisor1A_click_date = DateTime.Now; existingEntity.status_supervisor_click_date = null; noti_to_employee_id = current_eva.employee_id; noti_message = "แบบประเมินของ {0} ถูกตีกลับ"; noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d2?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "แบบประเมินถูกตีกลับ โดย ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง", model.employee_id, existingEntity.id); } else if (model.status_mode == "next4") { - existingEntity.status_supervisor2A_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_supervisor2A_click_date = DateTime.Now; noti_to_employee_id2 = owner_eva_employee_id; noti_message2 = "แบบประเมินของ {0} ได้รับการประเมินเรียบร้อยแล้ว"; noti_url2 = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด) อนุมัติแบบประเมินแล้ว", model.employee_id, existingEntity.id); } else if (model.status_mode == "back4") { - existingEntity.status_supervisor2A_click_date = MyHelper.RemoveTimeFromDate(DateTime.Now); + existingEntity.status_supervisor2A_click_date = DateTime.Now; existingEntity.status_supervisor1A_click_date = null; noti_to_employee_id = current_eva.supervisor1_id; noti_message = "แบบประเมินของ {0} ถูกตีกลับ"; noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d2?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "แบบประเมินถูกตีกลับ โดย ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด)", model.employee_id, existingEntity.id); } if (need_noti) diff --git a/Startup.cs b/Startup.cs index d4ee490..e89fc55 100644 --- a/Startup.cs +++ b/Startup.cs @@ -332,6 +332,9 @@ namespace Test01 services.AddScoped(); + services.AddScoped, BaseRepository2>(); + services.AddScoped(); + #endregion services.TryAddSingleton(); @@ -623,6 +626,10 @@ namespace Test01 cfg.CreateMap(); cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + }); #endregion diff --git a/Utils/MyHelper.cs b/Utils/MyHelper.cs index 19f3754..f82548b 100644 --- a/Utils/MyHelper.cs +++ b/Utils/MyHelper.cs @@ -95,6 +95,18 @@ public class MyHelper } } + public static string GetTimeStringFromDate(DateTime? date) + { + if (date.HasValue) + { + return date.Value.ToShortTimeString() + "น."; + } + else + { + return ""; + } + } + public static DateTime? GetDateFromString(string date) { if (string.IsNullOrEmpty(date)) return null; diff --git a/ViewControllers/eva_create_evaluation_detail_historyViewControllers.cs b/ViewControllers/eva_create_evaluation_detail_historyViewControllers.cs new file mode 100644 index 0000000..34d32b1 --- /dev/null +++ b/ViewControllers/eva_create_evaluation_detail_historyViewControllers.cs @@ -0,0 +1,66 @@ +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 eva_create_evaluation_detail_historyViewController : Controller + { + private ILogger _logger; + private Ieva_create_evaluation_detail_historyService _repository; + private IConfiguration Configuration { get; set; } + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public eva_create_evaluation_detail_historyViewController(ILogger logger, Ieva_create_evaluation_detail_historyService repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + public IActionResult eva_create_evaluation_detail_history() + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + return View(); + } + + // public IActionResult eva_create_evaluation_detail_history_d() + // { + //if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + // return View(); + // } + + //public IActionResult eva_create_evaluation_detail_history_report() + //{ + // if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + // return View(); + //} + + //public IActionResult eva_create_evaluation_detail_history_inline() + //{ + // 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/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d.cshtml b/Views/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d.cshtml index 25e48c7..10fefbc 100644 --- a/Views/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d.cshtml +++ b/Views/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d.cshtml @@ -453,11 +453,11 @@ }); function CheckPermission() { - //if (status_self === "Y") { - // $(".status_self").hide(); - // $(".status_self_text").attr("disabled", true); - // $("#status").text("คุณส่งแบบประเมินไปแล้ว"); - //} + if (status_self === "Y") { + $(".status_self").hide(); + $(".status_self_text").attr("disabled", true); + $("#status").text("คุณส่งแบบประเมินไปแล้ว"); + } } function OnWeightChanged(c) { diff --git a/Views/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d.cshtml b/Views/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d.cshtml index 93d67e8..6f95944 100644 --- a/Views/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d.cshtml +++ b/Views/eva_create_evaluation_detail_firstdocView/eva_create_evaluation_detail_firstdoc_d.cshtml @@ -154,7 +154,7 @@
- +
diff --git a/Views/eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history.cshtml b/Views/eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history.cshtml new file mode 100644 index 0000000..c92ae60 --- /dev/null +++ b/Views/eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history.cshtml @@ -0,0 +1,59 @@ +@using Microsoft.Extensions.Configuration +@inject IConfiguration Configuration +@{ + ViewData["Title"] = "eva_create_evaluation_detail_history"; + Layout = "_LayoutDirect"; +} + +
+
+
+ @Configuration["SiteInformation:modulename"] +
+
+
+ +
+
+ +
+
ประวัติการดำเนินการ
+ +
+
+
+ +
+ +
+
+ + + + + + + + + + + + +
+
+ +@section FooterPlaceHolder{ + + +} + diff --git a/tb320eva.csproj b/tb320eva.csproj index 52c903f..f557aa5 100644 --- a/tb320eva.csproj +++ b/tb320eva.csproj @@ -69,6 +69,7 @@ + @@ -84,6 +85,7 @@ + diff --git a/tb320eva.xml b/tb320eva.xml index a4b66cc..d6cf165 100644 --- a/tb320eva.xml +++ b/tb320eva.xml @@ -1191,6 +1191,124 @@ Returns the item Error Occurred + + + Default constructure for dependency injection + + + + + + + + Get specific item by id + + + + Return Get specific item by id + Returns the item + Error Occurred + + + + Get Blank Item + + + + Return a blank item + Returns the item + Error Occurred + + + + Get list items by evaluation_detail_id + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + + + + Get list items by search + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + + + + Download Report + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + + + + Create new item + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Update item + + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Delete item + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Update multiple item + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Refresh AutoField of all items + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + Default constructure for dependency injection @@ -1746,12 +1864,13 @@ If the model is invalid Error Occurred - + Default constructure for dependency injection + @@ -5266,6 +5385,14 @@ + + + Default constructure for dependency injection + + + + + Default constructure for dependency injection diff --git a/wwwroot/js/eva_create_evaluation_detail_history/eva_create_evaluation_detail_history.js b/wwwroot/js/eva_create_evaluation_detail_history/eva_create_evaluation_detail_history.js new file mode 100644 index 0000000..4660b8f --- /dev/null +++ b/wwwroot/js/eva_create_evaluation_detail_history/eva_create_evaluation_detail_history.js @@ -0,0 +1,209 @@ +var eva_create_evaluation_detail_history_editMode = "CREATE"; +var eva_create_evaluation_detail_history_API = "/api/eva_create_evaluation_detail_history/"; + +//================= Search Customizaiton ========================================= + +function eva_create_evaluation_detail_history_GetSearchParameter() { + var eva_create_evaluation_detail_historySearchObject = new Object(); + eva_create_evaluation_detail_historySearchObject.evaluation_detail_id = getUrlParameter("id"); + + return eva_create_evaluation_detail_historySearchObject; +} + +function eva_create_evaluation_detail_history_FeedDataToSearchForm(data) { + $("#s_eva_create_evaluation_detail_history_evaluation_detail_id").val(data.evaluation_detail_id); + +} + +//================= Form Data Customizaiton ========================================= + +function eva_create_evaluation_detail_history_FeedDataToForm(data) { + $("#eva_create_evaluation_detail_history_id").val(data.id); + $("#eva_create_evaluation_detail_history_evaluation_detail_id").val(data.evaluation_detail_id); + $("#eva_create_evaluation_detail_history_action_dt").val(formatDate(data.action_dt)); + $("#eva_create_evaluation_detail_history_action_detail").val(data.action_detail); + //DropDownClearFormAndFeedWithData($("#eva_create_evaluation_detail_history_action_emp_id"), data, "id", "employee_type", "item_action_emp_id", data.action_emp_id); + +} + +function eva_create_evaluation_detail_history_GetFromForm() { + var eva_create_evaluation_detail_historyObject = new Object(); + eva_create_evaluation_detail_historyObject.id = $("#eva_create_evaluation_detail_history_id").val(); + eva_create_evaluation_detail_historyObject.evaluation_detail_id = getUrlParameter("id"); + eva_create_evaluation_detail_historyObject.action_dt = getDate($("#eva_create_evaluation_detail_history_action_dt").val()); + eva_create_evaluation_detail_historyObject.action_detail = $("#eva_create_evaluation_detail_history_action_detail").val(); + eva_create_evaluation_detail_historyObject.action_emp_id = $("#eva_create_evaluation_detail_history_action_emp_id").val(); + + + return eva_create_evaluation_detail_historyObject; +} + +function eva_create_evaluation_detail_history_InitialForm(s) { + var successFunc = function (result) { + eva_create_evaluation_detail_history_FeedDataToForm(result); + eva_create_evaluation_detail_history_FeedDataToSearchForm(result); + if (s) { + // Incase model popup + $("#eva_create_evaluation_detail_historyModel").modal("show"); + } + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + eva_create_evaluation_detail_history_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Form Mode Setup and Flow ========================================= + +function eva_create_evaluation_detail_history_GoCreate() { + // Incase model popup + eva_create_evaluation_detail_history_SetCreateForm(true); + + // Incase open new page + //window_open(appsite + "/eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history_d"); +} + +function eva_create_evaluation_detail_history_GoEdit(a) { + // Incase model popup + eva_create_evaluation_detail_history_SetEditForm(a); + + // Incase open new page + //window_open(appsite + "/eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history_d?id=" + a); +} + +function eva_create_evaluation_detail_history_SetEditForm(a) { + var successFunc = function (result) { + eva_create_evaluation_detail_history_editMode = "UPDATE"; + eva_create_evaluation_detail_history_FeedDataToForm(result); + $("#eva_create_evaluation_detail_historyModel").modal("show"); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + eva_create_evaluation_detail_history_API + a, successFunc, AlertDanger); +} + +function eva_create_evaluation_detail_history_SetCreateForm(s) { + eva_create_evaluation_detail_history_editMode = "CREATE"; + eva_create_evaluation_detail_history_InitialForm(s); +} + +function eva_create_evaluation_detail_history_RefreshTable() { + // Incase model popup + eva_create_evaluation_detail_history_DoSearch(); + + // Incase open new page + //window.parent.eva_create_evaluation_detail_history_DoSearch(); +} + +//================= Update and Delete ========================================= + +var eva_create_evaluation_detail_history_customValidation = function (group) { + return ""; +}; + +function eva_create_evaluation_detail_history_PutUpdate() { + if (!ValidateForm('eva_create_evaluation_detail_history', eva_create_evaluation_detail_history_customValidation)) { + return; + } + + var data = eva_create_evaluation_detail_history_GetFromForm(); + + //Update Mode + if (eva_create_evaluation_detail_history_editMode === "UPDATE") { + var successFunc1 = function (result) { + $("#eva_create_evaluation_detail_historyModel").modal("hide"); + AlertSuccess(result.code + " " + result.message); + eva_create_evaluation_detail_history_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxPutRequest(apisite + eva_create_evaluation_detail_history_API + data.id, data, successFunc1, AlertDanger); + } + // Create mode + else { + var successFunc2 = function (result) { + $("#eva_create_evaluation_detail_historyModel").modal("hide"); + AlertSuccess(result.code + " " + result.message); + eva_create_evaluation_detail_history_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxPostRequest(apisite + eva_create_evaluation_detail_history_API, data, successFunc2, AlertDanger); + } +} + +function eva_create_evaluation_detail_history_GoDelete(a) { + if (confirm('คุณต้องการลบข้อมูล ใช่หรือไม่?')) { + var successFunc = function (result) { + $("#eva_create_evaluation_detail_historyModel").modal("hide"); + AlertSuccess(result.code + " " + result.message); + eva_create_evaluation_detail_history_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxDeleteRequest(apisite + eva_create_evaluation_detail_history_API + a, null, successFunc, AlertDanger); + } +} + +//================= Data Table ========================================= + +var eva_create_evaluation_detail_historyTableV; + +var eva_create_evaluation_detail_history_setupTable = function (result) { + tmp = '"'; + eva_create_evaluation_detail_historyTableV = $('#eva_create_evaluation_detail_historyTable').DataTable({ + "processing": true, + "serverSide": false, + "data": result, + //"select": { + // "style": 'multi' + //}, + "columns": [ + { "data": "txt_action_dt" }, + { "data": "action_detail" }, + { "data": "action_emp_id_external_employee_fullname" }, + ], + "columnDefs": [ + + ], + "language": { + "url": appsite + "/DataTables-1.10.16/thai.json" + }, + "paging": true, + "searching": false + }); + endLoad(); +}; + +function eva_create_evaluation_detail_history_InitiateDataTable() { + startLoad(); + var p = $.param(eva_create_evaluation_detail_history_GetSearchParameter()); + AjaxGetRequest(apisite + "/api/eva_create_evaluation_detail_history/GetListBySearch?" + p, eva_create_evaluation_detail_history_setupTable, AlertDanger); +} + +function eva_create_evaluation_detail_history_DoSearch() { + var p = $.param(eva_create_evaluation_detail_history_GetSearchParameter()); + var eva_create_evaluation_detail_history_reload = function (result) { + eva_create_evaluation_detail_historyTableV.destroy(); + eva_create_evaluation_detail_history_setupTable(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + "/api/eva_create_evaluation_detail_history/GetListBySearch?" + p, eva_create_evaluation_detail_history_reload, AlertDanger); +} + +function eva_create_evaluation_detail_history_GetSelect(f) { + var eva_create_evaluation_detail_history_selectitem = []; + $.each(eva_create_evaluation_detail_historyTableV.rows('.selected').data(), function (key, value) { + eva_create_evaluation_detail_history_selectitem.push(value[f]); + }); + alert(eva_create_evaluation_detail_history_selectitem); +} + +//================= File Upload ========================================= + + + +//================= Multi-Selection Function ========================================= + + +