public static string GetOperationLog(this XiuJiaDTO entity, XiuJiaDTO oldDTO = null)
        {
            var sb = new StringBuilder();

            if (oldDTO == null)
            {
                sb.AppendLine(string.Format("{0}: {1}", "员工编号", entity.UserId));
                sb.AppendLine(string.Format("{0}: {1}", "姓名", entity.Name));
                sb.AppendLine(string.Format("{0}: {1}", "部门", entity.Department));
                sb.AppendLine(string.Format("{0}: {1}", "职位", entity.Position));
                sb.AppendLine(string.Format("{0}: {1}", "填写时间", entity.InputTime));
                sb.AppendLine(string.Format("{0}: {1}", "休假起始时间", entity.ActionStartTime));
                sb.AppendLine(string.Format("{0}: {1}", "休假结束时间", entity.ActionEndTime));
                sb.AppendLine(string.Format("{0}: {1}", "休假类型", entity.Type));
                sb.AppendLine(string.Format("{0}: {1}", "请假原因", entity.Reason));
                sb.AppendLine(string.Format("{0}: {1}", "休假天数", entity.ActionDays));
                sb.AppendLine(string.Format("{0}: {1}", "休假小时数", entity.ActionHours));
                sb.AppendLine(string.Format("{0}: {1}", "状态", entity.Status));
            }
            else
            {
                if (entity.DepartmentSupervisorOpinion != oldDTO.DepartmentSupervisorOpinion)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "部门主管意见", oldDTO.DepartmentSupervisorOpinion, entity.DepartmentSupervisorOpinion));
                }
                if (entity.DepartmentSupervisorOpinionApproverId != oldDTO.DepartmentSupervisorOpinionApproverId)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "部门主管意见审批人", oldDTO.DepartmentSupervisorOpinionApproverId, entity.DepartmentSupervisorOpinionApproverId));
                }
                if (entity.DepartmentManagerOpinion != oldDTO.DepartmentManagerOpinion)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "部门经理意见", oldDTO.DepartmentManagerOpinion, entity.DepartmentManagerOpinion));
                }
                if (entity.DepartmentManagerOpinionApproverId != oldDTO.DepartmentManagerOpinionApproverId)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "部门经理意见审批人", oldDTO.DepartmentManagerOpinionApproverId, entity.DepartmentManagerOpinionApproverId));
                }
                if (entity.CompanyLeaderOpinion != oldDTO.CompanyLeaderOpinion)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "公司领导意见", oldDTO.CompanyLeaderOpinion, entity.CompanyLeaderOpinion));
                }
                if (entity.CompanyLeaderOpinionApproverId != oldDTO.CompanyLeaderOpinionApproverId)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "公司领导意见审批人", oldDTO.CompanyLeaderOpinionApproverId, entity.CompanyLeaderOpinionApproverId));
                }
                if (entity.Status != oldDTO.Status)
                {
                    sb.AppendLine(string.Format("{0}: {1} => {2}",
                                                "状态", oldDTO.Status, entity.Status));
                }
            }

            return(sb.ToString().TrimEnd('\r', '\n'));
        }
コード例 #2
0
        public XiuJiaDTO Add(XiuJiaDTO itemDto, UserDTO operatorDTO = null)
        {
            var model = itemDto.ToModel();

            model.Id        = IdentityGenerator.NewSequentialGuid();
            model.Created   = DateTime.UtcNow;
            model.Canceled  = SqlDateTime.MinValue.Value;
            model.Approved  = SqlDateTime.MinValue.Value;
            model.InputTime = DateTime.Today;

            model.ActionStartTime = model.ActionStartTime.ToUniversalTime();
            model.ActionEndTime   = model.ActionEndTime.ToUniversalTime();

            // 数据验证
            this.ValidateModel(model);

            model.Status = KaoQinStatusDTO.Submited.ToString();;

            _Repository.Add(model);

            this.OperationLog(KaoQinMessagesResources.Add_XiuJia, model.ToDto(), null, operatorDTO);

            //commit the unit of work
            _Repository.UnitOfWork.Commit();

            return(model.ToDto());
        }
