示例#1
0
        public void CallProcessEBayOrders(string orderNumber)
        {
            var syncInfo             = new DbSyncInformer(_dbFactory, _log, _time, SyncType.Orders, "", MarketType.eBay, String.Empty);
            var settings             = new SettingsService(_dbFactory);
            var dbFactory            = new DbFactory();
            var quantityManager      = new QuantityManager(_log, _time);
            var priceService         = new PriceService(dbFactory);
            var serviceFactory       = new ServiceFactory();
            var addressCheckServices = serviceFactory.GetAddressCheckServices(_log,
                                                                              _time,
                                                                              dbFactory,
                                                                              _company.AddressProviderInfoList);
            var companyAddress = new CompanyAddressService(_company);
            var addressService = new AddressService(addressCheckServices, companyAddress.GetReturnAddress(MarketIdentifier.Empty()), companyAddress.GetPickupAddress(MarketIdentifier.Empty()));
            var weightService  = new WeightService();
            var messageService = new SystemMessageService(_log, _time, _dbFactory);

            var rateProviders = serviceFactory.GetShipmentProviders(_log,
                                                                    _time,
                                                                    dbFactory,
                                                                    weightService,
                                                                    _company.ShipmentProviderInfoList,
                                                                    null,
                                                                    null,
                                                                    null,
                                                                    null);

            var stampsRateProvider = rateProviders.FirstOrDefault(r => r.Type == ShipmentProviderType.Stamps);

            var orderHistoryService = new OrderHistoryService(_log, _time, _dbFactory);
            var validatorService    = new OrderValidatorService(_log, _dbFactory, _emailService, settings, orderHistoryService, _actionService, priceService, _htmlScraper, addressService,
                                                                companyAddress.GetReturnAddress(MarketIdentifier.Empty()), stampsRateProvider, _time, _company);

            var actionService = new SystemActionService(_log, _time);
            var cacheService  = new CacheService(_log, _time, actionService, quantityManager);


            using (var db = _dbFactory.GetRWDb())
            {
                //if (!syncInfo.IsSyncInProgress())
                {
                    try
                    {
                        syncInfo.SyncBegin(null);

                        var synchronizer = new EBayOrdersSynchronizer(_log,
                                                                      _eBayApi,
                                                                      _company,
                                                                      settings,
                                                                      syncInfo,
                                                                      rateProviders,
                                                                      quantityManager,
                                                                      _emailService,
                                                                      validatorService,
                                                                      orderHistoryService,
                                                                      cacheService,
                                                                      _actionService,
                                                                      companyAddress,
                                                                      _time,
                                                                      weightService,
                                                                      messageService);

                        if (String.IsNullOrEmpty(orderNumber))
                        {
                            synchronizer.Sync(OrderSyncModes.Full, null);
                        }
                        else
                        {
                            synchronizer.ProcessSpecifiedOrder(db, orderNumber);
                        }
                    }
                    finally
                    {
                        syncInfo.SyncEnd();
                    }
                }
            }
        }
示例#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);
        }