示例#1
0
 public ErrorWriter(string file, InstanceReport baseReport, InstanceReport genReport, string failedPath)
 {
     this._baseReport      = baseReport;
     this._generatedReport = genReport;
     this._failedPath      = failedPath;
     this._fileName        = Path.GetFileName(file);
 }
示例#2
0
        public void StartReport( string file, InstanceReport baseReport, InstanceReport genReport, string failedPath )
        {
            ErrorWriter report = new ErrorWriter( file, baseReport, genReport, failedPath );
            this._reports.Push( report );

            this.WriteLine();
            this.WriteLine( "*************************Comparison STARTED " + file + "*************************" );
        }
示例#3
0
        /// <summary>
        /// Load the calendar columns from the base report.
        /// </summary>
        /// <param name="baseReport">The base report to load calendar items
        /// from.</param>
        public void LoadCalendarColumns(InstanceReport baseReport)
        {
            List <InstanceReportColumn> uniqueCalendars = new List <InstanceReportColumn>();

            foreach (InstanceReportColumn baseCol in baseReport.Columns)
            {
                if (!ReportUtils.Exists(uniqueCalendars, col => col.ReportingPeriodEquals(baseCol)))
                {
                    //create a clone so that we can slowly digest this data without affecting other references
                    InstanceReportColumn newCol = (InstanceReportColumn)baseCol.Clone();
                    uniqueCalendars.Add(newCol);
                }
            }

            uniqueCalendars.Sort(InstanceReport.CompareCalendars);
            this.DurationCalendars = new List <InstanceReportColumn>(uniqueCalendars);
            this.InstantCalendars  = SplitCalendars(uniqueCalendars);
        }
示例#4
0
        private static void VerifyReports(ErrorWriter writer, InstanceReport baseReport, InstanceReport genReport)
        {
            if (baseReport.ReportLongName != genReport.ReportLongName)
            {
                writer.WriteError("Long report name does not match:",
                                  "\tExpected:  " + WHITE_SPACE.Replace(baseReport.ReportLongName, " "),
                                  "\tGenerated: " + WHITE_SPACE.Replace(genReport.ReportLongName, " "),
                                  "\t...continuing...",
                                  string.Empty);
            }

            if (WHITE_SPACE.Replace(baseReport.ReportName, " ") != WHITE_SPACE.Replace(genReport.ReportName, " "))
            {
                writer.WriteError("Short report name does not match:",
                                  "\tExpected:  " + WHITE_SPACE.Replace(baseReport.ReportName, " "),
                                  "\tGenerated: " + WHITE_SPACE.Replace(genReport.ReportName, " "),
                                  "\t...continuing...",
                                  string.Empty);
            }

            VerifyReportColumns(writer, baseReport, genReport);
            VerifyReportRows(writer, baseReport, genReport);
        }
