/// <summary>
 /// Create a new Order object.
 /// </summary>
 /// <param name="orderId">Initial value of the OrderId property.</param>
 /// <param name="orderTypeId">Initial value of the OrderTypeId property.</param>
 /// <param name="masterOrderId">Initial value of the MasterOrderId property.</param>
 /// <param name="fillLocId">Initial value of the FillLocId property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Order CreateOrder(global::System.Int32 orderId, global::System.Int32 orderTypeId, global::System.Int32 masterOrderId, global::System.Int32 fillLocId, global::System.Int32 status)
 {
     Order order = new Order();
     order.OrderId = orderId;
     order.OrderTypeId = orderTypeId;
     order.MasterOrderId = masterOrderId;
     order.FillLocId = fillLocId;
     order.Status = status;
     return order;
 }
Пример #2
0
        public void UpdateSingleOrder(Order o, Dropship.CometProxy comet, Order_Entities db)
        {
            Console.WriteLine("Processing order {0}", o.DSLToolOrderId);

            // increment the number of update attempts
            o.UpdateAttempts = o.UpdateAttempts == null ? 1 : o.UpdateAttempts + 1;

            // make sure we have a valid integer for the order id
            int orderNum;
            if (!int.TryParse(o.VendorOrderId, out orderNum))
            {
                return;
            }

            // Get the order status back from Comet
            comet.Timeout = 60 * 1000 * 3;
            OrderStatus status = comet.GetOrderStatus(
                orderNum,
                0,
                ConfigurationManager.AppSettings["COMETUsername"],
                ConfigurationManager.AppSettings["COMETPassword"]
            );

            // Set the tracking numbers, if they exist

            if (status.ShippingStatus != null &&
                status.ShippingStatus.TrackingNumbers != null &&
                status.ShippingStatus.TrackingNumbers.Length > 0)
            {
                foreach (var s in status.ShippingStatus.TrackingNumbers)
                {
                    var trackingNumber = o.TrackingNumbers.FirstOrDefault(t => t.TrackingNumber1 == s);
                    if (trackingNumber == null)
                    {
                        var num = new TrackingNumber {TrackingNumber1 = s, TrackingNumberTypeId = 1};
                        o.TrackingNumbers.Add(num);
                    }
                }
            }

            // Map the Comet order status to the SIMPL order status
            switch (status.Status1)
            {
                case com.complemar.cometerpws.OrderStatuses.Approved:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Approved;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Cancelled:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Canceled;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Closed:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Closed;
                    break;
                case com.complemar.cometerpws.OrderStatuses.InProcess:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Confirmed;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Open:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Confirmed;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Received:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Closed;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Returned:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.RefusedOrder;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Shipped:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Shipped;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Submitted:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.Ordered;
                    break;
                case com.complemar.cometerpws.OrderStatuses.Unknown:
                    o.Status = (int)SIMPLDbEnums.OrderStatusEnum.NA;
                    break;
            }
            // apply the changes to the db after each order
            db.SaveChanges();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Orders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrders(Order order)
 {
     base.AddObject("Orders", order);
 }