public static async Task <T> RetryConflictsAsync <T>(this IAmazonService client, Func <Task <T> > a, Action <int> onRetry)
        {
            var       tryCount    = 0;
            var       sleepTimeMs = 2000;
            const int maxTryCount = 5;

            while (true)
            {
                try
                {
                    tryCount++;
                    return(await a().ConfigureAwait(false));
                }
                catch (AmazonServiceException ex)
                    when(ex.StatusCode == HttpStatusCode.Conflict &&
                         ex.ErrorCode == "OperationAborted")
                    {
                        if (tryCount >= maxTryCount)
                        {
                            throw;
                        }

                        var sleepTime = (sleepTimeMs * tryCount);

                        onRetry(sleepTime);
                        await Task.Delay(sleepTime).ConfigureAwait(false);
                    }
            }
        }
Ejemplo n.º 2
0
 public EtlService(IAmazonService amazonService, ICsvService csvService, IFtpService ftpService, ISqlService sqlService)
 {
     _amazonService = amazonService;
     _csvService    = csvService;
     _ftpService    = ftpService;
     _sqlService    = sqlService;
 }
 public AmazonBusinessService(IAmazonService service, ILogger <AmazonBusinessService> logger)
 {
     _amazonService = service;
     _logger        = logger;
     _loadedReviews = new List <LoadedReview>();
     _usCultureInfo = new CultureInfo("de-DE");
 }
Ejemplo n.º 4
0
        private void Sync(Object state)
        {
            DateTime createdBefore;
            DateTime createdAfter;

            if (m_lastSyncTime != null && m_counter % 50 != 0)
            {
                createdAfter = m_lastSyncTime.GetValueOrDefault();
            }
            else
            {
                createdAfter = DateTime.Now.AddDays(-7);
            }
            createdBefore = DateTime.Now.AddMinutes(-2);
            m_logger.Info("Start to sync Amazon orders created after " + createdAfter.ToLongTimeString() + " and created before " + createdBefore.ToLongTimeString());
            List <string> companies = m_platformServiceFactory.GetCompanies();

            foreach (string company in companies)
            {
                IAmazonService amazonService = m_platformServiceFactory.GetAmazonService(company);
                IOrderService  orderService  = m_platformServiceFactory.GetOrderService(company);
                orderService.SyncOrders(amazonService.GetAccountNames(), createdAfter, createdBefore);
            }

            m_lastSyncTime = createdBefore;
            m_counter++;
        }
        internal AmazonProductService(IAmazonService service)
        {
            if (service == null)
            {
                throw new ArgumentNullException("IAmazonService");
            }

            this.service = service;
        }
Ejemplo n.º 6
0
 public CinemaDialogWorker(
     IKinoheldDbAccess kinoheldDbAccess,
     ILogger <CinemaDialogWorker> logger,
     IMessages messages,
     IAmazonService amazonService,
     IKinoheldService kinoheldService)
 {
     m_dbAccess        = kinoheldDbAccess;
     m_logger          = logger;
     m_messages        = messages;
     m_amazonService   = amazonService;
     m_kinoheldService = kinoheldService;
 }
Ejemplo n.º 7
0
 public AffiliateAmazonTask(IRepository <ScheduleTask> taskRepository,
                            IAmazonService amazonService,
                            IProductAmazonService productAmazonService,
                            IStoreService storeService,
                            ISettingService settingService,
                            IWorkContext workContext,
                            IPluginFinder pluginFinder)
 {
     this._taskRepository       = taskRepository;
     this._amazonService        = amazonService;
     this._productAmazonService = productAmazonService;
     this._storeService         = storeService;
     this._settingService       = settingService;
     this._workContext          = workContext;
 }
Ejemplo n.º 8
0
        public AffiliateAmazonController(IWorkContext workContext,
                                         IStoreContext storeContext,
                                         IStoreService storeService,
                                         ISettingService settingService,
                                         ILocalizationService localizationService,
                                         ICategoryAmazonService categoryAmazonService,
                                         ICategoryService categoryService,
                                         IProductService productService,
                                         IProductMappingService productMappingService,
                                         ICategoryMappingService categoryMappingService,
                                         IPictureService pictureService,
                                         ICurrencyService currencyService,

                                         IAffiliateAmazonImportManager importManager,
                                         IAmazonService amazonService,
                                         IProductAmazonService productAmazonService,
                                         IRepository <CategoryMapping> categoryMapRepo,
                                         IRepository <Product> productRepo,
                                         IRepository <ProductMapping> productMappingRepo,
                                         IRepository <Category> categoryRepo,
                                         IRepository <CategoryAmazon> categoryAmazonRepo,
                                         IScheduleTaskService schedualTaskService,
                                         IPluginFinder pluginFinder)
        {
            this._localizationService    = localizationService;
            this._settingService         = settingService;
            this._storeContext           = storeContext;
            this._storeService           = storeService;
            this._workContext            = workContext;
            this._categoryAmazonService  = categoryAmazonService;
            this._categoryService        = categoryService;
            this._productService         = productService;
            this._productMappingRepo     = productMappingRepo;
            this._productMappingService  = productMappingService;
            this._categoryMappingService = categoryMappingService;
            this._pictureService         = pictureService;
            this._currencyService        = currencyService;
            this._categoryMapRepo        = categoryMapRepo;
            this._productRepo            = productRepo;
            this._importManager          = importManager;
            this._amazonService          = amazonService;
            this._productAmazonService   = productAmazonService;

            this._categoryRepo       = categoryRepo;
            this._categoryAmazonRepo = categoryAmazonRepo;

            this._schedualTaskService = schedualTaskService;
        }
Ejemplo n.º 9
0
 public GetOverviewDayIntent(
     ILogger <GetOverviewDayIntent> logger,
     IMessages messages,
     IKinoheldService kinoheldService,
     IKinoheldDbAccess dbAccess,
     IAmazonService amazonService,
     IWorkItemQueue workItemQueue,
     IEmailService emailService,
     ICinemaDialogWorker cinemaDialogWorker,
     IEmailBodyFormatter <DayOverview> dayOverviewEmailFormatter,
     ISsmlMessageFormatter <DayOverview> dayOverviewSsmlFormatter)
 {
     m_logger                    = logger;
     m_messages                  = messages;
     m_dbAccess                  = dbAccess;
     m_kinoheldService           = kinoheldService;
     m_amazonService             = amazonService;
     m_workItemQueue             = workItemQueue;
     m_emailService              = emailService;
     m_cinemaDialogWorker        = cinemaDialogWorker;
     m_dayOverviewEmailFormatter = dayOverviewEmailFormatter;
     m_dayOverviewSsmlFormatter  = dayOverviewSsmlFormatter;
 }
 public BooksController(IAmazonService amazonService) =>
 this.amazonService = amazonService;
Ejemplo n.º 11
0
 public DocumentService(IAmazonService amazonService, IDocumentRepository documentRepo)
 {
     this.amazonService = amazonService;
     this.documentRepo  = documentRepo;
 }
 public HomeController(ILogger <HomeController> logger, IYotubeService yotubeService, IAmazonService amazonService)
 {
     _logger        = logger;
     _yotubeService = yotubeService;
     _amazonService = amazonService;
 }
Ejemplo n.º 13
0
 public AmazonProxyService(IAmazonService client)
 {
     _client = client;
 }