Beispiel #1
0
 private void DealServerNodeLoop(Flow flow, FlowNode targetFlowNode, MessageContainer messageContainer)
 {
     var nodes = new Stack<FlowNodeInstance>();
     var node = DealServerNode(flow, targetFlowNode, messageContainer);
     if (node == null)
     {
         Finished(flow);
         return;
     }
     nodes.Push(node);
     while (nodes.Any())
     {
         //这里循环处理,主要是为了使服务器节点无延迟的即时处理,因为服务器节点仅依赖流程变量与客户无关
         //而客户节点肯定是依赖于客户的操作来处理
         var tempFlowNodeInstance = nodes.Pop();
         if (!tempFlowNodeInstance.BelongsFlowNode.IsServerNode)
         {
             DealClientNode(flow, tempFlowNodeInstance.GetNextNodeTypeWhenActioned(), messageContainer);
             return;
         }
         var returnNodeInstanace = DealServerNode(flow, tempFlowNodeInstance.GetNextNodeTypeWhenActioned(), messageContainer);
         //服务端与客户端的区别,服务端的处理完之后就已经Finished了,所以直接接着处理下一个节点,
         //如果是客户端则需要生成客户端任务,服务端则继续执行服务端的处理
         if (returnNodeInstanace == null)
         {
             Finished(flow);
             return;
         }
         nodes.Push(returnNodeInstanace);
     }
 }
Beispiel #2
0
 private FlowNodeInstance DealClientNode(Flow flow, FlowNode targetFlowNode, MessageContainer messageContainer)
 {
     //创建新节点实例
     var newFlowInstance = new FlowNodeInstance();
     newFlowInstance.BelongsFlow = flow;
     newFlowInstance.BelongsFlowNode = targetFlowNode;
     var newTasks = newFlowInstance.BuilderTasksAndReturnNewTasks();
     _flowNodeInstanceRepository.Save(newFlowInstance);
     newTasks.ToList().ForEach(task => _flowNodeInstanceTaskRepository.Save(task));
     return newFlowInstance;
 }
Beispiel #3
0
 private FlowNodeInstance DealServerNode(Flow flow, FlowNode targetFlowNode, MessageContainer messageContainer)
 {
     if (targetFlowNode == null)
         return null;
     //生成服务端节点实例
     var newFlowInstanceOfServer = new FlowNodeInstance();
     newFlowInstanceOfServer.BelongsFlow = flow;
     newFlowInstanceOfServer.BelongsFlowNode = targetFlowNode;
     newFlowInstanceOfServer.TimeOfFinished = DateTime.Now;
     newFlowInstanceOfServer.Execute();
     newFlowInstanceOfServer.InstanceStatus = InstanceStatus.Finished;
     _flowNodeInstanceRepository.Save(newFlowInstanceOfServer);
     return newFlowInstanceOfServer;
 }
        public void TestDefineFlow()
        {
            var trans = TransactionManager.BeginTransaction();
            var flowType = new FlowType();
            flowType.Name = "ProposalFlow";
            //添加流程变量声明
            flowType.FlowTypeDataFields.Add(new FlowTypeDataField() { Name = "Auditor" });
            FlowTypeRepository.Save(flowType);

            //第一个节点
            var firstNode = new FlowNode()
            {
                Name = "人大常委会审核",
                ExecutorType = FlowValueType.ByDataField,
                ExecutorValue = "NpcAuditor",
                IsExecutorWithArray = true,
                IsFirstNode = true,
                ProcessUrl = "/Proposals/ScNpcAudit"
            };

            //第一个节点的Actions
            firstNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "提交市政办" });
            firstNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "不提交" });
            //第二个节点
            var secordNode = new FlowNode()
            {
                Name = "市政办审核",
                ExecutorType = FlowValueType.ByDataField,
                ExecutorValue = "GovAuditor",
                IsExecutorWithArray = true,
                ProcessUrl = "/Proposals/GovOfficeAudit"
            };

            secordNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "提交主办单位" });
            secordNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "退回人大常委" });

            //第三个节点
            var thirdNode = new FlowNode()
            {
                Name = "主办单位处理",
                ExecutorType = FlowValueType.ByDataField,
                ExecutorValue = "Sponsor",
                IsExecutorWithArray = true,
                ProcessUrl = "/Proposals/SponsorAudit"
            };

            thirdNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "办结" });
            thirdNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "退回市政办" });

            //第四个节点
            var fourthNode = new FlowNode()
            {
                Name = "代表满意度回馈",
                ExecutorType = FlowValueType.ByDataField,
                ExecutorValue = "Originator",
                IsExecutorWithArray = true,
                ProcessUrl = "/Proposals/NpcAssessment"
            };

            fourthNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "不满意" });
            fourthNode.FlowNodeActions.Add(new FlowNodeAction() { Name = "满意" });

            //添加流程分支
            firstNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "提交", Name = "提交", ContactTo = secordNode });
            firstNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "不提交", Name = "不提交", ContactTo = null });

            secordNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "提交主办单位", Name = "提交主办单位", ContactTo = thirdNode });
            secordNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "退回人大常委", Name = "退回人大常委", ContactTo = firstNode });

            thirdNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "办结", Name = "办结", ContactTo = fourthNode });
            thirdNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "退回市政办", Name = "退回市政办", ContactTo = secordNode });

            fourthNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "不满意", Name = "不满意", ContactTo = thirdNode });
            fourthNode.FlowNodeLines.Add(new FlowNodeLine() { RuleCode = "满意", Name = "满意", ContactTo = null });

            flowType.FlowNodes.Add(firstNode);
            flowType.FlowNodes.Add(secordNode);
            flowType.FlowNodes.Add(thirdNode);
            flowType.FlowNodes.Add(fourthNode);

            FlowTypeRepository.Save(flowType);
            trans.Commit();
        }