private void resubmitInventoryStatusBySingleFeeds(List <eBayInventoryFeed> inventoryFeeds, string submittedBy, bool isPriceUpdate = false, bool isQuantityUpdate = false) { for (var i = 0; i < inventoryFeeds.Count; i++) { try { // create inventory item feed var inventoryStatus = new InventoryStatusType { ItemID = inventoryFeeds[i].ItemId }; // set the new price if its price update if (isPriceUpdate) { inventoryStatus.StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)inventoryFeeds[i].BinPrice, }; } // set the new quantity if its for inventory update if (isQuantityUpdate) { inventoryStatus.Quantity = inventoryFeeds[i].InventoryQuantity; inventoryStatus.QuantitySpecified = true; } var inventoryStatusCollection = new InventoryStatusTypeCollection(); inventoryStatusCollection.Add(inventoryStatus); // send the inventory collection request var apiCall = new ReviseInventoryStatusCall(_context); var inventoryStatusResult = apiCall.ReviseInventoryStatus(inventoryStatusCollection); var description = string.Format("Successfully posting {0} feed for {1}. \nRequested by: {2}", (isPriceUpdate ? "PRICE" : "INVENTORY"), inventoryFeeds[i].EisSKU, submittedBy); _logger.LogInfo(LogEntryType.eBayInventoryUpdate, description); Console.WriteLine(description); } catch (Exception ex) { var description = string.Format("Error in submitting single {0} feed for {1} . \nError Message: {2} \nRequested by: {3}", (isPriceUpdate ? "PRICE" : "INVENTORY"), inventoryFeeds[i].EisSKU, EisHelper.GetExceptionMessage(ex), submittedBy); _logger.LogError(LogEntryType.eBayInventoryUpdate, string.Format("Single: {0}/{1} - {2}", i + 1, inventoryFeeds.Count, description), ex.StackTrace); Console.WriteLine(description); } } }
public void SubmitSingleProductPriceFeed(MarketplacePriceFeedDto priceFeed, string submittedBy) { if (string.IsNullOrEmpty(priceFeed.eBayInventoryFeed.ItemId)) { _logger.LogInfo(LogEntryType.eBayPriceUpdate, string.Format("Unable to send price update feed for \'{0}\' since it doesn't have ItemId. \nRequested by: {1}", priceFeed.EisSKU, submittedBy)); return; } try { // create inventory item feed var inventoryStatus = new InventoryStatusType { ItemID = priceFeed.eBayInventoryFeed.ItemId, StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)priceFeed.eBayInventoryFeed.StartPrice } }; // set the log file name _context.ApiLogManager.ApiLoggerList.Add(new FileLogger(string.Format(_logDirectory, MethodBase.GetCurrentMethod().Name), false, true, true)); var inventoryStatusCollection = new InventoryStatusTypeCollection(); inventoryStatusCollection.Add(inventoryStatus); // send the inventory collection request var apiCall = new ReviseInventoryStatusCall(_context); var inventoryStatusResult = apiCall.ReviseInventoryStatus(inventoryStatusCollection); _logger.LogInfo(LogEntryType.eBayPriceUpdate, string.Format("Successfully posted single price feed for \'{0}\'. \nRequested by: {1}", priceFeed.EisSKU, submittedBy)); } catch (Exception ex) { var description = string.Format("Error in submitting single product price feed for \'{0}\'. \nError Message: {1} \nRequested by: {2}", priceFeed.EisSKU, EisHelper.GetExceptionMessage(ex), submittedBy); _logger.Add(LogEntrySeverity.Error, LogEntryType.eBayPriceUpdate, description, ex.StackTrace); } }
/// <summary> /// Revice the quantity of the items added recently. The new quantity is a fix value /// </summary> /// <returns>ItemType object</returns> #region ReviceItems void ReviceItems() { try { ReviseInventoryStatusCall call = new ReviseInventoryStatusCall(GetApiContext()); InventoryStatusTypeCollection inventory = new InventoryStatusTypeCollection(); foreach (Article article in articles) { InventoryStatusType type = new InventoryStatusType(); type.SKU = article.ArticleNumber; type.Quantity = 88; inventory.Add(type); } call.ReviseInventoryStatus(inventory); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void SubmitSingleProductInventoryFeed(MarketplaceInventoryFeed inventoryFeed, string submittedBy) { try { if (string.IsNullOrEmpty(inventoryFeed.eBayInventoryFeed.ItemId)) { _logger.LogInfo(LogEntryType.eBayInventoryUpdate, string.Format("Unable to send inventory update feed for \'{0}\' since it doesn't have ItemId. \nRequested by: {1}", inventoryFeed.EisSKU, submittedBy)); return; } // create inventory item feed var inventoryStatus = new InventoryStatusType { ItemID = inventoryFeed.eBayInventoryFeed.ItemId, Quantity = inventoryFeed.eBayInventoryFeed.InventoryQuantity }; var inventoryStatusCollection = new InventoryStatusTypeCollection(); inventoryStatusCollection.Add(inventoryStatus); // set the log file name _context.ApiLogManager.ApiLoggerList.Add(new FileLogger(string.Format(_logDirectory, MethodBase.GetCurrentMethod().Name), false, true, true)); // send the inventory collection request var apiCall = new ReviseInventoryStatusCall(_context); var inventoryStatusResult = apiCall.ReviseInventoryStatus(inventoryStatusCollection); _logger.LogInfo(LogEntryType.eBayInventoryUpdate, string.Format("Successfully posted single inventory feed for {0} - {1} item. \nRequested by: {2}", ChannelName, inventoryFeed.EisSKU, submittedBy)); } catch (Exception ex) { var description = string.Format("Error in submitting single inventory price feed for \'{0}\'. \nError Message: {1} \nRequested by: {2}", inventoryFeed.EisSKU, EisHelper.GetExceptionMessage(ex), submittedBy); _logger.Add(LogEntrySeverity.Error, LogEntryType.eBayInventoryUpdate, description, ex.StackTrace); } }
private List <eBayInventoryFeed> sendInventoryStatusFeeds(List <eBayInventoryFeed> inventoryItems, string submittedBy, bool isPriceUpdate = false, bool isQuantityUpdate = false) { var failedBatches = new List <eBayInventoryFeed>(); var totalBatches = Math.Ceiling(inventoryItems.Count() / 4.0); for (var i = 0; i < totalBatches; i++) { // only 4 items are allowed in single request for ReviseInventoryStatus var batchedInventories = inventoryItems.Skip(i * 4).Take(4).ToList(); var inventoryStatusCollection = new InventoryStatusTypeCollection(); try { foreach (var item in batchedInventories) { // create the item for inventory feed request var inventoryStatus = new InventoryStatusType { ItemID = item.ItemId }; // set the new price if its price update if (isPriceUpdate) { inventoryStatus.StartPrice = new AmountType { currencyID = CurrencyCodeType.USD, Value = (double)item.BinPrice }; } // set the new quantity if its for inventory update if (isQuantityUpdate) { inventoryStatus.Quantity = item.InventoryQuantity; inventoryStatus.QuantitySpecified = true; } inventoryStatusCollection.Add(inventoryStatus); } // send the inventory collection request var apiCall = new ReviseInventoryStatusCall(_context); var inventoryStatusResult = apiCall.ReviseInventoryStatus(inventoryStatusCollection); } catch (Exception ex) { var description = string.Format("Batch: {0}/{1} - Error in submitting {2} feed. \nError Message: {3} \nRequested by: {4}", i + 1, totalBatches, (isPriceUpdate ? "PRICE" : "INVENTORY"), EisHelper.GetExceptionMessage(ex), submittedBy); _logger.LogError(LogEntryType.eBayInventoryUpdate, description, ex.StackTrace); Console.WriteLine(description); // add the batched items to the list for resubmission 1 by 1 failedBatches.AddRange(batchedInventories); } } if (!failedBatches.Any()) { _logger.LogInfo(LogEntryType.eBayInventoryUpdate, string.Format("Successfully posted inventory/price feeds for {0} - {1} items. \nRequested by: {2}", ChannelName, inventoryItems.Count(), submittedBy)); } return(failedBatches); }