public void End(ApiContext apiContext, System.Diagnostics.EventLog eventLog = null) { ItemType itemType = ToItemType(); EndItemCall apiCall = new EndItemCall(apiContext); if (eventLog != null) { eventLog.WriteEntry(string.Format("Start relisting an item... ItemID={0}, Quantity={1}, Price={2}", itemType.ItemID, itemType.Quantity, itemType.StartPrice.Value)); } try { apiCall.EndItem(itemType.ItemID, EndReasonCodeType.NotAvailable); IsApiCallSuccess = true; } catch (Exception e) { if (eventLog != null) { eventLog.WriteEntry(string.Format("An error occured while ending an item... ItemID={0}, Quantity={1}, Price={2}, Message={3}", itemType.ItemID, itemType.Quantity, itemType.StartPrice.Value, e.Message)); } IsApiCallSuccess = false; ApiCallErrorMessage = e.Message; } }
public void SubmitSingleProductEndItem(ItemFeed itemFeed, string submittedBy) { try { if (string.IsNullOrEmpty(itemFeed.ItemId)) { _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Unable to send END_ITEM feed for \'{0}\' since it doesn't have ItemId. \nRequested by: {1}", itemFeed.EisSKU, submittedBy)); return; } // create the end item request var endItemCall = new EndItemCall(_context); endItemCall.EndItem(itemFeed.ItemId, EndReasonCodeType.NotAvailable); // let's set the eBay product ItemId to null _logger.SeteBayItemIdToNull(new List <ItemFeed> { itemFeed }); _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("Successfully posted single END_ITEM feed for {0} - {1} item. \nRequested by: {2} \nAPI Message: {3}", ChannelName, itemFeed.EisSKU, submittedBy, endItemCall.ApiResponse.Message)); } catch (Exception ex) { var description = string.Format("Error in submitting END_ITEM feed for {0}. \nError Message: {2} \nRequested by: {3}", itemFeed.EisSKU, EisHelper.GetExceptionMessage(ex), submittedBy); _logger.LogError(LogEntryType.eBayEndListing, description, ex.StackTrace); } }
public static void EndMyItem(string Token, string ItemID) { ApiContext apiContext = GetApiContext(Token); EndItemCall apiCall = new EndItemCall(apiContext); EndReasonCodeType Endreason = EndReasonCodeType.NotAvailable; apiCall.EndItem(ItemID, Endreason); }
public void DeleteEbayItem(string ebayId) { if (string.IsNullOrEmpty(ebayId)) { return; } var deleteEbayItem = new Func <string>(() => { deleteItemCall.EndItem(ebayId, EndReasonCodeType.NotAvailable, ""); return(ebayId); }); ExecuteWithExceptionHandling(deleteEbayItem, ebayId); }
private void BtnEndItem_Click(object sender, System.EventArgs e) { try { TxtStatus.Text = ""; EndItemCall apicall = new EndItemCall(Context); apicall.EndItem(TxtItemId.Text, (EndReasonCodeType)Enum.Parse(typeof(EndReasonCodeType), CboReason.SelectedItem.ToString())); TxtStatus.Text = apicall.ApiResponse.Ack.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <bool> EndItemListing(CommerceContext commerceContext, SellableItem sellableItem, string reason) { using (var activity = CommandActivity.Start(commerceContext, this)) { //Instantiate the call wrapper class try { var apiCall = new EndItemCall(await GetEbayContext(commerceContext)); if (sellableItem.HasComponent <EbayItemComponent>()) { var ebayItemComponent = sellableItem.GetComponent <EbayItemComponent>(); var reasonCodeType = EndReasonCodeType.NotAvailable; switch (reason) { case "NotAvailable": reasonCodeType = EndReasonCodeType.NotAvailable; break; case "CustomCode": reasonCodeType = EndReasonCodeType.CustomCode; break; case "Incorrect": reasonCodeType = EndReasonCodeType.Incorrect; break; case "LostOrBroken": reasonCodeType = EndReasonCodeType.LostOrBroken; break; case "OtherListingError": reasonCodeType = EndReasonCodeType.OtherListingError; break; case "SellToHighBidder": reasonCodeType = EndReasonCodeType.SellToHighBidder; break; case "Sold": reasonCodeType = EndReasonCodeType.Sold; break; default: reasonCodeType = EndReasonCodeType.CustomCode; break; } if (string.IsNullOrEmpty(ebayItemComponent.EbayId)) { ebayItemComponent.Status = "LostSync"; } else { if (ebayItemComponent.Status != "Ended") { //Call Ebay and End the Item Listing try { apiCall.EndItem(ebayItemComponent.EbayId, reasonCodeType); ebayItemComponent.Status = "Ended"; } catch (Exception ex) { if (ex.Message == "The auction has already been closed.") { //Capture a case where the listing has expired naturally and it can now no longer be ended. reason = "Expired"; ebayItemComponent.Status = "Ended"; } else { commerceContext.Logger.LogError(ex, $"EbayCommand.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "EbayCommand.EndItemListing", new [] { ex }, ex.Message).ConfigureAwait(false); } } } } ebayItemComponent.ReasonEnded = reason; ebayItemComponent.History.Add(new HistoryEntryModel { EventMessage = "Listing Ended", EventUser = commerceContext.CurrentCsrId() }); sellableItem.GetComponent <TransientListMembershipsComponent>().Memberships.Add("Ebay_Ended"); var persistResult = await this._commerceCommander.PersistEntity(commerceContext, sellableItem).ConfigureAwait(false); var listRemoveResult = await this._commerceCommander.Command <ListCommander>() .RemoveItemsFromList(commerceContext, "Ebay_Listed", new List <String>() { sellableItem.Id }).ConfigureAwait(false); } } catch (Exception ex) { commerceContext.Logger.LogError($"Ebay.EndItemListing.Exception: Message={ex.Message}"); await commerceContext.AddMessage("Error", "Ebay.EndItemListing.Exception", new Object[] { ex }, ex.Message).ConfigureAwait(false); } return(true); } }
protected override void bw_DoWork(object sender, DoWorkEventArgs e) { if (_isWorkerExecuted) { return; } // set the flag the this bw_DoWork has already called _isWorkerExecuted = true; var counter = 0; var service = new CredentialService(); var credential = (eBayCredentialDto)service.GetCredential(CredentialType.EBAY, _systemJob.SupportiveParameters); _itemFeeds = readProductItemFeeds(_systemJob.Parameters); // init the eBay API RequestHelper.SetCredentials(credential); // init the context var context = new ApiContext(); context.ApiCredential = RequestHelper.ApiCredential; context.SoapApiServerUrl = RequestHelper.ServiceUrl; setTotalItemsProcessed(_itemFeeds.Count); _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("{0} items for eBay EndListing has started...", _itemFeeds.Count)); // iterate and submit end item feed to the eBay for (var i = 0; i < _itemFeeds.Count; i++) { var itemFeed = _itemFeeds[i]; var percentage = (((double)i + 1) / _itemFeeds.Count) * 100.00; Console.WriteLine(string.Format("{0:#0.00}% Sending feed 1 x 1 for eBay Product EndItem...", percentage)); // report the progress counter++; _bw.ReportProgress(counter); try { if (string.IsNullOrEmpty(itemFeed.ItemId)) { itemFeed.Status = Status.NOT_PROCESSED; itemFeed.Message = "ItemId is NULL or empty"; continue; } // create the end item request var apiCall = new EndItemCall(context); apiCall.EndItem(itemFeed.ItemId, EndReasonCodeType.NotAvailable); // let's set the eBay product ItemId to null _repo.UpdateeBayEndedItem(itemFeed.EisSKU); itemFeed.Status = Status.SUCCESS; // sleep for 1 second - throttle limit Thread.Sleep(1000); } catch (Exception ex) { Console.WriteLine("Error in submitting eBay product end listing {0}. Error Message: {1}", _itemFeeds[i].EisSKU, EisHelper.GetExceptionMessage(ex)); itemFeed.Status = Status.FAILED; itemFeed.Message = string.Format("Error in sending endlisting feed. Message: {0}", EisHelper.GetExceptionMessage(ex)); } } _logger.LogInfo(LogEntryType.eBayEndListing, string.Format("{0} items for eBay EndListing has finished!", _itemFeeds.Count)); }