Ejemplo n.º 1
0
        public override OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            var payment = operation as PaymentIn;

            if (payment == null)
            {
                throw new NullReferenceException("payment");
            }

            base.FromModel(payment, pkMap);

            if (payment.PaymentMethod != null)
            {
                this.GatewayCode = payment.PaymentMethod != null ? payment.PaymentMethod.Code : payment.GatewayCode;
            }
            if (payment.BillingAddress != null)
            {
                this.Addresses = new ObservableCollection <AddressEntity>(new AddressEntity[] { AbstractTypeFactory <AddressEntity> .TryCreateInstance().FromModel(payment.BillingAddress) });
            }
            if (payment.TaxDetails != null)
            {
                this.TaxDetails = new ObservableCollection <TaxDetailEntity>(payment.TaxDetails.Select(x => AbstractTypeFactory <TaxDetailEntity> .TryCreateInstance().FromModel(x)));
            }
            if (payment.Discounts != null)
            {
                this.Discounts = new ObservableCollection <DiscountEntity>(payment.Discounts.Select(x => AbstractTypeFactory <DiscountEntity> .TryCreateInstance().FromModel(x)));
            }
            if (payment.Transactions != null)
            {
                this.Transactions = new ObservableCollection <PaymentGatewayTransactionEntity>(payment.Transactions.Select(x => AbstractTypeFactory <PaymentGatewayTransactionEntity> .TryCreateInstance().FromModel(x, pkMap)));
            }
            this.Status = payment.PaymentStatus.ToString();

            return(this);
        }
Ejemplo n.º 2
0
        public void TryAddOrderOperation(OrderHead orderHead, int operation, string reference)
        {
            bool hasOp = false;

            foreach (OrderOperation orderOperation in orderHead.OrderOperations)
            {
                if (orderOperation.Operation == operation)
                {
                    if (orderOperation.Reference == reference ||
                        (orderOperation.Reference == null && reference == null))
                    {
                        hasOp = true;
                    }
                }
            }

            if (!hasOp)
            {
                //没有找到Op,新增

                RoutingDetail routingDetail = this.routingDetailMgr.LoadRoutingDetail(orderHead.Routing, operation, reference);
                if (routingDetail != null)
                {
                    OrderOperation orderOperation = this.GenerateOrderOperation(orderHead, routingDetail);
                    this.CreateOrderOperation(orderOperation);
                }
                else
                {
                    throw new BusinessErrorException("Order.Error.RoutingDetail.Not.Found", orderHead.Routing.Code, operation.ToString(), reference);
                }
            }
        }
Ejemplo n.º 3
0
 void CloseOrders(IEnumerable <Order> orders)
 {
     foreach (Order currOrder in orders.ToList())
     {
         OrderOperation.CloseOrder(currOrder);
     }
 }
Ejemplo n.º 4
0
        public void AddOrderOperation(OrderOperation orderOperation)
        {
            if (this.OrderOperations == null)
            {
                this.OrderOperations = new List <OrderOperation>();
                this.OrderOperations.Add(orderOperation);
            }
            else
            {
                //查找Op,插入到合适位置
                int position = this.OrderOperations.Count;
                for (int i = 0; i < this.OrderOperations.Count; i++)
                {
                    OrderOperation oo = this.OrderOperations[i];
                    if (oo.Operation > orderOperation.Operation)
                    {
                        position = i;
                        break;
                    }

                    //判断是否已经有相同工序号的orderOperation,如果没有才添加
                    if (oo.Operation == orderOperation.Operation)
                    {
                        return;
                    }
                }

                this.OrderOperations.Insert(position, orderOperation);
            }
        }
Ejemplo n.º 5
0
        void AddModifyLimitOrder(int open, int slPIPS, int tp, OrderSide side)
        {
            open = MathPrice.RoundToDown(open);
            tp   = MathPrice.RoundToDown(tp);
            int sl = side == OrderSide.Buy ? open - slPIPS : open + slPIPS;

            List <Order> limitOrders = SelectMulti(side, OrderOperation.GetLimitOrders());

            if (limitOrders.Count != 0)
            {
                foreach (Order currOrder in limitOrders)
                {
                    Meta.OrderModify(currOrder.ID, open, sl, tp, currOrder.Type);
                }
            }
            else if (SelectMulti(side, OrderOperation.GetMarketOrders()).Count == 0)
            {
                try
                {
                    Meta.OrderSend(base.Symbol, OrderType.Limit, side, LotFunction(), open, sl, tp, "");
                }
                catch (Exception exc)
                {
                    logger.AddMessage(exc.ToString());
                }
            }
        }
