Ejemplo n.º 1
0
        /// <summary>
        /// Lists the initial searches available. very wow.
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var model = _searchLogic.GetItems();

            foreach (var item in model)
            {
                item.Tweets = _tweetsLogic.GetTweetsInDateRange(item.SearchId, DateTime.UtcNow.AddHours(-4), DateTime.UtcNow);
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public void RunAllSearches()
        {
            var appinfo = _twitterAppLogic.GetItem(1);

            if (appinfo.RateLimitRemaining < 10)
            {
                //wait 65 seconds so that hopefully everything is all reset and happy and such as
                Thread.Sleep(65000);
            }

            foreach (var search in _searchLogic.GetItems(SearchDependencies.Logs))
            {
                //search tweets
                var results = _twitterSearchRepository.Search(search.ToQuery(), search.ResultType, search.LastLog == null ? 0 : search.LastLog.LastTweetId, appinfo);

                //add a record to the history log
                var lastlog = new SearchHistoryLog()
                {
                    LastTweetId = results.LastId, SearchDate = DateTime.UtcNow, SearchId = search.SearchId, TweetCount = results.SearchResult.Statuses.Count()
                };
                _searchHistoryLogicRepository.Insert(lastlog);

                //update app info with last rate limit status
                appinfo.LastAccessedDTM    = DateTime.UtcNow;
                appinfo.RateLimitRemaining = results.RateLimitStatus.HourlyLimit = results.RateLimitStatus.RemainingHits;
                _twitterAppLogic.SaveOrUpdate(appinfo);


                //map tweets to domain model
                var tweets = Mapper.Map <List <TwitterStatus>, List <Tweet> >(results.SearchResult.Statuses.ToList());


                //persist tweets to database
                _tweetsLogic.PersistTweets(tweets, search.SearchId);
            }
        }
Ejemplo n.º 3
0
 public ActionResult Index()
 {
     return(View(_searchLogic.GetItems(SearchDependencies.Logs)));
 }