コード例 #1
0
 private void cmdConfig_Click(object sender, EventArgs e)
 {
     if (cboCollector.SelectedItem != null)
     {
         try
         {
             AgentRegistration ar  = (AgentRegistration)cboCollector.SelectedItem;
             ICollector        col = CollectorEntry.CreateCollectorEntry(ar.AssemblyPath, ar.ClassName);
             if (col != null)
             {
                 SelectedEntry.Collector = col;
                 if (SelectedEntry.Configuration == null)
                 {
                     SelectedEntry.Configuration = "";
                 }
                 string newConfig = col.ConfigureAgent(SelectedEntry.Configuration);
                 if (newConfig.Length > 0)
                 {
                     SelectedEntry.Configuration = newConfig;
                     CheckOkEnable();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #2
0
        private void configureEditButton1_ImportConfigurationClicked(object sender, EventArgs e)
        {
            ImportCollectorConfig importCollectorConfig = new ImportCollectorConfig();

            importCollectorConfig.IsCollector     = true;
            importCollectorConfig.MonitorPackPath = monitorPack.MonitorPackPath;
            importCollectorConfig.AgentType       = ((RegisteredAgent)cboCollector.SelectedItem).Name;
            if (importCollectorConfig.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                editingCollectorEntry.InitialConfiguration = importCollectorConfig.SelectedConfig;
                RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem;
                editingCollectorEntry.Collector = CollectorEntry.CreateCollectorEntry(ar);
                editingCollectorEntry.Collector.SetConfigurationFromXmlString(importCollectorConfig.SelectedConfig);
                editingCollectorEntry.CollectorRegistrationName = ar.Name;
            }
        }
コード例 #3
0
 private void cmdConfig_Click(object sender, EventArgs e)
 {
     if (cboCollector.SelectedItem != null)
     {
         try
         {
             RegisteredAgent ar = (RegisteredAgent)cboCollector.SelectedItem;
             ICollector      tmpcollector;
             if (editingCollectorEntry == null)
             {
                 editingCollectorEntry = new CollectorEntry();
             }
             tmpcollector = CollectorEntry.CreateCollectorEntry(ar);
             if (tmpcollector != null)
             {
                 if (editingCollectorEntry.Collector != null &&
                     (ar.Name == editingCollectorEntry.CollectorRegistrationName))
                 {
                     tmpcollector.SetConfigurationFromXmlString(editingCollectorEntry.Collector.AgentConfig.ToConfig());
                 }
                 else
                 {
                     tmpcollector.SetConfigurationFromXmlString(tmpcollector.GetDefaultOrEmptyConfigString());
                 }
                 if (txtName.Text.Length == 0)
                 {
                     txtName.Text = "No Name";
                 }
                 if (tmpcollector.ShowEditConfiguration("Edit '" + txtName.Text + "' Config"))
                 {
                     editingCollectorEntry.Collector                 = tmpcollector;
                     editingCollectorEntry.InitialConfiguration      = tmpcollector.AgentConfig.ToConfig();
                     editingCollectorEntry.CollectorRegistrationName = ar.Name;
                 }
             }
             CheckOkEnable();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #4
0
        private void cmdSaveConfig_Click(object sender, EventArgs e)
        {
            XmlDocument testXml = new XmlDocument();

            try
            {
                testXml.LoadXml(txtConfig.Text);
                editingCollectorEntry.InitialConfiguration = txtConfig.Text;
                RegisteredAgent ar           = (RegisteredAgent)cboCollector.SelectedItem;
                ICollector      tmpcollector = CollectorEntry.CreateCollectorEntry(ar);
                editingCollectorEntry.Collector = tmpcollector;
                editingCollectorEntry.Collector.SetConfigurationFromXmlString(txtConfig.Text);
                editingCollectorEntry.CollectorRegistrationName = ar.Name;
                HideManualConfig();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Error parsing xml\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #5
0
 private void cmdManualConfig_Click(object sender, EventArgs e)
 {
     try
     {
         if ((editingCollectorEntry.Collector == null || editingCollectorEntry.Collector.AgentConfig == null) && cboCollector.SelectedItem != null) // || SelectedEntry.Collector.AgentConfig.to .Configuration == null || SelectedEntry.Configuration.Length == 0) && cboCollector.SelectedItem != null)
         {
             RegisteredAgent ar  = (RegisteredAgent)cboCollector.SelectedItem;
             ICollector      col = CollectorEntry.CreateCollectorEntry(ar);
             txtConfig.Text = XmlFormattingUtils.NormalizeXML(col.GetDefaultOrEmptyConfigString());
         }
         else
         {
             txtConfig.Text = XmlFormattingUtils.NormalizeXML(editingCollectorEntry.Collector.AgentConfig.ToConfig());
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(string.Format("Error getting new/existing configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     ShowManualConfig();
 }