Ejemplo n.º 6
0
        public virtual OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            pkMap.AddPair(operation, this);

            Id           = operation.Id;
            CreatedDate  = operation.CreatedDate;
            CreatedBy    = operation.CreatedBy;
            ModifiedDate = operation.ModifiedDate;
            ModifiedBy   = operation.ModifiedBy;

            Comment       = operation.Comment;
            Currency      = operation.Currency;
            Number        = operation.Number;
            Status        = operation.Status;
            IsCancelled   = operation.IsCancelled;
            CancelledDate = operation.CancelledDate;
            CancelReason  = operation.CancelReason;
            IsApproved    = operation.IsApproved;
            Sum           = operation.Sum;

            return(this);
        }
Ejemplo n.º 7
0
        public List <AppCrmOrderHistoryResponse> AppOrderHistory(AppCrmOrderHistoryRequest orderHistoryRequest)
        {
            OrderOperation op = new OrderOperation();
            List <AppCrmOrderHistoryResponse> response = op.AppGetOrderHistory(orderHistoryRequest);

            return(response);
        }
        public override OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            var customerOrderExtension = operation as CustomerOrderExtension;

            if (customerOrderExtension != null)
            {
                if (customerOrderExtension.Invoices != null)
                {
                    this.Invoices = new ObservableCollection <InvoiceEntity>(customerOrderExtension.Invoices.Select(x => new InvoiceEntity().FromModel(x, pkMap)).OfType <InvoiceEntity>());
                }
            }

            base.FromModel(operation, pkMap);

            if (customerOrderExtension.Shipments != null)
            {
                this.Shipments = new ObservableCollection <ShipmentEntity>(customerOrderExtension.Shipments.Select(x => AbstractTypeFactory <ShipmentEntity> .TryCreateInstance().FromModel(x, pkMap)).OfType <ShipmentEntity>());
                //Link shipment item with order lineItem
                foreach (var shipmentItemEntity in this.Shipments.SelectMany(x => x.Items))
                {
                    shipmentItemEntity.LineItem = this.Items.FirstOrDefault(x => x.ModelLineItem == shipmentItemEntity.ModelLineItem);
                }
            }

            return(this);
        }
Ejemplo n.º 9
0
        public virtual OrderOperation ToModel(OrderOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            operation.Id           = Id;
            operation.CreatedDate  = CreatedDate;
            operation.CreatedBy    = CreatedBy;
            operation.ModifiedDate = ModifiedDate;
            operation.ModifiedBy   = ModifiedBy;

            operation.Comment            = Comment;
            operation.Currency           = Currency;
            operation.Number             = Number;
            operation.Status             = Status;
            operation.IsCancelled        = IsCancelled;
            operation.CancelledDate      = CancelledDate;
            operation.CancelReason       = CancelReason;
            operation.IsApproved         = IsApproved;
            operation.Sum                = Sum;
            operation.ChildrenOperations = GetAllChildOperations(operation);
            return(operation);
        }
Ejemplo n.º 10
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var shipment = operation as Shipment;

            if (shipment == null)
            {
                throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            shipment.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            shipment.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();
            shipment.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            shipment.Packages   = Packages.Select(x => x.ToModel(AbstractTypeFactory <ShipmentPackage> .TryCreateInstance())).ToList();
            shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            base.ToModel(shipment);

            operation.Sum = shipment.TotalWithTax;

            return(shipment);
        }
