コード例 #1
0
        private EntitySchemaQueryColumn AddAggregatedColumn(JObject yAxisConfig)
        {
            AggregationType columnAggregationType = AggregationType.Count;
            string          aggregationType       = SerieParameters.Value <string>("func");

            if (!string.IsNullOrEmpty(aggregationType))
            {
                columnAggregationType = (AggregationType)Enum.Parse(typeof(AggregationType),
                                                                    aggregationType);
            }
            EntitySchemaQueryExpression columnExpression = EntitySchemaQuery.CreateSchemaColumnExpression(
                Esq.RootSchema, GroupColumnPath);

            columnExpression.UId = Guid.NewGuid();
            var queryFunction = new EntitySchemaAggregationQueryFunction(columnAggregationType.ToStrict(),
                                                                         columnExpression, Esq);

            if (columnAggregationType == AggregationType.Count)
            {
                queryFunction.AggregationEvalType = AggregationEvalType.Distinct;
            }
            EntitySchemaQueryColumn column = Esq.AddColumn(queryFunction);
            var columnMap = new Dictionary <string, object>();

            columnMap["valueAlias"]           = column.ValueExpression.Function.QueryAlias;
            columnMap["dataValueType"]        = columnExpression.SchemaColumn.DataValueType;
            entityColumnsMap[GroupColumnPath] = columnMap;
            yAxisConfig["dataValueType"]      = GetColumnDataValueType(columnExpression);
            return(column);
        }
コード例 #2
0
        private EntitySchemaQueryColumn AddQueryColumn(JObject columnItem, string columnPath)
        {
            columnPath = DashboardDataUtils.ClearColumnPathSuffix(columnPath);
            string          filterData            = columnItem.Value <string>("serializedFilter");
            string          aggregationType       = columnItem.Value <string>("aggregationType");
            AggregationType columnAggregationType = AggregationType.None;

            if (!string.IsNullOrEmpty(aggregationType))
            {
                columnAggregationType = (AggregationType)Enum.Parse(typeof(AggregationType),
                                                                    aggregationType);
            }
            EntitySchemaQueryColumn column;

            if (columnAggregationType != AggregationType.None && !string.IsNullOrEmpty(filterData))
            {
                EntitySchemaQuery subQuery;
                column = Esq.AddColumn(columnPath, columnAggregationType.ToStrict(), out subQuery);
                var dashboardData = new BaseDashboardItemSelectBuilder(UserConnection, subQuery);
                dashboardData.AddFilterByJson(filterData);
            }
            else
            {
                column = Esq.AddColumn(columnPath);
                if (!string.IsNullOrEmpty(aggregationType))
                {
                    column.SummaryType = columnAggregationType;
                }
            }
            SetColumnOrder(columnItem, column);
            return(column);
        }
コード例 #3
0
        public override Select Build()
        {
            string columnPath = Parameters.Value <string>("columnName");

            if (string.IsNullOrEmpty(columnPath))
            {
                columnPath = Esq.RootSchema.PrimaryColumn.ColumnValueName;
            }
            EntitySchemaQueryExpression columnExpression = EntitySchemaQuery.CreateSchemaColumnExpression(
                Esq.RootSchema, columnPath);

            columnExpression.UId = Guid.NewGuid();
            AggregationType columnAggregationType = AggregationType.Count;
            string          aggregationType       = Parameters.Value <string>("aggregationType");

            if (!string.IsNullOrEmpty(aggregationType))
            {
                columnAggregationType = (AggregationType)Enum.Parse(typeof(AggregationType),
                                                                    aggregationType);
            }
            var queryFunction = new EntitySchemaAggregationQueryFunction(columnAggregationType.ToStrict(),
                                                                         columnExpression, Esq);

            ColumnDataValueType = GetColumnDataValueType(columnExpression);
            Esq.AddColumn(queryFunction);
            EntityColumnMap = new Dictionary <string, object>();
            EntityColumnMap["valueAlias"]    = queryFunction.QueryAlias;
            EntityColumnMap["dataValueType"] = columnExpression.SchemaColumn.DataValueType;
            string filterData = Parameters.Value <string>("filterData");

            AddFilterByJson(filterData);
            return(base.Build());
        }