示例#1
0
    /// <summary>
    /// Creates workflow transitions. Called when the "Create transition" button is pressed.
    /// Expects the CreateWorklow and CreateStep method to be run first.
    /// </summary>
    private bool CreateTransition()
    {
        // Get the workflow
        WorkflowInfo worklow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

        if (worklow != null)
        {
            // Get steps with codename 'MyNewStep' and 'Published'
            WorkflowStepInfo myNewStep     = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewStep", worklow.WorkflowID);
            WorkflowStepInfo publishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Published", worklow.WorkflowID);

            if ((myNewStep != null) && (publishedStep != null))
            {
                // Get existing transition leading to 'Published step'
                string where = "TransitionEndStepID = " + publishedStep.StepID;
                InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(worklow.WorkflowID, where, null, 1, null);
                WorkflowTransitionInfo existingTransition        = transitions.First <WorkflowTransitionInfo>();

                // Change existing transition to leads from 'Start step' to 'My new step'
                existingTransition.TransitionEndStepID = myNewStep.StepID;

                // Save existing transition
                WorkflowTransitionInfoProvider.SetWorkflowTransitionInfo(existingTransition);

                // Connect 'My new step' step to 'Published' step
                myNewStep.ConnectTo(myNewStep.StepDefinition.SourcePoints[0].Guid, publishedStep);

                return(true);
            }
        }

        return(false);
    }
示例#2
0
    /// <summary>
    /// Creates process transitions. Called when the "Create transitions" button is pressed.
    /// Expects the CreateProcess and CreateProcessStep method to be run first.
    /// </summary>
    private bool CreateProcessTransitions()
    {
        // Get the process
        WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation);

        if (process != null)
        {
            // Get the previously created process step
            WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewProcessStep", process.WorkflowID);

            // Get the step with codename 'Finished'
            WorkflowStepInfo finishedStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("Finished", process.WorkflowID);

            if ((step != null) && (finishedStep != null))
            {
                // Get existed transition from 'Start' step to 'Finished' step
                InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(process.WorkflowID, null, null, 1, null);
                WorkflowTransitionInfo existedTransition         = transitions.First <WorkflowTransitionInfo>();

                // Change existed transition to leads from 'Start' step to 'My new step' step
                existedTransition.TransitionEndStepID = step.StepID;
                // Save existed transition
                WorkflowTransitionInfoProvider.SetWorkflowTransitionInfo(existedTransition);

                // Connect 'My new step' step to 'Finished' step
                step.ConnectTo(step.StepDefinition.SourcePoints[0].Guid, finishedStep);

                return(true);
            }
        }

        return(false);
    }