Ejemplo n.º 11
0
        public AppCrmOrderResponse AppCreateOrder(AppCrmOrderRequest orderRequest)
        {
            OrderOperation      oo = new OrderOperation();
            AppCrmOrderResponse rs = oo.AppCreateOrder(orderRequest);

            return(rs);
        }
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var order = operation as CustomerOrder;

            if (order == null)
            {
                throw new ArgumentException(@"operation argument must be of type CustomerOrder", nameof(operation));
            }

            order.CustomerId           = CustomerId;
            order.CustomerName         = CustomerName;
            order.StoreId              = StoreId;
            order.StoreName            = StoreName;
            order.OrganizationId       = OrganizationId;
            order.OrganizationName     = OrganizationName;
            order.EmployeeId           = EmployeeId;
            order.EmployeeName         = EmployeeName;
            order.DiscountAmount       = DiscountAmount;
            order.Total                = Total;
            order.SubTotal             = SubTotal;
            order.SubTotalWithTax      = SubTotalWithTax;
            order.ShippingTotal        = ShippingTotal;
            order.ShippingTotalWithTax = ShippingTotalWithTax;
            order.PaymentTotal         = PaymentTotal;
            order.PaymentTotalWithTax  = PaymentTotalWithTax;
            order.FeeTotal             = HandlingTotal;
            order.FeeTotalWithTax      = HandlingTotalWithTax;
            order.DiscountTotal        = DiscountTotal;
            order.DiscountTotalWithTax = DiscountTotalWithTax;
            order.DiscountAmount       = DiscountAmount;
            order.TaxTotal             = TaxTotal;
            order.IsPrototype          = IsPrototype;
            order.SubscriptionNumber   = SubscriptionNumber;
            order.SubscriptionId       = SubscriptionId;
            order.LanguageCode         = LanguageCode;
            order.TaxPercentRate       = TaxPercentRate;

            order.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            order.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <LineItem> .TryCreateInstance())).ToList();
            order.Addresses  = Addresses.Select(x => x.ToModel(AbstractTypeFactory <Address> .TryCreateInstance())).ToList();
            order.Shipments  = Shipments.Select(x => x.ToModel(AbstractTypeFactory <Shipment> .TryCreateInstance())).OfType <Shipment>().ToList();
            order.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            order.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            order.DynamicProperties = DynamicPropertyObjectValues.GroupBy(g => g.PropertyId).Select(x =>
            {
                var property    = AbstractTypeFactory <DynamicObjectProperty> .TryCreateInstance();
                property.Id     = x.Key;
                property.Name   = x.FirstOrDefault()?.PropertyName;
                property.Values = x.Select(v => v.ToModel(AbstractTypeFactory <DynamicPropertyObjectValue> .TryCreateInstance())).ToArray();
                return(property);
            }).ToArray();

            base.ToModel(order);

            Sum = order.Total;

            return(order);
        }
Ejemplo n.º 13
0
 public Scenario()
 {
     productOperation      = new ProductOperation();
     campaignOperation     = new CampaignOperation();
     orderOperation        = new OrderOperation();
     increaseTimeOperation = new IncreaseTimeOperation();
     scenarioOperation     = new ScenarioOperation();
 }
Ejemplo n.º 14
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var shipment = operation as Shipment;

            if (shipment == null)
            {
                throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            shipment.Id           = Id;
            shipment.CreatedDate  = CreatedDate;
            shipment.CreatedBy    = CreatedBy;
            shipment.ModifiedDate = ModifiedDate;
            shipment.ModifiedBy   = ModifiedBy;

            shipment.Price                 = Price;
            shipment.PriceWithTax          = PriceWithTax;
            shipment.DiscountAmount        = DiscountAmount;
            shipment.DiscountAmountWithTax = DiscountAmountWithTax;
            shipment.FulfillmentCenterId   = FulfillmentCenterId;
            shipment.FulfillmentCenterName = FulfillmentCenterName;
            shipment.OrganizationId        = OrganizationId;
            shipment.OrganizationName      = OrganizationName;
            shipment.EmployeeId            = EmployeeId;
            shipment.EmployeeName          = EmployeeName;
            shipment.ShipmentMethodCode    = ShipmentMethodCode;
            shipment.ShipmentMethodOption  = ShipmentMethodOption;
            shipment.Height                = Height;
            shipment.Length                = Length;
            shipment.Weight                = Weight;
            shipment.Height                = Height;
            shipment.Width                 = Width;
            shipment.MeasureUnit           = MeasureUnit;
            shipment.WeightUnit            = WeightUnit;
            shipment.Length                = Length;
            shipment.TaxType               = TaxType;
            shipment.TaxPercentRate        = TaxPercentRate;
            shipment.TaxTotal              = TaxTotal;
            shipment.Total                 = Total;
            shipment.TotalWithTax          = TotalWithTax;

            shipment.Discounts  = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();
            shipment.Items      = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();
            shipment.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList();
            shipment.Packages   = Packages.Select(x => x.ToModel(AbstractTypeFactory <ShipmentPackage> .TryCreateInstance())).ToList();
            shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();

            base.ToModel(shipment);

            operation.Sum = shipment.TotalWithTax;

            return(shipment);
        }
