예제 #1
0
        /// <summary>
        /// 撤销操作时进行的相关审批记录操作,如果要用不同的记录,必须重写该方法
        /// </summary>
        /// <param name="instance">The instance.</param>
        protected virtual void TrackUndo(WorkflowInstance instance)
        {
            ApprovalRecord       record          = new ApprovalRecord();
            IIdentityService     service         = WorkflowRuntime.Current.GetService <IIdentityService>();
            IApprovalSaveService approvalService = WorkflowRuntime.Current.GetService <IApprovalSaveService>();

            if (service == null)
            {
                throw new WorkflowExecuteExeception("身份信息提供服务为空");
            }
            IUserIdentity userInfo = service.GetUserIdentity();

            record.OperatorTime       = DateTime.Now;
            record.WorkflowInstanceId = instance.Id;
            record.OperatorId         = userInfo.GetUserId();
            record.OperatorName       = userInfo.GetUserName();
            record.OperatorUnitCode   = userInfo.GetUserUnitCode();
            record.OperatorRole       = this.UserApprovalRole;
            record.EaId = instance.EaId;

            StateMachineWorkflowInstance stateMachine = instance as StateMachineWorkflowInstance;

            record.ApprovalType = GetUndoName(instance);
            record.StateName    = stateMachine.CurrentState.Description;
            if (recordId != 0)
            {
                ApprovalRecord historyRecord = approvalService.GetRecordById(recordId);
                historyRecord.IsCanceled = true;
                approvalService.SaveRecord(historyRecord);
            }
            WorkflowRuntime.Current.GetService <IApprovalSaveService>().InsertRecord(record);
        }
예제 #2
0
        /// <summary>
        /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
        /// </summary>
        /// <param name="obj">An object to compare with this instance.</param>
        /// <returns>
        /// A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has these meanings:
        /// Value
        /// Meaning
        /// Less than zero
        /// This instance is less than <paramref name="obj"/>.
        /// Zero
        /// This instance is equal to <paramref name="obj"/>.
        /// Greater than zero
        /// This instance is greater than <paramref name="obj"/>.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">
        ///     <paramref name="obj"/> is not the same type as this instance.
        /// </exception>
        public virtual int CompareTo(object obj)
        {
            ApprovalRecord record = obj as ApprovalRecord;

            if (record == null)
            {
                return(-1);
            }
            return(record.approvalTime.CompareTo(this.approvalTime));
        }
예제 #3
0
        /// <summary>
        /// 在记录操作日志前,需要判断代办情况重新设置操作记录,如果是代办那么操作用户名设置为格式***(代***),
        /// 同时需要设置当前动作的UserId为当前真正执行改该动作的用户,以允许该执行者可以撤销操作,该方法允许被重载
        /// </summary>
        /// <param name="record">The record.</param>
        protected virtual void ResetRecordAndUserId(ApprovalRecord record)
        {
            IIdentityService service       = WorkflowRuntime.Current.GetService <IIdentityService>();
            IUserIdentity    userInfo      = service.GetUserIdentity();
            string           currentUserId = userInfo.GetUserId();

            if (currentUserId != userId)
            {
                IUserIdentity userIdentity = service.GetUserIdentity(userId);
                record.OperatorName     = userInfo.GetUserName() + "(代" + userIdentity.GetUserName() + ")";
                record.OperatorUnitCode = userIdentity.GetUserUnitCode();
                userId = currentUserId;
            }
        }
예제 #4
0
        /// <summary>
        /// 执行审批操作时进行的相关审批记录操作,如果要用不同的记录,必须重写该方法
        /// </summary>
        /// <param name="instance">The instance.</param>
        protected virtual void TrackExecute(WorkflowInstance instance)
        {
            ApprovalRecord   record  = new ApprovalRecord();
            IIdentityService service = WorkflowRuntime.Current.GetService <IIdentityService>();

            if (service == null)
            {
                throw new WorkflowExecuteExeception("身份信息提供服务为空");
            }
            IUserIdentity userInfo = service.GetUserIdentity();

            record.OperatorTime       = DateTime.Now;
            record.WorkflowInstanceId = instance.Id;
            string currentUserId = userInfo.GetUserId();

            record.OperatorId       = userId;
            record.OperatorName     = userInfo.GetUserName();
            record.OperatorUnitCode = userInfo.GetUserUnitCode();

            ResetRecordAndUserId(record);

            record.OperatorRole = this.UserApprovalRole;
            record.EaId         = instance.EaId;
            StateMachineWorkflowInstance stateMachine = instance as StateMachineWorkflowInstance;

            //如果没有定义活动的名称,那么从时间的描述中取出来
            if (string.IsNullOrEmpty(this.activityName))
            {
                this.activityName = stateMachine.CurrentState.GetEventByName(eventName).Description;
            }
            record.ApprovalType = this.ActivityName;
            record.StateName    = stateMachine.CurrentState.Description;
            record.SolutionInfo = solutionInfo;
            WorkflowRuntime.Current.GetService <IApprovalSaveService>().InsertRecord(record);
            this.recordId = record.Id;
        }