Esempio n. 1
0
    /// <summary>
    /// Deletes workflow scope. Called when the "Delete scope" button is pressed.
    /// Expects the CreateWorkflowScope method to be run first.
    /// </summary>
    private bool DeleteWorkflowScope()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

        if (workflow != null)
        {
            // Get the workflow's scopes
            InfoDataSet <WorkflowScopeInfo> scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID);

            if (!DataHelper.DataSourceIsEmpty(scopes))
            {
                // Create the scope info object
                WorkflowScopeInfo deleteScope = scopes.First <WorkflowScopeInfo>();

                // Delete the workflow scope
                WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(deleteScope);

                return(true);
            }
            else
            {
                // No scope was found
                apiDeleteWorkflowScope.ErrorMessage = "The scope was not found.";
            }
        }

        return(false);
    }
Esempio n. 2
0
    /// <summary>
    /// Gets and updates workflow scope. Called when the "Get and update scope" button is pressed.
    /// Expects the CreateWorkflowScope method to be run first.
    /// </summary>
    private bool GetAndUpdateWorkflowScope()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (workflow != null)
        {
            // Get the workflow's scopes
            InfoDataSet <WorkflowScopeInfo> scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID);

            if (!DataHelper.DataSourceIsEmpty(scopes))
            {
                // Create the scope info object
                WorkflowScopeInfo updateScope = scopes.First <WorkflowScopeInfo>();

                // Update the properties - the scope will include all cultures and document types
                updateScope.ScopeCultureID = 0;
                updateScope.ScopeClassID   = 0;

                // Save the changes
                WorkflowScopeInfoProvider.SetWorkflowScopeInfo(updateScope);

                return(true);
            }
            else
            {
                // No scope was found
                apiGetAndUpdateWorkflowScope.ErrorMessage = "The scope was not found.";
            }
        }

        return(false);
    }
Esempio n. 3
0
    /// <summary>
    /// Deletes the workflow scope(s) and culture assignments used for this example. Called when the "Delete objects" button is pressed.
    /// Expects the "CreateExampleObjects" method to be run first.
    /// </summary>
    private bool DeleteObjects()
    {
        CultureInfo culture = CultureInfoProvider.GetCultureInfo("de-de");

        // Remove the example culture from the site
        CultureSiteInfoProvider.RemoveCultureFromSite(culture.CultureID, CMSContext.CurrentSiteID);

        // Prepare parameters
        string where = "ScopeStartingPath LIKE '/API-Example%'";
        string orderBy = null;
        int    topN    = 0;
        string columns = null;

        DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(where, orderBy, topN, columns);

        if (!DataHelper.DataSourceIsEmpty(scopes))
        {
            // Loop through all the scopes in case more identical scopes were accidentally created
            foreach (DataRow scopeRow in scopes.Tables[0].Rows)
            {
                // Create scope info object
                WorkflowScopeInfo scope = new WorkflowScopeInfo(scopeRow);

                // Delete the scope
                scope.Delete();
            }

            return(true);
        }

        return(false);
    }
Esempio n. 4
0
    /// <summary>
    /// Deletes workflow scope. Called when the "Delete scope" button is pressed.
    /// Expects the CreateWorkflowScope method to be run first.
    /// </summary>
    private bool DeleteWorkflowScope()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow");

        if (workflow != null)
        {
            // Get the workflow's scopes
            DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(workflow.WorkflowID);

            if (!DataHelper.DataSourceIsEmpty(scopes))
            {
                // Create the scope info object
                WorkflowScopeInfo deleteScope = new WorkflowScopeInfo(scopes.Tables[0].Rows[0]);

                // Delete the workflow scope
                WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(deleteScope);

                return(true);
            }
            else
            {
                // No scope was found
                apiDeleteWorkflowScope.ErrorMessage = "The scope was not found.";
            }
        }

        return(false);
    }
Esempio n. 5
0
    /// <summary>
    /// Deletes the workflow scope(s). Called when the "Delete workflow scope" button is pressed.
    /// Expects the "CreateWorkflowScope" method to be run first.
    /// </summary>
    private bool DeleteWorkflowScope()
    {
        // Prepare parameters
        string where = "ScopeStartingPath LIKE '/API-Example%'";
        string orderBy = null;
        int    topN    = 0;
        string columns = null;

        DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(where, orderBy, topN, columns);

        if (!DataHelper.DataSourceIsEmpty(scopes))
        {
            // Loop through all the scopes in case more identical scopes were accidentally created
            foreach (DataRow scopeRow in scopes.Tables[0].Rows)
            {
                // Create scope info object
                WorkflowScopeInfo scope = new WorkflowScopeInfo(scopeRow);

                // Delete the scope
                scope.Delete();
            }

            return(true);
        }

        return(false);
    }
Esempio n. 6
0
    /// <summary>
    /// Deletes the workflow scope, workflow step and the document used for this example. Called when the "Delete example objects" button is pressed.
    /// Expects the "CreateExampleObjects" method to be run first.
    /// </summary>
    private bool DeleteExampleObjects()
    {
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get the example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", "en-us");

        if (node != null)
        {
            // Delete the document
            DocumentHelper.DeleteDocument(node, tree, true, true, true);
        }

        string where = "ScopeStartingPath LIKE '/API-Example%'";

        // Get example workflow scopes
        DataSet scopes = WorkflowScopeInfoProvider.GetWorkflowScopes(where, null, 0, null);

        if (!DataHelper.DataSourceIsEmpty(scopes))
        {
            // Loop through all the scopes in case more identical scopes were accidentally created
            foreach (DataRow scopeRow in scopes.Tables[0].Rows)
            {
                // Create scope info object
                WorkflowScopeInfo scope = new WorkflowScopeInfo(scopeRow);

                // Delete the scope
                WorkflowScopeInfoProvider.DeleteWorkflowScopeInfo(scope);
            }
        }

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

        if (workflow != null)
        {
            // Get the example step
            WorkflowStepInfo step = WorkflowStepInfoProvider.GetWorkflowStepInfo("MyNewWorkflowStep", workflow.WorkflowID);

            if (step != null)
            {
                // Delete the step
                WorkflowStepInfoProvider.DeleteWorkflowStepInfo(step);
            }
        }

        return(true);
    }