Ejemplo n.º 15
0
        public OrderOperation GenerateOrderOperation(OrderHead orderHead, RoutingDetail routingDetail)
        {
            OrderOperation orderOp = new OrderOperation();
            CloneHelper.CopyProperty(routingDetail, orderOp, OrderOperationCloneFields);
            orderOp.OrderHead = orderHead;
            //todo UnitTime��WorkTime����

            orderHead.AddOrderOperation(orderOp);
            return orderOp;
        }
Ejemplo n.º 16
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var orderExtended = (DemoCustomerOrder)base.ToModel(operation);

            orderExtended.ConfiguredGroups =
                ConfiguredGroups
                .Select(x => x.ToModel(AbstractTypeFactory <DemoOrderConfiguredGroup> .TryCreateInstance()))
                .ToList();

            return(orderExtended);
        }
Ejemplo n.º 17
0
        public override void onTick(Tick <int> currTick)
        {
            try
            {
                spreadAnalyzer.EvaluateSpread(currTick);
                ShowComment(currTick);

                if (currTime.Ticks / TickHistory.tickInOneMinute == currTick.DateTime.Ticks / TickHistory.tickInOneMinute)
                {
                    return;
                }
                currTime = currTick.DateTime;

                ExtremumPoint.Process(Math.Max(currTick.Bid, Meta.High(this.Symbol, 1)), Math.Min(currTick.Bid, Meta.Low(this.Symbol, 1)), currTick.DateTime);
                fluctuationList.Update(ExtremumPoint);

                for (int i = fluctuationList.StartIndex; i < fluctuationList.EndIndex; i++)
                {
                    Meta.ObjectMove(GetHLineName(i), 0, DateTime.Now, fluctuationList[i].AveragePrice);
                }

                if (!strategyTime.IsSystemON(currTick) || newsPeriod.IsNewsTime(currTick.DateTime))
                {
                    OrderOperation.CloseAllOrders();
                    return;
                }

                //open/modify tp
                AddModifyLimitOrder(fluctuationList.GetHighest(param["OpenOrderPercent"]), param["SL"], fluctuationList.GetHighest(param["TPOrderPercent"]) + spreadAnalyzer.AverageSpread, OrderSide.Sell);
                AddModifyLimitOrder(fluctuationList.GetLowest(param["OpenOrderPercent"]) + spreadAnalyzer.AverageSpread, param["SL"], fluctuationList.GetLowest(param["TPOrderPercent"]), OrderSide.Buy);

                ModifyMarketOrders(OrderSide.Buy, fluctuationList.GetLowest(param["TPOrderPercent"]));
                ModifyMarketOrders(OrderSide.Sell, fluctuationList.GetHighest(param["TPOrderPercent"]) + spreadAnalyzer.AverageSpread);

                //close limit orders
                //move tp

                //                    //check condition to close order
                //int sign = fluctuationList.GetSignDistanceFromAverageInPercent(currTick.Bid);
                //if (sign >= 0)
                //    CloseOrders(OrderSide.Buy, marketOrders);
                //if (sign <= 0)
                //    CloseOrders(OrderSide.Sell, marketOrders);


                //int peakDistanceFromAverageMinAbs = fluctuationList.GetMinDistanceFromAverageInPercent(currTick.Bid);
                //if (Math.Abs(peakDistanceFromAverageMinAbs) > param["OpenOrderPercent"])
                //    OpenNewMarketOrder(peakDistanceFromAverageMinAbs < 0 ? OrderSide.Buy : OrderSide.Sell, marketOrders, currTick);
            }
            catch (HistoryNotAvailableExceptions exc)
            {
                return;
            }
        }
