Beispiel #1
0
        public void CloseAmazonListing(AmazonSyncModel model)
        {
            AmazonProgressBarHelper.Clean(model.Task);

            var amazonListing = _amazonListingService.Get(model.Id);

            if (amazonListing != null)
            {
                _amazonLogService.Add(AmazonLogType.Listings, AmazonLogStatus.Stage, null, null, AmazonApiSection.Feeds, null, null, amazonListing,
                                      null, "Preparing request to close Amazon Listing");
                AmazonProgressBarHelper.Update(model.Task, "Push", "Preparing request to close Amazon Listing", 100, 0);

                _closeAmazonListingService.CloseAmazonListing(model, amazonListing);

                AmazonProgressBarHelper.Update(model.Task, "Push", "Amazon Listing successfully closed",
                                               100, 100);
            }

            else
            {
                AmazonProgressBarHelper.Update(model.Task, "Push", "No listing to close", null, null);
            }

            AmazonProgressBarHelper.Update(model.Task, "Completed", "Completed", 100, 100);
        }
        public ActionResult ProgressBarMessages(AmazonSyncModel model)
        {
            var progress = AmazonProgressBarHelper.Get(model.Task);

            return(PartialView(new AmazonSyncModel()
            {
                TaskId = model.Task,
                Messages = progress.GetMessages(model.Page)
            }));
        }
Beispiel #3
0
        public void CheckIfRequestsWereProcessed(AmazonSyncModel model, AmazonListingGroup item, List <string> submissionIds)
        {
            var uploadSuccess = false;
            var retryCount    = 0;

            var feedContent = _amazonFeedsApiService.GetProductsImageFeeds(item);

            while (!uploadSuccess)
            {
                retryCount++;
                if (retryCount == 5)
                {
                    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(submissionIds.First()).FeedProcessingStatus ==
                        "_DONE_")
                    {
                        AmazonProgressBarHelper.Update(model.Task, "Push", "Request was processed", 100, 75);
                        foreach (var amazonListing in item.Items)
                        {
                            AmazonProgressBarHelper.Update(model.Task, "Push", "Updating local status of Amazon Listing with SKU:" + amazonListing.SellerSKU, 100, 85);
                            _amazonListingService.UpdateAmazonListingStatusAndAsin(amazonListing, null);
                        }

                        SubmitProductImageFeed(model, feedContent, ref submissionIds);

                        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)
                {
                    CurrentRequestData.ErrorSignal.Raise(ex);

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

                    Thread.Sleep(120000);
                }
            }
        }
        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 #5
0
        private void SubmitProductImageFeed(AmazonSyncModel model, FileStream feedContent, ref List <string> submissionIds)
        {
            if (feedContent == null)
            {
                return;
            }

            AmazonProgressBarHelper.Update(model.Task, "Push", "Pushing product image", 100, 85);
            var feedResponse = _amazonFeedsApiService.SubmitFeed(AmazonFeedType._POST_PRODUCT_IMAGE_DATA_, feedContent);
            var submissionId = feedResponse.FeedSubmissionId;

            submissionIds.Add(submissionId);
            AmazonProgressBarHelper.Update(model.Task, "Push", "Product image pushed", 100, 100);
        }
Beispiel #6
0
        private void SubmitProductInventoryFeed(AmazonSyncModel model, FileStream feedContent, ref List <string> submissionIds)
        {
            if (feedContent == null)
            {
                return;
            }

            AmazonProgressBarHelper.Update(model.Task, "Push", "Pushing product inventory information", 100, 50);
            var feedResponse = _amazonFeedsApiService.SubmitFeed(AmazonFeedType._POST_INVENTORY_AVAILABILITY_DATA_, feedContent);
            var submissionId = feedResponse.FeedSubmissionId;

            submissionIds.Add(submissionId);
            AmazonProgressBarHelper.Update(model.Task, "Push", "Product inventory information pushed", 100, 75);
        }
Beispiel #7
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);
                }
            }
        }
Beispiel #8
0
        public List <string> SubmitMainFeeds(AmazonSyncModel model, List <FileStream> feeds)
        {
            var submissionIds = new List <string>();
            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
                {
                    if (feeds.Count >= 1)
                    {
                        SubmitProductFeed(model, feeds.First(), ref submissionIds);
                    }

                    if (feeds.Count >= 2)
                    {
                        SubmitProductPriceFeed(model, feeds[1], ref submissionIds);
                    }

                    if (feeds.Count >= 3)
                    {
                        SubmitProductInventoryFeed(model, feeds[2], ref submissionIds);
                    }

                    uploadSuccess = true;
                }
                catch (Exception ex)
                {
                    CurrentRequestData.ErrorSignal.Raise(ex);

                    Thread.Sleep(120000);
                }
            }
            return(submissionIds);
        }
Beispiel #9
0
        public string SubmitCloseRequest(AmazonSyncModel model, FileStream productFeedContent)
        {
            var submissionId  = String.Empty;
            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", "Pushing request to Amazon", 100, 0);
                    var feedResponse = _amazonFeedsApiService.SubmitFeed(AmazonFeedType._POST_PRODUCT_DATA_, productFeedContent);
                    submissionId = feedResponse.FeedSubmissionId;
                    AmazonProgressBarHelper.Update(model.Task, "Push", "Request pushed to Amazon", 100, 75);

                    uploadSuccess = true;
                }
                catch (Exception ex)
                {
                    _amazonLogService.Add(AmazonLogType.Listings, AmazonLogStatus.Error, ex, null,
                                          AmazonApiSection.Feeds, null, null, null, null, "Error during push of product delete request to Amazon");

                    Thread.Sleep(120000);
                }
            }
            return(submissionId);
        }
Beispiel #10
0
        public void SyncAmazonListings(AmazonSyncModel model)
        {
            AmazonProgressBarHelper.Clean(model.Task);

            var amazonListingGroup = _amazonListingGroupService.Get(model.Id);

            if (amazonListingGroup != null)
            {
                _amazonLogService.Add(AmazonLogType.Listings, AmazonLogStatus.Stage, null, null, AmazonApiSection.Feeds, null, null, null,
                                      amazonListingGroup, "Preparing listings for Amazon");
                AmazonProgressBarHelper.Update(model.Task, "Push", "Preparing listings for Amazon", 100, 0);

                _exportAmazonListingService.SubmitProductFeeds(model, amazonListingGroup);

                AmazonProgressBarHelper.Update(model.Task, "Push", "Amazon Listings successfully synced", 100, 100);
            }

            else
            {
                AmazonProgressBarHelper.Update(model.Task, "Push", "No listing to sync", null, null);
            }

            AmazonProgressBarHelper.Update(model.Task, "Completed", "Completed", 100, 100);
        }
        public JsonResult ProgressBarStatus(AmazonSyncModel model)
        {
            var progress = AmazonProgressBarHelper.GetStatus(model.Task);

            return(Json(progress, JsonRequestBehavior.AllowGet));
        }