/// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void OnAction(string actionName, object actionArgument)
    {
        int workflowstepid = Convert.ToInt32(actionArgument);

        if (actionName == "delete")
        {
            // Check if documents use the workflow
            WorkflowStepInfo si = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid);
            if (si != null)
            {
                List <string> documentNames = new List <string>();
                if (WorkflowStepInfoProvider.CheckDependencies(workflowstepid, ref documentNames))
                {
                    // Encode and localize names
                    StringBuilder sb = new StringBuilder();
                    documentNames.ForEach(item => sb.Append("<br />", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(item))));
                    Control.ShowError(Control.GetString("Workflow.CannotDeleteStepUsed"), Control.GetString("workflow.documentlist") + sb);
                }
                else
                {
                    // Delete the workflow step
                    WorkflowStepInfoProvider.DeleteWorkflowStepInfo(workflowstepid);
                }
            }
        }
        else if (actionName == "moveup")
        {
            WorkflowStepInfoProvider.MoveStepUp(WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid));
        }
        else if (actionName == "movedown")
        {
            WorkflowStepInfoProvider.MoveStepDown(WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid));
        }
    }
예제 #2
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);
    }
예제 #3
0
    /// <summary>
    /// Deletes the workflow step. Called when the "Delete workflow step" button is pressed.
    /// Expects the CreateWorkflow and CreateWorkflowStep methods to be run first.
    /// </summary>
    private bool DeleteWorkflowStep()
    {
        // Get the workflow
        WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow", WorkflowTypeEnum.Approval);

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

            if (deleteStep != null)
            {
                // Remove the step
                WorkflowStepInfoProvider.DeleteWorkflowStepInfo(deleteStep);
                return(true);
            }
        }

        return(false);
    }
예제 #4
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void stepsGrid_OnAction(string actionName, object actionArgument)
    {
        int workflowstepid = Convert.ToInt32(actionArgument);

        if (actionName == "edit")
        {
            URLHelper.Redirect("Workflow_Step_Edit.aspx?workflowstepid=" + workflowstepid);
        }

        else if (actionName == "delete")
        {
            // Check if documents use the workflow
            WorkflowStepInfo si = WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid);
            if (si != null)
            {
                switch (si.StepName.ToLower())
                {
                case "edit":
                case "published":
                    // Delete the workflow step
                    WorkflowStepInfoProvider.DeleteWorkflowStepInfo(workflowstepid);
                    break;

                default:
                    string where = "DocumentWorkflowStepID = " + workflowstepid;

                    TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
                    DataSet      ds   = tree.SelectNodes(TreeProvider.ALL_SITES, "/%", TreeProvider.ALL_CULTURES, false, null, where, "SiteName, NodeAliasPath", -1, false);
                    if (!DataHelper.DataSourceIsEmpty(ds))
                    {
                        lblError.Text    = GetString("Workflow.CannotDeleteStepUsed") + "<br />";
                        lblError.Visible = true;

                        int index = 0;
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            if (index > 10)
                            {
                                lblError.Text += "<br />&nbsp;...";
                                break;
                            }
                            lblError.Text += "<br />&nbsp;" + dr["SiteName"] + " - " + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["DocumentNamePath"], ""));
                            index++;
                        }
                    }
                    else
                    {
                        // Delete the workflow step
                        WorkflowStepInfoProvider.DeleteWorkflowStepInfo(workflowstepid);
                    }
                    break;
                }
            }
        }

        else if (actionName == "moveup")
        {
            WorkflowStepInfoProvider.MoveStepUp(WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid));
        }

        else if (actionName == "movedown")
        {
            WorkflowStepInfoProvider.MoveStepDown(WorkflowStepInfoProvider.GetWorkflowStepInfo(workflowstepid));
        }
    }