Ejemplo n.º 18
0
        public OrderOperation GenerateOrderOperation(OrderHead orderHead, RoutingDetail routingDetail)
        {
            OrderOperation orderOp = new OrderOperation();

            CloneHelper.CopyProperty(routingDetail, orderOp, OrderOperationCloneFields);
            orderOp.OrderHead = orderHead;
            //todo UnitTime和WorkTime计算

            orderHead.AddOrderOperation(orderOp);
            return(orderOp);
        }
Ejemplo n.º 19
0
        public override OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            var shipment = operation as Shipment;

            if (shipment == null)
            {
                throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation));
            }

            base.FromModel(shipment, pkMap);

            //Allow to empty address
            Addresses = new ObservableCollection <AddressEntity>();

            if (shipment.ShippingMethod != null)
            {
                ShipmentMethodCode   = shipment.ShippingMethod.Code;
                ShipmentMethodOption = shipment.ShipmentMethodOption;
            }

            if (shipment.DeliveryAddress != null)
            {
                Addresses = new ObservableCollection <AddressEntity>(new[] { AbstractTypeFactory <AddressEntity> .TryCreateInstance().FromModel(shipment.DeliveryAddress) });
            }

            if (shipment.Items != null)
            {
                Items = new ObservableCollection <ShipmentItemEntity>(shipment.Items.Select(x => AbstractTypeFactory <ShipmentItemEntity> .TryCreateInstance().FromModel(x, pkMap)));
                foreach (var shipmentItem in Items)
                {
                    shipmentItem.ShipmentId = Id;
                }
            }

            if (shipment.Packages != null)
            {
                Packages = new ObservableCollection <ShipmentPackageEntity>(shipment.Packages.Select(x => AbstractTypeFactory <ShipmentPackageEntity> .TryCreateInstance().FromModel(x, pkMap)));
            }

            if (shipment.TaxDetails != null)
            {
                TaxDetails = new ObservableCollection <TaxDetailEntity>(shipment.TaxDetails.Select(x => AbstractTypeFactory <TaxDetailEntity> .TryCreateInstance().FromModel(x)));
            }

            if (shipment.Discounts != null)
            {
                Discounts = new ObservableCollection <DiscountEntity>(shipment.Discounts.Select(x => AbstractTypeFactory <DiscountEntity> .TryCreateInstance().FromModel(x)));
            }

            Sum = shipment.TotalWithTax;

            return(this);
        }
Ejemplo n.º 20
0
        public virtual OrderOperation ToModel(OrderOperation orderOperation)
        {
            if (orderOperation == null)
            {
                throw new ArgumentNullException("orderOperation");
            }

            orderOperation.InjectFrom(this);

            orderOperation.ChildrenOperations = GetAllChildOperations(orderOperation);
            return(orderOperation);
        }
Ejemplo n.º 21
0
        public virtual OrderOperation ToModel(OrderOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            operation.InjectFrom(this);

            operation.ChildrenOperations = OperationUtilities.GetAllChildOperations(operation);
            return(operation);
        }
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var order2 = operation as CustomerOrder2;

            if (order2 != null)
            {
                order2.Invoices = this.Invoices.Select(x => x.ToModel(new Invoice())).OfType <Invoice>().ToList();
            }

            base.ToModel(operation);

            return(operation);
        }
Ejemplo n.º 23
0
        public virtual OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            pkMap.AddPair(operation, this);

            this.InjectFrom(operation);

            return(this);
        }
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var customerOrderExtension = operation as CustomerOrderExtension;

            if (customerOrderExtension != null)
            {
                customerOrderExtension.Invoices = this.Invoices.Select(x => x.ToModel(new Invoice())).OfType <Invoice>().ToList();
            }

            base.ToModel(operation);

            return(operation);
        }
