Ejemplo n.º 1
0
        /// <summary>
        /// 修改请假单
        /// </summary>
        protected override void ExcuteSelf()
        {
            try
            {
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (_OldLeaveRequest.IfAutoCancel)
                    {
                        AutoCancelLeaveRequest();
                    }
                    if (_IfSubmit)
                    {
                        foreach (LeaveRequestItem item in _LeaveRequest.LeaveRequestItems)
                        {
                            item.Status = RequestStatus.Submit;
                        }
                        DiyStep currentStep = _LeaveRequest.DiyProcess.FindFirstStep();
                        DiyStep nextStep    = _LeaveRequest.DiyProcess.FindSecondStep();
                        _DalLeaveRequest.UpdateLeaveRequest(_LeaveRequest, nextStep.DiyStepID);
                        _LeaveRequest = _DalLeaveRequest.GetLeaveRequestByPKID(_LeaveRequest.PKID);
                        foreach (LeaveRequestItem item in _LeaveRequest.LeaveRequestItems)
                        {
                            _DalLeaveRequestFlow.InsertLeaveRequestFlow(PrepareLeaveRequestFlow(item));
                        }

                        new LeaveRequestMailAndPhoneDelegate().SubmitOperation(_LeaveRequest.PKID, _LeaveRequest.MailCC ?? new List <Account>(),
                                                                               currentStep.MailAccount, nextStep);
                    }
                    else
                    {
                        foreach (LeaveRequestItem item in _LeaveRequest.LeaveRequestItems)
                        {
                            item.Status = RequestStatus.New;
                        }
                        DiyStep nextStep = _LeaveRequest.DiyProcess.FindFirstStep();
                        _DalLeaveRequest.UpdateLeaveRequest(_LeaveRequest, nextStep.DiyStepID);
                    }
                    ts.Complete();
                }
            }
            catch
            {
                HrmisUtility.ThrowException(HrmisUtility._DbError);
            }
        }