Esempio n. 1
0
        public ChartDataReponse GetTopPostByProductChartData(List <int> smartChartIds)
        {
            var response = new ChartDataReponse();

            try
            {
                var context       = new SmartSocialContext();
                var containerList = new List <dynamic>();
                foreach (var id in smartChartIds)
                {
                    //var topSocialPost = new spGetChartData_TopSocialPostByProduct_Result();
                    var topSocialPost = new List <dynamic>();
                    var products      = context.spGet_SmartReportProduct(id).ToList();
                    foreach (var product in products)
                    {
                        topSocialPost.AddRange(context.spGetChartData_TopSocialPostByProduct(id, product).ToList());
                    }
                    containerList.AddRange(topSocialPost.OrderByDescending(x => x.dMessage).ToList());
                }
                response.ChartData      = (dynamic)containerList;
                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting Most Profilic Users Data exception:" + ex.Message;
            }
            return(response);
        }
Esempio n. 2
0
        public ChartDataReponse GetMostProlificUsersChartData(List <int> smartChartIds)
        {
            var response = new ChartDataReponse();

            try
            {
                var context       = new SmartSocialContext();
                var containerList = new List <dynamic>();
                //var unSortedData=new List<spGetChartData_AudienceStream_Result1()>;
                var unSortedData = context.spGetChartData_AudienceStream(smartChartIds.FirstOrDefault()).ToList();
                foreach (var id in smartChartIds)
                {
                    if (id != smartChartIds.FirstOrDefault())
                    {
                        unSortedData.AddRange(context.spGetChartData_AudienceStream(id).ToList());
                    }
                    //containerList.AddRange(unSortedData.OrderByDescending(x => int.Parse(x.Followers)).ToList());
                }
                containerList.AddRange(unSortedData.OrderByDescending(x => int.Parse(x.Followers)).ToList());
                response.ChartData      = (dynamic)containerList;
                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting Most Profilic Users Data exception:" + ex.Message;
            }
            return(response);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public ChartDataReponse GetLinearChartData(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_TermXTimeXCount(id).ToList());
                }

                var chartData = (dynamic)containerList;
                foreach (var chartDataSeries in chartData)
                {
                    if (!response.Series.groupNames.Contains(chartDataSeries.theTime))
                    {
                        response.Series.groupNames.Add(chartDataSeries.theTime);
                    }
                }

                var series = containerList.Select(x => x.Term).Distinct();
                foreach (var serie in series)
                {
                    var newSerie = new Serie();
                    newSerie.name = serie;
                    newSerie.data = new ArrayList(response.Series.groupNames.Count());
                    for (int i = 0; i < newSerie.data.Capacity; i++)
                    {
                        newSerie.data.Insert(i, null);
                    }
                    response.Series.series.Add(newSerie);
                }
                int index = 0;
                foreach (var value in response.Series.groupNames)
                {
                    var items = containerList.Where(x => x.theTime == value).ToList();
                    foreach (var item in items)
                    {
                        var addToSerie = response.Series.series.FirstOrDefault(x => x.name == item.Term);
                        if (addToSerie.data[index] == null)
                        {
                            addToSerie.data[index] = Convert.ToInt32(item.theCount);
                        }
                        else
                        {
                            addToSerie.data[index] = Convert.ToInt32(addToSerie.data[index]) + Convert.ToInt32(item.theCount);
                        }
                    }
                    index++;
                }


                response.Acknowledgment = true;
                response.Message        = "Success";
                context.Dispose();
            }
            catch (Exception ex)
            {
                response.Acknowledgment = false;
                response.Message        = "Error Getting Columns Data";
            }
            return(response);
        }