private object MaMarkerData(MapSearch map)
        {
            List <IMapIndexData> ma = iService.GetMaData();

            List <MaData> vals = CollectionHelpers.CollectionHelper <MaData> .GetProperList(ma);

            var hasFilters = Infrastructure.FilterChecker.FilterChecker.HasFilters(map);
            List <IMapIndexData> maWoutCompanies = new List <IMapIndexData>();

            SideFilterOptions sideFilters  = new SideFilterOptions();
            List <string>     autoComplete = new List <string>();

            if (map.Plays.Count > 0 || map.Regions.Count > 0 || map.Companies.Count > 0 || map.Entities.Count > 0 || !string.IsNullOrEmpty(map.TimeRange) || !string.IsNullOrEmpty(map.Keyword))
            {
                List <IMapIndexData> filteredList = iService.GetFilteredData(ma, map);
                vals = CollectionHelpers.CollectionHelper <MaData> .GetProperList(filteredList);

                List <MaData> withoutCompaniesSet = CollectionHelpers.CollectionHelper <MaData> .GetProperList(ma);

                if (!string.IsNullOrEmpty(map.Keyword) || map.Companies.Count > 0)
                {
                    maWoutCompanies = iService.GetDataBeforeCompanies(withoutCompaniesSet, map);
                }
                else
                {
                    maWoutCompanies = iService.GetDataBeforeCompanies(vals, map);
                }

                sideFilters = iService.GetSideFiltersMa(maWoutCompanies, map);
                //ma = iService.GetFilteredData(maWoutCompanies, map);
                ma           = filteredList;
                autoComplete = iService.GetKeywordAutoComplete(ma, map);
            }
            else
            {
                sideFilters  = iService.GetSideFiltersMa(ma, map);
                autoComplete = iService.GetKeywordAutoComplete(ma, map);
            }


            List <MaData> maResult = CollectionHelpers.CollectionHelper <MaData> .GetProperList(ma);

            ChartingData.IChartOutput charts = iMaChart.GetChartOutput(maResult, map);

            Models.Charting.ChartOptions chartOptions = ((Models.Charting.ChartOptions)charts);

            string companiesHtml = "";

            if ((map.ReloadCompanies || map.InitialLoad))
            {
                string cacheKey = ConfigurationFactory.Instance.Configuration().CacheKeyCompanyHtml + "_" + map.WhichDb;

                if (map.Plays.Count > 0)
                {
                    cacheKey += "_" + "PLAYS" + string.Join(",", map.Plays);
                }
                if (map.Regions.Count > 0)
                {
                    cacheKey += "_" + "REGIONS" + string.Join(",", map.Regions);
                }

                if (map.Entities.Count > 0)
                {
                    cacheKey += "_" + "DEALTYPES" + string.Join(",", map.Entities);
                }
                if (!string.IsNullOrEmpty(map.TimeRange))
                {
                    cacheKey += "_" + "TIMERANGE" + map.TimeRange;
                }
                if (!string.IsNullOrEmpty(map.Keyword))
                {
                    cacheKey += "_" + "KEYWORD" + map.Keyword;
                }
                companiesHtml = iMaDataGeoService.GenerateCompanyHtml(sideFilters.Companies, cacheKey, ConfigurationFactory.Instance.Configuration().CacheKeyPortfolioCompaniesPath, map);
            }

            #region MyRegion
            //if (map.MaDealIds.Count > 0)
            //{
            //    checkListMaData = checkListMaData.Where(s => map.MaDealIds.Contains(s.id)).ToList();
            //}

            //else
            //{
            //    checkListMaData = vals2;
            //}
            #endregion

            if (map.Companies.Count > 0)
            {
            }
            Infrastructure.ExportHelpers.IExportData export = iExport.GetChecklistTable(maResult.ToList <Infrastructure.ExportHelpers.IExportData>(), map);

            Models.ExportData.ExportDataSet exportSet = ((Models.ExportData.ExportDataSet)export);


            #region MyRegion
            //List<MaExport> exportSetzz = new List<MaExport>();

            //foreach (var item in checkListMaData)
            //{
            //    macheckList.MaTable.Add(new MaCheckListTable(new List<string> { "Legend", "Announced", "Buyers", "Sellers", "Link", "GeoId" }, new List<string> { item.HexColor, item.Date_Announced.Value.ToString("MM-dd-yy"), item.Buyers, item.Sellers, item.id, item.theId }, new List<string> { "checkbox", "date", "text", "text", "link", "primarykey" }));
            //    exportSet.Add(new MaExport(item.id, item.Buyers, item.Sellers, item.Date_Announced, item.Value___MM_, item.__Acre, item.__Daily_BOE, item.Hydrocarbon, item.Headline, item.US_Region, item.US_Play, item.Lat, item.Long, item.DealType));
            //}

            //List<string> exportHeaders = new List<string>();
            //exportHeaders.Add("Record ID");
            //exportHeaders.Add("Buyers");
            //exportHeaders.Add("Sellers");
            //exportHeaders.Add("Date Announced");
            //exportHeaders.Add("Value ($MM)");
            //exportHeaders.Add("$/Acre");
            //exportHeaders.Add("$/Daily_BOE");
            //exportHeaders.Add("Hydrocarbon");
            //exportHeaders.Add("Headline");
            //exportHeaders.Add("US Region");
            //exportHeaders.Add("US Play");
            //exportHeaders.Add("Lat");
            //exportHeaders.Add("Long");
            //exportHeaders.Add("Deal Type");
            #endregion


            string cql = "";

            if (hasFilters && !string.IsNullOrEmpty(map.Keyword))
            {
                cql = iService.GeoserverCqlFilter(ma);
            }
            else if (hasFilters)
            {
                cql = GeoserverHelpers.GeoserverCqlFilter.CreateMACql(maResult, map);
            }

            string cacheKeyTable = "MALISTTABLE";

            if (map.Plays.Count > 0)
            {
                cacheKeyTable += "_" + "PLAYS" + string.Join(",", map.Plays);
            }
            if (map.Regions.Count > 0)
            {
                cacheKeyTable += "_" + "REGIONS" + string.Join(",", map.Regions);
            }
            if (map.Companies.Count > 0)
            {
                cacheKeyTable += "_" + "COMPANIES" + string.Join(",", map.Companies);
            }
            if (map.Entities.Count > 0)
            {
                cacheKeyTable += "_" + "DEALTYPES" + string.Join(",", map.Entities);
            }
            if (!string.IsNullOrEmpty(map.TimeRange))
            {
                cacheKeyTable += "_" + "TIMERANGE" + map.TimeRange;
            }
            if (!string.IsNullOrEmpty(map.Keyword))
            {
                cacheKeyTable += "_" + "KEYWORD" + map.Keyword;
            }

            var result = new
            {
                Result      = iLeafService.GetMarkerData(maResult, new List <DfsData>(), new List <Models.EP.ViewModel.EpViewModel>(), map, "", false),
                SideFilters = sideFilters,
                //PortData = "",
                CheckSideListData  = exportSet.ExportSet,
                TableData          = maResult,
                CqlFilter          = cql,
                ExportTableSet     = exportSet.ExportSet,
                ExportHeaders      = exportSet.ExportHeaders,
                ChartSeries        = "",
                ChartX             = chartOptions.ChartXCategories,
                ChartDataSeries    = chartOptions.ChartSeries,
                CompanyHtml        = companiesHtml,
                AutoCompleteSource = autoComplete,
                TableSource        = iMaViewService.GenerateDataSetHtml(maResult, cacheKeyTable, "~/Views/Templates/MaTableList.cshtml", map)
                                     //DfsTableData = ""
            };

            return(result);
        }