示例#5
0
        private static void VerifyReportRows(ErrorWriter writer, InstanceReport baseReport, InstanceReport genReport)
        {
            if (baseReport.Rows.Count != genReport.Rows.Count)
            {
                int           differences = Math.Abs(baseReport.Rows.Count - genReport.Rows.Count);
                List <string> baseRows    = baseReport.Rows.ConvertAll(row => WHITE_SPACE.Replace(row.Label, " "));
                List <string> genRows     = genReport.Rows.ConvertAll(row => WHITE_SPACE.Replace(row.Label, " "));

                if (baseRows.Count < genRows.Count)
                {
                    writer.StartError("The new rendering generated too MANY rows.");

                    foreach (string commonLabel in baseRows)
                    {
                        if (genRows.Contains(commonLabel))
                        {
                            genRows.Remove(commonLabel);
                        }
                    }

                    if (genRows.Count == differences)
                    {
                        foreach (string newLabel in genRows)
                        {
                            writer.WriteError("\tAdded:   " + newLabel);
                        }
                    }
                    else
                    {
                        writer.WriteError("\tSEVERAL LABELS CHANGED");
                    }

                    writer.EndError();
                }
                else
                {
                    writer.StartError("The new rendering generated too FEW rows.");

                    foreach (string commonLabel in genRows)
                    {
                        if (baseRows.Contains(commonLabel))
                        {
                            baseRows.Remove(commonLabel);
                        }
                    }

                    if (baseRows.Count == differences)
                    {
                        foreach (string newLabel in baseRows)
                        {
                            writer.WriteError("\tRemoved: " + newLabel);
                        }
                    }
                    else
                    {
                        writer.WriteError("\tSEVERAL LABELS CHANGED");
                    }

                    writer.EndError();
                }
            }

            for (int bIdx = 0; bIdx < baseReport.Rows.Count; bIdx++)
            {
                InstanceReportRow baseRow   = baseReport.Rows[bIdx];
                string            baseLabel = WHITE_SPACE.Replace(baseRow.Label, " ");

                int gIdx = -1;
                InstanceReportRow genRow = null;
                if (genReport.Rows.Count > bIdx)
                {
                    if (WHITE_SPACE.Replace(genReport.Rows[bIdx].Label, " ") == baseLabel)
                    {
                        gIdx   = bIdx;
                        genRow = genReport.Rows[bIdx];
                    }
                }

                if (genRow == null)
                {
                    if (bIdx >= genReport.Rows.Count)
                    {
                        writer.WriteError(
                            "Generated report has too few rows to match Base row:",
                            "\tRow " + bIdx + ": " + baseLabel,
                            "\t***Row Skipped***"
                            );
                        continue;
                    }

                    gIdx = bIdx == 0 ?
                           genReport.Rows.FindIndex(bIdx, row => WHITE_SPACE.Replace(row.Label, " ") == baseLabel) :
                           genReport.Rows.FindIndex(bIdx - 1, row => WHITE_SPACE.Replace(row.Label, " ") == baseLabel);

                    if (gIdx == -1)
                    {
                        writer.WriteError(
                            "Base row not found in generated report:",
                            "\tRow " + bIdx + ": " + baseLabel,
                            "\t***Row Skipped***"
                            );
                        continue;
                    }

                    genRow = genReport.Rows[gIdx];
                    if (bIdx != gIdx)
                    {
                        writer.WriteError(
                            "Row moved: " + baseLabel,
                            "\tExpected:  " + bIdx.ToString(),
                            "\tGenerated: " + gIdx.ToString()
                            );
                    }
                }

                if (!string.Equals(baseRow.FootnoteIndexer, genRow.FootnoteIndexer))
                {
                    writer.WriteError(
                        "Row footnotes changed: " + baseLabel,
                        "\tExpected:  " + baseRow.FootnoteIndexer,
                        "\tGenerated: " + genRow.FootnoteIndexer
                        );
                }

                decimal baseSum = 0M;
                baseRow.Cells.FindAll(c => c.IsNumeric).ForEach(c => baseSum += c.NumericAmount);

                decimal genSum = 0M;
                genRow.Cells.FindAll(c => c.IsNumeric).ForEach(c => genSum += c.NumericAmount);

                bool    checkNumericCells = false;
                decimal difference        = baseSum - genSum;
                if (difference != 0)
                {
                    checkNumericCells = true;

                    if (difference > 0)
                    {
                        writer.WriteError(
                            "Row sum is SMALLER than expected:",
                            "\tRow " + bIdx + ": " + baseLabel,
                            "\tExpected:  " + baseSum,
                            "\tGenerated: " + genSum
                            );
                    }
                    else
                    {
                        writer.WriteError(
                            "Row sum is LARGER than expected:",
                            "\tRow " + bIdx + ": " + baseLabel,
                            "\tExpected:  " + baseSum,
                            "\tGenerated: " + genSum
                            );
                    }
                }

                foreach (Cell baseCell in baseRow.Cells)
                {
                    if (!checkNumericCells && baseCell.IsNumeric)
                    {
                        continue;
                    }

                    Cell genCell = null;
                    int  cIdx    = baseRow.Cells.IndexOf(baseCell);
                    if (genRow.Cells.Count > cIdx)
                    {
                        genCell = genRow.Cells[cIdx];
                    }

                    if (genCell == null)
                    {
                        writer.WriteError("Base cell not found in Generated report.");
                        continue;
                    }

                    if (genCell.IsNumeric)
                    {
                        if (!checkNumericCells)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        genCell.NonNumbericText = WHITE_SPACE.Replace(genCell.NonNumbericText, " ");
                    }

                    if (!baseCell.IsNumeric)
                    {
                        baseCell.NonNumbericText = WHITE_SPACE.Replace(baseCell.NonNumbericText, " ");
                    }


                    if (!baseCell.ValueEquals(genCell))
                    {
                        //if( baseCell.IsNumeric )
                        //{
                        //    genCell = genRow.Cells.Find( c => c.NumericAmount == baseCell.NumericAmount || c.RoundedNumericAmount == baseCell.RoundedNumericAmount );
                        //    if( genCell != null )

                        //}

                        baseCell.FlagID = 1;
                        genCell.FlagID  = 1;

                        writer.WriteError("Cell value does not match:",
                                          "\tRow " + bIdx + ", Cell " + cIdx,
                                          "\tExpected:  " + baseCell.ToString() + "[" + baseCell.FootnoteIndexer + "]",
                                          "\tGenerated: " + genCell.ToString() + "[" + genCell.FootnoteIndexer + "]");
                    }
                    else if (!string.Equals(baseCell.FootnoteIndexer, genCell.FootnoteIndexer))
                    {
                        writer.WriteError("Cell footnotes changed:",
                                          "\tRow " + bIdx + ", Cell " + cIdx,
                                          "\tExpected:  " + baseCell.FootnoteIndexer,
                                          "\tGenerated: " + genCell.FootnoteIndexer);
                    }
                }

                List <Cell> baseEmbedCells = baseRow.Cells.FindAll(c => c.HasEmbeddedReport && c.EmbeddedReport != null && c.EmbeddedReport.InstanceReport != null);
                List <Cell> genEmbedCells  = genRow.Cells.FindAll(c => c.HasEmbeddedReport && c.EmbeddedReport != null && c.EmbeddedReport.InstanceReport != null);
                if (baseEmbedCells.Count != genEmbedCells.Count)
                {
                    difference = Math.Abs(baseEmbedCells.Count - genEmbedCells.Count);
                    if (baseEmbedCells.Count > genEmbedCells.Count)
                    {
                        writer.WriteError("Row has MISSING embedded reports:",
                                          "\tExpected:  " + baseEmbedCells.Count,
                                          "\tGenerated: " + genEmbedCells.Count);
                    }
                    else
                    {
                        writer.WriteError("Row has EXTRA embedded reports:",
                                          "\tExpected:  " + baseEmbedCells.Count,
                                          "\tGenerated: " + genEmbedCells.Count);
                    }
                }

                for (int c = 0; c < baseEmbedCells.Count; c++)
                {
                    Cell           embedCell    = baseEmbedCells[c];
                    InstanceReport baseEmbed    = embedCell.EmbeddedReport.InstanceReport;
                    int            genCellIndex = c == 0 ?
                                                  genEmbedCells.FindIndex(cell => baseEmbed.ReportLongName == cell.EmbeddedReport.InstanceReport.ReportLongName) :
                                                  genEmbedCells.FindIndex(c - 1, cell => baseEmbed.ReportLongName == cell.EmbeddedReport.InstanceReport.ReportLongName);

                    if (genCellIndex == -1)
                    {
                        writer.WriteError("Embedded report not found in generated report:",
                                          "\tRow " + bIdx + ", Cell " + c + ": " + baseEmbed.ReportName,
                                          "\tEMBED Skipped");
                        continue;
                    }

                    Cell           genEmbedCell = genEmbedCells[genCellIndex];
                    InstanceReport genEmbed     = genEmbedCell.EmbeddedReport.InstanceReport;

                    try
                    {
                        writer.StartReport(baseEmbed.ReportLongName + ".xml", baseEmbed, genEmbed, null);
                        writer.WriteLine("*************** EMBED Comparison Started ***************");

                        VerifyReports(writer, baseEmbed, genEmbed);

                        writer.WriteLine("***************  EMBED Comparison Ended  ***************");
                    }
                    finally
                    {
                        writer.EndReport(baseEmbed.ReportLongName + ".xml");
                    }
                }
            }
        }
