Exemple #1
0
        public ChartDataReponse GetTopUserSummaryChartData(List <int> smartChartIds)
        {
            var response = new ChartDataReponse();

            try
            {
                var context = new SmartSocialContext();
                if (smartChartIds.Count == 1)
                {
                    int pastDeliveryChart = GetPastDeliveryChart(smartChartIds[0]);
                    if (pastDeliveryChart != 0)
                    {
                        response.PastDelivery = context.spGetChartData_TermXCount(pastDeliveryChart).FirstOrDefault();
                    }
                }
                var listOfTermCount = new List <TermCountObject>();
                foreach (var id in smartChartIds)
                {
                    var result = context.spGetChartData_TermXCount(id).FirstOrDefault();
                    listOfTermCount.Add(new TermCountObject()
                    {
                        Term     = result.Term,
                        theCount = Convert.ToInt32(result.theCount)
                    });
                }
                response.ChartData = (dynamic)listOfTermCount.OrderByDescending(x => x.theCount).First();


                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting TopUser Summary exception:" + ex.Message;
            }
            return(response);
        }
Exemple #2
0
        public ChartDataReponse GetWordCloudChartData(List <int> smartChartIds)
        {
            var response = new ChartDataReponse();

            try
            {
                var context       = new SmartSocialContext();
                var containerList = new List <dynamic>();
                foreach (var id in smartChartIds)
                {
                    containerList.AddRange(context.spGetChartData_TermXCount(id).ToList());
                }
                var listOfTermCount = new List <TermCountObject>();
                var series          = containerList.Select(x => x.Term).Distinct();
                foreach (var serie in series)
                {
                    listOfTermCount.Add(new TermCountObject()
                    {
                        Term     = serie,
                        theCount = 0
                    });
                }

                foreach (var item in containerList)
                {
                    listOfTermCount.FirstOrDefault(x => x.Term == item.Term).theCount = listOfTermCount.FirstOrDefault(x => x.Term == item.Term).theCount + int.Parse(item.theCount);
                }

                response.ChartData      = (dynamic)listOfTermCount.OrderByDescending(x => x.theCount);
                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting WordCloud Data exception:" + ex.Message;
            }
            return(response);
        }