示例#1
0
        static private void PreLoadTrends(TrendsList trendsList)
        {
            if (trendsList != null)
            {
                TopicService topicService = new TopicService();
                SearchService searchService = new SearchService();
                VideoService videoService = new VideoService();

                foreach (TrendItem trendItem in trendsList)
                {
                    String query = trendItem.Title;

                    topicService.GetTopic(query);

                    int pageMax = ConfigService.GetConfig(ConfigKeys.THEINTERNETBUZZ_SEARCH_COUNT_PER_PAGE_PER_PROVIDER, 8);
                    SearchContext searchContext = new SearchContext(query, 1, pageMax);
                    searchContext.SearchType = SearchTypeEnum.Web;
                    searchService.Search(searchContext);
                    searchContext.SearchType = SearchTypeEnum.News;
                    searchService.Search(searchContext);

                    videoService.Search(query);
                }
            }
        }
示例#2
0
 public SearchResultList Search()
 {
     SearchResultList searchResultList  = new SearchService().Search(searchContext);
     return searchResultList;
 }
示例#3
0
        static private void PreLoadTrendsImage(TrendsList trendsList)
        {
            if (trendsList != null)
            {
                SearchService searchService = new SearchService();

                foreach (TrendItem trendItem in trendsList)
                {
                    if (trendItem.ImageURL == null)
                    {
                        String query = trendItem.Title;
                        SearchContext searchContext = new SearchContext(query, 1, 1);
                        searchContext.SearchType = SearchTypeEnum.Image;
                        SearchResultList searchResultList = searchService.Search(searchContext);
                        if (searchResultList.Count() > 0)
                        {
                            SearchResultItem item = (SearchResultItem)searchResultList.Item(0);
                            trendItem.ImageURL = item.ImageURL;
                        }
                    }

                    if (trendItem.TileImageURL == null && trendItem.ImageURL != null)
                    {
                        int imageSize;
                        switch (trendItem.Weight)
                        {
                            case 1: imageSize = 150;
                                break;
                            case 2: imageSize = 150;
                                break;
                            case 3: imageSize = 150;
                                break;
                            case 4: imageSize = 150;
                                break;
                            case 5: imageSize = 150;
                                break;
                            default: imageSize = 150;
                                break;
                        }

                        string url = "http://src.sencha.io/" + imageSize + "/" + trendItem.ImageURL;

                        HttpStatusCode status = new HTTPConnector().GetStatus(url, "image/jpeg,image/gif.image/png");
                        if (status == HttpStatusCode.OK)
                        {
                            trendItem.TileImageURL = url;
                        }
                    }
                }
            }
        }