Ejemplo n.º 25
0
        public override OrderOperation ToModel(OrderOperation shipment)
        {
            var result = base.ToModel(shipment);

            var shipment2 = result as ShipmentExtension;

            shipment2.IsCommercial   = this.IsCommercial;
            shipment2.HasLoadingDock = this.HasLoadingDock;
            shipment2.shipmentDate   = this.shipmentDate;
            shipment2.Items          = this.Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList();

            return(shipment2);
        }
Ejemplo n.º 26
0
        public override OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            var orderEx = operation as CustomerOrderEx;

            if (orderEx != null && orderEx.Invoices != null)
            {
                Invoices = new ObservableCollection <InvoiceEntity>(orderEx.Invoices.Select(x => new InvoiceEntity().FromModel(x, pkMap)).OfType <InvoiceEntity>());
            }

            base.FromModel(operation, pkMap);

            return(this);
        }
        public override OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            var order = operation as CustomerOrder;

            if (order == null)
            {
                throw new ArgumentException(@"operation argument must be of type CustomerOrder", nameof(operation));
            }

            base.FromModel(order, pkMap);

            if (order.Addresses != null)
            {
                Addresses = new ObservableCollection <AddressEntity>(order.Addresses.Select(x => AbstractTypeFactory <AddressEntity> .TryCreateInstance().FromModel(x)));
            }

            if (order.Items != null)
            {
                Items = new ObservableCollection <LineItemEntity>(order.Items.Select(x => AbstractTypeFactory <LineItemEntity> .TryCreateInstance().FromModel(x, pkMap)));
            }

            if (order.Shipments != null)
            {
                Shipments = new ObservableCollection <ShipmentEntity>(order.Shipments.Select(x => AbstractTypeFactory <ShipmentEntity> .TryCreateInstance().FromModel(x, pkMap)).OfType <ShipmentEntity>());
                //Link shipment item with order lineItem
                foreach (var shipmentItemEntity in Shipments.SelectMany(x => x.Items))
                {
                    shipmentItemEntity.LineItem = Items.FirstOrDefault(x => x.ModelLineItem == shipmentItemEntity.ModelLineItem);
                }
            }

            if (order.InPayments != null)
            {
                InPayments = new ObservableCollection <PaymentInEntity>(order.InPayments.Select(x => AbstractTypeFactory <PaymentInEntity> .TryCreateInstance().FromModel(x, pkMap)).OfType <PaymentInEntity>());
            }

            if (order.Discounts != null)
            {
                Discounts = new ObservableCollection <DiscountEntity>(order.Discounts.Select(x => AbstractTypeFactory <DiscountEntity> .TryCreateInstance().FromModel(x)));
            }

            if (order.TaxDetails != null)
            {
                TaxDetails = new ObservableCollection <TaxDetailEntity>(order.TaxDetails.Select(x => AbstractTypeFactory <TaxDetailEntity> .TryCreateInstance().FromModel(x)));
            }

            Sum = order.Total;

            return(this);
        }
Ejemplo n.º 28
0
        public override OrderOperation ToModel(OrderOperation operation)
        {
            var payment = operation as PaymentIn;

            if (payment == null)
            {
                throw new ArgumentException(@"operation argument must be of type PaymentIn", nameof(operation));
            }

            if (!Addresses.IsNullOrEmpty())
            {
                payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance());
            }

            payment.Price                 = Price;
            payment.PriceWithTax          = PriceWithTax;
            payment.DiscountAmount        = DiscountAmount;
            payment.DiscountAmountWithTax = DiscountAmountWithTax;
            payment.TaxType               = TaxType;
            payment.TaxPercentRate        = TaxPercentRate;
            payment.TaxTotal              = TaxTotal;
            payment.Total                 = Total;
            payment.TotalWithTax          = TotalWithTax;

            payment.CustomerId       = CustomerId;
            payment.CustomerName     = CustomerName;
            payment.OrganizationId   = OrganizationId;
            payment.OrganizationName = OrganizationName;
            payment.GatewayCode      = GatewayCode;
            payment.Purpose          = Purpose;
            payment.OuterId          = OuterId;
            payment.Status           = Status;
            payment.AuthorizedDate   = AuthorizedDate;
            payment.CapturedDate     = CapturedDate;
            payment.VoidedDate       = VoidedDate;
            payment.IsCancelled      = IsCancelled;
            payment.CancelledDate    = CancelledDate;
            payment.CancelReason     = CancelReason;
            payment.Sum = Sum;

            payment.Transactions = Transactions.Select(x => x.ToModel(AbstractTypeFactory <PaymentGatewayTransaction> .TryCreateInstance())).ToList();
            payment.TaxDetails   = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList();
            payment.Discounts    = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList();

            base.ToModel(payment);

            payment.PaymentStatus = EnumUtility.SafeParse(Status, PaymentStatus.Custom);

            return(payment);
        }
