public void SubmitSingleProductPriceFeed(MarketplacePriceFeedDto priceItem, string submittedBy) { try { // create the Amazon envelope for the Price feed var envelope = RequestHelper.CreatePriceFeedEnvelope(new List <AmazonPriceFeed> { priceItem.AmazonPriceFeed }); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonSinglePriceFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_PRODUCT_PRICING_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Price, submittedBy); _logger.LogInfo(LogEntryType.AmazonPriceUpdate, string.Format("{0} - Successfully posted single price feed for EisSKU \'{1}\' \nRequested by: {2}", ChannelName, priceItem.EisSKU, submittedBy)); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting single price feed for EisSKU \'{3}\'. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, priceItem.EisSKU); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonPriceUpdate, description, ex.StackTrace); } }
public void SubmitSingleProductInventoryFeed(MarketplaceInventoryFeed inventoryFeed, string submittedBy) { try { // parse the EIS product and create Amazon envelope var envelope = RequestHelper.CreateInventoryFeedEnvelope(new List <AmazonInventoryFeed> { inventoryFeed.AmazonInventoryFeed }); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonSingleInventoryFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_INVENTORY_AVAILABILITY_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Inventory, submittedBy); _logger.LogInfo(LogEntryType.AmazonInventoryUpdate, string.Format("{0} - Successfully posted single inventory feed for EisSKU \'{1}\'.\nRequested by: {2}", ChannelName, inventoryFeed.EisSKU, submittedBy)); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting single product inventory feed for EisSKU \'{3}\'. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, inventoryFeed.EisSKU); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonInventoryUpdate, description, ex.StackTrace); } }
public void SubmitProductPriceFeeds(List <MarketplacePriceFeedDto> priceFeeds, string submittedBy) { try { // get the Amazon feed and that also allow price update enabled var priceItems = priceFeeds .Where(x => !x.IsBlacklisted && x.AmazonPriceFeed != null && x.AmazonPriceFeed.IsEnabled) .Select(x => x.AmazonPriceFeed) .ToList(); if (!priceItems.Any()) { _logger.LogWarning(LogEntryType.AmazonInventoryUpdate, string.Format("{0} - No products for price update! Products must be not blacklisted and Amazon enabled. Requested by {1}", ChannelName, submittedBy)); return; } // create the Amazon envelope for the Price feed var envelope = RequestHelper.CreatePriceFeedEnvelope(priceItems); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonPriceFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_PRODUCT_PRICING_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Price, submittedBy); _logger.LogInfo(LogEntryType.AmazonPriceUpdate, string.Format("{0} - Successfully posted price feeds for {1} items. \nRequested by: {2}", ChannelName, priceItems.Count, submittedBy)); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting pricing feed for {3} items. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, priceFeeds.Count); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonPriceUpdate, description, ex.StackTrace); } }
public void SubmitProductInventoryFeeds(List <MarketplaceInventoryFeed> inventoryFeeds, string submittedBy) { try { // get the AmazonInventorFeed and that is also Enabled var inventoryItems = inventoryFeeds .Where(x => !x.IsBlacklisted && x.AmazonInventoryFeed != null && x.AmazonInventoryFeed.IsEnabled) .Select(x => x.AmazonInventoryFeed) .ToList(); if (!inventoryItems.Any()) { _logger.LogWarning(LogEntryType.AmazonInventoryUpdate, string.Format("{0} - No products for inventory update! Products must be not blacklisted and Amazon enabled. Requested by {1}", ChannelName, submittedBy)); return; } // parse the EIS products and create Amazon envelope var envelope = RequestHelper.CreateInventoryFeedEnvelope(inventoryItems); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonInventoryFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_INVENTORY_AVAILABILITY_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Inventory, submittedBy); _logger.LogInfo(LogEntryType.AmazonInventoryUpdate, string.Format("Successfully posted product inventory feed for {0} - {1} items. \nRequested by: {2}", ChannelName, inventoryItems.Count, submittedBy)); } catch (Exception ex) { var description = string.Format("Error in submitting inventory feeds for {0} - {3} items. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, inventoryFeeds.Count); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonInventoryUpdate, description, ex.StackTrace); } }
public void SubmitProductsListingFeed(List <MarketplaceProductFeedDto> productPostFeeds, string submittedBy) { try { // take out the products which has no product type id or no information for Amazon var invalidProducts = productPostFeeds .Where(x => x.IsBlacklisted || x.AmazonProductFeed == null || x.ProductTypeId == null) .ToList(); if (invalidProducts.Any()) { _logger.Add(LogEntrySeverity.Warning, LogEntryType.AmazonListing, string.Format("{0}/{1} EIS products which will not be included to Amazon product listing feed due to no product type ID or no Amazon information or black listed.", invalidProducts.Count, productPostFeeds.Count)); productPostFeeds.RemoveAll(x => x.IsBlacklisted || x.AmazonProductFeed == null || x.ProductTypeId == null); } // create the Amazon envelope for the products var envelope = RequestHelper.CreateProductsFeedEnvelope(productPostFeeds, AmazonEnvelopeMessageOperationType.Update); // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(envelope, "AmazonProductsListingFeed"); var submitFeedController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitFeedController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_PRODUCT_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.Product, submittedBy); _logger.LogInfo(LogEntryType.AmazonListing, string.Format("{0} - Successfully posted product listing feed for {1} product items. \nRequested by: {2}", ChannelName, productPostFeeds.Count, submittedBy)); } catch (Exception ex) { var description = string.Format("{0} - Error in submitting product listing feed for {3} items. \nError Message: {1} \nRequested by: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), submittedBy, productPostFeeds.Count); _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonListing, description, ex.StackTrace); } }
public bool ConfirmOrderShimpmentDetails(MarketplaceOrderFulfillment marketplaceOrder, string submittedBy) { if (!marketplaceOrder.OrderItems.Any()) { return(false); } // create configuratin to use US marketplace var config = new MarketplaceWebServiceConfig { ServiceURL = RequestHelper.ServiceUrl }; config.SetUserAgentHeader(_ApplicationName, _Version, "C#"); _amazonClient = new MarketplaceWebServiceClient(_credential.AccessKeyId, _credential.SecretKey, config); try { // create fulfillment item list from the order items var fulfillmentItems = new List <OrderFulfillmentItem>(); foreach (var item in marketplaceOrder.OrderItems) { fulfillmentItems.Add(new OrderFulfillmentItem { Item = item.OrderItemId, Quantity = item.Quantity.ToString() }); } // create the order fulfillment information var fulfillment = new OrderFulfillment { Item = marketplaceOrder.OrderId, FulfillmentDate = marketplaceOrder.FulfillmentDate, FulfillmentData = new OrderFulfillmentFulfillmentData { Item = marketplaceOrder.Carrier.Code, ShippingMethod = marketplaceOrder.ShippingMethod, ShipperTrackingNumber = marketplaceOrder.ShipperTrackingNumber }, Item1 = fulfillmentItems.ToArray() }; // create Amazon envelope object var amazonEnvelope = new AmazonEnvelope { Header = new Header { DocumentVersion = "1.01", MerchantIdentifier = _credential.MerchantId }, MessageType = AmazonEnvelopeMessageType.OrderFulfillment, Message = new AmazonEnvelopeMessage[] { new AmazonEnvelopeMessage { MessageID = "1", Item = fulfillment } } }; // parse the envelope into file var xmlFullName = XmlParser.WriteXmlToFile(amazonEnvelope, "OrderFulfillment"); var submitController = new SubmitFeedController(_amazonClient, _logger, _credential.MarketplaceId, _credential.MerchantId, submittedBy); var streamResponse = submitController.SubmitFeedAndGetResponse(xmlFullName, AmazonFeedType._POST_ORDER_FULFILLMENT_DATA_); parsedResultStreamAndLogReport(streamResponse, AmazonEnvelopeMessageType.OrderFulfillment, submittedBy); _logger.Add(LogEntrySeverity.Information, LogEntryType.AmazonOrdersProvider, string.Format("{0} - Successfully sent confirming order shipment for Order ID \'{1}\'", ChannelName, marketplaceOrder.OrderId)); return(true); } catch (Exception ex) { _logger.Add(LogEntrySeverity.Error, LogEntryType.AmazonOrdersProvider, string.Format("{0} - Error in confirming order shipment for OrderId: {3}. <br/>Error Message: {1} <br/> Access Key: {2}", ChannelName, EisHelper.GetExceptionMessage(ex), _credential.AccessKeyId, marketplaceOrder.OrderId), ex.StackTrace); return(false); } }