private UIViewController CreateController(string tabTitle, string tabImagePath, TwitterSearcher searcher) { var controller = new MainViewController (tabTitle, searcher); controller.TabBarItem.Image = UIImage.FromFile (tabImagePath); return new UINavigationController (controller); }
public async Task <string> StudyTermAsync(StudyTermModel model) { // Get tweets of the term var twitterSearcher = new TwitterSearcher(); var tweets = await twitterSearcher.GetTweetsAsync(model.Term, 100).ConfigureAwait(false); // Analyze Tweets var result = await this.PredictTweetsAsync(tweets); return(result); }
public async Task <List <string> > CompareTerms(CompareTermsModel model) { // Get tweets of the term var twitterSearcher = new TwitterSearcher(); var results = new List <string>(); foreach (var term in model.Terms) { var result = await this.StudyTermAsync(new StudyTermModel { Term = term }); results.Add(result); } return(results); }
public MainScreanTabController() { var authService = new ApplicationOnlyTwitterAuthService (_consumerKey, _consumerSecret, _requestTokenUrl, _userAgent); var searcher = new TwitterSearcher (authService, _tweeterHostUrl, _tweeterRequestUrl); ViewControllers = new UIViewController[] { CreateController ("#Twitter","Images/TabBar/icon_twitter.png", searcher), CreateController ("#Dribbble","Images/TabBar/icon_dribbble.png", searcher), CreateController ("#Apple","Images/TabBar/icon_apple.png", searcher), CreateController ("#GitHub","Images/TabBar/icon_github.png", searcher) }; var titleAttributes = new UITextAttributes (); titleAttributes.Font = Fonts.HelveticaNeueBold (13); titleAttributes.TextColor = UIColor.FromRGB (255, 255, 255); TabBarItem.SetTitleTextAttributes (titleAttributes, UIControlState.Normal); }
public void TwitterSearch() { if (twitterSearching) { AddLog("이미 Twitter 서비스에서 검색을 실행중입니다.", TaskLogType.Failed); return; } if (!SettingManager.TwitterSearchOption.DateRange.Vaild) { AddLog("트위터 검색의 날짜 설정이 잘못되었습니다.", TaskLogType.Failed); return; } twitterSearching = true; _detailsOption.TwitterEnableChange(false); _vertManager.ChangeEditable(false, ServiceKind.Twitter); lvTwitter.Items.Clear(); Thread thr = new Thread(() => { var sw = new Stopwatch(); var twitterSearcher = new TwitterSearcher(); bool isCanceled = false; SearchResult info = SearchResult.Fail_APIError; TwitterSearchOption option = null; twitterSearcher.SearchProgressChanged += Searcher_SearchProgressChanged; twitterSearcher.SearchFinished += Searcher_SearchFinished; twitterSearcher.ChangeInfoMessage += Searcher_ChangeInfoMessage; twitterSearcher.SearchItemFound += Searcher_SearchItemFound; Dispatcher.Invoke(() => { sw.Start(); AddLog("Twitter 검색 엔진을 초기화중입니다.", TaskLogType.SearchReady); option = SettingManager.TwitterSearchOption; option.Query = tbQuery.Text; var tb = new TaskProgressBar(); tb.SetValue(title: "Twitter 검색", message: "검색이 진행중입니다.", maximum: 1); lvTask.Items.Insert(0, tb); dict[twitterSearcher] = tb; if (option.OutputServices == OutputFormat.None) { tb.SetValue(message: "결과를 내보낼 위치가 없습니다.", maximum: 1); AddLog("검색을 내보낼 위치가 없습니다.", TaskLogType.Failed); tb.TaskFinished = true; info = SearchResult.Fail_InvaildSetting; isCanceled = true; } if (!TwitterSearcher.IsVerification) { tb.SetValue(message: "API키가 인증되지 않았습니다.", maximum: 1); AddLog("API키가 인증되지 않았습니다.", TaskLogType.Failed); tb.TaskFinished = true; info = SearchResult.Fail_APIError; isCanceled = true; } }); IEnumerable <TwitterSearchResult> twitterResult = null; ExportResultPack pack = null; if (!isCanceled) { try { twitterResult = twitterSearcher.Search(option); if (twitterResult.Count() == 0) { info = SearchResult.Fail_NoResult; AddLog("검색 결과가 없습니다.", TaskLogType.Failed); } else { info = SearchResult.Success; AddLog("검색 결과를 내보내는 중입니다.", TaskLogType.Searching); pack = Export(option.OutputServices, twitterResult, ServiceKind.Twitter); } } catch (InvaildOptionException) { AddLog("'Twitter' 검색 중 오류가 발생했습니다. [날짜를 사용하지 않은 상태에서는 '하루 기준' 옵션을 사용할 수 없습니다.]", TaskLogType.Failed); info = SearchResult.Fail_InvaildSetting; } catch (InternetUnstableException) { AddLog("'Twitter' 검색 중 오류가 발생했습니다. [인터넷 환경이 불안정한거 같습니다.]", TaskLogType.Failed); } } Dispatcher.Invoke(() => { AddLog($"Twitter 검색에 소요된 시간 : {sw.ElapsedMilliseconds}ms", TaskLogType.Complete); _taskReport.AddReport(new TaskReportData() { Query = option.Query, RequestService = ServiceKind.Twitter, SearchCount = option.SearchCount, SearchData = twitterResult, SearchDate = DateTime.Now, SearchResult = info, OutputFormat = option.OutputServices, ExportResultPack = pack }); _taskReport.SetLastReport(); twitterSearching = false; _detailsOption.TwitterEnableChange(true); _vertManager.ChangeEditable(true, ServiceKind.Twitter); }); }); thr.Start(); }
private void InitStreams() { //borrar despues List <IQueryConfiguration> configs = main.GetCurrentsConfigurations(); if (configs.Count > 0 && threadStream == null) { stream = Stream.CreateFilteredStream(); stream.TweetMode = TweetMode.Extended; foreach (var config in configs) { foreach (var key in config.Keywords) { stream.AddTrack(key); } } threadStream = new Thread(() => { stream.MatchingTweetReceived += (sender, args) => { IPublication publication = TwitterSearcher.ParseTweetToPublication(args.Tweet, configs[0]); lock (this) { publications2.Add(publication); } }; stream.StartStreamMatchingAllConditions(); }); threadStream.Start(); threadShow = new Thread(() => { while (publications2.Count >= 0) { if (publications2.Count % 10 == 0) { show sho = new show(ShowPublications); this.Invoke(sho, publications2); } else { Thread.Sleep(500); } } }); threadShow.Start(); //Recordar las privacidades queries, y configurations, quitar static de parse tweet y quitar //delegado } else { StopStreams(); } }