/// <summary> /// Process the embed commands within the given <paramref /// name="baseReport"/>. /// </summary> /// <param name="baseReport">The <see cref="InstanceReport"/> in which /// to process embed commands.</param> /// <param name="messenger">An <see cref="ITraceMessenger"/> on which /// to log messages encountered during processing commands.</param> /// <returns></returns> public bool ProcessEmbedCommands(InstanceReport baseReport, ITraceMessenger messenger) { //Fill this in in case bar charts need to generate values if (this.IsBarChartReport()) { //TODO: audit this... foreach (InstanceReportRow row in baseReport.Rows) { row.EmbedRequirements = new ColumnRowRequirement { ElementRow = (InstanceReportRow)row.Clone() }; } } if (ReportUtils.IsShowElements(baseReport.ReportLongName)) { this.InstanceReport = baseReport; return(false); } try { this.AddDefaultIterators(baseReport); if (this.RowIterators.Length == 0) { messenger.TraceWarning("Warning: The embed commands for '" + baseReport.ReportLongName + "' are incomplete." + Environment.NewLine + "No 'row' commands were found."); this.InstanceReport = baseReport; return(false); } if (this.ColumnIterators.Length == 0) { messenger.TraceWarning("Warning: The embed commands for '" + baseReport.ReportLongName + "' are incomplete." + Environment.NewLine + "No 'column' commands were found."); this.InstanceReport = baseReport; return(false); } //Console.WriteLine( "Building Embedded Report: " + baseReport.ReportLongName ); foreach (CommandIterator itr in this.selections.Values) { //Console.WriteLine( "\t"+ itr.ToString() ); } this.IsTransposed = ReportUtils.IsTransposeReport(baseReport.ReportLongName); if (this.IsTransposed) { this.TransposeIterators(); } this.baseReport = baseReport; this.InstanceReport = new InstanceReport(); this.InstanceReport.AxisByPresentation = this.baseReport.AxisByPresentation; this.InstanceReport.AxisMembersByPresentation = this.baseReport.AxisMembersByPresentation; this.InstanceReport.AxisMemberDefaults = this.baseReport.AxisMemberDefaults; this.InstanceReport.IsEquityReport = this.baseReport.IsEquityReport; LinkedList <CommandIterator> iterators = new LinkedList <CommandIterator>(this.ColumnIterators); foreach (CommandIterator itr in this.RowIterators) { iterators.AddLast(itr); } DateTime start = DateTime.Now; { this.selectionCount = 0; this.ProcessIteratorsHierarchically(iterators, messenger); TimeSpan ts = DateTime.Now - start; //Console.WriteLine( this.selectionCount + " selections performed in " + ts.ToString() ); //because the rows might come in out of order, we simply need to correct the order at the last moment. this.SortByCommands(this.RowIterators); } if (this.InstanceReport.Rows.Count == 0 || this.InstanceReport.Columns.Count == 0) { this.InstanceReport = baseReport; return(false); } this.InstanceReport.PopulateEmbeddedReport(this.baseReport, this.ColumnIterators, this.RowIterators, messenger); if (this.InstanceReport.Rows.Count == 0 || this.InstanceReport.Columns.Count == 0) { this.InstanceReport = baseReport; this.baseReport = null; //a little cleanup return(false); } else { this.baseReport = null; //a little cleanup return(true); } } finally { this.InstanceReport.ReportLongName = baseReport.ReportLongName; this.InstanceReport.ShowElementNames = ReportUtils.IsShowElements(baseReport.ReportLongName); this.InstanceReport.RemoveLabelColumn(); #if DEBUG this.InstanceReport.Footnotes.Add( new Footnote(99, this.EmbedInstruction.Replace("<", "<").Replace(">", ">")) ); #endif } }