Esempio n. 1
0
        /// <summary>
        /// Main function that call searching tweets and loading database
        /// </summary>
        public void ExecuteSearch()
        {
            var              credentials = new CredentialsConfig();
            TweetAPI         api         = new TweetAPI(credentials);
            SQLiteRepository repo        = new SQLiteRepository();

            do
            {
                Console.WriteLine("\nType command:");
                var command = Console.ReadLine().Trim();
                if (command == "exit")
                {
                    return;
                }

                try
                {
                    GetCommandContext(command);
                }
                catch (UnknownCommandException e)
                {
                    Console.WriteLine(e.Message);
                    continue;
                }

                var tweets           = api.SearchTweetByKeyword(Keyword, NumberOfTweets);
                var insertedSearchId = repo.InsertNewSearchItem(new SearchModel(DateTime.Now, Keyword, NumberOfTweets));

                repo.InsertManyNewTweetItems(TweetMap(tweets, insertedSearchId));
            }while (true);
        }