Ejemplo n.º 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);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Deletes workflow transition. Called when the "Delete transition" button is pressed.
    /// Expects the CreateWorklow and CreateTransitions method to be run first.
    /// </summary>
    private bool DeleteTransition()
    {
        // Get the process
        WorkflowInfo worklow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

        if (worklow != null)
        {
            // Get step
            WorkflowStepInfo startStep = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewStep", worklow.WorkflowID);

            if (startStep != null)
            {
                // Get existing transition leading from 'My new step'
                string where = "TransitionStartStepID = " + startStep.StepID;
                InfoDataSet <WorkflowTransitionInfo> transitions = WorkflowTransitionInfoProvider.GetWorkflowTransitions(worklow.WorkflowID, where, null, 1, null);
                WorkflowTransitionInfo existingTransition        = transitions.First <WorkflowTransitionInfo>();

                if (existingTransition != null)
                {
                    // Delete transition
                    WorkflowTransitionInfoProvider.DeleteWorkflowTransitionInfo(existingTransition);

                    return(true);
                }
            }
        }

        return(false);
    }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Reloads the data in the selector.
    /// </summary>
    public void ReloadData()
    {
        if (ddlSourcePoints.Items.Count == 0)
        {
            WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo(WorkflowStepID);
            if (step != null)
            {
                Step definition = step.StepDefinition;
                if ((definition == null) || (definition.SourcePoints == null))
                {
                    Visible = false;
                }
                else
                {
                    List <SourcePoint> sourcePoints = definition.SourcePoints;
                    Guid?defaultCase = null;
                    List <WorkflowTransitionInfo> connections = WorkflowTransitionInfoProvider.GetStepTransitions(step, null);

                    foreach (SourcePoint sp in sourcePoints)
                    {
                        AddItem(sp, connections);

                        if (sp.Type == SourcePointTypeEnum.SwitchDefault)
                        {
                            defaultCase = sp.Guid;
                        }
                    }

                    // Ensure default source point for timeout
                    if (step.StepAllowDefaultTimeoutTarget && !sourcePoints.Exists(s => (s is TimeoutSourcePoint)))
                    {
                        AddItem(new TimeoutSourcePoint(), connections);
                    }

                    if (definition.TimeoutTarget != Guid.Empty)
                    {
                        ddlSourcePoints.SelectedValue = definition.TimeoutTarget.ToString();
                    }
                    else if (defaultCase.HasValue)
                    {
                        ddlSourcePoints.SelectedValue = defaultCase.Value.ToString();
                    }
                }
            }
        }

        // Set visibility
        Visible = IsVisible();
    }