コード例 #3
0
        public void Approve(XiuJiaDTO itemDto, UserDTO operatorDTO = null)
        {
            //get persisted item
            var persistedModel = _Repository.Get(itemDto.Id);

            if (persistedModel == null)
            {
                throw new DataNotFoundException(KaoQinMessagesResources.XiuJia_NotExists);
            }

            if (persistedModel.Status == KaoQinStatusDTO.Canceled.ToString())
            {
                throw new DataNotFoundException(KaoQinMessagesResources.Canceled_CanNot_Approved);
            }

            if (itemDto.DepartmentSupervisorOpinion.IsNullOrBlank() &&
                itemDto.DepartmentManagerOpinion.IsNullOrBlank() &&
                itemDto.CompanyLeaderOpinion.IsNullOrBlank())
            {
                throw new DataNotFoundException(KaoQinMessagesResources.Approve_Opinion_Empty);
            }

            if (persistedModel.DepartmentSupervisorOpinion != itemDto.DepartmentSupervisorOpinion)
            {
                UpdateDepartmentOpinion(persistedModel, itemDto, operatorDTO);
            }
            if (persistedModel.DepartmentManagerOpinion != itemDto.DepartmentManagerOpinion)
            {
                UpdateGeneralManagerOfficeOpinion(persistedModel, itemDto, operatorDTO);
            }
            if (persistedModel.CompanyLeaderOpinion != itemDto.CompanyLeaderOpinion)
            {
                UpdateCompanyLeaderOpinion(persistedModel, itemDto, operatorDTO);
            }
        }
コード例 #4
0
        public ActionResult Apply(XiuJiaDTO item)
        {
            return(HttpHandleExtensions.AjaxCallGetResult(() =>
            {
                var department = GetCurrentMemberDepartment();
                item.UserId = CurrentMember.Userid;
                item.Name = CurrentMember.Name;
                item.Position = CurrentMember.Position;
                item.DepartmentId = department.DepartmentId;
                item.Department = department.Name;
                _xiuJiaService.Add(item, GetCurrentOperator());
                this.JsMessage = MessagesResources.Add_Success;

                return Json(new AjaxResponse
                {
                    Succeeded = true,
                    RedirectUrl = Url.Action("Index")
                });
            }));
        }
コード例 #5
0
        public ActionResult Approve(XiuJiaDTO item)
        {
            return(HttpHandleExtensions.AjaxCallGetResult(() =>
            {
                if (!IsWeiXinManager())
                {
                    throw new DefinedException(NotWeiXinManagerMessage);
                }

                item.DepartmentSupervisorOpinionApproverId = CurrentMember.Userid;
                item.DepartmentManagerOpinionApproverId = CurrentMember.Userid;
                item.CompanyLeaderOpinionApproverId = CurrentMember.Userid;
                _xiuJiaService.Approve(item, GetCurrentOperator());

                this.JsMessage = MessagesResources.Approve_Success;
                return Json(new AjaxResponse
                {
                    Succeeded = true,
                    RedirectUrl = Url.Action("Approved")
                }, JsonRequestBehavior.AllowGet);
            }));
        }
コード例 #6
0
        private void UpdateCompanyLeaderOpinion(XiuJia persistedModel, XiuJiaDTO itemDto, UserDTO operatorDTO = null)
        {
            var oldDTO = persistedModel.ToDto();

            // 可以修改的字段
            var current = oldDTO.ToModel();

            current.CompanyLeaderOpinion           = itemDto.CompanyLeaderOpinion;
            current.CompanyLeaderOpinionApproverId = itemDto.CompanyLeaderOpinionApproverId;

            if (persistedModel.Status == KaoQinStatusDTO.Submited.ToString())
            {
                current.Status   = KaoQinStatusDTO.Approved.ToString();
                current.Approved = DateTime.UtcNow;
            }

            this.OperationLog(KaoQinMessagesResources.Update_XiuJia, current.ToDto(), oldDTO, operatorDTO);

            //Merge changes
            _Repository.Merge(persistedModel, current);
            //commit unit of work
            _Repository.UnitOfWork.Commit();
        }
コード例 #7
0
 public static XiuJia ToModel(this XiuJiaDTO dto)
 {
     return(Mapper.Map <XiuJia>(dto));
 }
コード例 #8
0
 /***********
  * 微信用户操作时,不能通过cookies找到登陆用户,因此,在表现层传当前的微信用户进来作为操作者
  *************/
 private void OperationLog(string action, XiuJiaDTO itemDto, XiuJiaDTO oldDto = null, UserDTO operatorDTO = null)
 {
     OperateRecorder.RecordOperation(itemDto.Id.ToString(), action,
                                     itemDto.GetOperationLog(oldDto), operatorDTO);
 }