示例#6
0
        private static void VerifyReportColumns(ErrorWriter writer, InstanceReport baseReport, InstanceReport genReport)
        {
            if (baseReport.Columns.Count != genReport.Columns.Count)
            {
                int           differences = Math.Abs(baseReport.Columns.Count - genReport.Columns.Count);
                List <string> baseColumns = baseReport.Columns.ConvertAll(col => WHITE_SPACE.Replace(col.Label, " "));
                List <string> genColumns  = genReport.Columns.ConvertAll(col => WHITE_SPACE.Replace(col.Label, " "));

                if (baseColumns.Count < genColumns.Count)
                {
                    writer.StartError("The new rendering generated too MANY columns.");

                    foreach (string commonLabel in baseColumns)
                    {
                        if (genColumns.Contains(commonLabel))
                        {
                            genColumns.Remove(commonLabel);
                        }
                    }

                    if (genColumns.Count == differences)
                    {
                        foreach (string newLabel in genColumns)
                        {
                            writer.WriteError("\tAdded:   " + newLabel);
                        }
                    }
                    else
                    {
                        writer.WriteError("\tSEVERAL LABELS CHANGED");
                    }

                    writer.EndError();
                }
                else
                {
                    writer.StartError("The new rendering generated too FEW columns.");

                    foreach (string commonLabel in genColumns)
                    {
                        if (baseColumns.Contains(commonLabel))
                        {
                            baseColumns.Remove(commonLabel);
                        }
                    }

                    if (baseColumns.Count == differences)
                    {
                        foreach (string newLabel in baseColumns)
                        {
                            writer.WriteError("\tRemoved: " + newLabel);
                        }
                    }
                    else
                    {
                        writer.WriteError("\tSEVERAL LABELS CHANGED");
                    }

                    writer.EndError();
                }
            }

            for (int bIdx = 0; bIdx < baseReport.Columns.Count; bIdx++)
            {
                InstanceReportColumn baseColumn = baseReport.Columns[bIdx];
                string baseLabel = WHITE_SPACE.Replace(baseColumn.Label, " ");

                InstanceReportColumn genColumn = null;
                if (genReport.Columns.Count > bIdx)
                {
                    genColumn = genReport.Columns[bIdx];
                }

                if (genColumn == null)
                {
                    writer.WriteError("Base column not found in generated report.");
                    continue;
                }

                if (WHITE_SPACE.Replace(genColumn.Label, " ") == baseLabel)
                {
                    continue;
                }

                decimal baseSum = 0.0M;
                Array.ForEach(baseColumn.GetCellArray(baseReport), cell => baseSum += cell.IsNumeric ? cell.NumericAmount : 0.0M);

                decimal genSum = 0.0M;
                Array.ForEach(genColumn.GetCellArray(genReport), cell => genSum += cell.IsNumeric ? cell.NumericAmount : 0.0M);

                if (baseSum == genSum)
                {
                    writer.WriteError("Label doesn't match base column at index " + bIdx + ":",
                                      "\tExpected:  " + baseLabel,
                                      "\tGenerated: " + WHITE_SPACE.Replace(genColumn.Label, " "));
                    continue;
                }

                genColumn = genReport.Columns.Find(col => WHITE_SPACE.Replace(col.Label, " ") == baseLabel);
                if (genColumn == null)
                {
                    writer.WriteError("Base column not found in generated report:",
                                      "\t" + baseLabel,
                                      "\t***Column Skipped***");
                    continue;
                }

                int gIdx = genReport.Columns.IndexOf(genColumn);
                if (bIdx != gIdx)
                {
                    writer.WriteError("Column moved: " + baseLabel,
                                      "\tExpected at:  " + bIdx.ToString(),
                                      "\tGenerated at: " + gIdx.ToString());
                }
            }
        }
