6

我正在使用此代码部分使用 ebay FindingAPI 查找拍卖类型的所有项目。现在我想过滤那些在指定日期(例如:2 天)内开始的项目。如何添加此首选项?

检查此链接和首选项类型。这是代码部分:

IPaginationInput pagination = new PaginationInput();

pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 100;
pagination.pageNumberSpecified = true;
pagination.pageNumber = curPage;
request.paginationInput = pagination;

ItemFilter if1 = new ItemFilter();
ItemFilter if2 = new ItemFilter();
if1.name = ItemFilterType.ListingType;
if1.value = new string[] { "Auction" };




ItemFilter[] ifa = new ItemFilter[1];
ifa[0] = if1;
request.itemFilter = ifa;

FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


foreach (var item in response.searchResult.item)
{

    tw.WriteLine(item.viewItemURL.ToString());
    links.Add(item.viewItemURL.ToString());
}
4

1 回答 1

1

这应该可以让你大致得到你需要的东西。将用于比较的两个日期设置为您想要的任何日期。

IPaginationInput pagination = new PaginationInput();

                    pagination.entriesPerPageSpecified = true;
                    pagination.entriesPerPage = 100;
                    pagination.pageNumberSpecified = true;
                    pagination.pageNumber = curPage;
                    request.paginationInput = pagination;

                    ItemFilter if1 = new ItemFilter();
                    ItemFilter if2 = new ItemFilter();
                    if1.name = ItemFilterType.ListingType;
                    if1.value = new string[] { "Auction" };




                    ItemFilter[] ifa = new ItemFilter[1];
                    ifa[0] = if1;
                    request.itemFilter = ifa;

                    FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


                    foreach (var item in response.searchResult.item)
                    {
                         // EDIT
                         if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow) > -1) // -1 is earlyer; 0 is same; +1 is later then
                         {
                           if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow.AddDays(-2)) == -1 )
                           {
                               // You have an Item that was started between now and two days ago.
                               // Do something

                           }
                        }
                        // END EDIT

                        tw.WriteLine(item.viewItemURL.ToString());
                        links.Add(item.viewItemURL.ToString());
                    }
于 2012-09-16T07:40:44.673 回答