/// <summary> /// Get the search results from the Twitter API. Cache the results. /// </summary> /// <returns></returns> private IList <TwitterStatus> GetSearch() { var cacheKey = String.Format("__TwitterSearch_{0}_{1}", this.Search, this.Count); var results = (IList <TwitterStatus>) this.Context.Cache[cacheKey]; if (results == null) { var api = new TwitterAPI(); try { results = api.GetSearch(this.Search, this.Count); } catch { return(null); } this.Context.Cache.Insert( cacheKey, results, null, DateTime.UtcNow.AddSeconds(this.CacheDuration), System.Web.Caching.Cache.NoSlidingExpiration ); } return(results); }
private IList <TwitterStatus> GenerateData() { if (_twitter.IsLiveContentOnDesignMode) { /*---- live mode---*/ IList <TwitterStatus> statuses = null; var api = new TwitterAPI(); switch (_twitter.Mode) { case TwitterMode.Profile: statuses = api.GetProfile(_twitter.ScreenName, _twitter.Count, _twitter.IncludeRetweets, _twitter.IncludeReplies); if (statuses != null && statuses.Count > 0) { var user = statuses[0].User; _twitter.Title = _twitter.Title ?? user.Name; _twitter.Caption = _twitter.Caption ?? user.ScreenName; _twitter.ProfileImageUrl = _twitter.ProfileImageUrl ?? user.ProfileImageUrl; } break; default: statuses = api.GetSearch(_twitter.Search, _twitter.Count); break; } return(statuses); } /*---- fake mode --*/ return(GenerateFakeData()); }
/// <summary> /// Get the search results from the Twitter API. Cache the results. /// </summary> /// <returns></returns> private IList<TwitterStatus> GetSearch() { var cacheKey = String.Format("__TwitterSearch_{0}_{1}", this.Search, this.Count); var results = (IList<TwitterStatus>)this.Context.Cache[cacheKey]; if (results == null) { var api = new TwitterAPI(); try { results = api.GetSearch(this.Search, this.Count); } catch { return null; } this.Context.Cache.Insert( cacheKey, results, null, DateTime.UtcNow.AddSeconds(this.CacheDuration), System.Web.Caching.Cache.NoSlidingExpiration ); } return results; }
private IList<TwitterStatus> GenerateData() { if (_twitter.IsLiveContentOnDesignMode) { /*---- live mode---*/ IList<TwitterStatus> statuses = null; var api = new TwitterAPI(); switch (_twitter.Mode) { case TwitterMode.Profile: statuses = api.GetProfile(_twitter.ScreenName, _twitter.Count, _twitter.IncludeRetweets, _twitter.IncludeReplies); if (statuses != null && statuses.Count > 0) { var user = statuses[0].User; _twitter.Title = _twitter.Title ?? user.Name; _twitter.Caption = _twitter.Caption ?? user.ScreenName; _twitter.ProfileImageUrl = _twitter.ProfileImageUrl ?? user.ProfileImageUrl; } break; default: statuses = api.GetSearch(_twitter.Search, _twitter.Count); break; } return statuses; } /*---- fake mode --*/ return GenerateFakeData(); }