示例#7
0
        private static void VerifyIndividualReports(ErrorWriter writer, string baselineResultFolder, string generatedResultFolder, string failedResultsFolder)
        {
            string[] baseFiles = new string[0];
            if (Directory.Exists(baselineResultFolder))
            {
                baseFiles = Directory.GetFiles(baselineResultFolder, "R*.xml");
                Array.Sort(baseFiles, natcasecmp);
            }

            string[] genFiles = new string[0];
            if (Directory.Exists(generatedResultFolder))
            {
                genFiles = Directory.GetFiles(generatedResultFolder, "R*.xml");
                Array.Sort(genFiles, natcasecmp);
            }

            if (baseFiles.Length < genFiles.Length)
            {
                writer.StartError("The new rendering generated too MANY files:");
                for (int i = 0; i < genFiles.Length; i++)
                {
                    string gFile = Path.GetFileName(genFiles[i]);
                    bool   found = Array.Exists(baseFiles, bFile => bFile.EndsWith(gFile));
                    if (!found)
                    {
                        writer.WriteError("\tAdded:  " + gFile);
                    }
                }
                writer.EndError();
            }
            else if (baseFiles.Length > genFiles.Length)
            {
                writer.StartError("The new rendering generated too FEW files.");
                for (int i = 0; i < baseFiles.Length; i++)
                {
                    string bFile = Path.GetFileName(baseFiles[i]);
                    bool   found = Array.Exists(genFiles, gFile => gFile.EndsWith(bFile));
                    if (!found)
                    {
                        writer.WriteError("\tAdded:  " + bFile);
                    }
                }
                writer.EndError();
            }

            Dictionary <string, int> allFiles = new Dictionary <string, int>();

            foreach (string bFile in baseFiles)
            {
                allFiles[Path.GetFileName(bFile)] = 1;
            }

            foreach (string gFile in genFiles)
            {
                allFiles[Path.GetFileName(gFile)] = 1;
            }

            Dictionary <string, InstanceReport> tryVerifyEmbedded = new Dictionary <string, InstanceReport>();

            foreach (string file in allFiles.Keys)
            {
                if (!R_FILE_REGEX.IsMatch(file))
                {
                    continue;
                }

                InstanceReport baseReport = null;
                InstanceReport genReport  = null;

                try
                {
                    string baseReportPath = Path.Combine(baselineResultFolder, file);
                    if (File.Exists(baseReportPath))
                    {
                        baseReport = InstanceReport.LoadXml(baseReportPath);
                    }

                    string genReportPath = Path.Combine(generatedResultFolder, file);
                    if (File.Exists(genReportPath))
                    {
                        genReport = InstanceReport.LoadXml(genReportPath);
                    }

                    if (baseReport == null)
                    {
                        throw new Exception("Base report is missing.");
                    }

                    if (genReport == null)
                    {
                        throw new Exception("Generated report is missing.");
                    }

                    writer.StartReport(file, baseReport, genReport, failedResultsFolder);
                    writer.WriteLine(PathCombine(baselineResultFolder, file));
                    writer.WriteLine(PathCombine(generatedResultFolder, file));

                    VerifyReports(writer, baseReport, genReport);
                }
                catch (Exception ex)
                {
                    writer.StartReport(file, baseReport, genReport, failedResultsFolder);
                    writer.WriteError(ex.Message);
                }
                finally
                {
                    writer.EndReport(file);
                }
            }
        }
