コード例 #1
0
        public List <MessageString> ProcessApplyResult(ApplyOrderResult applyResult,
                                                       IUnitOfWork db,
                                                       ILogService log,
                                                       ITime time,
                                                       IOrderSynchronizer synchronizer,
                                                       AddressChecker addressChecker,
                                                       IOrderHistoryService orderHistoryService,
                                                       IWeightService weightService,
                                                       long?by)
        {
            var results = new List <MessageString>();

            if (applyResult.RateRecalcRequested)
            {
                var dtoOrder = db.ItemOrderMappings.GetOrderWithItems(weightService, OrderId, unmaskReferenceStyle: false, includeSourceItems: true);

                try
                {
                    RetryHelper.ActionWithRetries(() => synchronizer.UIUpdate(db,
                                                                              dtoOrder,
                                                                              isForceOverride: false,
                                                                              keepActiveShipping: true,
                                                                              keepCustomShipping: applyResult.ShipmentProviderChanged ? false : true,
                                                                              switchToMethodId: null),
                                                  log,
                                                  2,
                                                  300,
                                                  RetryModeType.Normal,
                                                  true);

                    orderHistoryService.AddRecord(dtoOrder.Id, OrderHistoryHelper.RecalculateRatesKey, null, true, by);
                }
                catch (Exception ex)
                {
                    results.Add(MessageString.Error("", "An unexpected error has occurred. Please try again. Detail: " + ex.Message));
                }
            }

            if (applyResult.AddressValidationRequested)
            {
                addressChecker.UpdateOrderAddressValidationStatus(db, EntityId, null);
            }

            return(results);
        }
