Exemplo n.º 1
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());
            }
        }