示例#8
0
        public static void VerifyIndividualReports(ErrorWriter writer, IDirectoryInfo baselineResultInfo, IDirectoryInfo generatedResultInfo, string failedResultsFolder)
        {
            IFileInfo[] baseFiles = new IFileInfo[0];
            if (baselineResultInfo.Exists)
            {
                baseFiles = baselineResultInfo.GetFiles("R*.xml");
                Array.Sort(baseFiles, natcasecmp);
            }

            IFileInfo[] genFiles = new IFileInfo[0];
            if (generatedResultInfo.Exists)
            {
                genFiles = generatedResultInfo.GetFiles("R*.xml");
                Array.Sort(genFiles, natcasecmp);
            }

            if (baseFiles.Length < genFiles.Length)
            {
                writer.StartError("The new rendering generated too MANY files:");
                for (int i = 0; i < genFiles.Length; i++)
                {
                    bool found = Array.Exists(baseFiles, bFile => string.Equals(bFile.Name, genFiles[i].Name));
                    if (!found)
                    {
                        writer.WriteError("\tAdded:  " + genFiles[i].Name);
                    }
                }
                writer.EndError();
            }
            else if (baseFiles.Length > genFiles.Length)
            {
                writer.StartError("The new rendering generated too FEW files.");
                for (int i = 0; i < baseFiles.Length; i++)
                {
                    bool found = Array.Exists(genFiles, gFile => string.Equals(gFile.Name, baseFiles[i].Name));
                    if (!found)
                    {
                        writer.WriteError("\tAdded:  " + baseFiles[i].Name);
                    }
                }
                writer.EndError();
            }

            Dictionary <string, int> allFiles = new Dictionary <string, int>();

            foreach (IFileInfo bFile in baseFiles)
            {
                allFiles[bFile.Name] = 1;
            }

            foreach (IFileInfo gFile in genFiles)
            {
                allFiles[gFile.Name] = 1;
            }

            Dictionary <string, InstanceReport> tryVerifyEmbedded = new Dictionary <string, InstanceReport>();

            foreach (string file in allFiles.Keys)
            {
                if (!R_FILE_REGEX.IsMatch(file))
                {
                    continue;
                }

                InstanceReport baseReport = null;
                InstanceReport genReport  = null;

                try
                {
                    if (baselineResultInfo.FileExists(file))
                    {
                        using (Stream fileStream = baselineResultInfo.OpenStream(file))
                        {
                            baseReport = InstanceReport.LoadXmlStream(fileStream);
                        }
                    }

                    if (generatedResultInfo.FileExists(file))
                    {
                        using (Stream fileStream = generatedResultInfo.OpenStream(file))
                        {
                            genReport = InstanceReport.LoadXmlStream(fileStream);
                        }
                    }

                    if (baseReport == null)
                    {
                        throw new Exception("Base report is missing.");
                    }
                    else
                    {
                        foreach (InstanceReportRow row in baseReport.Rows)
                        {
                            foreach (Cell cell in row.Cells)
                            {
                                cell.FlagID = 0;
                            }
                        }
                    }

                    if (genReport == null)
                    {
                        throw new Exception("Generated report is missing.");
                    }
                    else
                    {
                        foreach (InstanceReportRow row in baseReport.Rows)
                        {
                            foreach (Cell cell in row.Cells)
                            {
                                cell.FlagID = 0;
                            }
                        }
                    }

                    writer.StartReport(file, baseReport, genReport, failedResultsFolder);
                    writer.WriteLine(PathCombine(baselineResultInfo.FullName, file));
                    writer.WriteLine(PathCombine(generatedResultInfo.FullName, file));

                    VerifyReports(writer, baseReport, genReport);
                }
                catch (Exception ex)
                {
                    writer.StartReport(file, baseReport, genReport, failedResultsFolder);
                    writer.WriteError(ex.Message);
                }
                finally
                {
                    writer.EndReport(file);
                }
            }
        }
