Ejemplo n.º 1
0
 /// <remarks/>
 public void findItemsByKeywordsAsync(FindItemsByKeywordsRequest findItemsByKeywordsRequest) {
     this.findItemsByKeywordsAsync(findItemsByKeywordsRequest, null);
 }
Ejemplo n.º 2
0
 /// <remarks/>
 public void findItemsByKeywordsAsync(FindItemsByKeywordsRequest findItemsByKeywordsRequest, object userState) {
     if ((this.findItemsByKeywordsOperationCompleted == null)) {
         this.findItemsByKeywordsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnfindItemsByKeywordsOperationCompleted);
     }
     this.InvokeAsync("findItemsByKeywords", new object[] {
                 findItemsByKeywordsRequest}, this.findItemsByKeywordsOperationCompleted, userState);
 }
Ejemplo n.º 3
0
        private List<eBayItemData> GetSimilarItems(Snipe snipe, int nbRetry)
        {
            if (this._backEndObject) this._eBayKeyHandler.NbApiCalls = this._eBayKeyHandler.NbApiCalls + 1;

            Logger.CreateLog("Beginning__GetSimilarItems", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO);

            string callname = "findItemsByKeywords";

            try
            {
                // Creating an object to the BestMatchService class
                CustomFindingService service = new CustomFindingService(callname, this.User.EBayRegistrationSiteID, this._eBayKeyHandler.GetEBayKeySet().AppID);
                service.Url = ServiceParametersHelper.eBayFindingUrl();

                FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();
                request.keywords = snipe.ItemTitle;
                request.sortOrder = SortOrderType.EndTimeSoonest;
                request.sortOrderSpecified = true;

                List<ItemFilter> itemF = new List<ItemFilter>();

                ItemFilter itemType = new ItemFilter();
                itemType.name = ItemFilterType.ListingType;
                List<string> itemT = new List<string>();
                itemT.Add("Auction");
                itemType.value = itemT.ToArray();
                itemF.Add(itemType);

                itemType = new ItemFilter();
                itemType.name = ItemFilterType.Seller;
                itemT = new List<string>();
                itemT.Add(snipe.ItemSellerID);
                itemType.value = itemT.ToArray();
                itemF.Add(itemType);

                request.itemFilter = itemF.ToArray();

                List<eBayItemData> items = new List<eBayItemData>();

                FindItemsByKeywordsResponse response = service.findItemsByKeywords(request);

                if (response.ack == AckValue.Success)
                {
                    SearchResult result = response.searchResult;

                    if (response.searchResult.item != null)
                    {
                        foreach (SearchItem itemC in response.searchResult.item)
                        {
                            if (itemC.title == snipe.ItemTitle)
                                items.Add(this.GetItemDetails(long.Parse(itemC.itemId)));
                        }
                    }
                }
                else
                {
                    string error = "";

                    foreach (ErrorData err in response.errorMessage) error += err.message + Environment.NewLine;

                    throw new Exception(error);
                }

                Logger.CreateLog("Ending__GetSimilarItems", snipe.SnipeID.ToString(), null, EnumLogLevel.INFO);

                return items;

            }
            catch (Exception ex)
            {
                if (nbRetry < ServiceParametersHelper.nbAPIRetry())
                    this.GetSimilarItems(snipe, nbRetry + 1);
                else
                {
                    Logger.CreateLog("Error__GetSimilarItems", snipe.SnipeID.ToString(), ex, EnumLogLevel.ERROR);
                    throw ex;
                }
            }

            throw new Exception("Unknow error when getting similar items.");
        }