/// <summary> /// Initializes master page elements. /// </summary> private void InitializeMasterPage() { if (!CurrentUser.IsGlobalAdministrator) { PageTitle title = CurrentMaster.Title; title.TitleText = GetString("ma.automationprocess.list"); title.TitleImage = GetImageUrl("Objects/MA_AutomationProcess/object.png"); title.HelpName = "helpTopic"; title.HelpTopicName = "ma_process_list"; } if (WorkflowInfoProvider.IsMarketingAutomationAllowed()) { HeaderAction newProcess = new HeaderAction() { // New process link Text = GetString("ma.newprocess"), ImageUrl = GetImageUrl("Objects/MA_AutomationProcess/add.png"), RedirectUrl = AddSiteQuery("Process/New.aspx", null), Enabled = WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName) }; AddHeaderAction(newProcess); } }
/// <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 gridProcesses_OnAction(string actionName, object actionArgument) { int processId = Convert.ToInt32(actionArgument); switch (actionName) { case "edit": var url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditProcess"); url = URLHelper.AddParameterToUrl(url, "displayTitle", "false"); url = URLHelper.AddParameterToUrl(url, "objectId", processId.ToString()); URLHelper.Redirect(url); break; case "delete": if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "ManageProcesses"); } // Delete the workflow with all the dependencies WorkflowInfoProvider.DeleteWorkflowInfo(processId); ShowConfirmation(GetString("ma.process.delete.confirmation")); break; } }
/// <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 gridProcesses_OnAction(string actionName, object actionArgument) { int processId = Convert.ToInt32(actionArgument); switch (actionName) { case "edit": var url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditProcess"); url = URLHelper.AddParameterToUrl(url, "displayTitle", "false"); url = URLHelper.AddParameterToUrl(url, "objectId", processId.ToString()); URLHelper.Redirect(AddSiteQuery(url, null)); break; case "delete": if (AutomationHelper.CheckProcessDependencies(processId)) { ShowError(GetString("MA.process.CannotDeleteUsed")); return; } if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "ManageProcesses"); } // Delete the workflow WorkflowInfoProvider.DeleteWorkflowInfo(processId); break; } }
protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "condition": return(MacroRuleTree.GetRuleText(ValidationHelper.GetString(parameter, String.Empty))); case "type": DataRowView row = parameter as DataRowView; if (row != null) { ObjectWorkflowTriggerInfo trigger = new ObjectWorkflowTriggerInfo(row.Row); if (!string.IsNullOrEmpty(trigger.TriggerTargetObjectType)) { return(GetTriggerDescription(trigger)); } else { return(AutomationHelper.GetTriggerName(trigger.TriggerType, trigger.TriggerObjectType)); } } return(parameter); case "delete": if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { CMSGridActionButton btn = (CMSGridActionButton)sender; btn.Enabled = false; } return(parameter); default: return(parameter); } }
protected void Page_PreRender(object sender, EventArgs e) { // Check permissions to create new record if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { headerActions.Enabled = false; } }
protected void Page_PreRender(object sender, EventArgs e) { // Check permissions to create new record if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { headerActions.Enabled = false; } // Allow new button only for particular sites or (global) site else if (!IsAddingAllowed) { headerActions.Enabled = false; lblWarnNew.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { // Set master page elements InitializeMasterPage(); // Check manage permission for object menu if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { gridProcesses.ShowObjectMenu = false; } // Control initialization gridProcesses.OnAction += gridProcesses_OnAction; gridProcesses.OnExternalDataBound += gridProcesses_OnExternalDataBound; gridProcesses.ZeroRowsText = GetString("general.nodatafound"); }
protected object gridProcesses_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "recurrencetype": return(WorkflowHelper.GetWorkflowRecurrenceTypeString((ProcessRecurrenceTypeEnum)ValidationHelper.GetInteger(parameter, (int)ProcessRecurrenceTypeEnum.Recurring))); case "delete": if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { ImageButton btn = (ImageButton)sender; btn.Enabled = false; btn.Attributes.Add("src", GetImageUrl("Design/Controls/UniGrid/Actions/DeleteDisabled.png")); } break; } return(parameter); }
/// <summary> /// Initializes master page elements. /// </summary> private void InitializeMasterPage() { if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor)) { PageTitle title = PageTitle; title.TitleText = GetString("ma.automationprocess.list"); } if (WorkflowInfoProvider.IsMarketingAutomationAllowed()) { HeaderAction newProcess = new HeaderAction { // New process link Text = GetString("ma.newprocess"), RedirectUrl = "Process/New.aspx", Enabled = WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName) }; AddHeaderAction(newProcess); } }
protected void Page_Load(object sender, EventArgs e) { if (ProcessID <= 0) { designerElem.StopProcessing = true; return; } designerElem.WorkflowID = ProcessID; designerElem.WorkflowType = WorkflowTypeEnum.Automation; bool licenseFail = !WorkflowInfoProvider.IsMarketingAutomationAllowed(); if (licenseFail || !WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { designerElem.ReadOnly = true; MessagesPlaceHolder.OffsetY = 10; MessagesPlaceHolder.UseRelativePlaceHolder = false; ShowInformation(GetString(licenseFail ? "wf.licenselimitation" : "general.modifynotallowed")); } }
/// <summary> /// Initializes master page elements. /// </summary> private void InitializeMasterPage() { if (!CurrentUser.IsGlobalAdministrator) { PageTitle title = PageTitle; title.TitleText = GetString("ma.automationprocess.list"); } if (WorkflowInfoProvider.IsMarketingAutomationAllowed()) { HeaderAction newProcess = new HeaderAction { // New process link Text = GetString("ma.newprocess"), RedirectUrl = AddSiteQuery("Process/New.aspx", null), Enabled = WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName) }; AddHeaderAction(newProcess); } }
protected object gridProcesses_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "recurrencetype": var val = (ProcessRecurrenceTypeEnum)ValidationHelper.GetInteger(parameter, (int)ProcessRecurrenceTypeEnum.Recurring); return(val.ToLocalizedString(null)); case "delete": if (!WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, CurrentSiteName)) { CMSGridActionButton btn = (CMSGridActionButton)sender; btn.Enabled = false; } break; case "enabled": return(UniGridFunctions.ColoredSpanYesNo(ValidationHelper.GetBoolean(parameter, true))); } return(parameter); }
private void ReloadMenu() { if (StopProcessing) { return; } // Handle several reloads ClearProperties(); if (!HideStandardButtons) { // If content should be refreshed if (AutomationManager.RefreshActionContent) { // Display action message WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(Step.StepActionID); string name = (action != null) ? action.ActionDisplayName : Step.StepDisplayName; string str = (action != null) ? "workflow.actioninprogress" : "workflow.stepinprogress"; string text = string.Format(ResHelper.GetString(str, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(name))); text = ScriptHelper.GetLoaderInlineHtml(Page, text); InformationText = text; EnsureRefreshScript(); } // Object update if (AutomationManager.Mode == FormModeEnum.Update) { if (InfoObject != null) { // Get current process WorkflowInfo process = AutomationManager.Process; string objectName = HTMLHelper.HTMLEncode(InfoObject.TypeInfo.GetNiceObjectTypeName().ToLowerCSafe()); // Next step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_NEXT)) { next = new NextStepAction(Page) { Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_NEXT, null), }; } // Move to specific step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_SPEC)) { var steps = WorkflowStepInfoProvider.GetWorkflowSteps() .Where("StepWorkflowID = " + process.WorkflowID + " AND StepType <> " + (int)WorkflowStepTypeEnum.Start) .OrderBy("StepDisplayName"); specific = new NextStepAction(Page) { Text = GetString("AutoMenu.SpecificStepIcon"), Tooltip = string.Format(ResHelper.GetString("AutoMenu.SpecificStepMultiple", ResourceCulture), objectName), CommandName = ComponentEvents.AUTOMATION_MOVE_SPEC, EventName = ComponentEvents.AUTOMATION_MOVE_SPEC, CssClass = "scrollable-menu", // Make action inactive OnClientClick = null, Inactive = true }; foreach (var s in steps) { string stepName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName)); NextStepAction spc = new NextStepAction(Page) { Text = string.Format(ResHelper.GetString("AutoMenu.SpecificStepTo", ResourceCulture), stepName), Tooltip = string.Format(ResHelper.GetString("AutoMenu.SpecificStep", ResourceCulture), objectName), CommandName = ComponentEvents.AUTOMATION_MOVE_SPEC, EventName = ComponentEvents.AUTOMATION_MOVE_SPEC, CommandArgument = s.StepID.ToString(), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_SPEC, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.MoveSpecificConfirmation"), objectName, ResHelper.LocalizeString(s.StepDisplayName))) + ")) { return false; }"), }; // Process action appearance ProcessAction(spc, Step, s); // Add step specific.AlternativeActions.Add(spc); } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_SPEC, specific, objectName); } // Previous step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_PREVIOUS)) { var prevSteps = Manager.GetPreviousSteps(InfoObject, StateObject); int prevStepsCount = prevSteps.Count; if (prevStepsCount > 0) { previous = new PreviousStepAction(Page) { Tooltip = string.Format(ResHelper.GetString("EditMenu.PreviousStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, null) }; // For managers allow move to specified step if (WorkflowStepInfoProvider.CanUserManageAutomationProcesses(MembershipContext.AuthenticatedUser, InfoObject.Generalized.ObjectSiteName)) { if (prevStepsCount > 1) { foreach (var s in prevSteps) { previous.AlternativeActions.Add(new PreviousStepAction(Page) { Text = string.Format(ResHelper.GetString("EditMenu.PreviousStepTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))), Tooltip = string.Format(ResHelper.GetString("EditMenu.PreviousStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, null), CommandArgument = s.RelatedHistoryID.ToString() }); } } } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, previous, objectName); } } if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_REMOVE)) { delete = new HeaderAction { CommandName = ComponentEvents.AUTOMATION_REMOVE, EventName = ComponentEvents.AUTOMATION_REMOVE, Text = ResHelper.GetString("autoMenu.RemoveState", ResourceCulture), Tooltip = string.Format(ResHelper.GetString("autoMenu.RemoveStateDesc", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_REMOVE, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), objectName)) + ")) { return false; }"), ButtonStyle = ButtonStyle.Default }; } // Handle multiple next steps if (next != null) { // Get next step info List <WorkflowStepInfo> steps = AutomationManager.NextSteps; int stepsCount = steps.Count; if (stepsCount > 0) { var nextS = steps[0]; // Only one next step if (stepsCount == 1) { if (nextS.StepIsFinished) { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Process action appearance ProcessAction(next, Step, nextS); } // Multiple next steps else { // Check if not all steps finish steps if (steps.Exists(s => !s.StepIsFinished)) { next.Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStepMultiple", ResourceCulture), objectName); } else { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStepMultiple", ResourceCulture), objectName); } // Make action inactive next.OnClientClick = null; next.Inactive = true; // Process action appearance ProcessAction(next, Step, null); string itemText = "EditMenu.NextStepTo"; string itemDesc = "EditMenu.NextStep"; foreach (var s in steps) { NextStepAction nxt = new NextStepAction(Page) { Text = string.Format(ResHelper.GetString(itemText, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))), Tooltip = string.Format(ResHelper.GetString(itemDesc, ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_NEXT, null), CommandArgument = s.StepID.ToString() }; if (s.StepIsFinished) { nxt.Text = string.Format(ResHelper.GetString("EditMenu.FinishTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))); nxt.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Process action appearance ProcessAction(nxt, Step, s); // Add step next.AlternativeActions.Add(nxt); } } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_NEXT, next, objectName); } else { bool displayAction = false; if (!Step.StepAllowBranch) { // Transition exists, but condition doesn't match var transitions = Manager.GetStepTransitions(Step); if (transitions.Count > 0) { WorkflowStepInfo s = WorkflowStepInfoProvider.GetWorkflowStepInfo(transitions[0].TransitionEndStepID); // Finish text if (s.StepIsFinished) { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Inform user displayAction = true; next.Enabled = false; // Process action appearance ProcessAction(next, Step, null); } } if (!displayAction) { // There is not next step next = null; } } } // Handle start button if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_START) && (process.WorkflowRecurrenceType != ProcessRecurrenceTypeEnum.NonRecurring)) { start = new HeaderAction { CommandName = ComponentEvents.AUTOMATION_START, EventName = ComponentEvents.AUTOMATION_START, Text = ResHelper.GetString("autoMenu.StartState", ResourceCulture), Tooltip = process.WorkflowEnabled ? ResHelper.GetString("autoMenu.StartStateDesc", ResourceCulture) : ResHelper.GetString("autoMenu.DisabledStateDesc", ResourceCulture), CommandArgument = process.WorkflowID.ToString(), Enabled = process.WorkflowEnabled, OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_START, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.startSameProcessConfirmation", ResourceCulture), objectName)) + ")) { return false; }"), ButtonStyle = ButtonStyle.Default }; } } } } // Add actions in correct order menu.ActionsList.Clear(); AddAction(previous); AddAction(next); AddAction(specific); AddAction(delete); AddAction(start); // Set the information text if (!String.IsNullOrEmpty(InformationText)) { lblInfo.Text = InformationText; lblInfo.CssClass = "LeftAlign EditMenuInfo"; lblInfo.Visible = true; } ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterModule(Page, "CMS/ScrollPane", new { selector = ".scrollable-menu ul" }); CssRegistration.RegisterCssLink(Page, "~/CMSScripts/jquery/jquery-jscrollpane.css"); }
private bool InitSteps() { if (AutomationManager.InfoObject == null) { return(false); } bool displayDDL = false; List <WorkflowStepInfo> steps = null; int stepsCount = 0; switch (ActionName) { case ComponentEvents.AUTOMATION_MOVE_NEXT: steps = Manager.GetNextSteps(InfoObject, AutomationManager.StateObject); stepsCount = steps.Count; if (stepsCount == 0) { return(false); } if (stepsCount > 1) { // Add all next steps foreach (var step in steps) { drpSteps.Items.Add(new ListItem(GetActionText(AutomationManager.Step, step), step.StepID.ToString())); } } displayDDL = (drpSteps.Items.Count > 0); break; case ComponentEvents.AUTOMATION_MOVE_SPEC: var allSteps = WorkflowStepInfoProvider.GetWorkflowSteps("StepWorkflowID=" + AutomationManager.StateObject.StateWorkflowID + " AND StepType<>" + (int)WorkflowStepTypeEnum.Start, "StepDisplayName"); // Add all steps foreach (var step in allSteps) { drpSteps.Items.Add(new ListItem(GetActionText(AutomationManager.Step, step), step.StepID.ToString())); } displayDDL = true; break; case ComponentEvents.AUTOMATION_MOVE_PREVIOUS: if (WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CurrentUser, InfoObject.Generalized.ObjectSiteName)) { steps = Manager.GetPreviousSteps(InfoObject, AutomationManager.StateObject); foreach (var step in steps) { drpSteps.Items.Add(new ListItem(GetActionText(AutomationManager.Step, step), step.RelatedHistoryID.ToString())); } } displayDDL = (drpSteps.Items.Count > 1); break; } plcSteps.Visible = displayDDL; return(true); }
private void ReloadMenu() { if (StopProcessing) { return; } // Handle several reloads ClearProperties(); if (!HideStandardButtons) { // If content should be refreshed if (AutomationManager.RefreshActionContent) { // Display action message WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(Step.StepActionID); string name = (action != null) ? action.ActionDisplayName : Step.StepDisplayName; string str = (action != null) ? "workflow.actioninprogress" : "workflow.stepinprogress"; string text = string.Format(ResHelper.GetString(str, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(name))); text = String.Concat("<img style=\"vertical-align:bottom;\" src=\"", GetImageUrl("Design/Preloaders/preload16.gif"), "\" alt=\"", text, "\" /> <span>", text, "</span>"); InformationText = text; EnsureRefreshScript(); } // Object update if (AutomationManager.Mode == FormModeEnum.Update) { if (InfoObject != null) { // Get current process WorkflowInfo process = AutomationManager.Process; string objectName = HTMLHelper.HTMLEncode(ResHelper.GetString(InfoObject.Generalized.GetObjectTypeResourceKey()).ToLowerCSafe()); // Next step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_NEXT)) { next = new NextStepAction(Page) { Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_NEXT, null), }; } // Move to specific step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_SPEC)) { var steps = WorkflowStepInfoProvider.GetWorkflowSteps("StepWorkflowID=" + process.WorkflowID + " AND StepType<>" + (int)WorkflowStepTypeEnum.Start, "StepDisplayName"); specific = new NextStepAction(Page) { ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/specific.png"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/specific.png"), Text = GetString("AutoMenu.SpecificStepIcon"), Tooltip = string.Format(ResHelper.GetString("AutoMenu.SpecificStepMultiple", ResourceCulture), objectName), CommandName = ComponentEvents.AUTOMATION_MOVE_SPEC, EventName = ComponentEvents.AUTOMATION_MOVE_SPEC, // Make action inactive OnClientClick = null, Inactive = true }; foreach (var s in steps) { string stepName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName)); NextStepAction spc = new NextStepAction(Page) { ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/specific.png"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/specific.png"), Text = string.Format(ResHelper.GetString("AutoMenu.SpecificStepTo", ResourceCulture), stepName), Tooltip = string.Format(ResHelper.GetString("AutoMenu.SpecificStep", ResourceCulture), objectName), CommandName = ComponentEvents.AUTOMATION_MOVE_SPEC, EventName = ComponentEvents.AUTOMATION_MOVE_SPEC, CommandArgument = s.StepID.ToString(), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_SPEC, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.MoveSpecificConfirmation"), objectName, ResHelper.LocalizeString(s.StepDisplayName))) + ")) { return false; }"), }; // Process action appearance ProcessAction(spc, Step, s); // Add step specific.AlternativeActions.Add(spc); } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_SPEC, specific, objectName); } // Previous step action if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_MOVE_PREVIOUS)) { var prevSteps = Manager.GetPreviousSteps(InfoObject, StateObject); int prevStepsCount = prevSteps.Count; if (prevStepsCount > 0) { previous = new PreviousStepAction(Page) { Tooltip = string.Format(ResHelper.GetString("EditMenu.PreviousStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, null) }; // For managers allow move to specified step if (WorkflowStepInfoProvider.CanUserManageAutomationProcesses(CMSContext.CurrentUser, InfoObject.Generalized.ObjectSiteName)) { if (prevStepsCount > 1) { foreach (var s in prevSteps) { previous.AlternativeActions.Add(new PreviousStepAction(Page) { Text = string.Format(ResHelper.GetString("EditMenu.PreviousStepTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))), Tooltip = string.Format(ResHelper.GetString("EditMenu.PreviousStep", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, null), CommandArgument = s.RelatedHistoryID.ToString() }); } } } // Add comment AddCommentAction(ComponentEvents.AUTOMATION_MOVE_PREVIOUS, previous, objectName); } } if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_REMOVE)) { delete = new HeaderAction() { ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/reject.png"), SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/reject.png"), CommandName = ComponentEvents.AUTOMATION_REMOVE, EventName = ComponentEvents.AUTOMATION_REMOVE, Text = ResHelper.GetString("autoMenu.RemoveState", ResourceCulture), Tooltip = string.Format(ResHelper.GetString("autoMenu.RemoveStateDesc", ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_REMOVE, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.RemoveStateConfirmation"), objectName)) + ")) { return false; }") }; } // Handle multiple next steps if (next != null) { string actionName = ComponentEvents.AUTOMATION_MOVE_NEXT; // Get next step info List <WorkflowStepInfo> steps = AutomationManager.NextSteps; int stepsCount = steps.Count; if (stepsCount > 0) { var nextS = steps[0]; // Only one next step if (stepsCount == 1) { if (nextS.StepIsFinished) { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Process action appearance ProcessAction(next, Step, nextS); } // Multiple next steps else { // Check if not all steps finish steps if (steps.Exists(s => !s.StepIsFinished)) { next.Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStepMultiple", ResourceCulture), objectName); } else { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.NextStepMultiple", ResourceCulture), objectName); } // Make action inactive next.OnClientClick = null; next.Inactive = true; // Process action appearance ProcessAction(next, Step, null); string itemText = "EditMenu.NextStepTo"; string itemDesc = "EditMenu.NextStep"; foreach (var s in steps) { NextStepAction nxt = new NextStepAction(Page) { Text = string.Format(ResHelper.GetString(itemText, ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))), Tooltip = string.Format(ResHelper.GetString(itemDesc, ResourceCulture), objectName), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_MOVE_NEXT, null), CommandArgument = s.StepID.ToString() }; if (s.StepIsFinished) { nxt.Text = string.Format(ResHelper.GetString("EditMenu.FinishTo", ResourceCulture), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(s.StepDisplayName))); nxt.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Process action appearance ProcessAction(nxt, Step, s); // Add step next.AlternativeActions.Add(nxt); } } // Add comment AddCommentAction(actionName, next, objectName); } else { bool displayAction = false; if (!Step.StepAllowBranch) { // Transition exists, but condition doesn't match var transitions = Manager.GetStepTransitions(Step); if (transitions.Count > 0) { WorkflowStepInfo s = WorkflowStepInfoProvider.GetWorkflowStepInfo(transitions[0].TransitionEndStepID); // Finish text if (s.StepIsFinished) { next.Text = ResHelper.GetString("EditMenu.IconFinish", ResourceCulture); next.Tooltip = string.Format(ResHelper.GetString("EditMenu.Finish", ResourceCulture), objectName); } // Inform user displayAction = true; next.Enabled = false; // Process action appearance ProcessAction(next, Step, null); } } if (!displayAction) { // There is not next step next = null; } } } // Handle start button if (AutomationManager.IsActionAllowed(ComponentEvents.AUTOMATION_START) && (process.WorkflowRecurrenceType != ProcessRecurrenceTypeEnum.NonRecurring)) { start = new HeaderAction() { ImageUrl = GetImageUrl("Objects/MA_AutomationState/add.png"), SmallImageUrl = GetImageUrl("Objects/MA_AutomationState/add.png"), CommandName = ComponentEvents.AUTOMATION_START, EventName = ComponentEvents.AUTOMATION_START, Text = ResHelper.GetString("autoMenu.StartState", ResourceCulture), Tooltip = string.Format(ResHelper.GetString("autoMenu.StartStateDesc", ResourceCulture), objectName), CommandArgument = process.WorkflowID.ToString(), OnClientClick = RaiseGetClientValidationScript(ComponentEvents.AUTOMATION_START, "if(!confirm(" + ScriptHelper.GetString(string.Format(ResHelper.GetString("autoMenu.startSameProcessConfirmation", ResourceCulture), objectName)) + ")) { return false; }") }; } } } // Ensure correct design with backward compatibility if (string.IsNullOrEmpty(LinkCssClass)) { if (!IsLiveSite) { menu.LinkCssClass = "MenuItemEdit"; } } else { menu.LinkCssClass = LinkCssClass; } } // Add actions in correct order menu.ActionsList.Clear(); AddAction(previous); AddAction(next); AddAction(specific); AddAction(delete); AddAction(start); // Set the information text if (!String.IsNullOrEmpty(InformationText)) { lblInfo.Text = InformationText; lblInfo.CssClass = "LeftAlign EditMenuInfo"; lblInfo.Visible = true; } }