Example #1
0
        public static async void SaveUsers()
        {
            TwitterDbContext db = new TwitterDbContext();
            var users           = await GetUsersAsync(S_NAME);

            db.Users.AddRange(users);
            if (await db.SaveChangesAsync() > 0)
            {
                userCount += users.Count;
                Console.WriteLine("Users Saved : " + DateTime.Now + " Total(" + userCount.ToString() + ") ");
            }
        }
Example #2
0
        public static async void SaveTweets()
        {
            TwitterDbContext db = new TwitterDbContext();
            var tweets          = await GetTweetsAsync();

            db.Tweets.AddRange(tweets);

            if (await db.SaveChangesAsync() > 0)
            {
                tweetCount += tweets.Count;
                Console.WriteLine("Tweets Saved : " + DateTime.Now + " Total(" + tweetCount.ToString() + ") ");
            }
        }
Example #3
0
        public override void ConsumeResponse(Tweet tweet)
        {
            try
            {
                _context.Tweets.AddAsync(tweet);
                _context.SaveChangesAsync();

                Console.WriteLine("");
                Console.WriteLine("----MSSQL Tweet----");
                Console.WriteLine("");
                Console.WriteLine($"Id: {tweet.Id}");
                Console.WriteLine($"Tweet: {tweet.Text}");
                Console.WriteLine("");
                Console.WriteLine("----MSSQL Fim------");
                Console.WriteLine("");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }