public void CloseAmazonListings(AmazonSyncModel model, AmazonListingGroup amazonListingGroup)
        {
            var feedContent = _amazonFeedsApiService.GetProductsDeleteFeeds(amazonListingGroup);

            var submissionId = _amazonRequestService.SubmitCloseRequest(model, feedContent);

            var isUploaded   = false;
            var retryCounter = 0;

            while (!isUploaded)
            {
                retryCounter++;
                retryCounter++;
                if (retryCounter == 3)
                {
                    AmazonProgressBarHelper.Update(model.Task, "Error",
                                                   "Request timed out. Please check logs for potential errors and try again later.", 100,
                                                   100);
                    break;
                }

                try
                {
                    AmazonProgressBarHelper.Update(model.Task, "Push", "Checking if request was processed...", 100, 75);
                    if (_amazonFeedsApiService.GetFeedSubmissionList(submissionId).FeedProcessingStatus == "_DONE_")
                    {
                        AmazonProgressBarHelper.Update(model.Task, "Push", "Request was processed", 100, 90);
                        foreach (var amazonListing in amazonListingGroup.Items)
                        {
                            AmazonProgressBarHelper.Update(model.Task, "Push", "Updating local status of Amazon Listing #" + amazonListing.SellerSKU, 100, 90);
                            _amazonListingService.UpdateAmazonListingStatus(amazonListing);
                        }

                        isUploaded = true;
                    }
                    else
                    {
                        AmazonProgressBarHelper.Update(model.Task, "Push", "Nothing yet, we will wait 2 min. more and try again...", 100, 75);
                        Thread.Sleep(120000);
                    }
                }
                catch (Exception ex)
                {
                    _amazonLogService.Add(AmazonLogType.Listings, AmazonLogStatus.Error, ex, null,
                                          AmazonApiSection.Feeds, null, null, null, null, "Closing Amazon Listings");

                    AmazonProgressBarHelper.Update(model.Task, "Push", "Amazon Api is busy, we will need to wait additional 2 min. and try again", 100, 75);
                    Thread.Sleep(120000);
                }
            }
        }
Beispiel #2
0
        public void CheckIfDeleteRequestWasProcessed(AmazonSyncModel model, AmazonListing amazonListing, string submissionId)
        {
            var uploadSuccess = false;
            var retryCount    = 0;

            while (!uploadSuccess)
            {
                retryCount++;
                if (retryCount == 3)
                {
                    AmazonProgressBarHelper.Update(model.Task, "Error",
                                                   "Request timed out. Please check logs for potential errors and try again later.", 100,
                                                   100);
                    break;
                }

                try
                {
                    AmazonProgressBarHelper.Update(model.Task, "Push", "Checking if request was processed...", 100, 75);
                    if (_amazonFeedsApiService.GetFeedSubmissionList(submissionId).FeedProcessingStatus == "_DONE_")
                    {
                        AmazonProgressBarHelper.Update(model.Task, "Push", "Request was processed", 100, 75);
                        AmazonProgressBarHelper.Update(model.Task, "Push",
                                                       "Updating local status of Amazon Listing with SKU:" + amazonListing.SellerSKU,
                                                       100, 85);
                        _amazonListingService.UpdateAmazonListingStatus(amazonListing);

                        uploadSuccess = true;
                    }
                    else
                    {
                        AmazonProgressBarHelper.Update(model.Task, "Push",
                                                       "Nothing yet, we will wait 2 min. more and try again...", 100, 75);
                        Thread.Sleep(120000);
                    }
                }
                catch (Exception ex)
                {
                    _amazonLogService.Add(AmazonLogType.Listings, AmazonLogStatus.Error, ex, null,
                                          AmazonApiSection.Feeds, null, null, amazonListing, null);

                    AmazonProgressBarHelper.Update(model.Task, "Push",
                                                   "Amazon Api is busy, we will need to wait additional 2 min. and try again",
                                                   100, 75);
                    Thread.Sleep(120000);
                }
            }
        }