예제 #1
0
        public async Task PullDirectMessages(SocialAccount account)
        {
            int      maxNumberOfMessagesRetrieve = 50;
            DateTime since = DateTime.UtcNow.AddHours(-1);

            _twitterClient.SetUserCredentials(account.Token, account.TokenSecret);

            var recivedMessages = PullReceivedDirectMessages(account, maxNumberOfMessagesRetrieve, since);
            var sentMessages    = PullSentDirectMessages(account, maxNumberOfMessagesRetrieve, since);

            var messages = recivedMessages.Concat(sentMessages).OrderBy(t => t.CreatedAt);

            foreach (var message in messages)
            {
                TwitterProcessResult result = null;
                await UnitOfWorkManager.RunWithNewTransaction(account.SiteId, async() =>
                {
                    result = await _twitterService.ProcessDirectMessage(account, message);
                });

                if (result != null)
                {
                    await result.Notify(account.SiteId);
                }
            }
        }
예제 #2
0
        public async Task PullTweets(SocialAccount account)
        {
            int      maxNumberOfTweetsRetrieve = 10;
            DateTime since = DateTime.UtcNow.AddHours(-1);

            _twitterClient.SetUserCredentials(account.Token, account.TokenSecret);

            var receivedTweets = PullMentionTimeLineTweets(account, maxNumberOfTweetsRetrieve, since);
            var sentTweets     = new List <ITweet>();
            //var sentTweets = PullUserTimeLineTweets(account, maxNumberOfTweetsRetrieve, since);

            var tweets = receivedTweets.Concat(sentTweets).OrderBy(t => t.CreatedAt);

            foreach (var tweet in tweets)
            {
                TwitterProcessResult result = null;
                await UnitOfWorkManager.RunWithNewTransaction(account.SiteId, async() =>
                {
                    result = await _twitterService.ProcessTweet(account, tweet);
                });

                if (result != null)
                {
                    await result.Notify(account.SiteId);
                }
            }
        }
예제 #3
0
        public async Task ProcessDirectMessage(SocialAccount account, IMessage directMsg)
        {
            TwitterProcessResult result = null;
            await UnitOfWorkManager.RunWithNewTransaction(account.SiteId, async() =>
            {
                result = await _twitterService.ProcessDirectMessage(account, directMsg);
            });

            if (result != null)
            {
                await result.Notify(account.SiteId);
            }
        }
예제 #4
0
        public async Task ProcessTweet(SocialAccount account, ITweet currentTweet)
        {
            TwitterProcessResult result = null;
            await UnitOfWorkManager.RunWithoutTransaction(account.SiteId, async() =>
            {
                result = await _twitterService.ProcessTweet(account, currentTweet);
            });

            if (result != null)
            {
                await result.Notify(account.SiteId);
            }
        }