Beispiel #1
0
        public bool Execute(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
        {
            var result = false;

            if (_predicates.Count > 0)
            {
                var query = _predicates.Skip(1);

                result = _predicates[0].Execute(pairs, data);

                if (!result)
                {
                    return(result);
                }

                foreach (var item in query)
                {
                    result = result && item.Execute(pairs, data);

                    if (!result)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        public bool Execute(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
        {
            if (data.ContainsKey(MeasureKey))
            {
                var value = data[MeasureKey];

                switch (_operator)
                {
                case LogicalOperators.EQUALS:
                    return(_value.Equals(value));

                case LogicalOperators.NOTEQUALS:
                    return(!_value.Equals(value));

                case LogicalOperators.GREATERTHAN:
                    return(_value.GreaterThan(value));

                case LogicalOperators.GREATEROREQUALS:
                    return(_value.GreaterOrEquals(value));

                case LogicalOperators.LOWERTHAN:
                    return(_value.LowerThan(value));

                case LogicalOperators.LOWEROREQUALS:
                    return(_value.LowerOrEquals(value));
                }
            }

            return(false);
        }
Beispiel #3
0
        private void EditProduct(object obj)
        {
            IsProductEdited = true;
            IsGroupEdited   = false;

            ProductKey      = (int)SelectedProduct.Row["ProductKey"];
            ProductName     = (string)SelectedProduct.Row["ProductName"];
            AutoCountEnergy = false;
            Protein         = (double)SelectedProduct.Row["Protein"];
            Fat             = (double)SelectedProduct.Row["Fat"];
            Carbohydrates   = (double)SelectedProduct.Row["Carbohydrates"];

            if (!AutoCountEnergy)
            {
                Energy = (double)SelectedProduct.Row["Energy"];
            }

            try
            {
                var res = _model.GetMeasures(ProductKey, 1)[0];
                DefaultMeasure = MeasureValuesCollection.FirstOrDefault(
                    x => x.nKey == (int)res.Row["MeasureKey"]);
            }
            catch
            {
                DefaultMeasure = null;
            }
        }
        public void AddRowData(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
        {
            var tasks = Task.WhenAll(
                Task.Run(() => _factsCache.AddFRow(pairs, data)),
                Task.Run(() =>
            {
                if (this.Config.MolapConfig.OperationType == OperationMode.PreAggregate)
                {
                    _globalGraph.AddRowInfo(data, pairs);
                }
            }));

            tasks.Wait();
        }
Beispiel #5
0
        public bool Execute(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
        {
            var result = false;

            foreach (var item in _predicates)
            {
                var value = item.Execute(pairs, data);

                if (value)
                {
                    result = value;
                    break;
                }
            }

            return(result);
        }
            public override void UpdateMeasures(U cell, MeasureValuesCollection <T> measures, CellContext <T> context)
            {
                MolapCell <T> mcell = (MolapCell <T>)(object) cell;

                foreach (var previousValue in mcell.Values)
                {
                    context.UpdateOldValue(previousValue.Key, previousValue.Value);
                }

                mcell.IncrementOcurrences();

                foreach (KeyValuePair <T, object> item in measures)
                {
                    if (item.Value != null)
                    {
                        ValueType nvalue = (ValueType)item.Value;

                        if (mcell.Values.ContainsKey(item.Key))
                        {
                            Type      measuretype = this._measures[item.Key].DataType;
                            ValueType ovalue      = mcell.Values[item.Key];
                            var       functor     = GetMeasureAggregationFunction(measuretype);

                            if (functor != null)
                            {
                                context.UpdateNewValue(item.Key, nvalue);
                                mcell.Values[item.Key] = this.Add(ovalue, nvalue, functor);
                            }
                        }
                        else
                        {
                            context.UpdateNewValue(item.Key, nvalue);
                            mcell.Values.Add(item.Key, nvalue);
                        }
                    }
                }
            }
Beispiel #7
0
        public bool Execute(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
        {
            var results = pairs
                          .Where(x => x.Key.Equals(Dimension))
                          .ToArray();

            if (results.Length > 0)
            {
                if (_operator == LogicalOperators.EQUALS || _operator == LogicalOperators.NOTEQUALS)
                {
                    return(Execute(results[0].Value, _values[0]));
                }

                if (_operator == LogicalOperators.IN)
                {
                    return(results
                           .Join(_values, x => x.Value, y => y, (x, y) => y)
                           .Any());
                }
            }

            return((_operator == LogicalOperators.EQUALS || _operator == LogicalOperators.IN)
        ? false : true);
        }
 public FactsRow(int index, T hashCode, KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data) : this(hashCode, pairs, data)
 {
     Index = index;
 }
 public FactsRow(T hashCode, KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
 {
     _pairs   = pairs;
     _data    = data;
     HashCode = hashCode;
 }
Beispiel #10
0
 public void AddRowInfo(MeasureValuesCollection <T> vardata, KeyValuePair <T, T>[] coords)
 {
     CreateNodes(coords, this.Root, null, 0, vardata);
 }
Beispiel #11
0
        private Node <T, U> CreateNDimNode(Node <T, U> rootnode, KeyValuePair <T, T> pair, MeasureValuesCollection <T> vardata)
        {
            KeyValuePair <T, T>[] coords = Node <T, U> .GetCoords(rootnode.Coords, pair);

            T           hashkey = _keyHandler.GetKey(coords);
            Node <T, U> rnode   = rootnode.InsertChildNodeIfNotExists(hashkey, coords);
            var         context = new GraphCellContext <T>(rnode.Container, rootnode.Container);

            _cellValueHelper.UpdateMeasures(rnode.Container, vardata, context);
            _cellValueHelper.UpdateMetrics(rnode.Container, context);

            return(rnode);
        }
Beispiel #12
0
        private void CreateNodes(KeyValuePair <T, T>[] coords, Node <T, U> rootnode, Node <T, U> connode, int index, MeasureValuesCollection <T> vardata)
        {
            for (int i = index; i < coords.Length; i++)
            {
                KeyValuePair <T, T> pair     = coords[i];
                Node <T, U>         dimnode  = CreateNDimNode(rootnode, new KeyValuePair <T, T>(pair.Key, default(T)), vardata);
                Node <T, U>         cellnode = null;

                if (connode != null)
                {
                    cellnode = CreateNDimNode(connode, pair, vardata);
                }
                else
                {
                    cellnode = CreateNDimNode(dimnode, pair, vardata);
                    dimnode.InsertNode(cellnode);
                }

                this.CreateNodes(coords, dimnode, cellnode, i + 1, vardata);
            }
        }
 public abstract void UpdateMeasures(U cell, MeasureValuesCollection <T> measures, CellContext <T> context);
Beispiel #14
0
 public bool Execute(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
 {
     return(true);
 }
 public bool Execute(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
 {
     return(_predicate.Execute(pairs, data));
 }
Beispiel #16
0
 public void AddFRow(KeyValuePair <T, T>[] pairs, MeasureValuesCollection <T> data)
 {
     _innerList.Add(new FactsRow <T>(_innerList.Count, _hasher.HashTuples(pairs), pairs, data));
 }