public static CollectorEntry CreateNewCollector(CollectorEntry parentCollectorEntry = null) { CollectorEntry newCollectorEntry = null; SelectNewAgentType selectNewAgentType = new SelectNewAgentType(); selectNewAgentType.InitialRegistrationName = ""; if (selectNewAgentType.ShowCollectorSelection() == System.Windows.Forms.DialogResult.OK) { LastLaunchAddEntryOption = selectNewAgentType.SelectedPreset == null; LastShowRawEditOnStartOption = selectNewAgentType.ImportConfigAfterSelect; newCollectorEntry = new CollectorEntry(); if (parentCollectorEntry != null) { newCollectorEntry.ParentCollectorId = parentCollectorEntry.UniqueId; } RegisteredAgent ar = null; if (selectNewAgentType.SelectedPreset != null) { ar = RegisteredAgentCache.GetRegisteredAgentByClassName(selectNewAgentType.SelectedPreset.AgentClassName); } else if (selectNewAgentType.SelectedAgent != null) { ar = selectNewAgentType.SelectedAgent; } else { return(null); } if (ar == null) //in case agent is not loaded or available { return(null); } else if (ar.ClassName != "QuickMon.Collectors.Folder") { string initialConfig = ""; if (selectNewAgentType.SelectedPreset != null) { initialConfig = MacroVariables.FormatVariables(selectNewAgentType.SelectedPreset.Config); newCollectorEntry.Name = selectNewAgentType.SelectedPreset.Description; } newCollectorEntry.CreateAndConfigureEntry(ar.ClassName, initialConfig, true, false); } else { newCollectorEntry.IsFolder = true; newCollectorEntry.CollectorRegistrationDisplayName = ar.DisplayName; newCollectorEntry.CollectorRegistrationName = ar.Name; } } return(newCollectorEntry); }
public static NotifierEntry CreateNewNotifier() { NotifierEntry newNotifierEntry = null; SelectNewAgentType selectNewAgentType = new SelectNewAgentType(); selectNewAgentType.InitialRegistrationName = ""; if (selectNewAgentType.ShowNotifierSelection() == System.Windows.Forms.DialogResult.OK) { LastLaunchAddEntryOption = selectNewAgentType.SelectedPreset == null; LastShowRawEditOnStartOption = selectNewAgentType.ImportConfigAfterSelect; newNotifierEntry = new NotifierEntry(); RegisteredAgent ar = null; if (selectNewAgentType.SelectedPreset != null) { ar = RegisteredAgentCache.GetRegisteredAgentByClassName(selectNewAgentType.SelectedPreset.AgentClassName, false); } else if (selectNewAgentType.SelectedAgent != null) { ar = selectNewAgentType.SelectedAgent; } else { return(null); } if (ar == null) //in case agent is not loaded or available { return(null); } else { string initialConfig = ""; if (selectNewAgentType.SelectedPreset != null) { initialConfig = MacroVariables.FormatVariables(selectNewAgentType.SelectedPreset.Config); newNotifierEntry.Name = selectNewAgentType.SelectedPreset.Description; } newNotifierEntry.CreateAndConfigureEntry(ar.ClassName, initialConfig, true, false); } } return(newNotifierEntry); }