Beispiel #1
0
        public void DoUpdate(string startStatus, string endStatus)
        {
            var statesRepository = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderStatesRepository>();
            var endState         = statesRepository.GetStates().Single(state => state.Code == endStatus);

            var orderManager    = Sitecore.Ecommerce.Context.Entity.Resolve <Orders.Management.IOrderManager <OrderExtension.Order> >();
            var ordersToProcess = orderManager.GetOrders().Where(order => order.State.Code == startStatus);

            foreach (var order in ordersToProcess)
            {
                try
                {
                    if (order.ExternalOrderId != Guid.Empty)
                    {
                        var client       = new Services.OrderServiceClient();
                        var serviceOrder = client.Get(order.ExternalOrderId);
                        if (serviceOrder != null && serviceOrder.Shipped)
                        {
                            order.DefaultDelivery.TrackingID = serviceOrder.TrackingUrl;
                            order.State = endState;
                            orderManager.Save();
                        }
                    }
                }
                catch (Exception e)
                {
                    Sitecore.Diagnostics.Log.Error("Error exporting order {0}".FormatWith(order.OrderId), e, this);
                }
            }
        }
Beispiel #2
0
        public void CheckOrder(ActiveCommerce.Training.OrderExtension.Order order, OrderStatus endStatus)
        {
            var orderManager = Sitecore.Ecommerce.Context.Entity.Resolve <IOrderManager <Order> >();
            var client       = new Services.OrderServiceClient();
            var serviceOrder = client.Get(order.ExternalOrderId);

            if (serviceOrder != null && serviceOrder.Shipped)
            {
                order.TrackingNumber = serviceOrder.TrackingUrl;
                order.Status         = endStatus;
                orderManager.SaveOrder(order);
            }
        }