示例#1
0
    /// <summary>
    /// Creates a new workflow step. Called when the "Create workflow step" button is pressed.
    /// Expects the CreateWorkflow method to be run first.
    /// </summary>
    private bool CreateWorkflowStep()
    {
        // Get the workflow
        WorkflowInfo myWorkflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (myWorkflow != null)
        {
            // Create new workflow step object
            WorkflowStepInfo newStep = new WorkflowStepInfo();

            // Set the properties
            newStep.StepWorkflowID  = myWorkflow.WorkflowID;
            newStep.StepName        = "MyNewWorkflowStep";
            newStep.StepDisplayName = "My new workflow step";
            newStep.StepOrder       = 1;
            newStep.StepType        = WorkflowStepTypeEnum.Standard;

            // Save the step into database
            WorkflowStepInfoProvider.SetWorkflowStepInfo(newStep);

            // Ensure correct step order
            WorkflowStepInfoProvider.InitStepOrders(myWorkflow);

            return(true);
        }

        return(false);
    }
示例#2
0
    /// <summary>
    ///Creates the document, workflow scope and step needed for this example. Called when the "Create example objects" button is pressed.
    /// </summary>
    private bool CreateExampleObjects()
    {
        // Create a new tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get the root node
        TreeNode parent = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", "en-us");

        if (parent != null)
        {
            // Create the API document
            TreeNode node = TreeNode.New("CMS.MenuItem", tree);

            node.DocumentName    = "API Example";
            node.DocumentCulture = "en-us";

            // Insert it to database
            DocumentHelper.InsertDocument(node, parent, tree);

            // Get the default workflow
            WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("default");

            if (workflow != null)
            {
                // Get the document data
                node = DocumentHelper.GetDocument(node, tree);

                // Create new workflow scope
                WorkflowScopeInfo scope = new WorkflowScopeInfo();

                // Assign to the default workflow and current site and set starting alias path to the example document
                scope.ScopeWorkflowID   = workflow.WorkflowID;
                scope.ScopeStartingPath = node.NodeAliasPath;
                scope.ScopeSiteID       = CMSContext.CurrentSiteID;

                // Save the scope into the database
                WorkflowScopeInfoProvider.SetWorkflowScopeInfo(scope);

                // Create a new workflow step
                WorkflowStepInfo step = new WorkflowStepInfo();

                // Set its properties
                step.StepWorkflowID  = workflow.WorkflowID;
                step.StepName        = "MyNewWorkflowStep";
                step.StepDisplayName = "My new workflow step";
                step.StepOrder       = 1;

                // Save the workflow step
                WorkflowStepInfoProvider.SetWorkflowStepInfo(step);

                // Ensure correct step order
                WorkflowStepInfoProvider.InitStepOrders(workflow);

                return(true);
            }
            else
            {
                apiCreateExampleObjects.ErrorMessage = "The default workflow was not found.";
            }
        }

        return(false);
    }