示例#1
0
 /// <summary>
 /// Defines one aspect of aggregation config
 /// </summary>
 /// <param name="aggregationAspect">The aggregation aspect to be declared.</param>
 /// <param name="types">The types to be set for the aspect</param>
 public imbAttribute(dataPointAggregationAspect aggregationAspect, dataPointAggregationType types)
 {
     nameEnum = imbAttributeName.reporting_aggregation;
     name     = nameof(imbAttributeName.reporting_aggregation);
     objExtra = aggregationAspect;
     objMsg   = types;
     msg      = types.ToString();
 }
示例#2
0
        public dataPointAggregationType this[dataPointAggregationAspect key]
        {
            get
            {
                switch (key)
                {
                case dataPointAggregationAspect.lateralMultiTable:
                    return(lateralRightColumns);

                    break;

                case dataPointAggregationAspect.onTableMultiRow:
                    return(multiRowType);

                    break;

                case dataPointAggregationAspect.overlapMultiTable:
                    return(multiTableType);

                    break;

                case dataPointAggregationAspect.subSetOfRows:
                    return(subSetOfRows);

                    break;

                default:
                    return(dataPointAggregationType.none);

                    break;
                }
            }
            set
            {
                switch (key)
                {
                case dataPointAggregationAspect.lateralMultiTable:
                    lateralRightColumns = value;
                    break;

                case dataPointAggregationAspect.onTableMultiRow:
                    multiRowType = value;
                    break;

                case dataPointAggregationAspect.overlapMultiTable:
                    multiTableType = value;
                    break;

                case dataPointAggregationAspect.subSetOfRows:
                    subSetOfRows = value;
                    break;

                default:

                    break;
                }
            }
        }
示例#3
0
        public DataTableAggregationDefinition(IEnumerable <DataTable> tables, dataPointAggregationAspect aspect = dataPointAggregationAspect.overlapMultiTable)
        {
            if (tables == null)
            {
                return;
            }
            if (!tables.Any())
            {
                return;
            }

            process(tables, aspect);
        }
示例#4
0
 public static DataTableAggregationDefinition GetAggregatedTableDescription(this IEnumerable <DataTable> tables, dataPointAggregationAspect aspect = dataPointAggregationAspect.overlapMultiTable)
 {
     return(new DataTableAggregationDefinition(tables, aspect));
 }
示例#5
0
        /// <summary>
        /// Gets the aggregated table> where values are computed as agregation from multi source tables.
        /// </summary>
        /// <param name="tables">The tables.</param>
        /// <param name="tablename">The tablename.</param>
        /// <param name="aspect">The aspect.</param>
        /// <param name="logger">The logger.</param>
        /// <returns></returns>
        public static DataTable GetAggregatedTable(this IEnumerable <DataTable> tables, string tablename = "summary", dataPointAggregationAspect aspect = dataPointAggregationAspect.overlapMultiTable, ILogBuilder logger = null)
        {
            if (tables == null)
            {
                if (logger != null)
                {
                    logger.log("GetAggregatedTable --> received no tables!!!");
                }
                return(new DataTable(tablename));
            }
            if (!tables.Any())
            {
                if (logger != null)
                {
                    logger.log("GetAggregatedTable --> received no tables!!!");
                }
                return(new DataTable(tablename));
            }

            DataTableAggregationDefinition definition = new DataTableAggregationDefinition(tables, dataPointAggregationAspect.overlapMultiTable);
            DataTable output = definition.getShema(tablename);

            for (int i = 0; i < definition.rowsMax; i++)
            {
                DataRow o_dr = output.Rows[i];
                foreach (var pair in definition.shemaColumns)
                {
                    double        min    = 0;
                    double        max    = 0;
                    List <double> i_data = new List <double>();

                    foreach (DataTable dt in tables)
                    {
                        if (i < dt.Rows.Count)
                        {
                            DataRow i_dr = dt.Rows[i];
                            i_data.Add(i_dr[pair.Key].imbConvertValueSafeTyped <double>());
                        }
                    }

                    foreach (var colDef in pair.Value)
                    {
                        double outValue = 0;

                        switch (colDef.aggregation)
                        {
                        case dataPointAggregationType.avg:
                            outValue = i_data.Average();
                            break;

                        case dataPointAggregationType.clear:
                            outValue = 0;
                            break;

                        case dataPointAggregationType.count:
                            outValue = i_data.Count();
                            break;

                        case dataPointAggregationType.max:
                            outValue = i_data.Max();
                            break;

                        case dataPointAggregationType.min:
                            outValue = i_data.Min();
                            break;

                        case dataPointAggregationType.range:
                            min      = i_data.Min();
                            max      = i_data.Max();
                            outValue = max - min;
                            break;

                        case dataPointAggregationType.sum:
                            outValue = i_data.Sum();
                            break;

                        case dataPointAggregationType.var:
                            outValue = i_data.GetVariance();
                            break;

                        case dataPointAggregationType.stdev:
                            outValue = i_data.GetStdDeviation();
                            break;

                        case dataPointAggregationType.firstEntry:
                            outValue = i_data.First();
                            break;

                        case dataPointAggregationType.lastEntry:
                            outValue = i_data.Last();
                            break;

                        case dataPointAggregationType.hidden:
                        case dataPointAggregationType.none:
                            break;
                        }

                        o_dr[colDef.columnName] = outValue.imbConvertValueSafe(colDef.columnValueType);
                    }

                    o_dr.AcceptChanges();
                    //output.Rows.Add(o_dr);
                }
            }

            return(output);
        }