示例#9
0
        /// <summary>
        /// Compares the footnotes of the base and generated reports and writes errors for discrepancies.
        /// </summary>
        /// <param name="writer">Where to output errors</param>
        /// <param name="baseReport">The base report to compare against</param>
        /// <param name="genReport">The new report for testing</param>
        private static void VerifyReportFootnotes(ErrorWriter writer, InstanceReport baseReport, InstanceReport genReport)
        {
            bool hasIssue = false;

            // Initial strict checks for performance
            if (baseReport.Footnotes.Count != genReport.Footnotes.Count)
            {
                hasIssue = true;
            }
            else
            {
                for (int i = 0; i < baseReport.Footnotes.Count; i++)
                {
                    if (!string.Equals(baseReport.Footnotes[i].NoteId, genReport.Footnotes[i].NoteId) || (baseReport.Footnotes[i].Note != baseReport.Footnotes[i].Note))
                    {
                        // If we find a discrepancy, there's no need to continue
                        hasIssue = true;
                        break;
                    }
                }
            }

            if (!hasIssue)
            {
                return;
            }

            // The first checks if the base footnotes are in the generated report
            bool inGen = false, outOfOrder = false;
            int  genFootnoteLocation = -1;

            foreach (Footnote iBase in baseReport.Footnotes)
            {
                // 99 and 100 are used for debug
                if (iBase.NoteId > 98)
                {
                    continue;
                }

                inGen      = false;
                outOfOrder = false;
                foreach (Footnote iGen in genReport.Footnotes)
                {
                    if (string.Equals(WHITE_SPACE.Replace(iBase.Note, " "), WHITE_SPACE.Replace(iGen.Note, " ")))
                    {
                        inGen = true;
                        if (iBase.NoteId != iGen.NoteId)
                        {
                            outOfOrder          = true;
                            genFootnoteLocation = iGen.NoteId;
                        }
                        break;
                    }
                }

                // Not found in the generated report
                if (!inGen)
                {
                    writer.WriteError("<strong>The generated report is missing a footnote:</strong>",
                                      "\t[" + iBase.NoteId.ToString() + "] " + iBase.Note);
                }
                // Found, but out of order
                else if (outOfOrder)
                {
                    writer.WriteError("<strong>The footnote location has changed:</strong>",
                                      "\tOriginal Footnote Location: " + iBase.NoteId.ToString(),
                                      "\tNew Footnote Location: " + genFootnoteLocation.ToString(),
                                      "\tFootnote Text: " + iBase.Note);
                }
            }

            // This loop ensures all generated footnotes were in the main report
            bool inBase = false;

            foreach (Footnote iGen in genReport.Footnotes)
            {
                // 99 and 100 are used for debug
                if (iGen.NoteId > 98)
                {
                    continue;
                }

                inBase = false;
                foreach (Footnote iBase in baseReport.Footnotes)
                {
                    if (string.Equals(WHITE_SPACE.Replace(iBase.Note, " "), WHITE_SPACE.Replace(iGen.Note, " ")))
                    {
                        inBase = true;
                        break;
                    }
                }

                // 99 and 100 are used for debug
                if (!inBase)
                {
                    writer.WriteError("<strong>The generated report created an additional footnote:</strong>",
                                      "\t[" + iGen.NoteId.ToString() + "] " + iGen.Note);
                }
            }

            return;
        }
