예제 #1
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;
 }
예제 #2
0
파일: Flow.cs 프로젝트: chenchunwei/NPC
 public virtual FlowNodeInstance Goto(string nodeName, Dictionary<string, string> args = null)
 {
     //HACK:这种跳转动作因为涉及到多个聚合根,所以不适合放在单独某个聚合根中,这里这样做是因为大家配置了双向关联,实现比较方便,但是这里违背了聚合的边界
     //会造成持久化上的一些困镜。除非抛弃持久化时聚合的边界
     var targetNode = FlowType.FlowNodes.First(o => o.Name.ToLower() == nodeName.ToLower());
     if (targetNode == null)
         throw new ArgumentException("要跳转的目标节点不存在");
     //合并流程变量
     WriteDataFields(args);
     //把当前执行的节点设置成忽略状态并创建新的流程实例
     FlowNodeInstances.ToList().ForEach(nodeInstance =>
     {
         if (!nodeInstance.TriggerActionCompletedRule())
         {
             nodeInstance.Ignore();
         }
     });
     var newInstance = new FlowNodeInstance();
     newInstance.BelongsFlow = this;
     newInstance.BelongsFlowNode = targetNode;
     newInstance.RecordDescription.CreateBy(null);
     newInstance.BuilderTasksAndReturnNewTasks();
     FlowNodeInstances.Add(newInstance);
     return newInstance;
 }