예제 #1
0
        /// <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 formProcessor = new FormProcessor(ContentFlow);

                var cv = new ConfigValidator(ConfigPath, SchemaPath);
                if (cv.Validate(true) != 0)
                {
                    throw new InvalidDataException("XSD-based Validation Failed.  Check for errors.");
                }

                var cf = new ConfigWriter(ConfigPath);
                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();
            }
        }
예제 #2
0
        /// <summary>
        /// Click event handler for the Validate button on the main form. Uses the error/save dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ValidateXml_Click(object sender, EventArgs e)
        {
            var cv = new ConfigValidator(ConfigPath, SchemaPath);
            int errorCount = cv.Validate();
            if (errorCount > 0)
            {
                Saved.Text = errorCount + " errors found, see validation.txt";
                Saved.BackColor = Color.DarkRed;
            }
            else if (errorCount == 0)
            {
                Saved.Text = "Valid";
                Saved.BackColor = Color.FromArgb(244, 144, 0);
            }
            else if (errorCount == -1)
            {
                Saved.Text = "Trouble reading the config or xsd files.";
                Saved.BackColor = Color.DarkRed;
            }

            Saved.Visible = true;
            _savedTimer.Start();
        }
예제 #3
0
        /// <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 formProcessor = new FormProcessor(ContentFlow);

                var cv = new ConfigValidator(ConfigPath, SchemaPath);
                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();
            }
        }