示例#10
0
        /// <summary>
        /// Perform some manipulation on the equity report to clean it up, sort
        /// it, and shift around segments, and shift items between rows and
        /// columns.
        /// </summary>
        /// <param name="baseReport">The base report upon which the equity
        /// report is being processed.</param>
        public void AdjustEquityPeriods(InstanceReport baseReport)
        {
            Dictionary <string, EquityPeriod> periodGroupings = new Dictionary <string, EquityPeriod>();

            foreach (InstanceReportRow row in this.EquityCandidate.Rows)
            {
                if (!periodGroupings.ContainsKey(row.EmbedRequirements.Period.ToString()))
                {
                    periodGroupings[row.EmbedRequirements.Period.ToString()] = new EquityPeriod();
                }

                periodGroupings[row.EmbedRequirements.Period.ToString()].Rows.Add(row);
            }

            List <string> keysToRemove = new List <string>();

            foreach (KeyValuePair <string, EquityPeriod> kvp in periodGroupings)
            {
                kvp.Value.DistributeRows();
                kvp.Value.RemoveEmptyRows();
                kvp.Value.RemoveActivityStyles();

                if (kvp.Value.AreBalancesEmpty())
                {
                    keysToRemove.Add(kvp.Key);
                }
                else if (kvp.Value.IsActivityEmpty())
                {
                    keysToRemove.Add(kvp.Key);
                }
                else if (!kvp.Value.HasSegmentedData(this.EquityCandidate.Columns))
                {
                    keysToRemove.Add(kvp.Key);
                }
            }

            foreach (string key in keysToRemove)
            {
                periodGroupings.Remove(key);
            }

            EquityPeriod nextPeriod = null;

            this.EquityCandidate.Rows.Clear();
            List <string> periodStrings = new List <string>(periodGroupings.Keys);

            if (periodStrings.Count == 0)
            {
                return;
            }

            if (periodStrings.Count == 1)
            {
                nextPeriod = periodGroupings[periodStrings[0]];
                nextPeriod.DistributeRows();
                nextPeriod.Sort(baseReport);
            }
            else
            {
                for (int k = 0; k < periodStrings.Count - 1; k++)
                {
                    string       thisPK     = periodStrings[k];
                    EquityPeriod thisPeriod = periodGroupings[thisPK];
                    thisPeriod.DistributeRows();

                    string nextPK = periodStrings[k + 1];
                    nextPeriod = periodGroupings[nextPK];
                    nextPeriod.DistributeRows();

                    if (thisPeriod.EndDateMatchesBeginDate(nextPeriod))
                    {
                        thisPeriod.MergeAndReduceBeginningBalances(nextPeriod);
                    }

                    thisPeriod.Sort(baseReport);
                    this.EquityCandidate.Rows.AddRange(thisPeriod.Rows);
                }

                nextPeriod.Sort(baseReport);
            }

            this.EquityCandidate.Rows.AddRange(nextPeriod.Rows);
        }
示例#11
0
        /// <summary>
        /// Creates and saves a list of unique columns based on their segments and scenarios.
        /// </summary>
        /// <param name="baseReport">The base report to load segment scenarios
        /// from.</param>
        public void LoadSegmentScenarioColumns(InstanceReport baseReport)
        {
            Dictionary <string, Segment> uniqueAdjustments = new Dictionary <string, Segment>();
            Dictionary <string, Segment> uniquePrevious    = new Dictionary <string, Segment>();


            List <InstanceReportColumn> consolidatedColumns  = new List <InstanceReportColumn>();
            List <InstanceReportColumn> uniqueSegmentColumns = new List <InstanceReportColumn>();

            foreach (InstanceReportColumn baseColumn in baseReport.Columns)
            {
                //create a clone so that we can digest this data without affecting other references
                InstanceReportColumn clone = (InstanceReportColumn)baseColumn.Clone();

                int index;
                if (clone.IsAdjusted(this.AdjustedAndPRMemberLookup, out index))
                {
                    Segment seg = (Segment)clone.Segments[index];
                    uniqueAdjustments[seg.DimensionInfo.dimensionId] = seg;

                    clone.RemoveAdjustedPreviouslyReported(this.AdjustedAndPRMemberLookup);
                    clone.RemoveMissingSegmentLabels();
                }
                else if (clone.IsAsPreviouslyReported(this.AdjustedAndPRMemberLookup, out index))
                {
                    Segment seg = (Segment)clone.Segments[index];
                    uniquePrevious[seg.DimensionInfo.dimensionId] = seg;

                    clone.RemoveAdjustedPreviouslyReported(this.AdjustedAndPRMemberLookup);
                    clone.RemoveMissingSegmentLabels();
                }


                bool exists = ReportUtils.Exists(uniqueSegmentColumns,
                                                 tmp =>
                {
                    if (!tmp.SegmentAndScenarioEquals(clone))
                    {
                        return(false);
                    }

                    if (!tmp.CurrencyEquals(clone))
                    {
                        return(false);
                    }

                    return(true);
                });

                if (!exists)
                {
                    if (clone.Segments == null || clone.Segments.Count == 0)
                    {
                        consolidatedColumns.Add(clone);
                    }

                    uniqueSegmentColumns.Add(clone);
                }
            }

            if (consolidatedColumns != null && consolidatedColumns.Count > 0)
            {
                foreach (InstanceReportColumn cCol in consolidatedColumns)
                {
                    uniqueSegmentColumns.Remove(cCol);
                    uniqueSegmentColumns.Add(cCol);
                    cCol.Labels[0].Label = InstanceReport.EQUITY_TOTAL_HEADER;
                }
            }


            this.EquityCandidate.Columns.AddRange(uniqueSegmentColumns);

            //now clean off the calendars
            this.SegmentColumns.ForEach(col => col.ClearReportingPeriod());

            //and sort according to presentation
            this.SegmentColumns.Sort(baseReport.CompareSegments);

            this.AdjustmentMembers = new List <Segment>(uniqueAdjustments.Values);
            this.PreviousMembers   = new List <Segment>(uniquePrevious.Values);
        }