Ejemplo n.º 29
0
        public override OperationEntity FromModel(OrderOperation operation, PrimaryKeyResolvingMap pkMap)
        {
            base.FromModel(operation, pkMap);

            var orderExtended = (DemoCustomerOrder)operation;

            if (orderExtended.ConfiguredGroups != null)
            {
                ConfiguredGroups = new ObservableCollection <DemoOrderConfiguredGroupEntity>(
                    orderExtended.ConfiguredGroups.Select(x => AbstractTypeFactory <DemoOrderConfiguredGroupEntity> .TryCreateInstance().FromModel(x, pkMap)));
            }

            return(this);
        }
Ejemplo n.º 30
0
        public static WebAPI.Order.Side GetSide(OrderOperation operation)
        {
            switch (operation)
            {
            case OrderOperation.Buy:
                return(WebAPI.Order.Side.BUY);

            case OrderOperation.Sell:
                return(WebAPI.Order.Side.SELL);

            default:
                throw new ArgumentOutOfRangeException("operation", operation, null);
            }
        }
Ejemplo n.º 31
0
        public override OperationEntity FromModel(OrderOperation shipment, PrimaryKeyResolvingMap pkMap)
        {
            base.FromModel(shipment, pkMap);
            ShipmentExtension shipment2 = new ShipmentExtension();

            shipment2           = (ShipmentExtension)shipment;
            this.IsCommercial   = shipment2.IsCommercial;
            this.HasLoadingDock = shipment2.HasLoadingDock;
            this.shipmentDate   = shipment2.shipmentDate;
            //if (shipment2.Items != null) {
            //    this.Items = new ObservableCollection<ShipmentItemEntity>(shipment2.Items.Select(x => AbstractTypeFactory<ShipmentItemEntity>.TryCreateInstance().FromModel(x, pkMap)));
            //}

            return(this);
        }
Ejemplo n.º 32
0
		public void ApplyDataOperation(Order currentOrder,OrderOperation operation) {
				switch (operation) {
					case OrderOperation.open:
						OrdersContext.Current.Context.RegisterOpenOrder(currentOrder,OrdersContext.Current.SessionGUID);
						break;
					case OrderOperation.close:
						OrdersContext.Current.Context.RegisterCloseOrder(currentOrder, OrdersContext.Current.SessionGUID);
						break;
					case OrderOperation.complete:
						OrdersContext.Current.Context.RegisterCompleteOrder(currentOrder, OrdersContext.Current.SessionGUID);
						break;
				}
				if ((currentOrder.OrderIsExtend||currentOrder.OrderIsFixErrorEnter) && (currentOrder.ParentOrder != null)) {
					OrdersContext.Current.Context.ReloadOrder(currentOrder.ParentOrder, OrdersContext.Current.SessionGUID);
				}
				OrdersContext.Current.SubmitChangesCallbackError();
		}
        public CommentCheckWindow(Window owner, string sourceMessage, Customer sender, Order order, Product product, OrderOperation requestedOperation)
        {
            InitializeComponent();

            Owner = owner;
            m_order = order;
            m_requestedOperation = requestedOperation;

            tbOriginalText.IsReadOnly = true;
            tbOriginalText.Text = sourceMessage;
            tbAmount.Text = order.Amount.ToString();
            lblPrice.Content = product.Price.ToString("C", CultureInfo.CurrentCulture);
            lblMin.Content = product.MinAmount.ToString("");
            tbTitle.Text = product.Title;
            lblCustomer.Content = sender.GetFullName();

            switch (requestedOperation)
            {
                case OrderOperation.Add:
                    rbAppendOrder.IsChecked = true;
                    break;
                case OrderOperation.Remove:
                    rbRemovePosition.IsChecked = true;
                    break;
                case OrderOperation.Decrease:
                    rbSkipComment.IsChecked = true;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("requestedOperation");
            }

            if (!String.IsNullOrEmpty(product.ImageFile)
                && System.IO.File.Exists(System.IO.Path.Combine(RegistrySettings.GetInstance().GalleryPath, product.ImageFile)))
            {
                image1.Source =
                    new BitmapImage(new Uri(String.Format("file://{0}",
                        System.IO.Path.Combine(RegistrySettings.GetInstance().GalleryPath, product.ImageFile))));
            }
            else
            {
                // set default image
                image1.Source =
                    new BitmapImage(new Uri("pack://application:,,,/Images/default.png"));
            }
        }
