示例#1
0
        public void AddFlow(FlowDef t)
        {
            if (string.IsNullOrEmpty(t.From) || string.IsNullOrEmpty(t.To))
            {
                throw new Exception("Flow must have start and target node");
            }
            NodeDef p = GetNode(t.From);

            if (p == null)
            {
                throw new Exception("Node not defined: " + t.From);
            }
            NodeDef q = GetNode(t.To);

            if (q == null)
            {
                throw new Exception("Node not defined: " + t.To);
            }
            t.Parent = this;

            if (t.IsCancelling || t.SourcePortType != TaskOutPortType.Out)
            {
                if (t.InputCondition != null && t.InputCondition.Length > 0)
                {
                    throw new NGinnBPM.ProcessModel.Exceptions.ProcessDefinitionException(this.ParentProcess.DefinitionId, t.From, "InputCondition not allowed");
                }
            }

            if (p is PlaceDef && q is PlaceDef)
            {
                throw new Exception("Flow cannot connect two places");
            }
            if (p is TaskDef && q is TaskDef)
            {
                //adding implicit place between p and q
                TaskDef  tq    = q as TaskDef;
                TaskDef  tp    = p as TaskDef;
                PlaceDef ptran = new PlaceDef {
                    Id        = string.Format("{0}.-.{1}", tp.Id, tq.Id),
                    PlaceType = PlaceTypes.Intermediate,
                    Implicit  = true
                };
                AddPlace(ptran);
                t.To = ptran.Id;
                FlowDef f2 = new FlowDef();
                f2.From = ptran.Id;
                f2.To   = tq.Id;
                AddFlow(t);
                AddFlow(f2);
            }
            else
            {
                Flows.Add(t);
            }
        }
示例#2
0
        public void AddFlow(FlowDef t)
        {
            if (string.IsNullOrEmpty(t.From) || string.IsNullOrEmpty(t.To)) throw new Exception("Flow must have start and target node");
            NodeDef p = GetNode(t.From);
            if (p == null) throw new Exception("Node not defined: " + t.From);
            NodeDef q = GetNode(t.To);
            if (q == null) throw new Exception("Node not defined: " + t.To);
            t.Parent = this;
            
            if (t.IsCancelling || t.SourcePortType != TaskOutPortType.Out)
            {
                if (t.InputCondition != null && t.InputCondition.Length > 0)
                    throw new NGinnBPM.ProcessModel.Exceptions.ProcessDefinitionException(this.ParentProcess.DefinitionId, t.From, "InputCondition not allowed");
            }

            if (p is PlaceDef && q is PlaceDef) throw new Exception("Flow cannot connect two places");
            if (p is TaskDef && q is TaskDef)
            {
                //adding implicit place between p and q
                TaskDef tq = q as TaskDef;
                TaskDef tp = p as TaskDef;
                PlaceDef ptran = new PlaceDef {Id = string.Format("{0}.-.{1}", tp.Id, tq.Id),
                    PlaceType = PlaceTypes.Intermediate,
                    Implicit = true
                };
                AddPlace(ptran);
                t.To = ptran.Id;
                FlowDef f2 = new FlowDef();
                f2.From = ptran.Id;
                f2.To = tq.Id;
                AddFlow(t);
                AddFlow(f2);
            }
            else
            {
                Flows.Add(t);
            }
        }
 private void ExecuteFlow(string instanceId, FlowDef fl)
 {
     TransitionInfo ti = GetTransitionInfo(instanceId);
     if (ti.TaskId != fl.From) throw new Exception();
     if (fl.IsCancelling)
     {
         RemoveAllTokensInPlace(fl.To);
     }
     else
     {
         AddToken(fl.To);
     }
 }
 /// <summary>
 /// Evaluate input condition for a flow
 /// </summary>
 /// <param name="fl"></param>
 /// <returns></returns>
 protected bool EvaluateFlowInputCondition(FlowDef fl)
 {
     return this.ScriptRuntime.EvalFlowCondition(this, fl, Context);
 }