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());
            }
        }
Ejemplo n.º 2
0
        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 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()) }));
        }
Ejemplo n.º 4
0
        public ActionResult FinalGraph()
        {
            try
            {
                IList <BOTweetMentions> listLatestTenTweetMentions = BOTweetMentions.TweetMentionsLatest(User.Identity.GetUserId());

                //List<string> timecollection = new List<string>();
                //List<object> tweetCountCollection = new List<object>();
                //List<object> tweetAvgSentimentCollection = new List<object>();

                List <DataPoint> tweetCountSeries   = new List <DataPoint>();
                List <DataPoint> avgSentimentSeries = new List <DataPoint>();

                foreach (BOTweetMentions tweetMention in listLatestTenTweetMentions)
                {
                    //timecollection.Add(tweetMention.Time.ToString("mm.ss", CultureInfo.InvariantCulture));
                    //tweetCountCollection.Add(tweetMention.Count.Value);
                    //tweetAvgSentimentCollection.Add(tweetMention.Avg.Value);
                    double floattime = float.Parse(tweetMention.Time.ToString("mm.ss", CultureInfo.InvariantCulture));
                    floattime = Math.Round(floattime, 2);
                    floattime = Math.Ceiling(floattime * 20) / 20;

                    //double xvalue = Math.Round((float.Parse(tweetMention.Time.ToString("mm.ss", CultureInfo.InvariantCulture))/5.0)*5,2);
                    double xvalue              = floattime;
                    double yvalue_tweetCount   = tweetMention.Count.Value;
                    double yvalue_avgSentiment = tweetMention.Avg.Value;

                    tweetCountSeries.Add(new DataPoint(xvalue, yvalue_tweetCount));
                    avgSentimentSeries.Add(new DataPoint(xvalue, yvalue_avgSentiment));
                }

                //var xDataMonths = timecollection.ToArray();
                //var yDataCounts = tweetCountCollection.ToArray();
                //var yDataAvgSentimentCounts = tweetAvgSentimentCollection.ToArray();
                // Highcharts mychart = lineChartSentiment("FinalDashBoard", xDataMonths, yDataCounts, yDataAvgSentimentCounts);
                ViewBag.TweetCountSeries   = JsonConvert.SerializeObject(tweetCountSeries, _jsonSetting);
                ViewBag.AvgSentimentSeries = JsonConvert.SerializeObject(avgSentimentSeries, _jsonSetting);

                return(PartialView());
            }
            catch (Exception ex)
            {
                logger.Log(ex.StackTrace, LOGLEVELS.ERROR);
                ViewBag.TweetCountSeries   = JsonConvert.SerializeObject(dummylist, _jsonSetting);
                ViewBag.AvgSentimentSeries = JsonConvert.SerializeObject(dummylist, _jsonSetting);

                return(PartialView());
            }
        }
        public ActionResult FinalGraph()
        {
            try
            {
                IList <BOTweetMentions> listLatestTenTweetMentions = BOTweetMentions.TweetMentionsLatest(User.Identity.GetUserId());



                List <DataPoint> tweetCountSeries   = new List <DataPoint>();
                List <DataPoint> avgSentimentSeries = new List <DataPoint>();

                foreach (BOTweetMentions tweetMention in listLatestTenTweetMentions)
                {
                    double floattime = float.Parse(tweetMention.Time.ToString("mm.ss", CultureInfo.InvariantCulture));
                    floattime = Math.Round(floattime, 2);
                    floattime = Math.Ceiling(floattime * 20) / 20;

                    double xvalue              = floattime;
                    double yvalue_tweetCount   = tweetMention.Count.Value;
                    double yvalue_avgSentiment = tweetMention.Avg.Value;

                    tweetCountSeries.Add(new DataPoint(xvalue, yvalue_tweetCount));
                    avgSentimentSeries.Add(new DataPoint(xvalue, yvalue_avgSentiment));
                }


                ViewBag.TweetCountSeries   = JsonConvert.SerializeObject(tweetCountSeries, _jsonSetting);
                ViewBag.AvgSentimentSeries = JsonConvert.SerializeObject(avgSentimentSeries, _jsonSetting);

                return(PartialView());
            }
            catch (Exception ex)
            {
                logger.Log(ex.StackTrace, LOGLEVELS.ERROR);
                ViewBag.TweetCountSeries   = JsonConvert.SerializeObject(dummylist, _jsonSetting);
                ViewBag.AvgSentimentSeries = JsonConvert.SerializeObject(dummylist, _jsonSetting);

                return(PartialView());
            }
        }