/// <summary> /// Click event handler for saving the new config file. Validates prior to saving. Displays the error/save message box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveFile_Click(object sender, EventArgs e) { try { var reader = new FormReader(ContentFlow); var cv = new ConfigValidator(); if (cv.Validate(true) != 0) { throw new InvalidDataException("XSD-based Validation Failed. Check for errors."); } var cf = new ConfigWriter(); cf.Write(); Saved.Text = "Saved newrelic.config successfully"; Saved.BackColor = Color.FromArgb(244, 144, 0); Saved.Visible = true; _savedTimer.Start(); } catch (Exception ex) { log.Error("01 - " + ex.Message); Saved.Text = ex.Message; Saved.BackColor = Color.DarkRed; Saved.Visible = true; _savedTimer.Start(); } }
/// <summary> /// Click event handler for saving the new config file to a new location. Validates prior to saving. Displays the error/save message box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveFileAs_Click(object sender, EventArgs e) { try { var reader = new FormReader(ContentFlow); var cv = new ConfigValidator(); if (cv.Validate(true) != 0) { throw new InvalidDataException("XSD-based Validation Failed. Check for errors."); } var cf = new ConfigWriter(); var safeFile = new SaveFileDialog(); safeFile.Title = "Select the new location for the newrelic.config file"; safeFile.FileName = "newrelic.config"; safeFile.Filter = "config files (*.config)|*.config|All files (*.*)|*.*"; safeFile.FilterIndex = 0; safeFile.RestoreDirectory = true; if (safeFile.ShowDialog() == DialogResult.OK) { cf.Write(safeFile.FileName); } Saved.Text = "Saved newrelic.config successfully"; Saved.BackColor = Color.FromArgb(244, 144, 0); Saved.Visible = true; _savedTimer.Start(); } catch (Exception ex) { log.Error(ex); Saved.Text = ex.Message; Saved.BackColor = Color.DarkRed; Saved.Visible = true; _savedTimer.Start(); } }