Пример #1
0
        public async Task LogReply(long tweetId, long replyTweetId)
        {
            var twitterLog = new TwitterLog
            {
                TweetId      = tweetId,
                ReplyTweetId = replyTweetId,
                CreatedDate  = DateTime.Now
            };

            await _repository.Add(twitterLog);
        }
Пример #2
0
        public async Task LogTweet(long tweetId)
        {
            if (await _repository.Any(v => v.TweetId == tweetId))
            {
                return;
            }

            var twitterLog = new TwitterLog
            {
                TweetId     = tweetId,
                CreatedDate = DateTime.Now
            };

            await _repository.Add(twitterLog);
        }
Пример #3
0
    public async Task LogReply(long tweetId, long replyTweetId, string tweetText)
    {
        if (await _repository.Any(x => x.TweetId == tweetId))
        {
            return;
        }

        var twitterLog = new TwitterLog
        {
            TweetId      = tweetId,
            ReplyTweetId = replyTweetId,
            CreatedDate  = DateTime.Now,
            Text         = tweetText
        };

        await _repository.Add(twitterLog);
    }
Пример #4
0
        public static void getTweetsFromTwitter()
        {
            CurtDevDataContext db = new CurtDevDataContext();
            double CallsPerHour = 12;
            double interval = (60 * 60) / CallsPerHour;
            DateTime lastCheck;
            try {
                lastCheck = db.TwitterLogs.OrderByDescending(x => x.lastUpdated).Select(x => x.lastUpdated).FirstOrDefault();
            } catch { lastCheck = DateTime.Now.AddSeconds(-(interval * 2)); };
            if (DateTime.Now.CompareTo(lastCheck.AddSeconds(interval)) >= 0) {

                TwitterLog log = new TwitterLog {
                    lastUpdated = DateTime.Now,
                    tweets = 0
                };
                db.TwitterLogs.InsertOnSubmit(log);
                db.SubmitChanges();
                log.tweets = getTimeline();
                db.SubmitChanges();
            }
        }