/// <summary>Runs the specified args.</summary> /// <param name="args">The arguments.</param> protected void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull((object)args, "args"); bool flag1 = args.IsPostBack; bool flag2 = args.Parameters["checkmodified"] == "1"; if (!this.CheckCommandValidity(Sitecore.Client.ContentDatabase.Items[args.Parameters["id"], Language.Parse(args.Parameters["language"]), Sitecore.Data.Version.Parse(args.Parameters["version"])], args.Parameters["commandid"])) { return; } if (flag2) { if (!flag1) { if (Context.ClientPage.Modified) { SheerResponse.CheckModified(true); args.WaitForPostBack(); return; } } else if (args.Result == "cancel") { return; } args.Parameters["checkmodified"] = (string)null; flag1 = false; } if (flag1 && args.Result == "cancel") { return; } Sitecore.Collections.StringDictionary commentFields = new Sitecore.Collections.StringDictionary(); bool flag3 = StringUtil.GetString(new string[1] { args.Parameters["ui"] }) != "1"; bool flag4 = StringUtil.GetString(new string[1] { args.Parameters["suppresscomment"] }) == "1"; string commandId = args.Parameters["commandid"]; string workflowId = args.Parameters["workflowid"]; ItemUri itemUri = new ItemUri(args.Parameters["id"], Language.Parse(args.Parameters["language"]), Sitecore.Data.Version.Parse(args.Parameters["version"]), Sitecore.Client.ContentDatabase); if (!flag1 && flag3 && !flag4) { ID result = ID.Null; ID.TryParse(commandId, out result); WorkflowUIHelper.DisplayCommentDialog(itemUri, result); args.WaitForPostBack(); } else { if (flag1) { if (args.Result == "null" || args.Result == "undefined") { return; } commentFields = WorkflowUIHelper.ExtractFieldsFromFieldEditor(args.Result); } var workflow = Context.ContentDatabase.WorkflowProvider.GetWorkflow(workflowId); var repository = new WorxboxItemsRepository(workflow); var item = Context.ContentDatabase.GetItem(itemUri.ItemID, itemUri.Language, itemUri.Version); var workflowState = workflow.GetState(item); var completionCallback = new Processor("Workflow completed callback", (object)this, "WorkflowCompleteCallback"); if (repository.IsWorxboxItem(workflowState, new DataUri(itemUri)) && repository.GetWorkflowCommandIDs().Any(x => x == ID.Parse(commandId))) { var items = repository.GetWorxboxItems( repository.GetWorxboxWorkflowStates(workflow) .First(x => x.WorkflowCommands.Any(y => y.CommandID == commandId)), item); foreach (var compositeItem in items) { WorkflowUIHelper.ExecuteCommand(compositeItem.Uri, workflowId, commandId, commentFields, () => { // NOP }); } } WorkflowUIHelper.ExecuteCommand(itemUri, workflowId, commandId, commentFields, () => { WorkflowCompleteCallback(null); }); } }
protected void Run(ClientPipelineArgs args) { Assert.ArgumentNotNull((object)args, "args"); bool flag1 = args.IsPostBack; if (args.Parameters["checkmodified"] == "1") { if (!flag1) { if (Context.ClientPage.Modified) { SheerResponse.CheckModified(true); args.WaitForPostBack(); return; } } else if (args.Result == "cancel") { return; } args.Parameters["checkmodified"] = (string)null; flag1 = false; } string comments = string.Empty; bool flag2 = StringUtil.GetString(new string[1] { args.Parameters["ui"] }) != "1"; bool flag3 = StringUtil.GetString(new string[1] { args.Parameters["suppresscomment"] }) == "1"; if (!flag1 && flag2 && !flag3) { SheerResponse.Input("Enter a comment:", ""); args.WaitForPostBack(); } else { if (flag1) { if (args.Result == "null") { return; } comments = args.Result; } IWorkflowProvider workflowProvider = Sitecore.Client.ContentDatabase.WorkflowProvider; if (workflowProvider != null) { IWorkflow workflow = workflowProvider.GetWorkflow(args.Parameters["workflowid"]); if (workflow != null) { Item obj = Sitecore.Client.ContentDatabase.Items[args.Parameters["id"], Language.Parse(args.Parameters["language"]), Sitecore.Data.Version.Parse(args.Parameters["version"])]; if (obj != null) { var workflowState = workflow.GetState(obj); var repository = new WorxboxItemsRepository(workflow); try { if (repository.IsWorxboxItem(workflowState, new DataUri(obj.Uri)) && repository.GetWorkflowCommandIDs().Any(x => x == ID.Parse(args.Parameters["commandid"]))) { var items = repository.GetWorxboxItems( repository.GetWorxboxWorkflowStates(workflow) .First(x => x.WorkflowCommands.Any(y => y.CommandID == args.Parameters["commandid"])), obj); foreach (var compositeItem in items) { var compositeWorkflowResult = workflow.Execute(args.Parameters["commandid"], compositeItem, comments, true); if (!compositeWorkflowResult.Succeeded) { if (!string.IsNullOrEmpty(compositeWorkflowResult.Message)) { SheerResponse.Alert(compositeWorkflowResult.Message); } } } } WorkflowResult workflowResult = workflow.Execute(args.Parameters["commandid"], obj, comments, true); if (!workflowResult.Succeeded) { if (!string.IsNullOrEmpty(workflowResult.Message)) { SheerResponse.Alert(workflowResult.Message); } } } catch (WorkflowStateMissingException ex) { SheerResponse.Alert("One or more items could not be processed because their workflow state does not specify the next step."); } } } } Context.ClientPage.SendMessage((object)this, "item:refresh"); SheerResponse.Eval("window.top.location.reload();"); } }