Esempio n. 1
0
        /// <summary>
        /// Builds the next element.
        /// </summary>
        /// <param name="runner">The runner.</param>
        /// <param name="currentElement">The current element.</param>
        /// <param name="endElement">The end element.</param>
        /// <param name="wfInstance">The wf instance.</param>
        private void BuildNextElement(WFRunner runner, WFElement currentElement,WFElement endElement, Workflow wfInstance)
        {
            WFElement outElement = null;

              if (currentElement.GetType() == typeof (Boundary))
              {
              // This should only be entered into during the top level invocation
              // i.e. for the "Start" boundary itself.

              string nextActivity = currentElement.NextActivityID();
              //TransformationEngine.Call aCall =
              // wfInstance.Call.Find(x => x.activityID.Equals(nextActivity));
              TransformationEngine.Call aCall = wfInstance.Call.Find(x=>x.activityID.Equals(nextActivity));//[WorkflowFactory.IndexOfActivity(nextActivity)];
              if ( null != aCall )
              {
                // Create and add the new call...set this boundary as one of it's predecessors
                outElement = new Call(aCall, wfInstance);
                outElement.PreviousElements.Add(currentElement);
                runner.WorkflowElements.Add(outElement);
                BuildNextElement(runner, outElement, endElement, wfInstance);
              }
              else
              {
                if (currentElement.NextActivityID().Equals(endElement.GetActivityID()))
                {
                  // Empty workflow...just add the start as a previous element to the end.
                  endElement.PreviousElements.Add(currentElement);
                }
              }
              }
              else if (currentElement.GetType() == typeof(Call))
              {
             ConstructCall(runner, currentElement, endElement, wfInstance);
              }
              else if (currentElement.GetType() == typeof(Decision))
              {
            TransformationEngine.Decision decision = ((Decision) currentElement).DecisionModel;
            string successID = decision.successPathID;
            string failID = decision.failPathID;

            currentElement.DefaultNextActivityID = successID;

            if (null == runner.WorkflowElements.Find(x => (x.GetActivityID().Equals(successID))))
            {
              // Find the item that this is
              // Construct the Success Branch
              ConstructDecisionBranch(runner,currentElement,successID,endElement,wfInstance);
            }
            if (null == runner.WorkflowElements.Find(x => x.GetActivityID().Equals(failID)))
            {
              // Find the item that this is
              // Construct the Fail Branch
              ConstructDecisionBranch(runner, currentElement, failID, endElement, wfInstance);
            }
              }
        }