/// <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)); } }
/// <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 /> ..."; break; } lblError.Text += "<br /> " + 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)); } }