示例#1
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();
        }
示例#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);
                    }
                }
            }
            IsSaveEnabled();
        }
示例#3
0
        public override bool EditAgent()
        {
            INotifier agent = NotifierHost.CreateNotifierFromClassName(AgentType);

            if (agent != null)
            {
                agent.Name    = AgentName;
                agent.Enabled = AgentEnabled;
                EditNotifierAgentEntry editNotifierAgentEntry = new EditNotifierAgentEntry();
                agent.InitialConfiguration = SelectedAgentConfig;
                agent.AgentConfig.FromXml(SelectedAgentConfig);
                editNotifierAgentEntry.SelectedEntry = agent;
                editNotifierAgentEntry.DetailEditor  = DetailEditor;
                if (editNotifierAgentEntry.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    agent               = editNotifierAgentEntry.SelectedEntry;
                    AgentName           = agent.Name;
                    AgentEnabled        = agent.Enabled;
                    SelectedAgentConfig = agent.AgentConfig.ToXml();
                    return(true);
                }
            }
            return(false);
        }