public MainForm() { InitializeComponent(); queue = new Queue(this); autoManager = new AutomationManager(this); LoadSettings(); if (string.IsNullOrEmpty(options.botName) || string.IsNullOrEmpty(options.password) || string.IsNullOrEmpty(options.channelName) || string.IsNullOrEmpty(options.host) && options.port >= 1 && options.port <= 65535) { if (MessageBox.Show("It appears that this is the first time you are running this application. Setup is required.", "Setup Required!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) { SettingsButton_Click(null, EventArgs.Empty); } } // Empty all fields. PlayerNameText.Text = ""; PlayerQueuedText.Text = ""; PlayerNameText2.Text = ""; PlayerQueuedText2.Text = ""; PlayerDeQueuedText2.Text = ""; metroTabControl1.SelectTab(0); metroTabControl2.SelectTab(0); }
private string ExecuteProcess(int processId, ObjectQuery <ContactInfo> query) { AutomationManager manager = AutomationManager.GetInstance(CurrentUser); string error = string.Empty; using (new CMSActionContext() { AllowAsyncActions = false }) { query.ForEachPage(contacts => { foreach (var contact in contacts) { try { manager.StartProcess(contact, processId); } catch (ProcessRecurrenceException ex) { error += "<div>" + ex.Message + "</div>"; } } }, 10000); } return(error); }
void UniSelector_OnItemsSelected(object sender, EventArgs e) { try { int contactId = ValidationHelper.GetInteger(ucSelector.Value, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var infoObj = ContactInfoProvider.GetContactInfo(contactId); if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(infoObj.ContactSiteID))) { using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; manager.StartProcess(infoObj, ProcessID); } } } catch (ProcessRecurrenceException ex) { ShowError(ex.Message); } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } listContacts.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Gets the automation state and move contact to specific step. Called when the "Move to specific step" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool MoveContactToSpecificStep() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null)) { // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Get the automation state AutomationStateInfo state = contact.Processes.FirstItem as AutomationStateInfo; if (state != null) { // Get the finished step WorkflowStepInfo finishedStep = manager.GetFinishedStep(contact, state); // Move contact to specific step manager.MoveToSpecificStep(contact, state, finishedStep, "Move to specific step"); return(true); } } return(false); }
public MainWindowViewModel(IDeviceValidator validator, INotificationService notificationService, IWindowManager manager) { this.validator = validator; this.logger = new TextLogger("../../../log.txt", true); this.notificationService = notificationService; Items = new ObservableCollection <Device>(); Connected = false; this.manager = manager; LogCommand = new GUIICommand(ShowLogs); commandExecutor = new CommandExecutor(logger); commandProcessor = new CommandProcessor(notificationService, validator, commandExecutor, logger); alarmProcessor = new AlarmProcessor(logger); automationManager = new AutomationManager(commandExecutor, Items, logger); try { LoadFromConfiguration(); factory = new ChannelFactory <IService>(new NetTcpBinding(), $"net.tcp://localhost:{servicePort}/WCFService"); proxy = factory.CreateChannel(); Connected = false; UpdateEvent += MainWindowViewModel_UpdateEvent; acquisitor = new Acquisitor(Items, acquisitionInterval, factory, commandExecutor, logger, automationManager); } catch (Exception ex) { notificationService.ShowNotification("Server", $"Error: {ex.Message}, ST: {ex.StackTrace}", Notifications.Wpf.NotificationType.Error); } }
protected override void OnInit(EventArgs e) { // Store client ID before replaced by short ID (original ID is needed when sending AJAX request to identify the control) originalClientId = ClientID; var parameters = Request.Form["params"]; if (parameters != null) { if (parameters.StartsWith(CALLBACK_ID + originalClientId, StringComparison.Ordinal)) { string[] args = parameters.Split(new[] { CALLBACK_SEP }, StringSplitOptions.None); AutomationManager.Mode = FormModeEnum.Update; AutomationManager.ClearObject(); AutomationManager.ObjectType = ValidationHelper.GetString(args[1], null); AutomationManager.ObjectID = ValidationHelper.GetInteger(args[2], 0); Response.Clear(); if (Step != null) { Response.Write(CALLBACK_ID + AutomationManager.GetAutomationInfo() + CALLBACK_SEP + AutomationManager.RefreshActionContent.ToString().ToLowerCSafe() + CALLBACK_SEP + Step.StepID); } else { Response.Write(CALLBACK_ID + AutomationManager.GetAutomationInfo() + CALLBACK_SEP + "false" + CALLBACK_SEP + "0"); } Response.End(); return; } } base.OnInit(e); // Perform full post-back if not in update panel menu.PerformFullPostBack = !ControlsHelper.IsInUpdatePanel(this); }
void UniSelector_OnItemsSelected(object sender, EventArgs e) { try { int processId = ValidationHelper.GetInteger(ucSelector.Value, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var infoObj = ProviderHelper.GetInfoById(listElem.ObjectType, listElem.ObjectID); using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; manager.StartProcess(infoObj, processId); } } catch (ProcessRecurrenceException ex) { ShowError(ex.Message); } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } listElem.UniGrid.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Registers action scripts /// </summary> private void RegisterActionScripts() { StringBuilder sb = new StringBuilder(); bool addComment = false; sb.Append("function CheckConsistency_", ClientID, "() { ", AutomationManager.GetJSFunction("CONS", null, null), "; } \n"); if (next != null) { addComment = true; sb.Append("function MoveNext_", ClientID, "(stepId, comment) { ", next.OnClientClick, AutomationManager.GetJSFunction(next.EventName, "stepId", "comment"), "; } \n"); } if (specific != null) { addComment = true; sb.Append("function MoveSpecific_", ClientID, "(stepId, comment) { ", specific.OnClientClick, AutomationManager.GetJSFunction(specific.EventName, "stepId", "comment"), "; } \n"); } if (previous != null) { addComment = true; sb.Append("function MovePrevious_", ClientID, "(historyId, comment) { ", previous.OnClientClick, AutomationManager.GetJSFunction(previous.EventName, "historyId", "comment"), "; } \n"); } if (addComment) { sb.Append("function AddComment_", ClientID, "(name, stateId, menuId) { ", AutomationManager.GetJSFunction(ComponentEvents.COMMENT, "name|stateId|menuId", null), "; } \n"); } // Register the script if (sb.Length > 0) { ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "AutoMenuActions" + ClientID, ScriptHelper.GetScript(sb.ToString())); } }
/// <summary> /// Gets the automation state and move contact to previous step. Called when the "Move to previous step" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool MoveContactToPreviousStep() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null)) { // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Get the process state AutomationStateInfo state = contact.Processes.FirstItem as AutomationStateInfo; if (state != null) { // Move contact to next step manager.MoveToPreviousStep(contact, state, "Move to previous step"); return(true); } } return(false); }
protected override void OnLoad(EventArgs e) { // Handle callback in OnLoad event because of ShortIDs var parameters = Request.Form["params"]; if (parameters != null) { if (parameters.StartsWith(CALLBACK_ID + ClientID)) { string[] args = parameters.Split(new string[] { CALLBACK_SEP }, StringSplitOptions.None); AutomationManager.Mode = FormModeEnum.Update; AutomationManager.ClearObject(); AutomationManager.ObjectType = ValidationHelper.GetString(args[1], null); AutomationManager.ObjectID = ValidationHelper.GetInteger(args[2], 0); Response.Clear(); if (Step != null) { Response.Write(CALLBACK_ID + AutomationManager.GetAutomationInfo() + CALLBACK_SEP + AutomationManager.RefreshActionContent.ToString().ToLowerCSafe() + CALLBACK_SEP + Step.StepID); } else { Response.Write(CALLBACK_ID + AutomationManager.GetAutomationInfo() + CALLBACK_SEP + "false" + CALLBACK_SEP + "0"); } Response.End(); return; } } base.OnLoad(e); // Perform full post-back if not in update panel menu.PerformFullPostBack = !ControlsHelper.IsInUpdatePanel(this); }
/// <summary> /// Creates automation state. Called when the "Start process" button is pressed. /// Expects the CreateProcess, CreateProcessStep and CreateTemporaryObjects method to be run first. /// </summary> private bool CreateAutomationState() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null)) { // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Start the process manager.StartProcess(contact, process.WorkflowID); return(true); } return(false); }
private void UniSelector_OnItemsSelected(object sender, EventArgs e) { var contacts = ValidationHelper.GetString(ucSelector.Value, null); if (String.IsNullOrEmpty(contacts) || !WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, CurrentSiteName)) { return; } var contactIds = contacts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(i => ValidationHelper.GetInteger(i, 0)); var manager = AutomationManager.GetInstance(CurrentUser); var processId = UIContext.ObjectID; var warningBuilder = new StringBuilder(); using (CMSActionContext context = new CMSActionContext { AllowAsyncActions = false }) { try { foreach (var contactId in contactIds) { var contact = ContactInfo.Provider.Get(contactId); try { manager.StartProcess(contact, processId); } catch (ProcessRecurrenceException ex) { warningBuilder.AppendFormat("<div>{0}</div>", ex.Message); } } } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); return; } } var warning = warningBuilder.ToString(); if (!String.IsNullOrEmpty(warning)) { ShowWarning(String.Format(GetString("sf.automation.error"), ""), warning); } else { ShowConfirmation(GetString("ma.process.startedselected")); } // Reload grid listContacts.ReloadData(); pnlUpdate.Update(); // Reset selector ucSelector.Value = null; }
protected void Page_Load(object sender, EventArgs e) { // Check permissions if (AutomationManager.IsActionAllowed(ActionName)) { InitControls(); } else { Visible = false; } }
private void gridState_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { case "delete": int stateId = ValidationHelper.GetInteger(actionArgument, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var obj = CMSObjectHelper.GetObjectById(ObjectType, ObjectID); var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId); manager.RemoveProcess(obj, state); break; } }
void Process_OnItemsSelected(object sender, EventArgs e) { try { int processId = ValidationHelper.GetInteger(processSelector.Value, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); ContactGroupContactListInfo listInfo = new ContactGroupContactListInfo(); var contacts = listInfo.Generalized.GetData(null, GetWhereCondition(), null, 0, "ContactID", false); if (!DataHelper.DataSourceIsEmpty(contacts)) { string error = null; using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; foreach (DataRow row in contacts.Tables[0].Rows) { // Get contact int contactId = ValidationHelper.GetInteger(row[0], 0); var contact = ContactInfoProvider.GetContactInfo(contactId); try { // Start process manager.StartProcess(contact, processId); } catch (ProcessRecurrenceException ex) { error += ex.Message + "<br />"; } } } if (string.IsNullOrEmpty(error)) { ShowConfirmation(GetString("ma.process.started")); } else { ShowError(GetString("ma.process.error"), error, null); } } } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } gridElem.ReloadData(); pnlUpdate.Update(); }
private void ClearProperties() { // Clear actions next = null; specific = null; previous = null; delete = null; start = null; mStep = null; // Clear security result AutomationManager.ClearProperties(); }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); ReloadMenu(); // Display information AutomationManager.ShowAutomationInfo(); // Hide menu if no actions Visible &= menu.Visible || pnlHelp.Visible || !string.IsNullOrEmpty(pnlDoc.Label.Text); if (Visible) { RegisterActionScripts(); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); ReloadMenu(); // Display information AutomationManager.ShowAutomationInfo(); // Hide menu if no actions plcMenu.Visible = menu.HasAnyVisibleAction() || !string.IsNullOrEmpty(pnlDoc.Label.Text) || lblInfo.Visible; if (plcMenu.Visible) { RegisterActionScripts(); } }
/// <summary> /// Remove contact from process. Called when the "Remove contact from process" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool RemoveContactFromProcess() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (DataHelper.DataSourceIsEmpty(contacts) || (process == null)) { return(false); } // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Get the states var states = AutomationStateInfoProvider.GetAutomationStates() .WhereEquals("StateWorkflowID", process.WorkflowID) .WhereEquals("StateObjectID", contact.ContactID) .WhereEquals("StateObjectType", PredefinedObjectType.CONTACT); if (states.Any()) { // Loop through the individual items foreach (AutomationStateInfo state in states) { // Remove contact from process manager.RemoveProcess(contact, state); } return(true); } return(false); }
private void gridState_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { case "delete": int stateId = ValidationHelper.GetInteger(actionArgument, 0); var obj = BaseAbstractInfoProvider.GetInfoById(ObjectType, ObjectID); var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId); if (!CurrentUser.IsAuthorizedPerResource(ModuleName.ONLINEMARKETING, "RemoveProcess", SiteInfoProvider.GetSiteName(state.StateSiteID))) { RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "RemoveProcess"); } AutomationManager manager = AutomationManager.GetInstance(CurrentUser); manager.RemoveProcess(obj, state); break; } }
/// <summary> /// Remove contact from process. Called when the "Remove contact from process" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool RemoveContactFromProcess() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null)) { // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Prepare the parameters where = "StateWorkflowID = " + process.WorkflowID + " AND StateObjectID = " + contact.ContactID + " AND StateObjectType = '" + PredefinedObjectType.CONTACT + "'"; // Get the states InfoDataSet <AutomationStateInfo> states = AutomationStateInfoProvider.GetStates(where, null); if (!DataHelper.DataSourceIsEmpty(states)) { // Loop through the individual items foreach (AutomationStateInfo state in states) { // Remove contact from process manager.RemoveProcess(contact, state); } return(true); } } return(false); }
public AssertRWebElement(RWebElement element, AutomationManager automationManager) { _element = element; }
public Have(ExpressionBuilder expression, RWebElement rWebElement, AutomationManager automationManager) { _expression = expression; _rWebElement = rWebElement; _automationManager = automationManager; }
private void RecaptureHandles(IntPtr hwndShellView) { bool fIsSysListView = false; IntPtr hwndListView = WindowUtils.FindChildWindow(hwndShellView, hwnd => { string name = PInvoke.GetClassName(hwnd); if(name == "SysListView32") { fIsSysListView = true; return true; } else if(!QTUtility.IsXP && name == "DirectUIHWND") { fIsSysListView = false; return true; } return false; }); if(CurrentListView != null) { if(CurrentListView.Handle == hwndListView) { return; } PreviousListView = CurrentListView; } if(hwndListView == IntPtr.Zero) { CurrentListView = new AbstractListView(); } else if(fIsSysListView) { CurrentListView = new ExtendedSysListView32(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect); } else { if(AutoMan == null) { AutoMan = new AutomationManager(); } CurrentListView = new ExtendedItemsView(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect, AutoMan); } CurrentListView.ListViewDestroyed += ListView_Destroyed; ListViewChanged(this, null); }
internal ExtendedItemsView(ShellBrowserEx ShellBrowser, IntPtr hwndShellView, IntPtr hwndListView, IntPtr hwndSubDirTipMessageReflect, AutomationManager AutoMan) : base(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect) { this.AutoMan = AutoMan; }
public TestAppPage(AutomationManager automationManager) : base(automationManager) { }
public RWebElementCollection(AutomationManager automationManager, BaseElementFinder <ReadOnlyCollection <IWebElement> > context) { _context = context; _automationManager = automationManager; }
private void StartNewProcess(What what, string where) { try { AutomationManager manager = AutomationManager.GetInstance(CurrentUser); List <string> contactIds = null; switch (what) { case What.All: // Get selected IDs based on where condition DataSet contacts = ContactGroupMemberInfoProvider.GetRelationships().Where(where).Column("ContactGroupMemberRelatedID"); if (!DataHelper.DataSourceIsEmpty(contacts)) { contactIds = DataHelper.GetUniqueValues(contacts.Tables[0], "ContactGroupMemberRelatedID", true); } break; case What.Selected: contactIds = gridElem.SelectedItems; break; } if (contactIds != null) { string error = String.Empty; using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; int processId = ValidationHelper.GetInteger(hdnIdentifier.Value, 0); foreach (string contactId in contactIds) { var contact = ContactInfoProvider.GetContactInfo(ValidationHelper.GetInteger(contactId, 0)); try { manager.StartProcess(contact, processId); } catch (ProcessRecurrenceException ex) { error += "<div>" + ex.Message + "</div>"; } } } if (String.IsNullOrEmpty(error)) { string confirmation = GetString(what == What.All ? "ma.process.started" : "ma.process.startedselected"); ShowConfirmation(confirmation); } else { ShowError(GetString("ma.process.error"), error, null); } } } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } }
public void Dispose() { if(fDisposed) return; if(CurrentListView != null) { CurrentListView.Dispose(); CurrentListView = null; } if(AutoMan != null) { AutoMan.Dispose(); AutoMan = null; } fDisposed = true; }
private void RecaptureHandles(IntPtr hwndShellView) { if(CurrentListView != null) { CurrentListView.Dispose(); } hwndEnumResult = IntPtr.Zero; PInvoke.EnumChildWindows(hwndShellView, CallbackEnumChildProc_ListView, IntPtr.Zero); if(hwndEnumResult == IntPtr.Zero) { CurrentListView = new AbstractListView(); } else if(fIsSysListView) { CurrentListView = new ExtendedSysListView32(ShellBrowser, hwndShellView, hwndEnumResult, hwndSubDirTipMessageReflect); } else { if(AutoMan == null) { AutoMan = new AutomationManager(); } CurrentListView = new ExtendedItemsView(ShellBrowser, hwndShellView, hwndEnumResult, hwndSubDirTipMessageReflect, AutoMan); } CurrentListView.ListViewDestroyed += ListView_Destroyed; ListViewChanged(this, null); }
public Manage(IRWebDriver driver, AutomationManager automationManager) { _driver = driver; _automationManager = automationManager; }
public RWebElementCollection(AutomationManager automationManager, By locator, [CallerMemberName] string name = "") { Name = name; _context = new ElementsFinder(locator, name, automationManager.Driver); _automationManager = automationManager; }
public StringShould(ExpressionBuilder <string> condition, AutomationManager automationManager, RWebElement rWebElement) { _automationManager = automationManager; _condition = condition; _rWebElement = rWebElement; }
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"); }
internal event MouseLeaveHandler MouseLeave; // SysListView Only internal ListViewWrapper(IShellBrowser ShellBrowser, IntPtr ExplorerHandle) { this.ShellBrowser = ShellBrowser; this.ExplorerHandle = ExplorerHandle; AutoMan = new AutomationManager(); if(QTUtility.IsVista) { hwndEnumResult = IntPtr.Zero; PInvoke.EnumChildWindows(ExplorerHandle, new EnumWndProc(this.CallbackEnumChildProc_Container), IntPtr.Zero); ShellContainer = hwndEnumResult; } else { ShellContainer = ExplorerHandle; } if(ShellContainer != IntPtr.Zero) { ContainerController = new NativeWindowController(ShellContainer); ContainerController.MessageCaptured += new NativeWindowController.MessageEventHandler(ContainerController_MessageCaptured); } Initialize(); }