示例#6
0
 public static DataTable SetAggregationAspect(this DataTable dc, dataPointAggregationAspect data_aggregation_type)
 {
     dc.ExtendedProperties.add(templateFieldDataTable.data_aggregation_type, data_aggregation_type);
     return(dc);
 }
示例#7
0
 /// <summary>
 /// Aggregation Aspect that used to create this table. If its <see cref="imbSCI.Core.math.aggregation.dataPointAggregationAspect.none" /> then this is a source table not derived one
 /// </summary>
 /// <param name="dc">The dc.</param>
 /// <param name="default_data_aggregation_type">Default type of the data aggregation.</param>
 /// <returns></returns>
 public static dataPointAggregationAspect AggregationAspect(this DataTable dc, dataPointAggregationAspect default_data_aggregation_type)
 {
     if (!dc.ExtendedProperties.ContainsKey(templateFieldDataTable.data_aggregation_type))
     {
         dc.ExtendedProperties.add(templateFieldDataTable.data_aggregation_type, default_data_aggregation_type);
     }
     return((dataPointAggregationAspect)dc.ExtendedProperties[templateFieldDataTable.data_aggregation_type]);
 }
        public DataTable RenderLegend()
        {
            DataTable legend = new DataTable(LEGENDTABLE_NAME);

            DataColumn columnName        = legend.Add("Name").SetDefaultBackground(styleSet.extraEven).SetWidth(20);
            DataColumn columnDescription = legend.Add("Description").SetDefaultBackground(styleSet.dataOdd).SetWidth(120);
            DataColumn columnGroup       = legend.Add("Group").SetDefaultBackground(styleSet.columnCaption).SetWidth(25);
            DataColumn columnLetter      = legend.Add("Letter").SetDefaultBackground(styleSet.extraOdd).SetWidth(20);
            DataColumn columnUnit        = legend.Add("Unit").SetDefaultBackground(styleSet.extraEven).SetWidth(10);

            extraRowStyles.Add(legend.AddRow("Table name", this.GetTitle()), DataRowInReportTypeEnum.columnDescription);
            extraRowStyles.Add(legend.AddRow("Table description", this.GetDescription()), DataRowInReportTypeEnum.columnDescription);

            dataPointAggregationAspect aspect = this.GetAggregationAspect();

            if (aspect != dataPointAggregationAspect.none)
            {
                extraRowStyles.Add(legend.AddRow("Aggregated aspect", this.GetAggregationAspect()), DataRowInReportTypeEnum.columnDescription);
                extraRowStyles.Add(legend.AddRow("Aggregated sources", this.GetAggregationOriginCount()), DataRowInReportTypeEnum.columnDescription);
            }

            String classname = this.GetClassName();

            if (!classname.isNullOrEmpty())
            {
                extraRowStyles.Add(legend.AddRow("Table class name", this.GetClassName()), DataRowInReportTypeEnum.columnDescription);
            }
            legend.AddLineRow();
            //legend.AddRow("Table class name", this.);

            extraRowStyles.Add(legend.AddExtraRow(templateFieldDataTable.col_caption, 200), DataRowInReportTypeEnum.columnCaption);

            foreach (DataColumn dc in Columns)
            {
                var dr = legend.NewRow();

                dr[columnGroup]       = dc.GetGroup();
                dr[columnName]        = dc.GetHeading();
                dr[columnLetter]      = dc.GetLetter();
                dr[columnUnit]        = dc.GetUnit();
                dr[columnDescription] = dc.GetDesc();

                legend.Rows.Add(dr);
            }

            extraRowStyles.Add(legend.AddLineRow(), DataRowInReportTypeEnum.mergedHorizontally);

            var pce = this.GetAdditionalInfo();

            extraRowStyles.Add(legend.AddRow("Additional information"), DataRowInReportTypeEnum.mergedFooterInfo);

            extraRowStyles.Add(legend.AddRow("Property", "Value", "Info"), DataRowInReportTypeEnum.columnCaption);
            foreach (KeyValuePair <object, PropertyEntry> entryPair in pce.entries)
            {
                extraRowStyles.Add(legend.AddRow(entryPair.Key, entryPair.Value[PropertyEntryColumn.entry_value], entryPair.Value[PropertyEntryColumn.entry_description]), DataRowInReportTypeEnum.columnInformation);
            }

            foreach (string ext in this.GetExtraDesc())
            {
                extraRowStyles.Add(legend.AddStringLine(ext), DataRowInReportTypeEnum.mergedFooterInfo);
            }

            extraRowStyles.Add(legend.AddLineRow(), DataRowInReportTypeEnum.mergedHorizontally);

            extraRowStyles.Add(legend.AddStringLine(imbSCICoreConfig.settings.DataTableReports_SignatureLine), DataRowInReportTypeEnum.mergedHorizontally);
            if (!imbSCICoreConfig.settings.DataTableReports_SignatureLine.Contains("imbVeles"))
            {
                extraRowStyles.Add(legend.AddStringLine(SHORT_SIGNATURE), DataRowInReportTypeEnum.mergedHorizontally);
            }

            return(legend);
        }
