Пример #1
0
        public void SetTwitterDataByIds(List <string> twitterIds)
        {
            logger.Info("/-----Twitter Service Save Timelines In Ids Start-----/");
            int savedCount = 0;

            UserTimelineParameters parameters = new UserTimelineParameters()
            {
                IncludeRTS = false,
                MaximumNumberOfTweetsToRetrieve = 100,
                ExcludeReplies = true
            };

            try
            {
                if (twitterIds.Count > 0)
                {
                    foreach (string twitterId in twitterIds)
                    {
                        var tweets = User.GetUserFromScreenName(twitterId).GetUserTimeline(parameters);

                        foreach (var tweet in tweets)
                        {
                            /*
                             * [Column("TWITTER_ID")]
                             * [Column("ACCOUNT_NAME")]
                             * [Column("TWEET_TEXT")]
                             * [Column("HASHTAGS")]
                             * [Column("RETWEET_CNT")]
                             * [Column("URL")]
                             */
                            TwitterT entity = new TwitterT()
                            {
                                TwitterId    = tweet.IdStr,
                                TweetText    = tweet.FullText,
                                hashTags     = string.Join(" ", tweet.Hashtags),
                                AccountName  = tweet.CreatedBy.Name,
                                RetweetCount = tweet.RetweetCount,
                                Url          = tweet.Url
                            };
                            twitterRepository.InsertTwitterData(entity);

                            savedCount++;
                        }
                    }
                }
                logger.Info("/-----Twitter Service Save Timelines In Ids End! Saved Count : " + savedCount + " -----/");
                logger.Info("/-----Twitter Data Save End-----/");
            }
            catch (Exception e)
            {
                logger.Error(e, "Twitter Service Error");
            }
        }