private object DfsMarkerData(MapSearch map)
        {
            List <IMapIndexData> dfs  = iDfsService.GetDfsData();
            List <DfsData>       vals = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(dfs);

            string cql = "";


            var hasFilters = Infrastructure.FilterChecker.FilterChecker.HasFilters(map);

            //checklistDfsData = vals;
            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 = iDfsService.GetFilteredData(dfs, map);
                vals = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(filteredList);

                List <DfsData> withoutCompaniesSet = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(dfs);

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

                sideFilters = iDfsService.GetSideFiltersDfs(maWoutCompanies, map);

                dfs          = filteredList;
                autoComplete = iDfsService.GetKeywordAutoComplete(dfs, map);
            }
            else
            {
                sideFilters  = iDfsService.GetSideFiltersDfs(dfs, map);
                autoComplete = iDfsService.GetKeywordAutoComplete(dfs, map);
            }


            List <DfsData> dfsResult = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(dfs);

            if (hasFilters && !string.IsNullOrEmpty(map.Keyword))
            {
                cql = iDfsService.GeoserverCqlFilter(dfs);
            }
            else if (hasFilters)
            {
                cql = GeoserverHelpers.GeoserverCqlFilter.CreateDFSCql(dfsResult, map);
            }


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

            //else
            //{
            //    checklistDfsData = vals2;
            //}
            #endregion
            string companiesHtml = "";


            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;
            }

            string cacheKeyTable = "DFSLISTTABLE";

            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;
            }
            companiesHtml = iMaDataGeoService.GenerateCompanyHtml(sideFilters.Companies, cacheKey, ConfigurationFactory.Instance.Configuration().CacheKeyPortfolioCompaniesPath, map);
            Infrastructure.ExportHelpers.IExportData export = iDfsExport.GetChecklistTable(dfsResult.ToList <Infrastructure.ExportHelpers.IExportData>(), map);

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

            var result = new
            {
                Result             = iLeafService.GetMarkerData(new List <MaData>(), dfsResult, new List <Models.EP.ViewModel.EpViewModel>(), map, "", false),
                SideFilters        = sideFilters,
                CqlFilter          = cql,
                CheckSideListData  = exportSet.ExportSet,
                TableData          = dfsResult,
                ExportTableSet     = exportSet.ExportSet,
                ExportHeaders      = exportSet.ExportHeaders,
                CompanyHtml        = companiesHtml,
                AutoCompleteSource = autoComplete,
                TableSource        = iDfsViewService.GenerateDataSetHtml(dfsResult, cacheKeyTable, "~/Views/Templates/DfsTableList.cshtml", map)
            };
            return(result);
        }
        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);
        }
        private object PortfolioMarkerData(MapSearch map)
        {
            List <IMapIndexData>      port      = iPortfolioService.GetData();
            List <Data.IMapIndexData> ep        = iEpService.GetData();
            List <EpViewModel>        epResults = CollectionHelpers.CollectionHelper <EpViewModel> .GetProperList(ep);

            List <PortfolioData> vals = CollectionHelpers.CollectionHelper <PortfolioData> .GetProperList(port);

            var hasFilters = Infrastructure.FilterChecker.FilterChecker.HasFilters(map);

            //if (hasFilters)
            //{
            //    port = iPortfolioService.GetFilteredData(port, map);
            //}

            // port list before company
            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.Entities.Count > 0 || !string.IsNullOrEmpty(map.Keyword) || map.Companies.Count > 0)
            {
                List <IMapIndexData> filteredList = iPortfolioService.GetFilteredData(port, map);
                vals = CollectionHelpers.CollectionHelper <PortfolioData> .GetProperList(filteredList);

                List <PortfolioData> withoutCompaniesSet = CollectionHelpers.CollectionHelper <PortfolioData> .GetProperList(port);

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

                if (map.Regions.Count > 0)
                {
                    epResults = epResults.Where(s => s.RegionId != null).Where(s => map.Regions.Contains(s.RegionId)).ToList();
                }
                port         = filteredList;
                autoComplete = iPortfolioService.GetKeywordAutoComplete(port, map);
            }
            else
            {
                sideFilters  = iPortfolioService.GetSideFilters(port, map);
                autoComplete = iPortfolioService.GetKeywordAutoComplete(port, map);
            }

            List <PortfolioData> portResult = CollectionHelpers.CollectionHelper <PortfolioData> .GetProperList(port);

            //portResult = portResult.OrderBy(s => s.CompanyName).ToList();

            string companiesHtml = "";

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

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

            //    }

            //    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);

            //}
            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 (!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);
            Infrastructure.ExportHelpers.IExportData export = iPortExport.GetChecklistTable(portResult.ToList <Infrastructure.ExportHelpers.IExportData>(), map);

            Models.ExportData.ExportDataSet exportSet = ((Models.ExportData.ExportDataSet)export);
            string cacheKeyTable = "PORTLISTTABLE";

            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;
            }
            string        cql   = GeoserverHelpers.GeoserverCqlFilter.CreatePortfolioCql(portResult, map);
            PortfolioData p     = new PortfolioData();
            string        popup = "";

            if (map.Companies.Count > 0)
            {
                try
                {
                    p     = portResult.Where(s => map.Companies.Last() == s.CompanyId).FirstOrDefault();
                    popup = GeoserverHelpers.GeoserverPopupHelper.GeneratePopupPortfolio(p);
                }
                catch (Exception ex)
                {
                }
            }

            if (p == null)
            {
                p           = new PortfolioData();
                p.Latitude  = "";
                p.Longitude = "";
            }
            if (popup == null)
            {
                popup = "";
            }

            var result = new
            {
                Result      = iLeafService.GetMarkerData(new List <MaData>(), new List <DfsData>(), epResults.Take(500).ToList(), map, System.DateTime.Now.Date.ToString(), false),
                SideFilters = sideFilters,
                //PortData = "",
                CheckSideListData = exportSet.ExportSet,
                TableData         = portResult,
                CqlFilter         = cql,
                ExportTableSet    = exportSet.ExportSet,
                ExportHeaders     = exportSet.ExportHeaders,
                Popup             = popup,
                Lat                = p.Latitude,
                Long               = p.Longitude,
                CompanyHtml        = companiesHtml,
                AutoCompleteSource = autoComplete,
                TableSource        = iPortViewService.GenerateDataSetHtml(portResult, cacheKeyTable, "~/Views/Templates/PortfolioTableList.cshtml", map)
                                     //DfsTableData = ""
            };

            return(result);
        }