Пример #1
0
        /// <summary>
        /// 获取指定工作流、角色、时间段的实例集合
        /// </summary>
        /// <param name="workflowName">流程名称</param>
        /// <param name="userIdentity">用户身份</param>
        /// <param name="role">审批角色</param>
        /// <param name="startDate">时间段起始时间</param>
        /// <param name="endDate">时间段截止时间</param>
        /// <returns></returns>
        protected override InstanceCollection Distill(string workflowName, IUserIdentity userIdentity, ApprovalRole role, DateTime startDate, DateTime endDate)
        {
            string               userId    = userIdentity.GetUserId();
            string               unitCode  = IgnoreUnit ? "" : userIdentity.GetUserUnitCode();
            InstanceCollection   instances = new InstanceCollection();
            StateMachineWorkflow workflow  = (StateMachineWorkflow)WorkflowRuntime.Current.GetService <IWorkFlowDefinePersistService>().GetWorkflowDefine(workflowName);
            //遍历工作流中的每一个状态,获取可以处理的状态对应的实例.
            List <string> canDoStates = new List <string>();

            foreach (ApprovalState oneState in workflow.States)
            {
                if (oneState.IsApprovalState && InstanceDistillerHelper.IsMineICanDo(oneState, role))
                {
                    canDoStates.Add(oneState.Name);
                }
            }

            if (canDoStates.Count == 0)
            {
                return(instances);
            }
            List <StateMachineWorkflowInstance> list = WorkflowRuntime.Current.PersistService.GetWorkflowInstance(workflowName, canDoStates.ToArray(), userId, unitCode);

            //获取指定给本单位办理的实例
            foreach (StateMachineWorkflowInstance instance in list)
            {
                if (instance.PersistTime >= startDate &&
                    instance.PersistTime <= endDate)
                {
                    instances.Add(new InstanceWithRole(instance, role, true));
                }
            }

            return(instances);
        }
        /// <summary>
        /// 判断某用户是否能撤销实例的上一步操作
        /// </summary>
        /// <param name="instance">工作流实例</param>
        /// <returns></returns>
        public virtual bool CanCancel(WorkflowInstance instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            IUserIdentity userIdentity = WorkflowRuntime.Current.GetService <IIdentityService>().GetUserIdentity();
            StateMachineWorkflowInstance stateMachine = (StateMachineWorkflowInstance)WorkflowRuntime.Current.GetInstance(instance.Id);

            if (stateMachine == null)
            {
                return(false);
            }
            if (stateMachine.LastActivity == null)
            {
                return(false);
            }

            //逐个判断activity的执行用户,如果有一个和当前匹配,那么允许撤销
            string[] users       = stateMachine.LastActivity.UserId.Trim().Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string   currentUser = userIdentity.GetUserId().Trim();

            for (int i = 0; i < users.Length; i++)
            {
                if (users[i].Equals(currentUser, StringComparison.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
		/// <summary>
		/// 获取某流程的所有任务的名称
		/// </summary>
		/// <param name="workflowName">流程的名称</param>
		/// <returns></returns>
		public string[] GetTaskNames(string workflowName)
		{
			List<ApprovalRole> roles = WorkflowUtility.GetUserRoles(workflowName, userIdentity.GetUserId());
			List<string> taskNameList = new List<string>();
			foreach (ApprovalRole role in roles)
			{
				List<string> taskList = CreateProcess(workflowName, role).GetTaskNameList();
				foreach (string taskName in taskList)
				{
					if (!taskNameList.Contains(taskName))
						taskNameList.Add(taskName);
				}
			}
			taskNameList.Sort();
			return taskNameList.ToArray();
		}
Пример #4
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);
        }
Пример #5
0
 /// <summary>
 /// 根据工作流名称创建一个过程对象
 /// </summary>
 /// <param name="workflowName">工作流名称</param>
 /// <param name="rules">审批规则</param>
 /// <param name="userIdentity">用户省份</param>
 public ApprovalProcess(string workflowName, IApprovalRules rules, IUserIdentity userIdentity)
 {
     this.approvalService        = WorkflowRuntime.Current.GetService <IApprovalSaveService>();
     this.workflowPersistService = WorkflowRuntime.Current.GetService <IWorkflowPersistService>();
     this.workflow     = (StateMachineWorkflow)WorkflowRuntime.Current.GetService <IWorkFlowDefinePersistService>().GetWorkflowDefine(workflowName);
     this.rules        = rules;
     this.userIdentity = userIdentity;
     this.unitCode     = userIdentity.GetUserUnitCode();
     this.userId       = userIdentity.GetUserId();
 }
Пример #6
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;
            }
        }
        public bool validarUsuario()
        {
            var username = _userIdentity.GetUserId();
            var usuario  = _ctx.Usuarios.FirstOrDefault(x => x.UserName.Equals(username));

            if (usuario != null)
            {
                return(usuario.Administrador ?? false);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
        /// <summary>
        /// 判断指定实例是否需要满足过滤条件,满足则返回True,否则返回False
        /// </summary>
        /// <param name="instance">工作流实例</param>
        /// <param name="role">用户的审批角色</param>
        /// <param name="userIdentity">用户的身份</param>
        /// <returns>满足则返回True,否则返回False</returns>
        protected override bool IsMatch(StateMachineWorkflowInstance instance, ApprovalRole role, IUserIdentity userIdentity)
        {
            List <ApprovalRecord> records = WorkflowRuntime.Current.SaveService.GetRecord(instance.WorkflowName, instance.EaId);

            foreach (ApprovalRecord record in records)
            {
                if (record.OperatorId == userIdentity.GetUserId() &&
                    record.OperatorRole == role.Name)
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #9
0
        /// <summary>
        /// 获取指定工作流、角色、时间段的实例集合
        /// </summary>
        /// <param name="workflowName">流程名称</param>
        /// <param name="userIdentity">用户身份</param>
        /// <param name="role">审批角色</param>
        /// <param name="startDate">时间段起始时间</param>
        /// <param name="endDate">时间段截止时间</param>
        /// <returns></returns>
        protected override InstanceCollection Distill(string workflowName, IUserIdentity userIdentity, ApprovalRole role, DateTime startDate, DateTime endDate)
        {
            StateMachineWorkflow workflow = WorkflowRuntime.Current.GetService <IWorkFlowDefinePersistService>().GetWorkflowDefine(workflowName) as StateMachineWorkflow;
            string userId, unitCode, roleName;

            userId = unitCode = roleName = "";
            if (isMatchUser)
            {
                userId = userIdentity.GetUserId();
            }
            if (isMatchUnit)
            {
                unitCode = userIdentity.GetUserUnitCode();
            }
            if (isMatchRole)
            {
                roleName = role.Name;
            }
            List <ApprovalRecord> records = WorkflowRuntime.Current.GetService <IApprovalSaveService>().GetRecord(workflowName, startDate, endDate, userId, unitCode, roleName);
            List <Guid>           ids     = new List <Guid>();

            foreach (ApprovalRecord record in records)
            {
                if (!ids.Contains(record.WorkflowInstanceId))
                {
                    ids.Add(record.WorkflowInstanceId);
                }
            }
            List <StateMachineWorkflowInstance> instances = new List <StateMachineWorkflowInstance>();

            foreach (Guid id in ids)
            {
                instances.Add((StateMachineWorkflowInstance)WorkflowRuntime.Current.GetInstance(id));
            }
            InstanceCollection collection = new InstanceCollection();

            foreach (StateMachineWorkflowInstance instance in instances)
            {
                collection.Add(new InstanceWithRole(instance, role, false));
            }
            return(collection);
        }
Пример #10
0
        /// <summary>
        /// 获取角色和对应实例集合的键-值对
        /// </summary>
        /// <param name="workflowName">流程名称</param>
        /// <param name="userId">用户Id</param>
        /// <param name="roleName">角色名称</param>
        /// <param name="startDate">时间段起始时间</param>
        /// <param name="endDate">时间段截止时间</param>
        /// <returns></returns>
        private InstanceCollection DistillInstances(string workflowName, string userId, string roleName, DateTime startDate, DateTime endDate)
        {
            IUserIdentity userIdentity = identityService.GetUserIdentity(userId);
            //获取流程对应的审批角色对象,并从角色-提取者字典中获取角色对应的提取者
            InstanceCollection instances = new InstanceCollection();
            ApprovalRole       role      = WorkflowUtility.GetUserRoleByName(workflowName, roleName);

            if (role != null)
            {
                //用户不在该角色
                if (!userInRole.IsUserInRole(userIdentity.GetUserId(), role.Name))
                {
                    throw new ApplicationException(string.Format("{0} is not in role {1}", userIdentity.GetUserId(), role.Name));
                }
                //取得角色的任务提取器
                TaskDistiller distiller = GetRoleDistiller(roleName);
                instances.AddRange(distiller.Distill(workflowName, userIdentity, role, startDate, endDate));
            }
            return(instances);
        }
Пример #11
0
        /// <summary>
        /// 从任务类表中除去已经指派给他人专办的项目
        /// </summary>
        /// <param name="instanceList">The instance list.</param>
        protected virtual void RemoveAssignedInstance(List <StateMachineWorkflowInstance> instanceList)
        {
            //去除已指定他人专办的实例
            for (int i = instanceList.Count - 1; i >= 0; i--)
            {
                StateMachineWorkflowInstance instance       = instanceList[i];
                List <ApprovalAssignment>    assignmentList = approvalService.GetAssignmentByAssignToRole(this.workflow.Name, rules.UserRole.Name, instance.Id, instance.StateName);

                //是否已指定同角色中他人专办标识
                bool isAssignedToCurrentUser = true;
                if (assignmentList.Count > 0)
                {
                    foreach (ApprovalAssignment assignment in assignmentList)
                    {
                        if (assignment.ToUserId != null)
                        {
                            if (assignment.ToUserId.ToLower() == userIdentity.GetUserId().ToLower())
                            {
                                isAssignedToCurrentUser = true;
                                break;
                            }
                            //如果遍历所有委派列表没有当前用互的记录,则该任务未指定当前用户
                            else
                            {
                                isAssignedToCurrentUser = false;
                            }
                        }
                    }
                }
                //无指定记录则某认指定了所有人
                else
                {
                    isAssignedToCurrentUser = true;
                }
                //已指定专办标识为假,从List中除去该实例
                if (!isAssignedToCurrentUser)
                {
                    instanceList.Remove(instance);
                }
            }
        }
Пример #12
0
        private static bool IsOthers(IUserIdentity userIdentity, List <ApprovalAssignment> assignmentList)
        {
            //是否已指定同角色中他人专办标识
            bool assignToOther = false;

            foreach (ApprovalAssignment assignment in assignmentList)
            {
                if (assignment.ToUserId != null)
                {
                    if (assignment.ToUserId.ToLower() == userIdentity.GetUserId().ToLower())
                    {
                        return(false);
                    }
                    else
                    {
                        assignToOther = true;
                    }
                }
            }
            return(assignToOther);
        }
Пример #13
0
        /// <summary>
        /// 判断指定实例是否需要满足过滤条件,满足则返回True,否则返回False
        /// </summary>
        /// <param name="instance">工作流实例</param>
        /// <param name="role">用户的审批角色</param>
        /// <param name="userIdentity">用户的身份</param>
        /// <returns>满足则返回True,否则返回False</returns>
        protected override bool IsMatch(StateMachineWorkflowInstance instance, ApprovalRole role, IUserIdentity userIdentity)
        {
            //最后一个Activity的执行者是否为当前用户如果是返回false
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            StateMachineWorkflowInstance stateMachine = (StateMachineWorkflowInstance)WorkflowRuntime.Current.GetInstance(instance.Id);

            //最后一个activity为空 返回true
            if (stateMachine.LastActivity == null)
            {
                return(true);
            }
            //最后一个activity执行者与用户身份和角色匹配,返回false
            if (string.Equals(stateMachine.LastActivity.UserId.Trim(), userIdentity.GetUserId().Trim(), StringComparison.OrdinalIgnoreCase) &&
                string.Equals(stateMachine.LastActivity.UserApprovalRole, role.Name))
            {
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// 判断某用户是否具有对指定实例进行指定动作的执行权限
        /// </summary>
        /// <param name="instance">工作流实例</param>
        /// <param name="actionName">执行动作</param>
        /// <returns></returns>
        public virtual bool CanDoAction(WorkflowInstance instance, string actionName)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (string.IsNullOrEmpty(actionName))
            {
                throw new ArgumentNullException("actionName");
            }
            IUserInRole   userInRole   = WorkflowRuntime.Current.GetService <IIdentityService>().GetUserInRole();
            IUserIdentity userIdentity = WorkflowRuntime.Current.GetService <IIdentityService>().GetUserIdentity();

            if (GetActionRole(instance, userIdentity.GetUserId(), actionName) != null)
            {
                return(true);
            }
            ApprovalEvent        approvalEvent   = ((StateMachineWorkflowInstance)instance).CurrentState.GetEventByName(actionName);
            IApprovalSaveService approvalService = WorkflowRuntime.Current.GetService <IApprovalSaveService>();
            List <ApprovalAgent> agentList       = approvalService.GetValidAgentInfoByToUser(userIdentity.GetUserId());

            if (agentList != null && agentList.Count > 0)
            {
                foreach (ApprovalAgent agentInfo in agentList)
                {
                    foreach (EventRole role in approvalEvent.Roles)
                    {
                        if (IsAuthorized(agentInfo.SetUserId, approvalEvent, instance))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Пример #15
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;
        }
Пример #16
0
        /// <summary>
        /// 获取指定工作流、角色、时间段的实例集合
        /// </summary>
        /// <param name="workflowName">流程名称</param>
        /// <param name="userIdentity">用户身份</param>
        /// <param name="role">审批角色</param>
        /// <param name="startDate">时间段起始时间</param>
        /// <param name="endDate">时间段截止时间</param>
        /// <returns></returns>
        protected override InstanceCollection Distill(string workflowName, IUserIdentity userIdentity, ApprovalRole role, DateTime startDate, DateTime endDate)
        {
            List <StateMachineWorkflowInstance> instances = new List <StateMachineWorkflowInstance>();
            string userName   = "";
            string fromUserId = "";
            //找到代理条目给获取授权人Id和授权人姓名
            List <ApprovalAgent> agentList = WorkflowRuntime.Current.GetService <IApprovalSaveService>().GetAgentInfoByToUser(userIdentity.GetUserId());

            foreach (ApprovalAgent agent in agentList)
            {
                if (agent.BeginDate == startDate && agent.EndDate == endDate)
                {
                    userName   = string.Format("{0}(代{1})", agent.ToUserName, agent.SetUserName);
                    fromUserId = agent.SetUserId;
                }
            }
            //获取用户时间段内的审批记录,找到符合代理信息的记录,获取相应的实例
            StateMachineWorkflow  workflow = WorkflowRuntime.Current.GetService <IWorkFlowDefinePersistService>().GetWorkflowDefine(workflowName) as StateMachineWorkflow;
            List <ApprovalRecord> records  = WorkflowRuntime.Current.GetService <IApprovalSaveService>().GetRecord(workflowName, startDate, endDate, fromUserId);
            List <Guid>           ids      = new List <Guid>();

            foreach (ApprovalRecord record in records)
            {
                if (record.OperatorName == userName)
                {
                    ids.Add(record.WorkflowInstanceId);
                }
            }
            instances = new List <StateMachineWorkflowInstance>();
            foreach (Guid id in ids)
            {
                instances.Add((StateMachineWorkflowInstance)WorkflowRuntime.Current.GetInstance(id));
            }
            InstanceCollection collection = new InstanceCollection();

            foreach (StateMachineWorkflowInstance instance in instances)
            {
                if (instance.WorkflowName == workflowName)
                {
                    collection.Add(new InstanceWithRole(instance, role, false));
                }
            }
            return(collection);
        }
Пример #17
0
        /// <summary>
        /// 获取指定工作流、角色、时间段的实例集合
        /// </summary>
        /// <param name="workflowName">流程名称</param>
        /// <param name="userIdentity">用户身份</param>
        /// <param name="role">审批角色</param>
        /// <param name="startDate">时间段起始时间</param>
        /// <param name="endDate">时间段截止时间</param>
        /// <returns></returns>
        protected override InstanceCollection Distill(string workflowName, IUserIdentity userIdentity, ApprovalRole role, DateTime startDate, DateTime endDate)
        {
            List <StateMachineWorkflowInstance> instances = new List <StateMachineWorkflowInstance>();
            StateMachineWorkflow workflow  = (StateMachineWorkflow)WorkflowRuntime.Current.GetService <IWorkFlowDefinePersistService>().GetWorkflowDefine(workflowName);
            List <string>        allStates = new List <string>();

            foreach (ApprovalState state in workflow.States)
            {
                if (state.IsApprovalState && !state.Name.Equals(workflow.InitState))
                {
                    allStates.Add(state.Name);
                }
            }
            if (allStates.Count == 0)
            {
                return(new InstanceCollection());
            }

            instances.AddRange(WorkflowRuntime.Current.GetOwnerList(workflowName, allStates.ToArray(), userIdentity.GetUserId(), userIdentity.GetUserUnitCode()));
            InstanceCollection collection = new InstanceCollection();

            foreach (StateMachineWorkflowInstance one in instances)
            {
                InstanceWithRole o = new InstanceWithRole(one, role, true);
                o.TaskName = "a." + one.CurrentState.Description;
                collection.Add(o);
            }
            return(collection);
        }
Пример #18
0
        /// <summary>
        /// 获取指定工作流、角色、时间段的实例集合
        /// </summary>
        /// <param name="workflowName">流程名称</param>
        /// <param name="userIdentity">用户身份</param>
        /// <param name="role">审批角色</param>
        /// <param name="startDate">时间段起始时间</param>
        /// <param name="endDate">时间段截止时间</param>
        /// <returns></returns>
        protected override InstanceCollection Distill(string workflowName, IUserIdentity userIdentity, ApprovalRole role, DateTime startDate, DateTime endDate)
        {
            InstanceCollection collection = new InstanceCollection();
            List <StateMachineWorkflowInstance> instances = new List <StateMachineWorkflowInstance>();
            List <string> states = InstanceDistillerHelper.GetMineICanCancelStates(workflowName, role);

            if (states.Count == 0)
            {
                return(collection);
            }
            instances.AddRange(WorkflowRuntime.Current.GetOwnerList(workflowName, states.ToArray(), userIdentity.GetUserId(), userIdentity.GetUserUnitCode()));


            foreach (StateMachineWorkflowInstance instance in instances)
            {
                if (instance.PersistTime >= startDate &&
                    instance.PersistTime <= endDate)
                {
                    collection.Add(new InstanceWithRole(instance, role, true));
                }
            }
            return(collection);
        }
Пример #19
0
        /// <summary>
        /// 获取实例的操作项目集合,方法是从工作流配置xml文件中定义的操作(动作),如果是作为工具条形式提取,那么自动<see cref="GetToolbarAddtionActionItems"/>方法,附加额外的自定义项目.
        /// </summary>
        /// <param name="instance">某实例</param>
        /// <param name="isTooBar">if set to <c>true</c> 工具条形式提取.</param>
        /// <returns></returns>
        public List <ITaskActionItem> GetInstanceActionItems(StateMachineWorkflowInstance instance, bool isTooBar)
        {
            List <ITaskActionItem> items = new List <ITaskActionItem>();
            List <ApprovalRole>    roles = WorkflowUtility.GetUserRoles(instance.WorkflowName, userIdentity.GetUserId());

            //如是任务栏,则先添加任务栏相关的动作项目
            if (isTooBar)
            {
                items.AddRange(GetToolbarAddtionActionItems(instance));
            }
            //遍历当前用户所有角色,添加每个角色对应的动作项目
            foreach (ApprovalRole role in roles)
            {
                items.AddRange(GetInstanceActionItems(instance, role));
            }
            return(items);
        }
Пример #20
0
 /// <summary>
 /// 判断指定实例是否需要满足过滤条件,满足则返回True,否则返回False
 /// </summary>
 /// <param name="instance">工作流实例</param>
 /// <param name="role">用户的审批角色</param>
 /// <param name="userIdentity">用户的身份</param>
 /// <returns>满足则返回True,否则返回False</returns>
 protected override bool IsMatch(StateMachineWorkflowInstance instance, ApprovalRole role, IUserIdentity userIdentity)
 {
     return(WorkflowRuntime.Current.GetService <IWorkflowSecurityService>().IsMyTaskInstance(instance, userIdentity.GetUserId()));
 }