Пример #1
0
        public ChartDataReponse GetStackedColumnChartData(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_TermXGroupedTermXCount(id).ToList());
                }
                var chartData = (dynamic)containerList;

                foreach (var chartDataSeries in chartData)
                {
                    if (!response.Series.groupNames.Contains(chartDataSeries.theGroup))
                    {
                        response.Series.groupNames.Add(chartDataSeries.theGroup);
                    }
                    var serie = response.Series.series.FirstOrDefault(x => x.name == chartDataSeries.Term);
                    if (serie != null)
                    {
                        serie.data.Add(Convert.ToInt32(chartDataSeries.theCount));
                    }
                    else
                    {
                        var newSerie = new Serie();
                        newSerie.name = chartDataSeries.Term;
                        newSerie.data.Add(Convert.ToInt32(chartDataSeries.theCount));
                        response.Series.series.Add(newSerie);
                    }
                }

                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting Stacked Columns Data";
            }
            return(response);
        }
Пример #2
0
        public ChartDataReponse GetLocationAnalysisChartData(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_TermXGroupedTermXCount(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;
                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting Location Analysis Data exception:" + ex.Message;
            }
            return(response);
        }