Ejemplo n.º 34
0
        public void AddOrderOperation(OrderOperation orderOperation)
        {
            if (this.OrderOperations == null)
            {
                this.OrderOperations = new List<OrderOperation>();
                this.OrderOperations.Add(orderOperation);
            }
            else
            {
                //查找Op,插入到合适位置
                int position = this.OrderOperations.Count;
                for (int i = 0; i < this.OrderOperations.Count; i++)
                {
                    OrderOperation oo = this.OrderOperations[i];
                    if (oo.Operation > orderOperation.Operation)
                    {
                        position = i;
                        break;
                    }

                    //判断是否已经有相同工序号的orderOperation,如果没有才添加
                    if (oo.Operation == orderOperation.Operation)
                    {
                        return;
                    }
                }

                this.OrderOperations.Insert(position, orderOperation);
            }
        }
Ejemplo n.º 35
0
        public void AddOrderOperation(OrderOperation orderOperation)
        {
            if (this.OrderOperations == null)
            {
                this.OrderOperations = new List<OrderOperation>();
                this.OrderOperations.Add(orderOperation);
            }
            else
            {
                //����Op�����뵽����λ��
                int position = this.OrderOperations.Count;
                for (int i = 0; i < this.OrderOperations.Count; i++)
                {
                    OrderOperation oo = this.OrderOperations[i];
                    if (oo.Operation > orderOperation.Operation)
                    {
                        position = i;
                        break;
                    }

                    //�ж��Ƿ��Ѿ�����ͬ����ŵ�orderOperation�����û�в����
                    if (oo.Operation == orderOperation.Operation)
                    {
                        return;
                    }
                }

                this.OrderOperations.Insert(position, orderOperation);
            }
        }
        private void rbAlwaysSkipComment_Checked(object sender, RoutedEventArgs e)
        {
            if (rbAlwaysSkipComment.IsChecked.HasValue && rbAlwaysSkipComment.IsChecked.Value)
            {
                tbAmount.IsEnabled = false;
                tbAmount.IsReadOnly = true;
            }
            else
            {
                tbAmount.IsEnabled = true;
                tbAmount.IsReadOnly = false;
            }

            m_result = Result.Accept;
            m_requestedOperation = OrderOperation.Forget;
        }
 private void rbDecreaseOrder_Checked(object sender, RoutedEventArgs e)
 {
     m_result = Result.Accept;
     m_requestedOperation = OrderOperation.Decrease;
     tbAmount.IsEnabled = true;
     tbAmount.IsReadOnly = false;
 }
 public virtual void CreateOrderOperation(OrderOperation entity)
 {
     entityDao.CreateOrderOperation(entity);
 }
        private void rbRemovePosition_Checked(object sender, RoutedEventArgs e)
        {
            if (rbRemovePosition.IsChecked.HasValue && rbRemovePosition.IsChecked.Value)
            {
                tbAmount.IsEnabled = false;
                tbAmount.IsReadOnly = true;
            }
            else
            {
                tbAmount.IsEnabled = true;
                tbAmount.IsReadOnly = false;
            }

            m_requestedOperation = OrderOperation.Remove;
            m_result = Result.Accept;
        }
 public virtual void UpdateOrderOperation(OrderOperation entity)
 {
     entityDao.UpdateOrderOperation(entity);
 }
 public virtual void DeleteOrderOperation(OrderOperation entity)
 {
     entityDao.DeleteOrderOperation(entity);
 }