示例#12
0
        /// <summary>
        /// Looks through each segment of each axis in the given report to
        /// determine which is column/row based, then passes the results on for
        /// embed processing.  The result is stored in <see
        /// cref="EquityCandidate"/>.
        /// </summary>
        /// <param name="baseReport">The <see cref="InstanceReport"/> upon
        /// which to generate an equity style report.</param>
        /// <returns>A <see cref="bool"/> indicating success.</returns>
        public bool PopulateEquityReport(InstanceReport baseReport)
        {
            Dictionary <string, CommandIterator> columnCommands = new Dictionary <string, CommandIterator>();

            foreach (string axis in baseReport.AxisByPresentation)
            {
                bool axisFound = false;
                foreach (InstanceReportColumn segmentColumn in this.SegmentColumns)
                {
                    if (segmentColumn.Segments == null || segmentColumn.Segments.Count == 0)
                    {
                        continue;
                    }

                    foreach (Segment seg in segmentColumn.Segments)
                    {
                        if (string.Equals(seg.DimensionInfo.dimensionId, axis))
                        {
                            CommandIterator ci = new CommandIterator(CommandIterator.IteratorType.Column, axis, CommandIterator.StyleType.Compact, "*");
                            columnCommands[ci.AxisName] = ci;
                            axisFound = true;
                        }
                    }

                    if (axisFound)
                    {
                        break;
                    }
                }
            }

            CommandIterator unitCmd = new CommandIterator(CommandIterator.IteratorType.Column, "unit", CommandIterator.StyleType.Grouped, "*");

            columnCommands[unitCmd.SelectionString] = unitCmd;



            Dictionary <string, CommandIterator> rowCommands = new Dictionary <string, CommandIterator>();
            CommandIterator calCmd = new CommandIterator(CommandIterator.IteratorType.Row, "period", CommandIterator.StyleType.Grouped, "*");

            rowCommands[calCmd.SelectionString] = calCmd;

            CommandIterator elCmd = new CommandIterator(CommandIterator.IteratorType.Row, "primary", CommandIterator.StyleType.Compact, "*");

            rowCommands[elCmd.SelectionString] = elCmd;

            foreach (string axis in baseReport.AxisByPresentation)
            {
                if (columnCommands.ContainsKey(axis))
                {
                    continue;
                }

                if (rowCommands.ContainsKey(axis))
                {
                    continue;
                }

                CommandIterator specCmd = new CommandIterator(CommandIterator.IteratorType.Row, axis, CommandIterator.StyleType.Compact, "*");
                rowCommands[specCmd.AxisName] = specCmd;
            }


            EmbedReport            equityTransform = new EmbedReport();
            List <CommandIterator> colCmds         = new List <CommandIterator>(columnCommands.Values);

            equityTransform.ColumnIterators = colCmds.ToArray();

            List <CommandIterator> rowCmds = new List <CommandIterator>(rowCommands.Values);

            equityTransform.RowIterators = rowCmds.ToArray();

            equityTransform.AxisByPresentation = baseReport.AxisByPresentation;
            if (equityTransform.ProcessEmbedCommands(baseReport, null))
            {
                this.EquityCandidate = equityTransform.InstanceReport;
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#13
0
 /// <summary>
 /// Pull the rows from the <paramref name="baseReport"/> into the
 /// respective lists for each type of balance.
 /// </summary>
 /// <param name="baseReport">The base report to load rows from.</param>
 public void LoadRowTypes(InstanceReport baseReport)
 {
     this.BBRows  = baseReport.Rows.FindAll(row => row.IsBeginningBalance);
     this.RegRows = baseReport.Rows.FindAll(row => !(row.IsBeginningBalance || row.IsEndingBalance));
     this.EBRows  = baseReport.Rows.FindAll(row => row.IsEndingBalance);
 }