示例#9
0
        public void process(IEnumerable <DataTable> tables, dataPointAggregationAspect __aspect = dataPointAggregationAspect.overlapMultiTable)
        {
            aspect = __aspect;

            string __desc = "This table is result of summary operation (" + aspect.ToString() + ") over tables: ";
            int    tc     = 0;

            int rcMin  = int.MaxValue;
            int rcMax  = int.MinValue;
            int rcProc = 0;

            DataTable shemaProvider = null;

            foreach (DataTable dt in tables)
            {
                if (shemaProvider == null)
                {
                    shemaProvider = dt;
                }

                tc++;
                if (tc < 5)
                {
                    __desc = __desc.add(dt.GetTitle(), ", ");
                }
                rcMin   = Math.Min(dt.Rows.Count, rcMin);
                rcMax   = Math.Max(dt.Rows.Count, rcMax);
                rcProc += dt.Rows.Count;
            }

            additionalProps.AddRange(shemaProvider.GetAdditionalInfo(), false, false, false);

            categoriesPriority = shemaProvider.GetCategoryPriority();
            if (categoriesPriority.Any())
            {
            }

            if (tc > 4)
            {
                __desc = __desc.add("... in total: " + tc + " tables", ", ");
            }
            sources       = tc;
            rowsMax       = rcMax;
            rowsCommon    = rcMin;
            rowsProcessed = rcProc;

            additionalProps.Add(ADDPROPS_ROWSMAX, rcMax, ADDPROPS_ROWSMAX, "Highest row count in the table set");
            additionalProps.Add(ADDPROPS_ROWSCOMMON, rcMin, ADDPROPS_ROWSCOMMON, "Lowest row count in the table set");
            additionalProps.Add(ADDPROPS_ROWSPROCESSED, rcProc, ADDPROPS_ROWSPROCESSED, "Total count of rows processed");
            additionalProps.Add("Category", categoriesPriority.toCsvInLine());

            extraDescriptions.Add("[" + sources + "] source tables had at least [" + rowsCommon + "] rows. Maximum rows per source table: [" + rowsMax + "]");

            shemaColumns = new DataColumnMetaDictionary();

            foreach (DataColumn dc in shemaProvider.Columns)
            {
                /* FINDING AGGREGATION SETTINGS */
                settingsPropertyEntry          spe = dc.GetSPE();
                dataPointAggregationDefinition agg = null;
                if (spe.aggregation == null)
                {
                    PropertyInfo pi = dc.ExtendedProperties.getProperObject <PropertyInfo>(templateFieldDataTable.col_propertyInfo); //, col_spe.pi);
                    if (pi != null)
                    {
                        spe = new settingsPropertyEntry(pi);
                    }
                }
                if (spe.aggregation == null)
                {
                    spe.aggregation = new dataPointAggregationDefinition();
                }
                agg = spe.aggregation;
                /* ----------------------------- */

                if (agg[aspect] != dataPointAggregationType.none)
                {
                    List <dataPointAggregationType> aggTypes = agg[aspect].getEnumListFromFlags <dataPointAggregationType>();

                    foreach (dataPointAggregationType a in aggTypes)
                    {
                        if (a != dataPointAggregationType.hidden)
                        {
                            shemaColumns.Add(DataColumnInReportTypeEnum.dataSummed, dc, a, dc.GetUnit());
                        }
                    }
                }
            }

            desc = __desc;
        }