Пример #1
0
        public void ProcessNew()
        {
            foreach (var pr in Products)
            {
                CalculatedProduct calcProduct = new CalculatedProduct
                {
                    Product          = pr,
                    CalculatedValues = new List <CalculatedValue>()
                };
                calculatedProducts.Add(calcProduct);
            }


            foreach (var ord in order.OrderBy(x => x.Order))
            {
                switch (ord.ItemType)
                {
                case 1:
                {
                    var item = _calculationItems.FirstOrDefault(x => x.ID == ord.ItemID);
                    CalculateItem(item);
                    break;
                }

                case 2:
                {
                    var dynamic = dynamicConst.FirstOrDefault(x => x.ID == ord.ItemID);
                    CalculateDynamic(dynamic);
                    break;
                }

                case 3:
                {
                    var item = _calculationItems.FirstOrDefault(x => x.ID == ord.ItemID);
                    GetSum(item);
                    break;
                }
                }
            }
        }
Пример #2
0
        public void Process()
        {
            foreach (var product in Products)
            {
                CalculatedProduct calcProduct = new CalculatedProduct
                {
                    Product          = product,
                    CalculatedValues = new List <CalculatedValue>()
                };

                foreach (var item in _calculationItems.OrderBy(x => x.OrderID))
                {
                    var calcValue = new CalculatedValue
                    {
                        Item  = item,
                        Value = CalculateValue(ParseExpression(calcProduct.Product, item, calcProduct.CalculatedValues))
                    };
                    calcProduct.CalculatedValues.Add(calcValue);
                }

                calculatedProducts.Add(calcProduct);
            }
        }