public void ChangeActionType(MacroActionType actionType) { if (actionType == MacroActionType.Distribute || actionType == MacroActionType.Wait) { throw new ArgumentException("Cannot change action type of macro process action to distribute and wait"); } Type = actionType; }
public MacroWaitAction(Guid id, MacroActionType type, MacroActionWaitForEvent waitForEvent, int timeoutMilliseconds = 0) { if (type != MacroActionType.Wait) { throw new ArgumentException("Invalid wait action type"); } ID = id; Type = type; WaitForEvent = waitForEvent; TimeoutMilliseconds = timeoutMilliseconds; }
public MacroProcessAction(Guid id, MacroActionType type, Guid machineID, Guid groupID, Guid applicationID) { if (type != MacroActionType.Start && type != MacroActionType.Stop && type != MacroActionType.Restart) { throw new ArgumentException("Invalid process action type"); } ID = id; Type = type; MachineID = machineID; GroupID = groupID; ApplicationID = applicationID; }
public MacroDistributionAction(Guid id, MacroActionType type, Guid sourceMachineID, Guid groupID, Guid applicationID, Guid destinationMachineID) { if (type != MacroActionType.Distribute) { throw new ArgumentException("Invalid distribution action type"); } ID = id; Type = type; SourceMachineID = sourceMachineID; GroupID = groupID; ApplicationID = applicationID; DestinationMachineID = destinationMachineID; }
private MacroMachineNode(Guid id, Guid machineID, MacroActionType type, Macro macro, IEnumerable <IMacroNode> childNodes) : base(childNodes, !Settings.Client.M_CollapsedNodes.Contains(id)) { if (type == MacroActionType.Wait) { throw new ArgumentException("Invalid action type for macro machine node"); } _id = id; MachineID = machineID; Type = type; Macro = macro; _nodeName = GetNodeName(); //BackColor = Color.FromArgb(255, 208, 160); }
public void ChangeActionType(MacroActionType actionType) { if (Type == MacroActionType.Distribute || Type == MacroActionType.Wait) { throw new InvalidOperationException("Cannot change action type of distribution and wait macro actions"); } if (actionType == MacroActionType.Distribute || actionType == MacroActionType.Wait) { throw new ArgumentException("Cannot change action type of process macro actions to distribute and wait"); } Type = actionType; Actions.ForEach(action => action.ChangeActionType(actionType)); }
//private static List<List<IMacroAction>> ChunkMacroActions(IEnumerable<IMacroAction> macroActions) //{ // int chunkNo = 0; // List<List<IMacroAction>> chunkedMacroActions = new List<List<IMacroAction>>(); // foreach (IMacroAction macroAction in macroActions) // { // if (chunkedMacroActions[chunkNo] == null) // chunkedMacroActions[chunkNo] = new List<IMacroAction>(); // chunkedMacroActions[chunkNo].Add(macroAction); // if (macroAction.Type == MacroActionType.Wait) // chunkNo++; // } // return chunkedMacroActions; //} private static ActionType Convert(MacroActionType macroActionType) { switch (macroActionType) { case MacroActionType.Start: return(ActionType.Start); case MacroActionType.Stop: return(ActionType.Stop); case MacroActionType.Restart: return(ActionType.Restart); case MacroActionType.Distribute: return(ActionType.Distribute); default: throw new ArgumentException("No matching ActionType available"); } }
private void SelectActionType(MacroActionType actionType) { if (_macroActionItem != null) { _macroActionItem.MacroActionItemChanged -= MacroActionItem_MacroActionItemChanged; _macroActionItem.Dispose(); panelAction.Controls.Remove((Control)_macroActionItem); _macroActionItem = null; } linkLabelActionType.Text = actionType.ToString(); switch (actionType) { case MacroActionType.Start: case MacroActionType.Stop: case MacroActionType.Restart: ProcessActionBundle?.ChangeActionType(actionType); ActionBundle = ProcessActionBundle ?? new MacroActionBundle(actionType); _macroActionItem = new MacroProcessActionItem(ProcessActionBundle); break; case MacroActionType.Distribute: ActionBundle = DistributionActionBundle ?? new MacroActionBundle(actionType); _macroActionItem = new MacroDistributionActionItem(DistributionActionBundle); break; case MacroActionType.Wait: ActionBundle = WaitActionBundle ?? new MacroActionBundle(actionType); _macroActionItem = new MacroWaitActionItem(WaitActionBundle); break; } if (_macroActionItem != null) { labelSeparator.Visible = true; _macroActionItem.MacroActionItemChanged += MacroActionItem_MacroActionItemChanged; _macroActionItem.SetWidth(panelAction.Width); panelAction.Controls.Add((Control)_macroActionItem); } }
public MacroMachineNode(Guid machineID, MacroActionType type, Macro macro, IEnumerable <IMacroNode> childNodes) : this(MakeID(macro.ID, machineID), machineID, type, macro, childNodes) { }
public MacroWaitAction(MacroActionType type, MacroActionWaitForEvent waitForEvent, int timeoutMilliseconds = 0) : this(Guid.NewGuid(), type, waitForEvent, timeoutMilliseconds) { }
public void ChangeActionType(MacroActionType actionType) { throw new InvalidOperationException("Cannot change action type of macro wait action"); }
public MacroDistributionAction(MacroActionType type, Guid sourceMachineID, Guid groupID, Guid applicationID, Guid destinationMachineID) : this(Guid.NewGuid(), type, sourceMachineID, groupID, applicationID, destinationMachineID) { }
public MacroActionBundle(MacroActionType type) { Type = type; Actions = new List <IMacroAction>(); }
public MacroProcessAction(MacroActionType type, Guid machineID, Guid groupID, Guid applicationID) : this(Guid.NewGuid(), type, machineID, groupID, applicationID) { }
public static void LoadClientSettings(ClientSettingsType clientSettingsType) { RegistryKey key = _registryHive.OpenSubKey(APPLICATION_REGISTRY_KEY, false); if (key == null) { return; } switch (clientSettingsType) { case ClientSettingsType.Machines: Settings.Client.Machines.Clear(); RegistryKey machinesKey = key.OpenSubKey("Machines", false); if (machinesKey != null) { RegistryKey machineKey = machinesKey.OpenSubKey("Machine " + Settings.Client.Machines.Count.ToString("00"), false); while (machineKey != null) { string hostName = (string)machineKey.GetValue("Host Name", "<unknown>"); Settings.Client.Machines.Add(new Machine(hostName)); machineKey.Close(); machineKey = machinesKey.OpenSubKey("Machine " + Settings.Client.Machines.Count.ToString("00"), false); } machinesKey.Close(); } break; case ClientSettingsType.Macros: Settings.Client.Macros.Clear(); RegistryKey macrosKey = key.OpenSubKey("Macros", false); if (macrosKey != null) { foreach (string macroID in macrosKey.GetSubKeyNames()) { RegistryKey macroKey = macrosKey.OpenSubKey(macroID, false); if (macroKey == null) { continue; } string name = (string)macroKey.GetValue("Name", "<unknown>"); Macro macro = new Macro(Guid.Parse(macroID), name); try { RegistryKey bundleKey = macroKey.OpenSubKey("Action Bundle " + macro.ActionBundles.Count.ToString("00"), false); while (bundleKey != null) { string actionTypeStr = (string)bundleKey.GetValue("Action Type"); if (actionTypeStr == null) { break; } MacroActionType actionType = (MacroActionType)Enum.Parse(typeof(MacroActionType), actionTypeStr); MacroActionBundle actionBundle = new MacroActionBundle(actionType); RegistryKey actionKey = bundleKey.OpenSubKey("Action " + actionBundle.Actions.Count.ToString("00"), false); while (actionKey != null) { IMacroAction action = null; string id = (string)actionKey.GetValue("ID"); if (id == null) { break; } switch (actionType) { case MacroActionType.Start: case MacroActionType.Stop: case MacroActionType.Restart: string processMachineID = (string)actionKey.GetValue("Machine ID", Guid.Empty.ToString()); string processGroupID = (string)actionKey.GetValue("Group ID", Guid.Empty.ToString()); string processApplicationID = (string)actionKey.GetValue("Application ID", Guid.Empty.ToString()); action = new MacroProcessAction(Guid.Parse(id), actionType, Guid.Parse(processMachineID), Guid.Parse(processGroupID), Guid.Parse(processApplicationID)); break; case MacroActionType.Distribute: string distributionSourceMachineID = (string)actionKey.GetValue("Source Machine ID", Guid.Empty.ToString()); string distributionGroupID = (string)actionKey.GetValue("Group ID", Guid.Empty.ToString()); string distributionApplicationID = (string)actionKey.GetValue("Application ID", Guid.Empty.ToString()); string distributionDestinationMachineID = (string)actionKey.GetValue("Destination Machine ID", Guid.Empty.ToString()); action = new MacroDistributionAction(Guid.Parse(id), actionType, Guid.Parse(distributionSourceMachineID), Guid.Parse(distributionGroupID), Guid.Parse(distributionApplicationID), Guid.Parse(distributionDestinationMachineID)); break; case MacroActionType.Wait: string waitForEvent = (string)actionKey.GetValue("Wait For Event"); string timeoutMilliseconds = (string)actionKey.GetValue("Timeout Milliseconds", "0"); action = new MacroWaitAction(Guid.Parse(id), actionType, (MacroActionWaitForEvent)Enum.Parse(typeof(MacroActionWaitForEvent), waitForEvent), int.Parse(timeoutMilliseconds)); break; } if (action == null) { break; } actionBundle.Actions.Add(action); actionKey.Close(); actionKey = bundleKey.OpenSubKey("Action " + actionBundle.Actions.Count.ToString("00"), false); } macro.ActionBundles.Add(actionBundle); bundleKey.Close(); bundleKey = macroKey.OpenSubKey("Action Bundle " + macro.ActionBundles.Count.ToString("00"), false); } } catch { continue; } Settings.Client.Macros.Add(macro); macroKey.Close(); } macrosKey.Close(); } break; case ClientSettingsType.Options: RegistryKey optionsKey = key.OpenSubKey("Options", false); if (optionsKey != null) { Settings.Client.StartWithWindows = bool.Parse((string)optionsKey.GetValue("Start With Windows", Settings.Client.Defaults.START_WITH_WINDOWS)); Settings.Client.UserOwnsControlPanel = bool.Parse((string)optionsKey.GetValue("User Owns Control Panel", Settings.Client.Defaults.USER_OWNS_CONTROL_PANEL)); Settings.Client.KeepControlPanelTopMost = bool.Parse((string)optionsKey.GetValue("Keep Control Panel Top Most", Settings.Client.Defaults.KEEP_CONTROL_PANEL_TOP_MOST)); Settings.Client.LogTypeMinLevel = (LogType)Enum.Parse(typeof(LogType), (string)optionsKey.GetValue("Log Type Min Level", Settings.Client.Defaults.LOG_TYPE_MIN_LEVEL)); optionsKey.Close(); } break; case ClientSettingsType.States: RegistryKey statesKey = key.OpenSubKey("States", false); if (statesKey != null) { Settings.Client.CFG_SelectedHostName = (string)statesKey.GetValue("CFG Selected Host Name", Settings.Client.Defaults.SELECTED_HOST_NAME); Settings.Client.CFG_SelectedConfigurationSection = (string)statesKey.GetValue("CFG Selected Configuration Section", Settings.Client.Defaults.SELECTED_CONFIGURATION_SECTION); Settings.Client.CP_SelectedTab = (string)statesKey.GetValue("CP Selected Tab", Settings.Client.Defaults.SELECTED_TAB); Settings.Client.P_SelectedGrouping = (string)statesKey.GetValue("P Selected Grouping", Settings.Client.Defaults.SELECTED_PROCESS_GROUPING); Settings.Client.P_SelectedFilterMachine = (string)statesKey.GetValue("P Selected Filter Machine", Settings.Client.Defaults.SELECTED_PROCESS_FILTER_MACHINE); Settings.Client.P_SelectedFilterGroup = (string)statesKey.GetValue("P Selected Filter Group", Settings.Client.Defaults.SELECTED_PROCESS_FILTER_GROUP); Settings.Client.P_SelectedFilterApplication = (string)statesKey.GetValue("P Selected Filter Application", Settings.Client.Defaults.SELECTED_PROCESS_FILTER_APPLICATION); Settings.Client.P_CheckedNodes.Clear(); RegistryKey checkedNodesKey = statesKey.OpenSubKey("P Checked Nodes", false); if (checkedNodesKey != null) { string nodeID = (string)checkedNodesKey.GetValue("Node " + Settings.Client.P_CheckedNodes.Count.ToString("00")); while (nodeID != null) { Settings.Client.P_CheckedNodes.Add(new Guid(nodeID)); nodeID = (string)checkedNodesKey.GetValue("Node " + Settings.Client.P_CheckedNodes.Count.ToString("00")); } checkedNodesKey.Close(); } Enum.GetValues(typeof(ProcessGrouping)).Cast <ProcessGrouping>().ToList().ForEach(grouping => Settings.Client.P_CollapsedNodes[grouping].Clear()); RegistryKey collapsedNodesKey = statesKey.OpenSubKey("P Collapsed Nodes", false); if (collapsedNodesKey != null) { foreach (ProcessGrouping grouping in Enum.GetValues(typeof(ProcessGrouping))) { RegistryKey groupingKey = collapsedNodesKey.OpenSubKey(grouping.ToString(), false); if (groupingKey != null) { string nodeID = (string)groupingKey.GetValue("Node " + Settings.Client.P_CollapsedNodes[grouping].Count.ToString("00")); while (nodeID != null) { Settings.Client.P_CollapsedNodes[grouping].Add(new Guid(nodeID)); nodeID = (string)groupingKey.GetValue("Node " + Settings.Client.P_CollapsedNodes[grouping].Count.ToString("00")); } groupingKey.Close(); } } collapsedNodesKey.Close(); } Settings.Client.D_SelectedGrouping = (string)statesKey.GetValue("D Selected Grouping", Settings.Client.Defaults.SELECTED_DISTRIBUTION_GROUPING); Settings.Client.D_SelectedFilterSourceMachine = (string)statesKey.GetValue("D Selected Filter Source Machine", Settings.Client.Defaults.SELECTED_DISTRIBUTION_FILTER_SOURCE_MACHINE); Settings.Client.D_SelectedFilterGroup = (string)statesKey.GetValue("D Selected Filter Group", Settings.Client.Defaults.SELECTED_DISTRIBUTION_FILTER_GROUP); Settings.Client.D_SelectedFilterApplication = (string)statesKey.GetValue("D Selected Filter Application", Settings.Client.Defaults.SELECTED_DISTRIBUTION_FILTER_APPLICATION); Settings.Client.D_SelectedFilterDestinationMachine = (string)statesKey.GetValue("D Selected Filter Destination Machine", Settings.Client.Defaults.SELECTED_DISTRIBUTION_FILTER_DESTINATION_MACHINE); Settings.Client.D_CheckedNodes.Clear(); checkedNodesKey = statesKey.OpenSubKey("D Checked Nodes", false); if (checkedNodesKey != null) { string nodeID = (string)checkedNodesKey.GetValue("Node " + Settings.Client.D_CheckedNodes.Count.ToString("00")); while (nodeID != null) { Settings.Client.D_CheckedNodes.Add(new Guid(nodeID)); nodeID = (string)checkedNodesKey.GetValue("Node " + Settings.Client.D_CheckedNodes.Count.ToString("00")); } checkedNodesKey.Close(); } Enum.GetValues(typeof(DistributionGrouping)).Cast <DistributionGrouping>().ToList().ForEach(grouping => Settings.Client.D_CollapsedNodes[grouping].Clear()); collapsedNodesKey = statesKey.OpenSubKey("D Collapsed Nodes", false); if (collapsedNodesKey != null) { foreach (DistributionGrouping grouping in Enum.GetValues(typeof(DistributionGrouping))) { RegistryKey groupingKey = collapsedNodesKey.OpenSubKey(grouping.ToString(), false); if (groupingKey != null) { string nodeID = (string)groupingKey.GetValue("Node " + Settings.Client.D_CollapsedNodes[grouping].Count.ToString("00")); while (nodeID != null) { Settings.Client.D_CollapsedNodes[grouping].Add(new Guid(nodeID)); nodeID = (string)groupingKey.GetValue("Node " + Settings.Client.D_CollapsedNodes[grouping].Count.ToString("00")); } groupingKey.Close(); } } collapsedNodesKey.Close(); } Settings.Client.M_CheckedNodes.Clear(); checkedNodesKey = statesKey.OpenSubKey("M Checked Nodes", false); if (checkedNodesKey != null) { string nodeID = (string)checkedNodesKey.GetValue("Node " + Settings.Client.M_CheckedNodes.Count.ToString("00")); while (nodeID != null) { Settings.Client.M_CheckedNodes.Add(new Guid(nodeID)); nodeID = (string)checkedNodesKey.GetValue("Node " + Settings.Client.M_CheckedNodes.Count.ToString("00")); } checkedNodesKey.Close(); } Settings.Client.M_CollapsedNodes.Clear(); collapsedNodesKey = statesKey.OpenSubKey("M Collapsed Nodes", false); if (collapsedNodesKey != null) { string nodeID = (string)collapsedNodesKey.GetValue("Node " + Settings.Client.M_CollapsedNodes.Count.ToString("00")); while (nodeID != null) { Settings.Client.M_CollapsedNodes.Add(new Guid(nodeID)); nodeID = (string)collapsedNodesKey.GetValue("Node " + Settings.Client.M_CollapsedNodes.Count.ToString("00")); } collapsedNodesKey.Close(); } statesKey.Close(); } break; } key.Close(); }
private void ContextMenu_SelectActionType_ActionTypeClicked(MacroActionType actionType) { SelectActionType(actionType); RaiseMacroActionItemChangedEvent(); }