Example #1
0
        /// <summary>
        /// Loops through the orders in the SIMPL db that are not closed, cancelled, or NA
        /// </summary>
        public void UpdateOrderStatusFromComet()
        {
            Console.Write("Begin updating individual orders...");
            using (var db = new Order_Entities())
            {
                // Get al orders where the vendor ID is known AND either the status is not a "final" status, or the number of update attempts is 0
                var orders = db.Orders.Where(o => !string.IsNullOrEmpty(o.VendorOrderId) &&
                    ((o.OrderStatus.OrderStatusId != (int)SIMPLDbEnums.OrderStatusEnum.Canceled &&
                    o.OrderStatus.OrderStatusId != (int)SIMPLDbEnums.OrderStatusEnum.NA &&
                    o.OrderStatus.OrderStatusId != (int)SIMPLDbEnums.OrderStatusEnum.Closed) ||
                    o.UpdateAttempts == null))
                    .ToList();

                using (var comet = new Dropship.CometProxy())
                {
                    foreach (var o in orders)
                    {
                        UpdateSingleOrder(o, comet, db);
                    }
                }
            }
            Console.WriteLine("Done updating individual orders");
        }
Example #2
0
        /// <summary>
        /// Private method to do actual retrieval of orders
        /// </summary>
        /// <param name="startTime">Must be valid DateTime</param>
        /// <param name="endTime">Must be valid DateTime that is less than startTime</param>
        private IEnumerable<OrderStatus> RetrieveOrders(DateTime startTime, DateTime endTime)
        {
            OrderStatus[] statuses;
            using (var c = new Dropship.CometProxy())
            {
                c.Timeout = 60 * 1000 * 10; // 10 minute timeout

                statuses = c.GetOrderStatusList(
                   startTime,
                   endTime,
                   ConfigurationManager.AppSettings["COMETUsername"],
                   ConfigurationManager.AppSettings["COMETPassword"]);
            }
            return statuses;
        }