เพิ่มประวัติ การดำเนินกิจกรรมการประเมิน
This commit is contained in:
@@ -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 ("<br/><a href='javascript:window_open({0}../eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history?id=" + id.ToString() + "{0});'>ดูประวัติ</a>").Replace("{0}", '"'.ToString());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ("<br/><a href='javascript:window_open({0}../eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history?id=" + id.ToString() + "{0});'>ดูประวัติ</a>").Replace("{0}", '"'.ToString());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private string getStatusText(string s)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(s))
|
||||
|
||||
@@ -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<int, eva_create_evaluation_detail_historyInputModel, eva_create_evaluation_detail_historyViewModel>
|
||||
{
|
||||
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<eva_create_evaluation_detail_historyViewModel> GetListByevaluation_detail_id(int? evaluation_detail_id);
|
||||
List<eva_create_evaluation_detail_historyViewModel> GetListBySearch(eva_create_evaluation_detail_historySearchModel model);
|
||||
|
||||
string UpdateMultiple(List<eva_create_evaluation_detail_historyInputModel> 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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<int>
|
||||
{
|
||||
|
||||
|
||||
[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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<eva_create_evaluation_detail_historyEntity, int> _repository;
|
||||
private IMyDatabase db;
|
||||
private Iexternal_linkageService ext;
|
||||
private Iexternal_employeeService emp;
|
||||
|
||||
public eva_create_evaluation_detail_historyService(IBaseRepository2<eva_create_evaluation_detail_historyEntity, int> 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<eva_create_evaluation_detail_historyEntity>(model);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_historyEntity> GetEntityList(List<eva_create_evaluation_detail_historyInputModel> models)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_historyEntity>>(models);
|
||||
}
|
||||
private eva_create_evaluation_detail_historyViewModel GetDto(eva_create_evaluation_detail_historyEntity entity)
|
||||
{
|
||||
return Mapper.Map<eva_create_evaluation_detail_historyViewModel>(entity);
|
||||
}
|
||||
private List<eva_create_evaluation_detail_historyViewModel> GetDtoList(List<eva_create_evaluation_detail_historyEntity> entities)
|
||||
{
|
||||
return Mapper.Map<List<eva_create_evaluation_detail_historyViewModel>>(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<eva_create_evaluation_detail_historyWithSelectionViewModel>(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<eva_create_evaluation_detail_historyViewModel> 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<eva_create_evaluation_detail_historyViewModel> 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<eva_create_evaluation_detail_historyViewModel>(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<eva_create_evaluation_detail_historyViewModel>(existingEntity);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new NotificationException("No data to update");
|
||||
}
|
||||
|
||||
public string UpdateMultiple(List<eva_create_evaluation_detail_historyInputModel> 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<string,string> GetLookupForLog()
|
||||
{
|
||||
var i = new Dictionary<string, string>();
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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<int>
|
||||
{
|
||||
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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<external_employeeViewModel> item_action_emp_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 ("<br/><a href='javascript:window_open({0}../eva_create_evaluation_detail_historyView/eva_create_evaluation_detail_history?id=" + id.ToString() + "{0});'>ดูประวัติ</a>").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); } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<eva_create_evaluation_detailEntity, int> 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)
|
||||
|
||||
Reference in New Issue
Block a user