/// <summary> /// Gets and bulk updates actions. Called when the "Get and bulk update actions" button is pressed. /// Expects the CreateAction method to be run first. /// </summary> private bool GetAndBulkUpdateActions() { // Prepare the parameters string where = "ActionName LIKE N'MyNewAction%'"; // Get the data InfoDataSet <WorkflowActionInfo> actions = WorkflowActionInfoProvider.GetWorkflowActions(where, null); if (!DataHelper.DataSourceIsEmpty(actions)) { // Loop through the individual items foreach (WorkflowActionInfo modifyAction in actions) { // Update the properties modifyAction.ActionDisplayName = modifyAction.ActionDisplayName.ToUpper(); // Save the changes WorkflowActionInfoProvider.SetWorkflowActionInfo(modifyAction); } return(true); } return(false); }
/// <summary> /// Field editor updated event. /// </summary> private void fieldEditor_OnAfterDefinitionUpdate(object sender, EventArgs e) { if (ActionInfo != null) { ActionInfo.ActionParameters = fieldEditor.FormDefinition; WorkflowActionInfoProvider.SetWorkflowActionInfo(ActionInfo); } }
/// <summary> /// Deletes action. Called when the "Delete action" button is pressed. /// Expects the CreateAction method to be run first. /// </summary> private bool DeleteAction() { // Get the action WorkflowActionInfo deleteAction = WorkflowActionInfoProvider.GetWorkflowActionInfo("MyNewAction", WorkflowTypeEnum.Approval); // Delete the action WorkflowActionInfoProvider.DeleteWorkflowActionInfo(deleteAction); return(deleteAction != null); }
// Individual upgrade methods belong here /// <summary> /// Update all "Log Activity Action" steps. Replace value in ActivityCampaign field where <see cref="CampaignInfo.CampaignName"/> is stored by <see cref="CampaignInfo.CampaignID"/>. /// </summary> private static void UpdateCustomActivityActionStep() { var customActivityAction = WorkflowActionInfoProvider.GetWorkflowActions() .WhereEquals("ActionName", "Log_custom_activity") .FirstOrDefault(); if (customActivityAction == null) { return; } WorkflowStepInfoProvider.GetWorkflowSteps() .WhereEquals("StepActionID", customActivityAction.ActionID) .ToList() .ForEach(UpdateCustomActivityStep); }
/// <summary> /// Gets and updates action. Called when the "Get and update action" button is pressed. /// Expects the CreateAction method to be run first. /// </summary> private bool GetAndUpdateAction() { // Get the action WorkflowActionInfo updateAction = WorkflowActionInfoProvider.GetWorkflowActionInfo("MyNewAction", WorkflowTypeEnum.Approval); if (updateAction != null) { // Update the properties updateAction.ActionDisplayName = updateAction.ActionDisplayName.ToLowerCSafe(); // Save the changes WorkflowActionInfoProvider.SetWorkflowActionInfo(updateAction); return(true); } return(false); }
/// <summary> /// Creates workflow action. Called when the "Create action" button is pressed. /// </summary> private bool CreateAction() { // Create new workflow action WorkflowActionInfo newAction = new WorkflowActionInfo(); // Set the properties newAction.ActionDisplayName = "My new action"; newAction.ActionName = "MyNewAction"; newAction.ActionAssemblyName = "MyNewActionAssembly"; newAction.ActionClass = "MyNewActionClass"; newAction.ActionEnabled = true; // Save the action WorkflowActionInfoProvider.SetWorkflowActionInfo(newAction); return(true); }
/// <summary> /// Adds group for actions. /// </summary> /// <param name="where">Pattern to be used to filter actions</param> private void AddActionGroup(string where) { string condition = "ActionEnabled = 1"; // Allowed objects condition = SqlHelper.AddWhereCondition(condition, "ActionAllowedObjects IS NULL OR ActionAllowedObjects LIKE N'%" + Workflow.WorkflowAllowedObjects + "%'"); // Workflow type condition = SqlHelper.AddWhereCondition(condition, Workflow.IsAutomation ? "ActionWorkflowType = " + (int)Workflow.WorkflowType : "ActionWorkflowType = " + (int)Workflow.WorkflowType + " OR ActionWorkflowType IS NULL"); InfoDataSet <WorkflowActionInfo> actions = WorkflowActionInfoProvider.GetWorkflowActions(condition, "ActionDisplayName", "ActionID, ActionThumbnailGUID, ActionThumbnailClass, ActionDisplayName, ActionDescription, ActionIconGUID, ActionIconClass"); List <Item> nodesMenuItems = Factory.GetSettingsObjectBy(actions); nodesMenuItems = FilterList(nodesMenuItems, where); nodesMenuItems = nodesMenuItems.OrderBy(i => i.Text).ToList(); if (nodesMenuItems.Count > 0) { KeyValuePair <string, object> nodesValue = new KeyValuePair <string, object>("NodesMenuItems", nodesMenuItems); AppendGroup(NodesControlPath, nodesValue, ""); } }
/// <summary> /// Returns true if process had passed through one/all selected automation actions. /// </summary> /// <param name="state">Process instance to check</param> /// <param name="actions">Automation action names separated with a semicolon</param> /// <param name="allActions">If true all actions must have been passed.</param> public static bool PassedThroughActions(object state, string actions, bool allActions) { AutomationStateInfo si = state as AutomationStateInfo; if (si != null) { if (!String.IsNullOrEmpty(actions)) { // Get IDs of action steps this process visited in history string historyWhere = String.Format("HistoryStepType = {0} AND HistoryStateID = {1}", (int)WorkflowStepTypeEnum.Action, si.StateID); var history = AutomationHistoryInfoProvider.GetAutomationHistories(historyWhere, null, 0, "HistoryStepID"); // Get action IDs of actions associated to the visited action steps string stepWhere = SqlHelperClass.GetWhereCondition("StepID", history.Select <AutomationHistoryInfo, int>(h => h.HistoryStepID).ToList()); var actionSteps = WorkflowStepInfoProvider.GetWorkflowSteps(stepWhere, null, 0, "StepActionID"); string[] selectedActions = actions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Get action infos to visited actions that have selected name string actionWhere = SqlHelperClass.GetWhereCondition("ActionID", actionSteps.Select <WorkflowStepInfo, int>(s => s.StepActionID).ToList()); actionWhere = SqlHelperClass.AddWhereCondition(actionWhere, SqlHelperClass.GetWhereCondition("ActionName", selectedActions)); var actionInfos = WorkflowActionInfoProvider.GetWorkflowActions(actionWhere, null, "ActionName").Items; // Return true if all/any actions were visited in history return(allActions ? (actionInfos.Count == selectedActions.Length) : (actionInfos.Count > 0)); } else if (allActions) { // No actions were selected return(true); } } return(false); }
/// <summary> /// Returns true if document had passed through one/all selected workflow actions. /// </summary> /// <param name="document">Document to check</param> /// <param name="actions">Workflow action names separated with a semicolon</param> /// <param name="allActions">If true all actions must have been passed.</param> public static bool PassedThroughActions(object document, string actions, bool allActions) { TreeNode doc = document as TreeNode; if (doc != null) { if (!String.IsNullOrEmpty(actions)) { // Get IDs of action steps this document visited in history string historyWhere = String.Format("StepType = {0} AND HistoryObjectID = {1} AND HistoryObjectType = '{2}'", (int)WorkflowStepTypeEnum.Action, doc.DocumentID, DocumentObjectType.DOCUMENT); var history = WorkflowHistoryInfoProvider.GetWorkflowHistories(historyWhere, null, 0, "StepID"); // Get action IDs of actions associated to the visited action steps string stepWhere = SqlHelperClass.GetWhereCondition("StepID", history.Select <WorkflowHistoryInfo, int>(h => h.StepID).ToList()); var actionSteps = WorkflowStepInfoProvider.GetWorkflowSteps(stepWhere, null, 0, "StepActionID"); string[] selectedActions = actions.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // Get action infos to visited actions that have selected name string actionWhere = SqlHelperClass.GetWhereCondition("ActionID", actionSteps.Select <WorkflowStepInfo, int>(s => s.StepActionID).ToList()); actionWhere = SqlHelperClass.AddWhereCondition(actionWhere, SqlHelperClass.GetWhereCondition("ActionName", selectedActions)); var actionInfos = WorkflowActionInfoProvider.GetWorkflowActions(actionWhere, null, "ActionName").Items; // Return true if all/any actions were visited in history return(allActions ? (actionInfos.Count == selectedActions.Length) : (actionInfos.Count > 0)); } else if (allActions) { // No actions were selected return(true); } } return(false); }
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"); }
/// <summary> /// Loads data of edited workflow from DB into TextBoxes. /// </summary> protected void LoadData(WorkflowStepInfo wsi) { // Timeout UI is always enabled for wait step type ucTimeout.AllowNoTimeout = (wsi.StepType != WorkflowStepTypeEnum.Wait); // Display action parameters form only for action step type if (wsi.StepIsAction) { WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(wsi.StepActionID); if (action != null) { if (!RequestHelper.IsPostBack()) { pnlContainer.CssClass += " " + action.ActionName.ToLowerCSafe(); } ucActionParameters.FormInfo = new FormInfo(action.ActionParameters); lblParameters.Text = String.Format(GetString("workflowstep.parameters"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(action.ActionDisplayName))); } ucActionParameters.BasicForm.AllowMacroEditing = true; ucActionParameters.BasicForm.ShowValidationErrorMessage = false; ucActionParameters.BasicForm.ResolverName = WorkflowHelper.GetResolverName(CurrentWorkflow); ucActionParameters.Parameters = wsi.StepActionParameters; ucActionParameters.ReloadData(!RequestHelper.IsPostBack()); ucActionParameters.Visible = ucActionParameters.CheckVisibility(); } plcParameters.Visible = ucActionParameters.Visible; if (plcTimeoutTarget.Visible) { ucTimeoutTarget.WorkflowStepID = CurrentStepInfo.StepID; } // Initialize condition edit for certain step types ucSourcePointEdit.StopProcessing = true; if ((CurrentWorkflow != null) && !CurrentWorkflow.IsBasic) { bool conditionStep = (wsi.StepType == WorkflowStepTypeEnum.Condition); if (conditionStep || (wsi.StepType == WorkflowStepTypeEnum.Wait) || (!wsi.StepIsStart && !wsi.StepIsAction && !wsi.StepIsFinished && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin))) { // Initialize source point edit control var sourcePoint = CurrentStepInfo.StepDefinition.DefinitionPoint; if (sourcePoint != null) { plcCondition.Visible = true; lblCondition.ResourceString = conditionStep ? "workflowstep.conditionsettings" : "workflowstep.advancedsettings"; ucSourcePointEdit.StopProcessing = false; ucSourcePointEdit.SourcePointGuid = sourcePoint.Guid; ucSourcePointEdit.SimpleMode = !conditionStep; ucSourcePointEdit.ShowCondition = (wsi.StepType != WorkflowStepTypeEnum.Userchoice) && (wsi.StepType != WorkflowStepTypeEnum.Multichoice) && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin); ucSourcePointEdit.RuleCategoryNames = CurrentWorkflow.IsAutomation ? ModuleName.ONLINEMARKETING : WorkflowInfo.OBJECT_TYPE; } } } if (!RequestHelper.IsPostBack()) { if (ShowTimeout) { ucTimeout.TimeoutEnabled = wsi.StepDefinition.TimeoutEnabled; ucTimeout.ScheduleInterval = wsi.StepDefinition.TimeoutInterval; } } }
/// <summary> /// Loads data of edited workflow from DB into TextBoxes. /// </summary> protected void LoadData(WorkflowStepInfo wsi) { // Don't display settings for archived, edit and action step plcReject.Visible = !wsi.StepIsArchived && !wsi.StepIsEdit && !wsi.StepIsStart && !wsi.StepIsAction; // Change reject label if (CurrentWorkflow.IsAutomation) { lblAllowReject.ResourceString = "WorkflowStep.AllowMoveToPrevious"; lblAllowReject.RefreshText(); } // Display settings for Standard, DocumentEdit and Start step type only plcPublish.Visible = !CurrentWorkflow.IsAutomation && ((wsi.StepType == WorkflowStepTypeEnum.Standard) || wsi.StepIsEdit || wsi.StepIsStart || (wsi.StepType == WorkflowStepTypeEnum.Wait)); // Timeout UI is always enabled for wait step type ucTimeout.AllowNoTimeout = (wsi.StepType != WorkflowStepTypeEnum.Wait); // Display action parameters form only for action step type if (wsi.StepIsAction) { WorkflowActionInfo action = WorkflowActionInfoProvider.GetWorkflowActionInfo(wsi.StepActionID); if (action != null) { if (!RequestHelper.IsPostBack()) { pnlContainer.CssClass += " " + action.ActionName.ToLowerCSafe(); } ucActionParameters.FormInfo = new FormInfo(action.ActionParameters); } ucActionParameters.BasicForm.AllowMacroEditing = true; ucActionParameters.BasicForm.ResolverName = WorkflowHelper.GetResolverName(CurrentWorkflow); ucActionParameters.Parameters = wsi.StepActionParameters; ucActionParameters.ReloadData(!RequestHelper.IsPostBack()); ucActionParameters.Visible = ucActionParameters.CheckVisibility(); pnlParameters.GroupingText = string.Format(GetString("workflowstep.parameters"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(action.ActionDisplayName))); } pnlParameters.Visible = ucActionParameters.Visible; if (plcTimeoutTarget.Visible) { ucTimeoutTarget.WorkflowStepID = WorkflowStepID; } // Initialize condition edit for certain step types ucSourcePointEdit.StopProcessing = true; if (!CurrentWorkflow.IsBasic) { plcStepType.Visible = true; WorkflowNode node = WorkflowNode.GetInstance(wsi.StepType); lblWorkflowStepTypeValue.Text = node.Name; bool conditionStep = (wsi.StepType == WorkflowStepTypeEnum.Condition); if (conditionStep || (wsi.StepType == WorkflowStepTypeEnum.Wait) || (!wsi.StepIsStart && !wsi.StepIsAction && !wsi.StepIsFinished && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin))) { // Initialize source point edit control ucSourcePointEdit.WorkflowStepId = WorkflowStepID; var sourcePoint = CurrentStepInfo.StepDefinition.DefinitionPoint; if (sourcePoint != null) { pnlCondition.Visible = true; pnlCondition.GroupingText = conditionStep ? GetString("workflowstep.conditionsettings") : GetString("workflowstep.advancedsettings"); ucSourcePointEdit.StopProcessing = false; ucSourcePointEdit.SourcePointGuid = sourcePoint.Guid; ucSourcePointEdit.SimpleMode = !conditionStep; ucSourcePointEdit.ShowCondition = (wsi.StepType != WorkflowStepTypeEnum.Userchoice) && (wsi.StepType != WorkflowStepTypeEnum.Multichoice) && (wsi.StepType != WorkflowStepTypeEnum.MultichoiceFirstWin); ucSourcePointEdit.RuleCategoryNames = CurrentWorkflow.IsAutomation ? ModuleEntry.ONLINEMARKETING : WorkflowObjectType.WORKFLOW; } } } if (!RequestHelper.IsPostBack()) { if (ShowTimeout) { ucTimeout.TimeoutEnabled = wsi.StepDefinition.TimeoutEnabled; ucTimeout.ScheduleInterval = wsi.StepDefinition.TimeoutInterval; } txtWorkflowStepCodeName.Text = wsi.StepName; txtWorkflowStepDisplayName.Text = wsi.StepDisplayName; chkAllowReject.Checked = wsi.StepAllowReject; chkAllowPublish.Checked = wsi.StepAllowPublish; } }
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; } }