Exemple #1
0
        public override bool EditAgent()
        {
            ICollector agent = CollectorHost.CreateCollectorFromClassName(AgentType);

            if (agent != null)
            {
                agent.Name    = AgentName;
                agent.Enabled = AgentEnabled;
                EditCollectorAgentEntries editCollectorAgentEntries = new EditCollectorAgentEntries();
                agent.InitialConfiguration = SelectedAgentConfig;
                agent.AgentConfig.FromXml(SelectedAgentConfig);

                editCollectorAgentEntries.SelectedEntry = agent;
                editCollectorAgentEntries.DetailEditor  = DetailEditor;
                if (editCollectorAgentEntries.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    agent               = editCollectorAgentEntries.SelectedEntry;
                    AgentName           = agent.Name;
                    AgentEnabled        = agent.Enabled;
                    SelectedAgentConfig = agent.AgentConfig.ToXml();
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        private void cboClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (txtConfig.Text.Length == 0)
            if (cboType.SelectedIndex == 2 || cboType.SelectedIndex == 4)
            {
                RegisteredAgent ra = (from r in RegisteredAgentCache.Agents
                                      where r.ClassName.EndsWith(cboClass.Text)
                                      select r).FirstOrDefault();
                if (ra != null)
                {
                    IAgent a;

                    if (ra.IsCollector)
                    {
                        a = CollectorHost.CreateCollectorFromClassName(ra.ClassName.Replace("QuickMon.Collectors.", ""));
                    }
                    else
                    {
                        a = NotifierHost.CreateNotifierFromClassName(ra.ClassName.Replace("QuickMon.Notifiers.", ""));
                    }
                    if (a != null)
                    {
                        string agentConfig = a.AgentConfig.GetDefaultOrEmptyXml();
                        if (cboType.SelectedIndex == 2)
                        {
                            txtConfig.Text = Properties.Resources.BlankTemplateCollectorAgent.Replace("{0}", agentConfig);
                        }
                        else if (cboType.SelectedIndex == 4)
                        {
                            txtConfig.Text = Properties.Resources.BlankTemplateNotifierAgent.Replace("{0}", agentConfig);
                        }
                        //txtConfig.Text = XmlFormattingUtils.NormalizeXML(txtConfig.Text);
                        try
                        {
                            txtConfig.Text = txtConfig.Text.BeautifyXML(); // XmlFormattingUtils.NormalizeXML(txtConfig.Text);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(string.Format("Error formatting xml\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }
            IsSaveEnabled();
        }
Exemple #3
0
        private void cboClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            //if (txtConfig.Text.Length == 0)
            if (cboType.SelectedIndex == 2 || cboType.SelectedIndex == 4)
            {
                RegisteredAgent ra = (from r in RegisteredAgentCache.Agents
                                      where r.ClassName.EndsWith(cboClass.Text)
                                      select r).FirstOrDefault();
                if (ra != null)
                {
                    IAgent a;

                    if (ra.IsCollector)
                    {
                        a = CollectorHost.CreateCollectorFromClassName(ra.ClassName.Replace("QuickMon.Collectors.", ""));
                    }
                    else
                    {
                        a = NotifierHost.CreateNotifierFromClassName(ra.ClassName.Replace("QuickMon.Notifiers.", ""));
                    }
                    if (a != null)
                    {
                        string agentConfig = a.AgentConfig.GetDefaultOrEmptyXml();
                        if (cboType.SelectedIndex == 2)
                        {
                            txtConfig.Text = Properties.Resources.BlankTemplateCollectorAgent.Replace("{0}", agentConfig);
                        }
                        else if (cboType.SelectedIndex == 4)
                        {
                            txtConfig.Text = Properties.Resources.BlankTemplateNotifierAgent.Replace("{0}", agentConfig);
                        }
                        txtConfig.Text = XmlFormattingUtils.NormalizeXML(txtConfig.Text);
                    }
                }
            }
            IsSaveEnabled();
        }