Exemplo n.º 1
0
        public override Expression DoResolve(ParseContext ec)
        {
            if (Type != null)
            {
                return(this);
            }

            if (!ResolveInitializers(ec))
            {
                return(null);
            }

            if (ResolvedElementType == null ||
                ResolvedElementType == TypeManager.CoreTypes.Null ||
                ResolvedElementType == TypeManager.CoreTypes.Void ||
                (Dimensions.Any() && Dimensions.Count != ResolvedDimensions))
            {
                OnErrorNoBestType(ec);
                return(null);
            }

            //
            // At this point we found common base type for all initializer elements
            // but we have to be sure that all static initializer elements are of
            // same type
            //
            UnifyInitializerElement(ec);

            Type            = TypeManager.GetConstructedType(ResolvedElementType, RankSpecifier);
            ExpressionClass = ExpressionClass.Value;

            return(this);
        }
        private void OnCheckDimension(bool isChecked)
        {
            var selectedType = Dimensions.FirstOrDefault(x => x.IsSelected)?.Type;

            foreach (var d in Dimensions)
            {
                // nothing selected let's enable everything
                if (string.IsNullOrEmpty(selectedType))
                {
                    d.IsEnabled = true;
                    continue;
                }

                // only dimensions that match the type selected
                // should be enabled here
                d.IsEnabled = d.Type == selectedType;
            }

            var replacementSelected = ReplacementDimensions.Count(x => x.IsSelected) > 0;

            foreach (var d in ReplacementDimensions)
            {
                if (string.IsNullOrEmpty(selectedType))
                {
                    d.IsEnabled = true;
                    continue;
                }

                if (replacementSelected)
                {
                    d.IsEnabled = d.IsSelected;
                    continue;
                }

                d.IsEnabled = d.Type == selectedType &&
                              !Dimensions.Where(x => x.IsSelected).Contains(d);
            }

            // if none of the types are selected let's clean selection
            // in replacement table as well
            if (Dimensions.Any(x => x.IsSelected))
            {
                return;
            }
            foreach (var d in ReplacementDimensions)
            {
                d.IsSelected = false;
            }
        }
Exemplo n.º 3
0
        public IEnumerable <IDictionary <string, object> > GetGroupedData()
        {
            PreQueryCompileChecks();
            var connection = new SqlConnection(connectionString);

            var db = new QueryFactory(connection, new SqlServerCompiler());

            db.Logger = compiled => { Debugger.Log(1, "logged", compiled.ToString()); };

            var query = db.Query(TableName);

            if (Dimensions.Any())
            {
                var dimensionColumns = GetDimensionColumns(Dimensions);
                query.Select(dimensionColumns.ToArray());
                query.GroupBy(dimensionColumns.ToArray());
            }
            var measureColumns = GenerateSelectColumnsForMeasures(Measures);

            foreach (var filter in Filters)
            {
                if (filter.Operator.ToLower() == "in")
                {
                    query.WhereIn(filter.ColumnName, filter.value.Split(','));
                }
                else
                {
                    query.Where(filter.ColumnName, filter.Operator, filter.value);
                }
            }

            foreach (var measureColumn in measureColumns)
            {
                query.SelectRaw(measureColumn);
            }

            var results = query.Get();
            List <IDictionary <string, object> > convertedResults = new List <IDictionary <string, object> >();

            foreach (var result in results)
            {
                convertedResults.Add((IDictionary <string, object>)result);
            }
            return(convertedResults);
        }
Exemplo n.º 4
0
        public string GetTitle()
        {
            if (Label != null)
            {
                return(Label);
            }

            if (Dimensions.Any())
            {
                if (Dimensions.Count > 1)
                {
                    return(Dimensions.Last().Value);
                }
                return($"{Dimensions.Single().Value} {Name}");
            }

            return(Name);
        }
Exemplo n.º 5
0
            public DimVariable(NameToken name, IEnumerable <Expression> dimensions)
            {
                if (name == null)
                {
                    throw new ArgumentNullException("name");
                }

                Name = name;
                if (dimensions == null)
                {
                    Dimensions = null;
                    return;
                }
                Dimensions = dimensions.ToList().AsReadOnly();
                if (Dimensions.Any(d => d == null))
                {
                    throw new ArgumentException("Null reference encountered in dimensions set");
                }
            }