public ActionResult OverAllTweets() { try { IList <BOTweetMentions> tweetMentionTopicList = BOTweetMentions.TweetMentionsDistinctTopics(User.Identity.GetUserId()); List <string> distinctTopicList = tweetMentionTopicList.Select(data => data.Topic).ToList(); List <DataPoint> tweetSpeeder = new List <DataPoint>(); foreach (var topic in distinctTopicList) { int speed = 0; speed = BOTweetCount.TweetSpeed(User.Identity.GetUserId(), topic); tweetSpeeder.Add(new DataPoint(speed, topic)); } //IList<BOTweetCount> listLatestTenTweetCount = BOTweetCount.TweetCountCollection(User.Identity.GetUserId()); //Dictionary<string, int> allTweetsCountbyTopic = new Dictionary<string, int>(); //Dictionary<string, Dictionary<string, int>> allSentimentsbyTopic = new Dictionary<string, Dictionary<string, int>>(); //foreach (BOTweetCount tweetCount in listLatestTenTweetCount) //{ // if (!allTweetsCountbyTopic.ContainsKey(tweetCount.Topic.ToUpper())) // { // allTweetsCountbyTopic.Add(tweetCount.Topic.ToUpper(), 0); // } // else // { // allTweetsCountbyTopic[tweetCount.Topic.ToUpper()] += 1; // } //}; ////var xDataMonths = allTweetsCountbyTopic.Keys.ToArray(); ////var yDataCounts = allTweetsCountbyTopic.Values.Select(count => (object)count).ToArray(); //List<DataPoint> barcharTopicsCount = new List<DataPoint>(); ////Highcharts overAllSentimentChart = barChartTweetsByTopic("OverAllTweets", xDataMonths, yDataCounts); //foreach(string key in allTweetsCountbyTopic.Keys) //{ // barcharTopicsCount.Add(new DataPoint(allTweetsCountbyTopic[key], key)); //} ViewBag.TopicSpeeder = JsonConvert.SerializeObject(tweetSpeeder, _jsonSetting); return(PartialView()); } catch (Exception ex) { //error = ex.StackTrace; logger.Log(ex.StackTrace, LOGLEVELS.ERROR); ViewBag.TopicSpeeder = JsonConvert.SerializeObject(dummylist, _jsonSetting); return(PartialView()); } }
public ActionResult OverAllTweets() { try { IList <BOTweetMentions> tweetMentionTopicList = BOTweetMentions.TweetMentionsDistinctTopics(User.Identity.GetUserId()); List <string> distinctTopicList = tweetMentionTopicList.Select(data => data.Topic).ToList(); List <DataPoint> tweetSpeeder = new List <DataPoint>(); foreach (var topic in distinctTopicList) { int speed = 0; speed = BOTweetCount.TweetSpeed(User.Identity.GetUserId(), topic); tweetSpeeder.Add(new DataPoint(speed, topic)); } ViewBag.TopicSpeeder = JsonConvert.SerializeObject(tweetSpeeder, _jsonSetting); return(PartialView()); } catch (Exception ex) { //error = ex.StackTrace; logger.Log(ex.StackTrace, LOGLEVELS.ERROR); ViewBag.TopicSpeeder = JsonConvert.SerializeObject(dummylist, _jsonSetting); return(PartialView()); } }
private void _timer_Elapsed(object sender, ElapsedEventArgs e) { try { if (!string.IsNullOrWhiteSpace(userId)) { IList <BOTweetCount> latestTweets = BOTweetCount.TweetCountGetTweetsGreatorThanId(SentTweetId, userId); //Keep records of total no of tweets received for each topic. foreach (BOTweetCount tweet in latestTweets) { //SignalR Code to send Tweet to All Client Clients.All.sendTweetsToPage(((DateTime)tweet.CreatedAt).ToString("hh:mm:ss.ff", CultureInfo.InvariantCulture), tweet.TweetText); } //Keep an eye on latest Tweet push to dashboard if (latestTweets.Count > 0) { SentTweetId = (long)latestTweets[latestTweets.Count - 1].Id; } } } catch (Exception ex) { logger.Log(ex.StackTrace, LOGLEVELS.ERROR); } }
public ActionResult FilterCriteria(FilterCriteria filterCriteria) { try { throw new Exception(); if (string.IsNullOrWhiteSpace(filterCriteria.Topics)) { var timeZoneList = BOTimeZone.TimeZoneCollection().OrderBy(tz => tz.TimeZoneDisplayName). Select(tz => new SelectListItem { Value = tz.TimeZoneDisplayName, Text = tz.TimeZoneDisplayName }).ToList(); timeZoneList.Insert(0, new SelectListItem() { Text = "All", Value = "All" }); filterCriteria.TimeZone = timeZoneList; filterCriteria.Duration = new[] { new SelectListItem { Text = "15 min", Value = "15 min" }, new SelectListItem { Text = "30 min", Value = "30 min" }, new SelectListItem { Text = "1 hr", Value = "1 hr" }, new SelectListItem { Text = "1 week", Value = "1 week" } }.ToList(); return(View(filterCriteria)); } } catch (Exception ex) { logger.Log(ex.StackTrace, LOGLEVELS.ERROR); //error = ex.StackTrace; } //Clearing existing data for current User for fresh analysis BOTweetMentions.DeleteAll(User.Identity.GetUserId()); BOTweetCount.DeleteAll(User.Identity.GetUserId()); return(RedirectToAction("Index", "Home", new { UserId = Url.Encode(User.Identity.GetUserId()) })); }
public ActionResult OverAllSentimentsCount() { List <DataPoint> dummylist = new List <DataPoint>(); dummylist.Add(new DataPoint(0, 0)); try { IList <BOTweetCount> listLatestTweetCounts = BOTweetCount.TweetCountCollection(User.Identity.GetUserId()); Dictionary <string, Dictionary <string, int> > allSentimentsbyTopic = new Dictionary <string, Dictionary <string, int> >(); foreach (BOTweetCount tweetCount in listLatestTweetCounts) { if (!allSentimentsbyTopic.ContainsKey(tweetCount.Topic.ToUpper())) { allSentimentsbyTopic.Add(tweetCount.Topic.ToUpper(), new Dictionary <string, int>() { { Enum.GetName(typeof(SentimentScore), SentimentScore.Negative).ToUpper(), 0 }, { Enum.GetName(typeof(SentimentScore), SentimentScore.Positive).ToUpper(), 0 }, { Enum.GetName(typeof(SentimentScore), SentimentScore.Neutral).ToUpper(), 0 } }); } else { allSentimentsbyTopic[tweetCount.Topic.ToUpper()][Enum.GetName(typeof(SentimentScore), tweetCount.SentimentScore).ToUpper()] += 1; } } var topics = allSentimentsbyTopic.Keys.ToArray(); List <Series> yAxisData = new List <Series>(); List <DataPoint> negativeSentimentbyTopic = new List <DataPoint>(); List <DataPoint> positiveSentimentbyTopic = new List <DataPoint>(); List <DataPoint> neutralSentimentbyTopic = new List <DataPoint>(); string[] sentimentScoreCounter = new string[] { "NEGATIVE", "POSITIVE", "NEUTRAL" }; foreach (string item in sentimentScoreCounter) { //List<object> data = new List<object>(); foreach (string key in allSentimentsbyTopic.Keys) { //data.Add(allSentimentsbyTopic[key][item]); if (string.Compare(item, "NEGATIVE", true) == 0) { negativeSentimentbyTopic.Add(new DataPoint(allSentimentsbyTopic[key][item], key)); } else if (string.Compare(item, "POSITIVE", true) == 0) { positiveSentimentbyTopic.Add(new DataPoint(allSentimentsbyTopic[key][item], key)); } else if (string.Compare(item, "NEUTRAL", true) == 0) { neutralSentimentbyTopic.Add(new DataPoint(allSentimentsbyTopic[key][item], key)); } } } ViewBag.NegativeSentimentbyTopic = JsonConvert.SerializeObject(negativeSentimentbyTopic, _jsonSetting); ViewBag.PositiveSentimentbyTopic = JsonConvert.SerializeObject(positiveSentimentbyTopic, _jsonSetting); ViewBag.NeutralSentimentbyTopic = JsonConvert.SerializeObject(neutralSentimentbyTopic, _jsonSetting); return(PartialView()); } catch (Exception ex) { //error = ex.StackTrace; logger.Log(ex.StackTrace, LOGLEVELS.ERROR); ViewBag.NegativeSentimentbyTopic = JsonConvert.SerializeObject(dummylist, _jsonSetting); ViewBag.PositiveSentimentbyTopic = JsonConvert.SerializeObject(dummylist, _jsonSetting); ViewBag.NeutralSentimentbyTopic = JsonConvert.SerializeObject(dummylist, _jsonSetting); return(PartialView()); } }