Example #1
0
        private void btnRunGroup_Activate(object sender, EventArgs e)
        {
            _auditTesting = new AuditTesting(_auditController.AuditGroup);

            // Wire up the events
            _auditTesting.AuditTestingStarting += _auditTesting_AuditTestingStarting;
            _auditTesting.CurrentAuditRunning += _auditTesting_CurrentAuditRunning;
            _auditTesting.CurrentAuditDone += _auditTesting_CurrentAuditDone;

            XpLinkRun.Enabled = false;
            btnRunGroup.Enabled = false;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                _auditTesting.RunAudits();

                AuditUtils.SendResult(_auditTesting.Audits);
            }
            catch (NoAuditsLoadedException ex)
            {
                MessageBox.Show("There are no audits to run!", "No Audits", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (System.Net.Mail.SmtpException mailSmtpException)
            {
                this.Refresh();

                // Change the icon to the "paused" icon
                foreach (ListViewItem objItem in lsvAudits.Items)
                {
                    objItem.ImageIndex = 4;
                    objItem.SubItems[2].Text = "Email Failure";
                    this.Refresh();
                }

                MessageBox.Show(mailSmtpException.Message, "NAudit Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                this.Refresh();

                // Change the icon to the "paused" icon
                foreach (ListViewItem objItem in lsvAudits.Items)
                {
                    objItem.ImageIndex = 4;
                    objItem.SubItems[2].Text = "Failure";
                    this.Refresh();
                }

                MessageBox.Show(ex.Message, "NAudit Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                this.Cursor = Cursors.Default;
                XpLinkRun.Enabled = true;
                btnRunGroup.Enabled = true;
            }
        }
Example #2
0
        /// <summary>
        /// Creates the output body.
        /// </summary>
        /// <returns>System.String.</returns>
        public override string CreateOutputBody()
        {
            var body = new StringBuilder();

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            string sourceEmailDescription = config.AppSettings.Settings["sourceEmailDescription"].Value;

            if (Audits[0].ShowThresholdMessage)
            {
                body.AppendLine("<h2>ERROR MESSAGE</h2>");
                body.Append(Audits[0].Test.FailedMessage + AuditUtils.HtmlBreak + AuditUtils.HtmlBreak);
            }

            if (Audits[0].ShowCommentMessage)
            {
                body.AppendLine("COMMENTS AND INSTRUCTIONS" + AuditUtils.HtmlBreak);
                body.AppendLine("============================" + AuditUtils.HtmlBreak);

                if (Audits[0].Test.Instructions != null)
                {
                    if (Audits[0].Test.Instructions.Length > 0)
                    {
                        body.Append(Audits[0].Test.Instructions.ToHtml() + AuditUtils.HtmlBreak);
                        body.AppendLine(AuditUtils.HtmlBreak);
                    }
                }
            }

            if (Audits[0].IncludeDataInEmail)
            {
                if (Audits[0].ResultDataSet.Tables.Count > 0)
                {
                    EmailTableTemplate currTemplate = Audits[0].Test.TemplateColorScheme;

                    string htmlData = AuditUtils.CreateHtmlData(Audits[0], Audits[0].ResultDataSet, currTemplate);

                    body.Append(htmlData);
                }
            }

            body.AppendLine(AuditUtils.HtmlBreak);

            body.Append("This audit ran at " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt", CultureInfo.InvariantCulture) + AuditUtils.HtmlBreak);

            if (Audits[0].ShowQueryMessage)
            {
                body.Append(AuditUtils.HtmlBreak);
                body.Append("The '" + Audits[0].Name + "' audit has failed. The following SQL statement was used to test this audit :" + AuditUtils.HtmlBreak);
                body.Append(Audits[0].Test.SqlStatementToCheck.ToHtml() + AuditUtils.HtmlBreak);
                body.Append("<b>This query was run on: " + Audits[0].TestServer + "</b>" + AuditUtils.HtmlBreak + AuditUtils.HtmlBreak);
            }

            string cleanBody = body.ToString().Replace("\r\n", string.Empty);

            return(cleanBody);
        }
Example #3
0
        private static void ProcessAudits(string auditGroupFile)
        {
            var colAudits = new AuditController(auditGroupFile);

            _auditTesting = new AuditTesting(colAudits.AuditGroup);

            // Wire up the events
            _auditTesting.AuditTestingStarting += _auditTesting_AuditTestingStarting;
            _auditTesting.CurrentAuditRunning  += _auditTesting_CurrentAuditRunning;
            _auditTesting.CurrentAuditDone     += _auditTesting_CurrentAuditDone;

            _auditTesting.RunAudits();

            Console.WriteLine("DataAuditor ran {0} test(s).", _auditTesting.Audits.Count);

            // Try Unit Test Type report until the rest gets sorted out
            AuditUtils.SendAuditUnitTestReportEmail(colAudits.AuditGroup);

            Console.WriteLine("Sent results email to recipients.");
        }