Exemplo n.º 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)
        {
            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.GetListByState(workflowName, canDoStates.ToArray());

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

            return(instances);
        }
Exemplo n.º 2
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);
            }

            string unitCode = userIdentity.GetUserUnitCode();

            unitCode = string.IsNullOrEmpty(unitCode) ? "  " : (unitCode.Trim() + "%");
            instances.AddRange(WorkflowRuntime.Current.GetUnitList(workflowName, states.ToArray(), unitCode));
            foreach (StateMachineWorkflowInstance instance in instances)
            {
                if (instance.PersistTime >= startDate &&
                    instance.PersistTime <= endDate)
                {
                    collection.Add(new InstanceWithRole(instance, role, true));
                }
            }
            return(collection);
        }
Exemplo n.º 3
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>();
            List <ApprovalAssignment>           assignmentList = WorkflowRuntime.Current.GetService <IApprovalSaveService>().GetAssignmentByToUnit(workflowName, userIdentity.GetUserUnitCode());
            List <Guid> ids = new List <Guid>();

            foreach (ApprovalAssignment assignment in assignmentList)
            {
                if (!string.IsNullOrEmpty(assignment.ToUserId))
                {
                    continue;
                }
                if (!ids.Contains(assignment.WorkflowInstanceId))
                {
                    ids.Add(assignment.WorkflowInstanceId);
                }
            }
            foreach (Guid id in ids)
            {
                instances.Add((StateMachineWorkflowInstance)WorkflowRuntime.Current.GetInstance(id));
            }
            InstanceCollection collection = new InstanceCollection();

            foreach (StateMachineWorkflowInstance instance in instances)
            {
                if (InstanceDistillerHelper.IsAssignedICanDo(instance.CurrentState, role) &&
                    instance.PersistTime >= startDate &&
                    instance.PersistTime <= endDate)
                {
                    collection.Add(new InstanceWithRole(instance, role, false));
                }
            }
            return(collection);
        }
Exemplo n.º 4
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);
            }
            List <StateMachineWorkflowInstance> list = WorkflowRuntime.Current.GetListByState(workflowName, states.ToArray());

            instances.AddRange(list);

            foreach (StateMachineWorkflowInstance instance in instances)
            {
                if (instance.PersistTime >= startDate &&
                    instance.PersistTime <= endDate)
                {
                    collection.Add(new InstanceWithRole(instance, role, true));
                }
            }
            return(collection);
        }