コード例 #1
0
        private bool CompareRowCells(
            InstanceReportRow baseRow, InstanceReportRow newRow,
            InstanceReport baseReport, InstanceReport newReport,
            string basePath, string newPath,
            int rowCount, DateTime reportDate, out string error)
        {
            error = string.Empty;
            //Row# {0}:'{1}' has unmatched data.<br>Expected Results: '{2}' Actual Results: '{3}'
            output op        = new output(Output);
            bool   retval    = true;
            string labelText = baseRow.Label.Replace("\r\n", " ");


            //if (!string.Equals( baseRow.ToString(), newRow.ToString(), StringComparison.InvariantCultureIgnoreCase ) )
            //{
            for (int i = 0; i < baseRow.Cells.Count; i++)
            {
                Cell baseCell = baseRow.Cells[i];
                Cell newCell  = newRow.Cells[i];

                if (baseCell.HasEmbeddedReport == newCell.HasEmbeddedReport)
                {
                    if (newCell.HasEmbeddedReport)
                    {
                        this.ReportCompare(baseCell.EmbeddedReport.InstanceReport, newCell.EmbeddedReport.InstanceReport,
                                           basePath, newPath, reportDate, out error);
                        continue;
                    }
                }
                else
                {
                    if (baseCell.HasEmbeddedReport)
                    {
                        this.htmlStarter("Unmatched embedded reports<br>BaseRep cell has an embedded report, but NewRep cell does not.", reportDate, out error);
                    }
                    else
                    {
                        this.htmlStarter("Unmatched embedded reports<br>NewRep cell has an embedded report, but BaseRep cell does not.", reportDate, out error);
                    }
                }

                string baseText = WHITE_SPACE.Replace(baseCell.ToString().Trim(), " ");
                string newText  = WHITE_SPACE.Replace(newCell.ToString().Trim(), " ");
                if (!string.Equals(baseText, newText, StringComparison.InvariantCultureIgnoreCase))
                {
                    retval = false;


                    htmlStarter(string.Format(mismatchCell,
                                              i.ToString(), labelText, baseRow.Cells[i].ToString(), newRow.Cells[i].ToString()), reportDate, out error);

                    if (errorID > 0)
                    {
                        //RLogger.Info(string.Format(debugParameters, baseReport.ReportName, newReport.ReportName, errorID, 464));
                        using (BaselineRules baseL = new BaselineRules(baseReport, newReport, errorID))
                        {
                            baseL.EvaluateUnmatchedDataError(rowCount);
                        }
                    }
                    else if (errorID == 0)
                    {
                        RLogger.Error("No error ID on " + baseReport.ReportName + " " + workingHeader.XmlFileName + " SQL DB returned 0");
                    }
                }

                if (!string.Equals(baseCell.FootnoteIndexer, newCell.FootnoteIndexer))
                {
                    retval = false;
                    htmlStarter(string.Format(mismatchCell,
                                              i.ToString(), labelText, "Footnotes: " + baseCell.FootnoteIndexer, "Footnotes: " + newCell.FootnoteIndexer), reportDate, out error);
                }
            }
            //}
            return(retval);
        }
コード例 #2
0
        private bool ReportCompare(InstanceReport baseRep, InstanceReport newRep,
                                   string basePath, string newPath,
                                   DateTime reportDate, out string error)
        {
            error = string.Empty;

            bool retval = true;

            if (WHITE_SPACE.Replace(baseRep.ReportName.Trim(), " ") != WHITE_SPACE.Replace(newRep.ReportName.Trim(), " "))
            {
                htmlStarter(string.Format("Report Names do not match. " + expectedResults, baseRep.ReportName, newRep.ReportName), reportDate, out error);
                retval = false;
            }

            //If counts don't match, we can't do the cell by cell compare, skip
            if (baseRep.Rows.Count != newRep.Rows.Count)
            {
                htmlStarter(string.Format("Row counts do not match " + expectedResults, baseRep.Rows.Count, newRep.Rows.Count), reportDate, out error);
                retval = false;
            }

            if (baseRep.Columns.Count != newRep.Columns.Count)
            {
                htmlStarter(string.Format("Column counts do not match " + expectedResults, baseRep.Columns.Count, newRep.Columns.Count), reportDate, out error);
                retval = false;
            }

            if (!this.CompareRows(baseRep, newRep, reportDate, out error))
            {
                retval = false;
            }

            if (retval)
            {
                //Only run this if row/column counts match, otherwise, this will error out
                for (int i = 0; i < baseRep.Rows.Count; i++)
                {
                    if (!CompareRowCells(baseRep.Rows[i], newRep.Rows[i], baseRep, newRep, basePath, newPath, i + 1, reportDate, out error))
                    {
                        retval = false;
                    }
                }

                if (!CompareColumns(baseRep, newRep, reportDate, out error))
                {
                    retval = false;
                }
            }

            //Compare this last. A false here won't effect the outcome of the row/column check
            if (!baseRep.RoundingOption.Equals(newRep.RoundingOption))
            {
                htmlStarter(string.Format("Rounding options do not match." + expectedResults, baseRep.RoundingOption, newRep.RoundingOption), reportDate, out error);
                //RLogger.Info(string.Format(debugParameters, baseRep.ReportLongName, newRep.ReportLongName, errorID, 397));
                using (BaselineRules baseL = new BaselineRules(baseRep, newRep, errorID))
                {
                    baseL.EvaluateRoundingOptionError();
                }
                retval = false;
            }

            if (!retval)
            {
                //Save the baseRep and newRep HTML
                this.HTML(newRep, newPath, rFileLoc1);
                this.HTML(baseRep, basePath, rFileLoc2);
            }

            return(retval);
        }