Ejemplo n.º 1
0
        private void btnSearchByProductName_Click(object sender, EventArgs e)
        {
            StoreProductSearchRequest searchRequest = new StoreProductSearchRequest
            {
                ProductName = txtSeachProduct.Text.Trim(),
                MyStoreOnly = true,

            };

            FindResult<StoreProductSearchModel> searchResult = new eBayServiceCall().SearchExternalStoreProduct(searchRequest);

            if (searchResult.Success)
            {

            }
        }
        public FindResult<StoreProductSearchModel> SearchExternalStoreProducts(StoreProductSearchRequest searchRequest)
        {
            IExternalStoreService externalService = null;

            FindResult<StoreProductSearchModel> result = new FindResult<StoreProductSearchModel>();

            if (searchRequest.StoreType == Lotus.Core.Common.StoreProviderTypeEnum.Amazon)
            {
                externalService = new AmazonServiceClient();
            }

            if (searchRequest.StoreType == Lotus.Core.Common.StoreProviderTypeEnum.eBay)
            {
                externalService = new eBayServiceCall();
            }

            result = externalService.SearchExternalStoreProduct(searchRequest);

            return result;
        }
Ejemplo n.º 3
0
        private void btnSearchAmazonProducts_Click(object sender, EventArgs e)
        {
            StoreProductSearchRequest request = new StoreProductSearchRequest();

            request.ProductName = txtSearchProductName.Text.Trim();

            request.StoreType = StoreProviderTypeEnum.Amazon;

            AmazonServiceClient amazonClient = new AmazonServiceClient();

            FindResult<StoreProductSearchModel> findResult = amazonClient.SearchExternalStoreProduct(request);

            if(findResult.Success)
            {

            }
        }
Ejemplo n.º 4
0
        public FindResult<StoreProductSearchModel> SearchExternalStoreProduct(StoreProductSearchRequest searchRequest)
        {
            List<string> itemIds = new List<string>();

            FindResult<StoreProductSearchModel> searchResult = new FindResult<StoreProductSearchModel>()
            {
                Entities = new List<StoreProductSearchModel>(),
                Success = false
            };

            int totalItems = 0;

            eBayContext = eBayApiContextFactory.CreateServiceContext();
            eBayFindingApiClient findingClient = new eBayFindingApiClient(eBayFindingApiClient.FindingServiceType.findItemsByKeywords.ToString());

            FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();

            request.keywords = searchRequest.ProductName;

            PaginationInput pagination = new PaginationInput();
            pagination.entriesPerPageSpecified = true;
            pagination.entriesPerPage = 100;
            pagination.pageNumberSpecified = true;
            pagination.pageNumber = 1;
            request.paginationInput = pagination;

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

            filters.Add(new ItemFilter
            {
                name = ItemFilterType.Currency,
                value = new string[] { "GBP" }
            });

            filters.Add(new ItemFilter
            {
                name = ItemFilterType.Seller,
                value = new string[] { "stellatraders" },

            });

            request.itemFilter = filters.ToArray();

            request.sortOrderSpecified = true;

            request.sortOrder = SortOrderType.BestMatch;
            request.keywords = searchRequest.ProductName;

            FindItemsByKeywordsResponse response = findingClient.findItemsByKeywords(request);

            if (response.ack != AckValue.Failure)
            {
                if (response.paginationOutput.totalEntriesSpecified)
                {
                    totalItems = response.paginationOutput.totalEntries;
                }

                foreach (SearchItem searchItem in response.searchResult.item)
                {
                    if (itemIds.Contains(searchItem.itemId.Trim()))
                    {
                        continue;
                    }

                    itemIds.Add(searchItem.itemId);

                    searchResult.Entities.Add(ConvertSearchItemToSearchItemModel(searchItem));

                    //StoreProductSearchModel searchModel = new StoreProductSearchModel()
                    //{
                    //    ProductTitle = searchItem.title,
                    //    StoreProductId = searchItem.itemId,

                    //    StoreProductId1 = searchItem.productId.Value,

                    //};

                }

                if (response.paginationOutput.pageNumberSpecified && response.paginationOutput.totalPagesSpecified)
                {

                    int totalPages = response.paginationOutput.totalPages;
                    int currentPageNo = response.paginationOutput.pageNumber;

                    while (totalPages > currentPageNo)
                    {

                        currentPageNo += 1;
                        pagination.pageNumber = currentPageNo;
                        request.paginationInput = pagination;

                        response = findingClient.findItemsByKeywords(request);

                        if (response.ack != AckValue.Failure)
                        {
                            foreach (SearchItem searchItem in response.searchResult.item)
                            {

                                if (itemIds.Contains(searchItem.itemId.Trim()))
                                {
                                    continue;
                                }

                                itemIds.Add(searchItem.itemId);

                                searchResult.Entities.Add(ConvertSearchItemToSearchItemModel(searchItem));

                            }

                        }
                    }

                }

                searchResult.Success = true;
            }
            else
            {
                searchResult.Success = false;

                searchResult.ErrorMessage = "Error occurred while searching for product in Ebay";
            }

            return searchResult;
        }
        public FindResult<StoreProductSearchModel> FindProducts(StoreProductSearchRequest request)
        {
            FindResult<StoreProductSearchModel> retVal = new FindResult<StoreProductSearchModel>();

            return retVal;
        }
Ejemplo n.º 6
0
 public FindResult<StoreProduct> SearchStoreProduct(StoreProductSearchRequest searchRequest)
 {
     throw new NotImplementedException();
 }