Esempio n. 1
0
 public void UpDate(Account account)
 {
     var contextBuilder = new TwitterContextBuilder();
     IQueryBuilder queryBuilder = new QueryTimeLineBuilder(contextBuilder.Build(account.TwitterCredentials));
     var result = Load(queryBuilder, account.MaxId);
     if (result == null || result.Count == 0) return;
     _storage.AddStatuses(_statusMapper.Map(result));
     account.MaxId = result[0].StatusID;
     _storage.UpdateIdsAccount(account);
 }
Esempio n. 2
0
 public int Count(ulong userId, Storage storage)
 {
     var contextBuilder = new TwitterContextBuilder();
     var twitterContext = contextBuilder.Build(storage.GetAccountById(2765688547).TwitterCredentials);
     var userResponse =
         (from user in twitterContext.User
             where user.Type == UserType.Lookup &&
                   user.UserIdList == userId.ToString()
             select user).ToListAsync();
     userResponse.Wait();
     return userResponse.Result[0].StatusesCount;
 }
Esempio n. 3
0
 public IEnumerable<TwitterStatus> LoadReplies(long userId, ulong tweetId)
 {
     var account = Storage.GetAccountById(userId);
     var statusAuthor = Storage.GetTweeById(tweetId).UserName;
     var twitterContextBuilder = new TwitterContextBuilder();
     var context = twitterContextBuilder.Build(
         new TwitterCredentials(
             new TwitterToken(account.TwitterCredentials.Tokens.Token,
                 account.TwitterCredentials.Tokens.TokenSecret), account.TwitterCredentials.ScreenName,
             account.TwitterCredentials.UserId));
     return LoadReplies(new TaskBuilder(context), statusAuthor, tweetId).ToList();
 }
Esempio n. 4
0
        public void Initialize(Account account)
        {
            var twitterContextBuilder = new TwitterContextBuilder();
            var context = twitterContextBuilder.Build(account.TwitterCredentials);
            IQueryBuilder queryBuilder = new QueryTimeLineBuilder(context);

            var result = LoadStatuses(queryBuilder, account.MinId - 1);
            result = result.OrderByDescending(x => x.CreatedAt).ToList();
            account.MarkAsInitialized();
            if (result.Count != 0)
            {
                account.MinId = result[result.Count - 1].StatusID;
                if (account.MaxId < result[0].StatusID)
                {
                    account.MaxId = result[0].StatusID;
                }
            }
            var following = Followers(context, account.TwitterCredentials.ScreenName);

            _storage.AddStatuses(_statusMapper.Map(result));
            _storage.UpdateIdsAccount(account, true);
            _storage.SetFollowing(account, following);
        }
Esempio n. 5
0
 public IList<Status> LoadUserTimeLine(TwitterCredentials credentials)
 {
     var twitterContextBuilder = new TwitterContextBuilder();
     IQueryBuilder userStatusesBuilder = new QueryTimeLineBuilder(twitterContextBuilder.Build(credentials));
     return LoadStatuses(userStatusesBuilder, 3000);
 }