private void configureToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode currentNode = tvwMonPack.SelectedNode; if (currentNode.Tag != null && currentNode.Tag is CollectorEntry) { CollectorEntry ce = (CollectorEntry)currentNode.Tag; EditCollectorEntry editCollectorEntry = new EditCollectorEntry(); string oldParent = ce.ParentCollectorId; editCollectorEntry.SelectedEntry = ce; if (editCollectorEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { ce = editCollectorEntry.SelectedEntry; string uniqueId = ce.UniqueId; RefreshMonitorPack(); TreeNode collectorRootNode = (from TreeNode n in tvwMonPack.Nodes[0].Nodes where n.Name == "Collectors" select n).First(); SelectCollectorNodeById(uniqueId, collectorRootNode); } } else if (currentNode.Tag != null && currentNode.Tag is NotifierEntry) { NotifierEntry ne = (NotifierEntry)currentNode.Tag;; EditNotifierEntry editNotifierEntry = new EditNotifierEntry(); editNotifierEntry.SelectedEntry = ne; if (editNotifierEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { RefreshMonitorPack(); } } }
private void cmdOK_Click(object sender, EventArgs e) { try { if (SelectedEntry == null) { SelectedEntry = new NotifierEntry(); } SelectedEntry.Name = txtName.Text; SelectedEntry.Enabled = chkEnabled.Checked; SelectedEntry.AlertLevel = (AlertLevel)cboAlertLevel.SelectedIndex; SelectedEntry.DetailLevel = (DetailLevel)cboDetailLevel.SelectedIndex; SelectedEntry.NotifierRegistrationName = editingNotifierEntry.NotifierRegistrationName; SelectedEntry.InitialConfiguration = editingNotifierEntry.InitialConfiguration; SelectedEntry.AlertForCollectors.Clear(); if (editingNotifierEntry.AlertForCollectors != null && editingNotifierEntry.AlertForCollectors.Count > 0) { SelectedEntry.AlertForCollectors.AddRange(editingNotifierEntry.AlertForCollectors.ToArray()); } SelectedEntry.AttendedOptionOverride = (AttendedOption)cboAttendedOptionOverride.SelectedIndex; SelectedEntry.ServiceWindows.CreateFromConfig(editingNotifierEntry.ServiceWindows.ToConfig()); SelectedEntry.ConfigVariables = new List <ConfigVariable>(); SelectedEntry.ConfigVariables.AddRange((from ConfigVariable cv in editingNotifierEntry.ConfigVariables select cv.Clone()).ToArray()); SelectedEntry.CreateAndConfigureEntry(SelectedEntry.NotifierRegistrationName); DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cmdConfig_Click(object sender, EventArgs e) { if (cboNotifier.SelectedItem != null) { try { AgentRegistration ar = (AgentRegistration)cboNotifier.SelectedItem; INotifier notifier = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName); if (notifier != null) { SelectedEntry.Notifier = notifier; if (SelectedEntry.Configuration == null) { SelectedEntry.Configuration = ""; } string newConfig = notifier.ConfigureAgent(SelectedEntry.Configuration); if (newConfig.Length > 0) { SelectedEntry.Configuration = newConfig; CheckOkEnable(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public EditNotifierEntry() { InitializeComponent(); SelectedEntry = new NotifierEntry(); SelectedEntry.Enabled = true; SelectedEntry.AlertLevel = AlertLevel.Warning; SelectedEntry.DetailLevel = DetailLevel.Detail; }
private void RemoveNotifier(TreeNode parentNode) { foreach (TreeNode collectorNode in parentNode.Nodes) { RemoveCollector(collectorNode); } NotifierEntry ne = (NotifierEntry)parentNode.Tag; monitorPack.Notifiers.Remove(ne); }
private void LoadNotifierEntry(NotifierEntry ne, TreeNode parentNode) { TreeNode neNode = new TreeNode(ne.NotifierRegistrationName + ": " + ne.Name, 2, 2); neNode.Tag = ne; parentNode.Nodes.Add(neNode); if (monitorPack.AgentRegistrations == null || (from nr in monitorPack.AgentRegistrations where nr.IsNotifier && nr.Name == ne.NotifierRegistrationName select nr).Count() != 1) { neNode.ForeColor = Color.Red; } else if (!ne.Enabled) { neNode.ForeColor = Color.Gray; } }
private void cmdOK_Click(object sender, EventArgs e) { try { SelectedEntry.Name = txtName.Text; SelectedEntry.Enabled = chkEnabled.Checked; SelectedEntry.AlertLevel = (AlertLevel)cboAlertLevel.SelectedIndex; SelectedEntry.DetailLevel = (DetailLevel)cboDetailLevel.SelectedIndex; SelectedEntry.NotifierRegistrationName = ((AgentRegistration)cboNotifier.SelectedItem).Name; AgentRegistration ar = (AgentRegistration)cboNotifier.SelectedItem; SelectedEntry.Notifier = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName); DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cmdManualConfig_Click(object sender, EventArgs e) { try { if ((SelectedEntry.Configuration == null || SelectedEntry.Configuration.Length == 0) && cboNotifier.SelectedItem != null) { AgentRegistration ar = (AgentRegistration)cboNotifier.SelectedItem; INotifier col = NotifierEntry.CreateNotifierEntry(ar.AssemblyPath, ar.ClassName); txtConfig.Text = XmlFormattingUtils.NormalizeXML(col.GetDefaultOrEmptyConfigString()); } else { txtConfig.Text = XmlFormattingUtils.NormalizeXML(SelectedEntry.Configuration); } } catch (Exception ex) { MessageBox.Show(string.Format("Error getting new/existing configuration\r\n{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } ShowManualConfig(); }
private void ShowEdit() { System.Threading.ThreadPool.QueueUserWorkItem(delegate { this.Invoke((MethodInvoker) delegate { if (tvwMonPack.SelectedNode != null) { TreeNode currentNode = tvwMonPack.SelectedNode; if (currentNode.Tag != null && currentNode.Tag is CollectorEntry) { CollectorEntry ce = (CollectorEntry)currentNode.Tag; EditCollectorEntry editCollectorEntry = new EditCollectorEntry(); string oldParent = ce.ParentCollectorId; editCollectorEntry.SelectedEntry = ce; if (editCollectorEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { ce = editCollectorEntry.SelectedEntry; string uniqueId = ce.UniqueId; RefreshMonitorPack(); TreeNode collectorRootNode = (from TreeNode n in tvwMonPack.Nodes[0].Nodes where n.Name == "Collectors" select n).First(); SelectCollectorNodeById(uniqueId, collectorRootNode); } } else if (currentNode.Tag != null && currentNode.Tag is NotifierEntry) { NotifierEntry ne = (NotifierEntry)currentNode.Tag;; EditNotifierEntry editNotifierEntry = new EditNotifierEntry(); editNotifierEntry.SelectedEntry = ne; if (editNotifierEntry.ShowDialog(monitorPack) == System.Windows.Forms.DialogResult.OK) { RefreshMonitorPack(); } } } }); }); }
private void enableToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode currentNode = tvwMonPack.SelectedNode; if (currentNode.Tag != null) { if (currentNode.Tag is CollectorEntry) { CollectorEntry ce = (CollectorEntry)currentNode.Tag; ce.Enabled = !ce.Enabled; currentNode.Tag = ce; enableToolStripMenuItem.Text = ce.Enabled ? "Disable" : "Enable"; if (!ce.Enabled) { currentNode.ForeColor = Color.Gray; } else { currentNode.ForeColor = SystemColors.WindowText; } } else if (currentNode.Tag is NotifierEntry) { NotifierEntry ne = (NotifierEntry)currentNode.Tag; ne.Enabled = !ne.Enabled; currentNode.Tag = ne; enableToolStripMenuItem.Text = ne.Enabled ? "Disable" : "Enable"; if (!ne.Enabled) { currentNode.ForeColor = Color.Gray; } else { currentNode.ForeColor = SystemColors.WindowText; } } } }
private void llblNotifierType_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (MessageBox.Show("Are you sure you want to change the Notifier type?\r\n\r\nIf you continue this will reset any existing configuration.", "Notifier type", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes) { List <ConfigVariable> configVars = new List <ConfigVariable>(); foreach (ConfigVariable cv in editingNotifierEntry.ConfigVariables) { configVars.Add(cv.Clone()); } NotifierEntry newNotifierEntry = AgentHelper.CreateNewNotifier(); if (newNotifierEntry != null) { editingNotifierEntry = null; editingNotifierEntry = newNotifierEntry; editingNotifierEntry.ConfigVariables = configVars; ApplyConfigToControls(); if (AgentHelper.LastShowRawEditOnStartOption) { llblRawEdit_LinkClicked(sender, e); } } } }
public DialogResult ShowDialog(MonitorPack monitorPack) { if (SelectedEntry == null) { return(System.Windows.Forms.DialogResult.Cancel); } else { this.monitorPack = monitorPack; editingNotifierEntry = NotifierEntry.FromConfig(SelectedEntry.ToConfig()); try { //Create Notifier instance but do not apply Config Variables! editingNotifierEntry.CreateAndConfigureEntry(editingNotifierEntry.NotifierRegistrationName, "", false); return(ShowDialog()); } catch (Exception ex) { MessageBox.Show(ex.Message, "Loading", MessageBoxButtons.OK, MessageBoxIcon.Error); return(System.Windows.Forms.DialogResult.Cancel); } } }