Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void NewAgent()
        {
            //Display a list of existing types of agents/by template...
            //Once type is selected load edit agent with default settings
            //CollectorHost.GetCollectorAgentFromString()
            try
            {
                SelectNewAgentType selectNewAgentType = new SelectNewAgentType();
                if (selectNewAgentType.ShowNotifierSelection() == System.Windows.Forms.DialogResult.OK)
                {
                    INotifier agent = (INotifier)selectNewAgentType.SelectedAgent;
                    if (agent.Name == null || agent.Name.Length == 0)
                    {
                        agent.Name = agent.AgentClassDisplayName;
                    }
                    agent.Enabled = true;

                    ListViewItem lvi = new ListViewItem(agent.Name);
                    if (agent.Enabled)
                    {
                        lvi.ImageIndex = 1;
                    }
                    else
                    {
                        lvi.ImageIndex = 0;
                    }
                    lvi.SubItems.Add(agent.AgentClassDisplayName);
                    lvi.SubItems.Add(agent.AgentConfig.ConfigSummary);
                    lvi.Tag = agent;
                    lvwEntries.Items.Add(lvi);
                    lvwEntries.SelectedItems.Clear();
                    lvi.Selected = true;
                    EditAgent();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            CheckOkEnabled();
        }