/// <summary> /// Create a new Alert Definition /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnCreate_Click(object sender, EventArgs e) { FormAlertMonitorWizard form = new FormAlertMonitorWizard(); form.ShowDialog(); RefreshAlertMonitors(); }
private void btnEditAlert_Click(object sender, EventArgs e) { TextReader textReader = null; FormAlertMonitorWizard form = null; string fileName = String.Empty; try { UltraListViewItem lvi = lvAlertDefinitions.SelectedItems[0]; int selectedIndex = lvi.Index; if (selectedIndex != -1) { fileName = lvAlertDefinitions.Items[selectedIndex].Text; string selectedFileName = Path.Combine(Application.StartupPath, "scanners\\alertmonitors\\") + fileName + ".xml"; XmlSerializer serializer = new XmlSerializer(typeof(AlertDefinition)); textReader = new StreamReader(selectedFileName); form = new FormAlertMonitorWizard((AlertDefinition)serializer.Deserialize(textReader)); } } catch (Exception ex) { MessageBox.Show("An error occurred whilst trying to load the alert definition : " + Environment.NewLine + Environment.NewLine + ex.Message, "AuditWizard", MessageBoxButtons.OK, MessageBoxIcon.Error); // JML TODO log this exception } finally { // close text writer textReader.Close(); } if (form != null) { form.ShowDialog(); } RefreshAlertMonitors(); }