예제 #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)
        {
            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());
            }

            string unitCode = userIdentity.GetUserUnitCode();

            unitCode = string.IsNullOrEmpty(unitCode) ? "  " : (unitCode.Trim() + "%");
            instances.AddRange(WorkflowRuntime.Current.GetUnitList(workflowName, allStates.ToArray(), unitCode));

            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);
        }
예제 #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)
        {
            List <StateMachineWorkflowInstance> instances = new List <StateMachineWorkflowInstance>();
            StateMachineWorkflow     workflow             = (StateMachineWorkflow)WorkflowRuntime.Current.GetService <IWorkFlowDefinePersistService>().GetWorkflowDefine(workflowName);
            Dictionary <string, int> stateIndex           = new Dictionary <string, int>();
            List <string>            allStates            = new List <string>();

            for (int i = 0; i < workflow.States.Length; i++)
            {
                ApprovalState state = workflow.States[i];
                if (state.IsApprovalState && !state.Name.Equals(workflow.InitState))
                {
                    stateIndex.Add(state.Name, i);
                    allStates.Add(state.Name);
                }
            }
            if (allStates.Count == 0)
            {
                return(new InstanceCollection());
            }

            instances.AddRange(WorkflowRuntime.Current.GetListByState(workflowName, allStates.ToArray()));
            InstanceCollection collection = new InstanceCollection();

            foreach (StateMachineWorkflowInstance one in instances)
            {
                InstanceWithRole o = new InstanceWithRole(one, role, true);
                o.TaskName = ((char)((int)'a' + stateIndex[one.CurrentState.Name])) + "." + one.CurrentState.Description;
                collection.Add(o);
            }
            return(collection);
        }
예제 #3
0
        private List <ApprovalAssignment> GetAssignment(InstanceWithRole instance, List <ApprovalAssignment> assignmentList)
        {
            List <ApprovalAssignment> rtn = new List <ApprovalAssignment>();

            foreach (ApprovalAssignment one in assignmentList)
            {
                if (one.WorkflowInstanceId.Equals(instance.Instance.Id))
                {
                    rtn.Add(one);
                }
            }
            return(rtn);
        }
        /// <summary>
        /// 设置任务项目的相关属性值
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="taskItem">工作项目</param>
        /// <param name="userIdentity">The user identity.</param>
        public virtual void FillItemProperty(InstanceCollection collection, ITaskItem taskItem, IUserIdentity userIdentity)
        {
            if (collection == null || collection.Count == 0)
            {
                throw new ArgumentException("实例集合不能为空", "collection");
            }
            taskItem.EaId = collection[0].Instance.EaId;
            InstanceWithRole instance = GetInstance(collection);

            taskItem.InstanceId  = instance.Instance.Id;
            taskItem.PersistTime = instance.Instance.PersistTime;
            taskItem.ExceedTime  = instance.ExceedTime;
        }