示例#2
0
        IChartOutput IChartingData <MaData> .GetChartData(List <MaData> data, MapSearch map)
        {
            Models.Charting.ChartOptions chart = new Models.Charting.ChartOptions();

            try
            {
                chart.ChartXCategories = new List <Models.Charting.ChartXAxis>();

                //Dictionary<string, string> q = new Dictionary<string, string>();

                ////var groups = data.OrderByDescending(s => s.Date_Announced.Value).GroupBy(item => ((item.Date_Announced.Value.Month - 1) / 3));

                //var groupedByQuarter = from date in data
                //                       group date by (date.Date_Announced.Value.Month - 1) / 3
                //                        into groupedDates
                //                       orderby groupedDates.Key
                //                       select groupedDates;

                //foreach (var quarter in groupedByQuarter)
                //{
                //    q.Add("Q" + quarter.Key, string.Join(",", quarter.Select(s => s.Date_Announced.Value.Year).Distinct()));
                //    // {0} --> Quarter
                //    // quarter --> Date
                //    //Console.WriteLine("Q: {0}, Dates: {1}", quarter.Key + 1, string.Join(", ", quarter));
                //}
                data = data.Where(s => s.Date_Announced >= Convert.ToDateTime("01/01/2016")).ToList();
                // base list of years and quarters
                var query = (from t in data
                             group t by new { t.Date_Announced.Value.Year, Quarter = ((t.Date_Announced.Value.Month - 1) / 3) + 1 }
                             into grp
                             select new
                {
                    grp.Key.Year,
                    grp.Key.Quarter
                    ///Quantity = grp.Sum(t => Convert.ToDouble(t.Value___MM_))
                }).ToList();

                // if data is found in the quarter/year combo

                foreach (var item in query)
                {
                    chart.ChartXCategories.Add(new Models.Charting.ChartXAxis()
                    {
                        Category = item.Quarter.ToString() + item.Year.ToString(),
                        Year     = item.Year.ToString(),
                        Quarter  = item.Quarter.ToString()
                    });
                }


                // MUST HAVE EQUIVALENT CHART SERIES VALUES FOR EACH NAME FOR THE CHART TO WORK
                int countOfXCategories = 0;
                chart.ChartSeries = new List <Models.Charting.Chart>();
                var distinctPlays = data.Select(s => s.US_Play).OrderBy(s => s).Distinct();

                int i = 1;
                foreach (var item in distinctPlays)
                {
                    int           id     = i;
                    string        play   = item;
                    List <double> values = new List <double>();
                    foreach (var a in chart.ChartXCategories)
                    {
                        double number = data.Where(t => ((t.Date_Announced.Value.Month - 1) / 3 + 1) == Convert.ToInt32(a.Quarter) &&
                                                   t.Date_Announced.Value.Year == Convert.ToInt32(a.Year) && t.US_Play == item && t.Value___MM_ != null)
                                        .Sum(s => Convert.ToDouble(s.Value___MM_));
                        values.Add(number);
                    }
                    chart.ChartSeries.Add(new Models.Charting.Chart()
                    {
                        Id = i, Name = item, Values = values
                    }
                                          );
                    i++;
                }
            }
            catch (Exception ex)
            {
            }


            return(chart as IChartOutput);
        }