Ejemplo n.º 1
0
    public SimpleItemType[] GetMultipleItemsDetails(SearchResult result)
    {
        List<SimpleItemType> listSimpleItemType = new List<SimpleItemType>();
        Shopping service = new Shopping();
        service.Url = ConfigurationManager.AppSettings["ShoppingService"] + "?appid=" + ConfigurationManager.AppSettings["AppId"] + "&version=523&siteid=" + siteID + "&callname=GetMultipleItems&responseencoding=SOAP&requestencoding=SOAP";
        int page = 0;
        int perPage = 20;
        int skip = 0;
        if(result.count > 40)
        {
            page = 3;
        }
        else if (result.count > 20 && result.count <= 40)
        {
            page = 2;
        }
        else
        {
            page = 1;
        }

        for (int i = 0; i < page; i++)
        {
            skip = i * perPage;
            var resultItems = result.item.Skip(skip).Take(perPage);
            List<String> items = new List<String>();
            foreach (SearchItem item in resultItems)
            {
                items.Add(item.itemId);
            }
            System.Net.ServicePointManager.Expect100Continue = false;
            GetMultipleItemsRequestType multipleRequest = new GetMultipleItemsRequestType();
            multipleRequest.IncludeSelector = "Details,ItemSpecifics,Variations";
            multipleRequest.ItemID = items.ToArray();
            GetMultipleItemsResponseType multipleResponse = service.GetMultipleItems(multipleRequest);
            listSimpleItemType.AddRange(multipleResponse.Item.ToList());
        }
        return listSimpleItemType.ToArray();
    }