示例#1
0
        private SimpleReport Pivot(SimpleReport simpleReport, PivotType pivotType)
        {
            var crossTabHeaders = pivotType == null
                ? new ReportColumn[0]
                : pivotType.GetCrosstabHeaders(simpleReport.Columns);
            var groupByColumns = pivotType == null
                ? new ReportColumn[0]
                : pivotType.GetGroupByColumns(simpleReport.Columns);

            foreach (ReportColumn id in crossTabHeaders)
            {
                groupByColumns.Remove(id);
            }
            var normalColumns   = new List <ReportColumn>();
            var crossTabColumns = new List <ReportColumn>();

            foreach (ReportColumn id in simpleReport.Columns)
            {
                Type   table;
                String column;
                Schema.Resolve(id.Table, id.Column, out table, out column);
                if (pivotType != null && pivotType.IsCrosstabValue(table, column))
                {
                    crossTabColumns.Add(id);
                }
                else
                {
                    normalColumns.Add(id);
                }
            }
            if (crossTabColumns.Count == 0)
            {
                return(simpleReport);
            }
            return(new PivotReport
            {
                Columns = normalColumns,
                GroupByColumns = new List <ReportColumn>(groupByColumns),
                CrossTabHeaders = crossTabHeaders,
                CrossTabValues = crossTabColumns
            });
        }
示例#2
0
        /// <summary>
        /// Returns a Report for the given set of columns.
        /// The columns are inspected to see which table has to be queried.
        /// Also, a PivotReport will be returned if any columns from a Results table were
        /// selected, and pivotResults is true.
        /// </summary>
        public Report GetReport(List <NodeData> columnInfos, PivotType pivotType)
        {
            // Get the common prefix, and the ancestor table it represents
            Identifier commonPrefix = GetCommonPrefix(columnInfos);
            Table      table        = MostManyTable;
            int        prefixLength = 0;

            if (commonPrefix != null)
            {
                prefixLength = commonPrefix.Parts.Count;
                for (int i = 0; i < prefixLength; i++)
                {
                    table = table.Parent.ParentTable;
                }
            }
            // Calculate the list of ReportColumns from the NodeData
            var displayColumns = new List <ReportColumn>();

            foreach (NodeData columnInfo in columnInfos)
            {
                Identifier identifier = columnInfo.ReportColumn.Column.RemovePrefix(prefixLength);
                if (columnInfo.Results)
                {
                    displayColumns.Add(new ReportColumn(table.ResultsClass, ToResultsIdentifier(identifier)));
                }
                else if (columnInfo.ResultsSummary)
                {
                    displayColumns.Add(new ReportColumn(table.ResultsSummaryClass, ToResultsSummaryIdentifier(identifier)));
                }
                else
                {
                    displayColumns.Add(new ReportColumn(table.PersistentClass, identifier));
                }
            }
            SimpleReport simpleReport = new SimpleReport
            {
                Columns = displayColumns
            };

            return(Pivot(simpleReport, pivotType));
        }
示例#3
0
 private bool IsEnabled(PivotType pivotType)
 {
     foreach (NodeData nodeData in _columns)
     {
         Type table;
         String column;
         _columnSet.ResolveColumn(nodeData, out table, out column);
         if (pivotType.IsCrosstabValue(table, column))
         {
             return true;
         }
     }
     return false;
 }
示例#4
0
        private SimpleReport Pivot(SimpleReport simpleReport, PivotType pivotType)
        {
            var crossTabHeaders = pivotType == null
                ? new ReportColumn[0]
                : pivotType.GetCrosstabHeaders(simpleReport.Columns);
            var groupByColumns = pivotType == null
                ? new ReportColumn[0]
                : pivotType.GetGroupByColumns(simpleReport.Columns);

            foreach (ReportColumn id in crossTabHeaders)
            {
                groupByColumns.Remove(id);
            }
            var normalColumns = new List<ReportColumn>();
            var crossTabColumns = new List<ReportColumn>();
            foreach (ReportColumn id in simpleReport.Columns)
            {
                Type table;
                String column;
                Schema.Resolve(id.Table, id.Column, out table, out column);
                if (pivotType != null && pivotType.IsCrosstabValue(table, column))
                {
                    crossTabColumns.Add(id);
                }
                else
                {
                    normalColumns.Add(id);
                }
            }
            if (crossTabColumns.Count == 0)
            {
                return simpleReport;
            }
            return new PivotReport
                       {
                           Columns = normalColumns,
                           GroupByColumns = new List<ReportColumn>(groupByColumns),
                           CrossTabHeaders = crossTabHeaders,
                           CrossTabValues = crossTabColumns
                       };
        }
示例#5
0
 /// <summary>
 /// Returns a Report for the given set of columns.
 /// The columns are inspected to see which table has to be queried.
 /// Also, a PivotReport will be returned if any columns from a Results table were
 /// selected, and pivotResults is true.
 /// </summary>
 public Report GetReport(List<NodeData> columnInfos, PivotType pivotType)
 {
     // Get the common prefix, and the ancestor table it represents
     Identifier commonPrefix = GetCommonPrefix(columnInfos);
     Table table = MostManyTable;
     int prefixLength = 0;
     if (commonPrefix != null)
     {
         prefixLength = commonPrefix.Parts.Count;
         for (int i = 0; i < prefixLength; i++ )
         {
             table = table.Parent.ParentTable;
         }
     }
     // Calculate the list of ReportColumns from the NodeData
     var displayColumns = new List<ReportColumn>();
     foreach(NodeData columnInfo in columnInfos)
     {
         Identifier identifier = columnInfo.ReportColumn.Column.RemovePrefix(prefixLength);
         if (columnInfo.Results)
         {
             displayColumns.Add(new ReportColumn(table.ResultsClass, ToResultsIdentifier(identifier)));
         }
         else if (columnInfo.ResultsSummary)
         {
             displayColumns.Add(new ReportColumn(table.ResultsSummaryClass, ToResultsSummaryIdentifier(identifier)));
         }
         else
         {
             displayColumns.Add(new ReportColumn(table.PersistentClass, identifier));
         }
     }
     SimpleReport simpleReport = new SimpleReport
                    {
                        Columns = displayColumns
                    };
     return Pivot(simpleReport, pivotType);
 }