コード例 #2
0
        public IOrderSynchronizer GetForMarket(IMarketApi api,
                                               ILogService log,
                                               CompanyDTO company,
                                               ISettingsService settings,
                                               ISyncInformer syncInfo,
                                               IList <IShipmentApi> rateProviders,
                                               IQuantityManager quantityManager,
                                               IEmailService emailService,
                                               IOrderValidatorService validatorService,
                                               IOrderHistoryService orderHistoryService,
                                               ICacheService cacheService,
                                               ISystemActionService systemAction,
                                               ICompanyAddressService companyAddress,
                                               ITime time,
                                               IWeightService weightService,
                                               ISystemMessageService messageService)
        {
            IOrderSynchronizer synchronizer = null;

            switch (api.Market)
            {
            case MarketType.Amazon:
            case MarketType.AmazonEU:
            case MarketType.AmazonAU:
                synchronizer = new AmazonOrdersSynchronizer(log,
                                                            api,
                                                            company,
                                                            settings,
                                                            syncInfo,
                                                            rateProviders,
                                                            quantityManager,
                                                            emailService,
                                                            validatorService,
                                                            orderHistoryService,
                                                            cacheService,
                                                            systemAction,
                                                            companyAddress,
                                                            time,
                                                            weightService,
                                                            messageService);
                break;

            case MarketType.eBay:
                synchronizer = new EBayOrdersSynchronizer(log,
                                                          api,
                                                          company,
                                                          settings,
                                                          syncInfo,
                                                          rateProviders,
                                                          quantityManager,
                                                          emailService,
                                                          validatorService,
                                                          orderHistoryService,
                                                          cacheService,
                                                          systemAction,
                                                          companyAddress,
                                                          time,
                                                          weightService,
                                                          messageService);
                break;

            case MarketType.Magento:
                synchronizer = new MagentoOrdersSynchronizer(log,
                                                             api,
                                                             company,
                                                             settings,
                                                             syncInfo,
                                                             rateProviders,
                                                             quantityManager,
                                                             emailService,
                                                             validatorService,
                                                             orderHistoryService,
                                                             cacheService,
                                                             systemAction,
                                                             companyAddress,
                                                             time,
                                                             weightService,
                                                             messageService);
                break;

            case MarketType.Groupon:
                synchronizer = new GrouponOrdersSynchronizer(log,
                                                             api,
                                                             company,
                                                             settings,
                                                             syncInfo,
                                                             rateProviders,
                                                             quantityManager,
                                                             emailService,
                                                             validatorService,
                                                             orderHistoryService,
                                                             cacheService,
                                                             systemAction,
                                                             companyAddress,
                                                             time,
                                                             weightService,
                                                             messageService);
                break;

            case MarketType.Shopify:
                synchronizer = new ShopifyOrdersSynchronizer(log,
                                                             api,
                                                             company,
                                                             settings,
                                                             syncInfo,
                                                             rateProviders,
                                                             quantityManager,
                                                             emailService,
                                                             validatorService,
                                                             orderHistoryService,
                                                             cacheService,
                                                             systemAction,
                                                             companyAddress,
                                                             time,
                                                             weightService,
                                                             messageService);
                break;

            case MarketType.WooCommerce:
                synchronizer = new WooCommerceOrdersSynchronizer(log,
                                                                 api,
                                                                 company,
                                                                 settings,
                                                                 syncInfo,
                                                                 rateProviders,
                                                                 quantityManager,
                                                                 emailService,
                                                                 validatorService,
                                                                 orderHistoryService,
                                                                 cacheService,
                                                                 systemAction,
                                                                 companyAddress,
                                                                 time,
                                                                 weightService,
                                                                 messageService);
                break;

            case MarketType.Walmart:
            case MarketType.WalmartCA:
                synchronizer = new WalmartOrdersSynchronizer(log,
                                                             api,
                                                             company,
                                                             settings,
                                                             syncInfo,
                                                             rateProviders,
                                                             quantityManager,
                                                             emailService,
                                                             validatorService,
                                                             orderHistoryService,
                                                             cacheService,
                                                             systemAction,
                                                             companyAddress,
                                                             time,
                                                             weightService,
                                                             messageService);
                break;

            case MarketType.Jet:
                synchronizer = new JetOrdersSynchronizer(log,
                                                         api,
                                                         company,
                                                         settings,
                                                         syncInfo,
                                                         rateProviders,
                                                         quantityManager,
                                                         emailService,
                                                         validatorService,
                                                         orderHistoryService,
                                                         cacheService,
                                                         systemAction,
                                                         companyAddress,
                                                         time,
                                                         weightService,
                                                         messageService);
                break;

            case MarketType.DropShipper:
                synchronizer = new DSOrdersSynchronizer(log,
                                                        api,
                                                        company,
                                                        settings,
                                                        syncInfo,
                                                        rateProviders,
                                                        quantityManager,
                                                        emailService,
                                                        validatorService,
                                                        orderHistoryService,
                                                        cacheService,
                                                        systemAction,
                                                        companyAddress,
                                                        time,
                                                        weightService,
                                                        messageService);
                break;

            case MarketType.OverStock:
                synchronizer = new SupplierOasisOrdersSynchronizer(log,
                                                                   api,
                                                                   company,
                                                                   settings,
                                                                   syncInfo,
                                                                   rateProviders,
                                                                   quantityManager,
                                                                   emailService,
                                                                   validatorService,
                                                                   orderHistoryService,
                                                                   cacheService,
                                                                   systemAction,
                                                                   companyAddress,
                                                                   time,
                                                                   weightService,
                                                                   messageService);
                break;

            case MarketType.OfflineOrders:
                synchronizer = new UserOrdersSynchronizer(log,
                                                          api,
                                                          company,
                                                          settings,
                                                          syncInfo,
                                                          rateProviders,
                                                          quantityManager,
                                                          emailService,
                                                          validatorService,
                                                          orderHistoryService,
                                                          cacheService,
                                                          systemAction,
                                                          companyAddress,
                                                          time,
                                                          weightService,
                                                          messageService);
                break;

            default:
                throw new NotImplementedException("MarketType not supported=" + api.Market.ToString());
                break;
            }

            return(synchronizer);
        }