private void MapSearch_TextChanged(object sender, EventArgs e) { if (MapSearch.Equals("")) { listBox1.Items.Clear(); listBox1.SelectedIndex = -1; foreach (var item in mapsList) { listBox1.Items.Add(item); } listBox1.Items.Add(MapBuilder.parentMap); } else if (!MapSearch.Equals("")) { listBox1.Items.Clear(); listBox1.SelectedIndex = -1; foreach (var item in mapsList) { if (item.mapName.Contains(MapSearch.Text) || item.identifier.ToString().Equals(MapSearch.Text)) { listBox1.Items.Add(item); } } listBox1.Items.Add(MapBuilder.parentMap); } }
public async Task <IEnumerable <AutoCompleteResult> > Search(MapSearch request) { if (string.IsNullOrWhiteSpace(request.Query)) { return(new List <AutoCompleteResult>()); } _logger.LogInformation("Query maps"); var baseUrl = _configuration.GetMapsUrl(); var key = _configuration.GetMapsKey(); var url = $"{baseUrl}?key={key}&input={request.Query}&fields=geometry/location"; using (var client = new HttpClient()) { var httpRequest = new HttpRequestMessage { RequestUri = new Uri(url), Method = HttpMethod.Get }; var response = await client.SendAsync(httpRequest); _logger.LogInformation($"processing response statusCode:{response.StatusCode} url:{url}"); var data = await response.Content.ReadAsStringAsync(); var structure = new { Predictions = new List <GoogleAutoCompleteResult>() }; var googleData = JsonConvert.DeserializeAnonymousType(data, structure); return(_mapper.Map <List <AutoCompleteResult> >(googleData.Predictions)); } }
public IHttpActionResult GenerateMarkers(MapSearch map) { //map.TheSessionId = HttpContext.Current.Session.SessionID; Models.Authentication.ViewModels.AuthViewModel auth = Infrastructure.Session.AuthSession.GetAuthModel(map); map.TheSessionId = map.UserName + "_" + map.QbTicket + "_" + map.QbToken; if (iAuth.IsUserValid(auth)) { object result = null; if (map.WhichDb == "DFSTAB") { result = DfsMarkerData(map); } else if (map.WhichDb == "MATAB") { result = MaMarkerData(map); } else if (map.WhichDb == "PORTFOLIOTAB") { result = PortfolioMarkerData(map); } return(Ok(result)); } else { return(Ok("Ok")); } }
public HttpResponseMessage FetchShapeFiles(MapSearch map) { Models.Authentication.ViewModels.AuthViewModel auth = Infrastructure.Session.AuthSession.GetAuthModel(map); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); //response.Headers.Add("Set-Cookie", "fileDownload=false; path=/"); try { if (iAuth.IsUserValid(auth)) { if (map.WhichDb == "MATAB") { response = MaSourceDocs(map); } else if (map.WhichDb == "DFSTAB") { response = DfsSourceDocs(map); } else if (map.WhichDb == "PORTFOLIOTAB") { response = PortfolioSourceDocs(map); } } } catch (Exception ex) { LogFactory.Instance.Log().GenerateEmail("Error Zipping Source Docs", ex.Message); } return(response); }
public List <DealTypes> GetDealTypes(List <IMapIndexData> dfs, MapSearch map) { List <DealTypes> dealTypes = new List <DealTypes>(); string query = @"SELECT dealtypeid, DealType FROM [MapIndex].[dbo].[DealType] WHERE IsDfs = 1 ORDER BY DealType ASC"; System.Data.DataTable dt = GetDataTable(query); List <DfsData> vals = GetProperList(dfs); foreach (System.Data.DataRow dr in dt.Rows) { DealTypes dealType = new DealTypes(); try { dealType.DealCount = vals.Where(s => s.DealTypeId == dr["dealtypeid"].ToString()).Count(); } catch (Exception e) { } dealType.DealType = dr["DealType"].ToString(); dealType.Id = dr["dealtypeid"].ToString(); //if (dealType.DealCount > 0) //{ dealTypes.Add(dealType); //} } return(dealTypes); }
private HttpResponseMessage PortfolioSourceDocs(MapSearch map) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); string cql = GeoserverHelpers.GeoserverCqlFilter.CreateCqlFilter(map); //Data.Geoserver.Portfolio.PortfolioGeoserverRepository.DownloadShapeFiles(map); string baseUrl = ConfigurationFactory.Instance.Configuration().GeoServerBaseUrl + "MA-DS/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=MA-DS:portfolioGeometryByPlayView&maxFeatures=50&outputFormat=SHAPE-ZIP&CQL_FILTER=" + cql; byte[] theFile; using (var client = new WebClient()) { theFile = client.DownloadData(baseUrl); } response.Content = new StreamContent(new MemoryStream(theFile)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return(response); }
private HttpResponseMessage DfsSourceDocs(MapSearch map) { List <Data.IMapIndexData> dfs = iDfsService.GetDfsData(); var hasFilters = Infrastructure.FilterChecker.FilterChecker.HasFilters(map); if (hasFilters) { dfs = iDfsService.GetFilteredData(dfs, map); } List <DfsData> vals2 = new List <DfsData>(dfs.Count); foreach (IMapIndexData d in dfs) { vals2.Add((DfsData)d); } ZipFile zip = new ZipFile(); iDfsGeoService.GetSourceDocs(dfs, map, zip); MemoryStream ms = new MemoryStream(); zip.Name = "MaSelectDealDocs.zip"; zip.Save(ms); return(ZipContentResult(zip)); }
protected List <IMapIndexData> DataBeforeCompanies(List <T> data, MapSearch map) { List <IMapIndexData> results = new List <IMapIndexData>(); return(results); }
public virtual void OnCancel(BaseEventData eventData) { MapSearch dropdown = GetComponentInParent <MapSearch>(); if (dropdown) { dropdown.HideDropdown(); } }
public IChartOutput GetChartData(List <MaData> data, MapSearch map) { try { return(_commonRepository.GetChartData(data, map)); } catch (Exception ex) { return(null); } }
public SideFilterOptions GetBaseSideFilters(List <IMapIndexData> dfs, MapSearch map) { SideFilterOptions sideFilter = new SideFilterOptions(); List <DfsData> vals = GetProperList(dfs); DataTable companyDt = CompanyDataSet(); DataTable regionDt = RegionDataSet(); DataTable playDt = PlayDataSet(); sideFilter.Plays = GetBasePlays(vals, map, playDt); sideFilter.Companies = GetBaseCompanies(vals, map, companyDt); sideFilter.Regions = GetBaseRegions(vals, map, regionDt); sideFilter.DealTypes = GetDealTypes(dfs, map); return(sideFilter); }
public List <DealTypes> GetDealTypes(List <IMapIndexData> dfs, MapSearch r) { StringBuilder cacheKey = new StringBuilder(); cacheKey.Append("CACHE_KEY_DFS_DEALTYPES"); if (r.Companies != null && r.Companies.Count > 0) { cacheKey.Append("_").Append("COMPANIES").Append("_").Append(string.Join(",", r.Companies)); } if (r.Regions != null && r.Regions.Count > 0) { cacheKey.Append("_").Append("REGIONS").Append("_").Append(string.Join(",", r.Regions)); } if (r.Plays != null && r.Plays.Count > 0) { cacheKey.Append("_").Append("PLAYS").Append("_").Append(string.Join(",", r.Plays)); } if (r.Entities != null && r.Entities.Count > 0) { cacheKey.Append("_").Append("DEALTYPES").Append("_").Append(string.Join(",", r.Entities)); } if (!string.IsNullOrEmpty(r.TimeRange)) { cacheKey.Append("_").Append("TIMERANGE").Append("_").Append(r.TimeRange); } if (!string.IsNullOrEmpty(r.Keyword)) { cacheKey.Append("_").Append("KEYWORD").Append("_").Append(r.Keyword); } cacheKey.Append("_").Append("SESSIONID").Append(r.TheSessionId); var items = _cacheProvider.Retrieve <List <DealTypes> >(cacheKey.ToString()); if (items == null || !items.Any()) { items = _commonRepository.GetDealTypes(dfs, r); if (items.Any()) { _cacheProvider.Store(cacheKey.ToString(), items, int.MaxValue); } } return(items); }
internal virtual List <string> GetPlayFilters(List <string> theQueryString, MapSearch map) { try { if (map.Plays != null) { if (map.Plays.Count > 0) { theQueryString.AddRange(BuildEqualQuery("PlayId", map.Plays.OfType <string>().ToList())); } } } catch (Exception ex) { } return(theQueryString); }
protected List <Region> GetBaseRegions(List <T> data, MapSearch map, DataTable dt) { List <Region> regions = new List <Region>(); StringBuilder whereClause = new StringBuilder(); foreach (System.Data.DataRow dr in dt.Rows) { Region region = new Region(); region.RegionName = dr["RegionName"].ToString(); if (map.WhichDb == "PORTFOLIOTAB") { whereClause.Append("US_Region.Contains(" + "\"" + dr["RegionName"].ToString() + "\"" + ")"); } else if (map.WhichDb == "MATAB") { whereClause.Append("RegionId != null AND RegionId " + " = " + "\"" + dr["regionid"].ToString() + "\""); } else if (map.WhichDb == "DFSTAB") { whereClause.Append("RegionId != null AND RegionId " + " = " + "\"" + dr["regionid"].ToString() + "\""); } try { //play.LayerGroupName = MaPlayLayerGroups()[dr["PlayName"].ToString()]; region.DealCount = data.Where(whereClause.ToString()).Count(); } catch (Exception ex) { LogFactory.Instance.Log().WriteMessage("Error Getting Map Queries: " + ex.Message); } region.IsSelected = false; region.Id = dr["regionid"].ToString(); regions.Add(region); whereClause.Clear(); } return(regions); }
public SideFilterOptions GetBaseSideFilters(List <IMapIndexData> data, MapSearch r) { //string cacheKey = "CACHE_KEY_SIDE_FILTERS_DFS_DEAL_COUNT_" + dfs.Count; StringBuilder cacheKey = new StringBuilder(); //cacheKey.Append("CACHE_KEY_SIDE_FILTERS_DFS_DEAL_COUNT_").Append(dfs.Count); List <DfsData> dfs = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(data); DataTable companyDt = CompanyDataSet(); DataTable regionDt = RegionDataSet(); DataTable playDt = PlayDataSet(); List <Company> company = GetBaseCompanies(dfs, r, companyDt); List <Play> play = GetBasePlays(dfs, r, playDt); List <Region> region = GetBaseRegions(dfs, r, regionDt); List <DealTypes> dealTypes = GetDealTypes(data, r); SideFilterOptions filters = new SideFilterOptions(); filters.Companies = company; filters.Plays = play; filters.Regions = region; filters.DealTypes = dealTypes; return(filters); }
internal override List <IMapIndexData> QueryData(List <DfsData> data, MapSearch map, string query) { List <IMapIndexData> retVal = new List <IMapIndexData>(); data = data.Where(s => s.SellerId != null && s.AgentId != null).Where(query).ToList(); data = data.Select(s => s).Distinct().ToList(); retVal = data.ToList <IMapIndexData>(); if (!string.IsNullOrEmpty(map.TimeRange)) { retVal = TimeRange("", retVal, map); } if (!string.IsNullOrEmpty(map.Keyword)) { retVal = KeywordSearch("", retVal, map); } if (map.Companies.Count > 0) { retVal = CompanySearch("", retVal, map); } return(retVal); }
internal virtual List <IMapIndexData> RegionSearch(string theQueryString, List <IMapIndexData> data, MapSearch map) { return(data); }
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); }
protected List <string> GetKeywordAutoComplete(List <IMapIndexData> data, MapSearch map) { List <string> list = new List <string>(); if (map.WhichDb == "MATAB") { List <MaData> results = CollectionHelpers.CollectionHelper <MaData> .GetProperList(data); foreach (var item in results.Select(s => s.Buyers.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } foreach (var item in results.Select(s => s.Sellers.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } var sellers = results.Select(s => s.Sellers.Trim().Split(';')).ToList().Distinct(); list.AddRange(results.Select(s => s.Hydrocarbon).Distinct()); list.AddRange(results.Select(s => s.OpNonOp).Distinct()); list.AddRange(results.Select(s => s.Resource_Type).Distinct()); list.AddRange(results.Select(s => s.US_Play).Distinct()); list.AddRange(results.Select(s => s.US_Region).Distinct()); foreach (var item in results.Select(s => s.Counties.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } foreach (var item in results.Select(s => s.States.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } } else if (map.WhichDb == "PORTFOLIOTAB") { List <PortfolioData> results = CollectionHelpers.CollectionHelper <PortfolioData> .GetProperList(data); foreach (var item in results.Take(100).Select(s => s.Counties.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } } else if (map.WhichDb == "DFSTAB") { List <DfsData> results = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(data); foreach (var item in results.Select(s => s.Sellers.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } foreach (var item in results.Select(s => s.Agent_Broker.Trim())) { foreach (string splitItem in item.Split(';')) { if (!list.Contains(item)) { list.Add(splitItem); } } } var sellers = results.Select(s => s.Sellers.Trim().Split(';')).ToList().Distinct(); list.AddRange(results.Select(s => s.DealType).Distinct()); list.AddRange(results.Select(s => s.US_Play).Distinct()); list.AddRange(results.Select(s => s.US_Region).Distinct()); } return(list); }
private object EpMarkerData(MapSearch map) { List <Data.IMapIndexData> ep = iDfsService.GetDfsData(); List <EpViewModel> vals = CollectionHelpers.CollectionHelper <EpViewModel> .GetProperList(ep); var hasFilters = Infrastructure.FilterChecker.FilterChecker.HasFilters(map); //checklistDfsData = vals; if (hasFilters) { //ep = iEpService.GetFilteredData(ep, map); } List <EpViewModel> vals2 = CollectionHelpers.CollectionHelper <EpViewModel> .GetProperList(ep); List <IMapIndexData> maWoutCompanies = new List <IMapIndexData>(); SideFilterOptions sideFilters = new SideFilterOptions(); if (map.Plays.Count > 0 || map.Regions.Count > 0 || map.Entities.Count > 0 || !string.IsNullOrEmpty(map.TimeRange)) { //maWoutCompanies = iEpService.GetDataBeforeCompanies(vals, map); //sideFilters = iEpService.GetSideFiltersDfs(maWoutCompanies, map); } else { //sideFilters = iEpService.GetSideFiltersDfs(dfs, map); } #region MyRegion //if (map.ListingIds.Count > 0) //{ // checklistDfsData = vals2.Where(s => map.ListingIds.Contains(s.id)).ToList(); //} //else //{ // checklistDfsData = vals2; //} #endregion string companiesHtml = ""; if ((map.ReloadCompanies || map.InitialLoad)) { companiesHtml = GeoserverHelpers.GeoserverPopupHelper.GenerateCompaniesLegendPortfolio(sideFilters.Companies); } //Infrastructure.ExportHelpers.IExportData export = iDfsExport.GetChecklistTable(vals2.ToList<Infrastructure.ExportHelpers.IExportData>(), map); //Models.ExportData.ExportDataSet exportSet = ((Models.ExportData.ExportDataSet)export); string cql = ""; if (hasFilters && !string.IsNullOrEmpty(map.Keyword)) { //cql = iDfsService.GeoserverCqlFilter(dfs); } else if (hasFilters) { cql = GeoserverHelpers.GeoserverCqlFilter.CreateCqlFilter(map); } var result = new { Result = iLeafService.GetMarkerData(new List <MaData>(), new List <DfsData>(), vals2, map, "", false), SideFilters = sideFilters, CqlFilter = cql, //CheckSideListData = exportSet.ExportSet, TableData = vals2, //ExportTableSet = exportSet.ExportSet, //ExportHeaders = exportSet.ExportHeaders, CompanyHtml = companiesHtml }; return(result); }
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 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); }
protected List <IMapIndexData> GetFilteredData(List <T> data, MapSearch map) { List <string> theQueryString = new List <string>(); List <string> andQueryString = new List <string>(); List <string> companyQueryString = new List <string>(); List <string> dealTypeQueryString = new List <string>(); StringBuilder sb = new StringBuilder(); List <IMapIndexData> retVal = new List <IMapIndexData>(); theQueryString = map.WhichDb != "PORTFOLIOTAB" ? GetPlayFilters(theQueryString, map) : new List <string>(); theQueryString = map.WhichDb != "PORTFOLIOTAB" ? GetRegionFilters(theQueryString, map) : new List <string>(); andQueryString = GetDealTypeFilters(andQueryString, map); companyQueryString = GetCompanyFilters(companyQueryString, map); //andQueryString = GetRecordIdFilters(andQueryString, map); if (theQueryString.Count > 0 && sb.ToString() == "") { sb.Append("(").Append(string.Join(" OR ", theQueryString)).Append(")"); //if (companyQueryString.Count > 0) //{ // sb.Append(" AND ").Append(string.Join(" OR ", companyQueryString)); //} if (andQueryString.Count > 0) { sb.Append(" AND (").Append(string.Join(" OR ", andQueryString)).Append(")"); } if (dealTypeQueryString.Count > 0) { sb.Append(" AND ").Append(string.Join(" OR ", dealTypeQueryString)); } } else { if (companyQueryString.Count > 0 && andQueryString.Count > 0) { sb.Append(string.Join(" OR ", companyQueryString)).Append(" AND (").Append(string.Join(" OR ", andQueryString)).Append(")"); if (dealTypeQueryString.Count > 0) { sb.Append(" AND ").Append(string.Join(" OR ", dealTypeQueryString)); } } else if (companyQueryString.Count > 0 && andQueryString.Count == 0) { sb.Append(string.Join(" OR ", companyQueryString)); if (dealTypeQueryString.Count > 0) { sb.Append(" AND ").Append(string.Join(" OR ", dealTypeQueryString)); } } else if (companyQueryString.Count == 0 && andQueryString.Count > 0) { sb.Append(string.Join(" OR ", andQueryString)); } else if (true) { } } if (sb.ToString() != "") { if (map.WhichDb == "MATAB") { retVal = QueryData(data, map, sb.ToString()); } else if (map.WhichDb == "DFSTAB") { retVal = QueryData(data, map, sb.ToString()); } else if (map.WhichDb == "PORTFOLIOTAB") { retVal = QueryData(data, map, sb.ToString()); } else { List <IMapIndexData> retValTimeRange = new List <IMapIndexData>(); foreach (T d in data) { retValTimeRange.Add((IMapIndexData)d); } retVal = TimeRange(sb.ToString(), retValTimeRange, map); List <IMapIndexData> retValKeyword = new List <IMapIndexData>(); List <IMapIndexData> retValCompany = new List <IMapIndexData>(); if (!string.IsNullOrEmpty(map.TimeRange)) { retValKeyword = retVal; retValCompany = retVal; } else { foreach (T d in data) { retValKeyword.Add((IMapIndexData)d); retValCompany.Add((IMapIndexData)d); } } retVal = QueryData(data, map, sb.ToString()); if (map.WhichDb == "PORTFOLIOTAB") { List <IMapIndexData> retValPlay = retVal; List <IMapIndexData> retValRegion = retVal; retValPlay = PlaySearch(sb.ToString(), retValPlay, map); retValRegion = RegionSearch(sb.ToString(), retValRegion, map); if (map.Plays.Count > 0 && map.Regions.Count > 0) { retVal = retValPlay.Concat(retValRegion).ToList(); } else if (map.Plays.Count > 0 && map.Regions.Count == 0) { retVal = retValPlay; } else if (map.Plays.Count == 0 && map.Regions.Count > 0) { retVal = retValRegion; } } retValCompany = CompanySearch(sb.ToString(), retValCompany, map); retValKeyword = KeywordSearch(sb.ToString(), retValKeyword, map); if (!string.IsNullOrEmpty(map.Keyword)) { if (map.Companies.Count > 0) { retVal = retValKeyword.Concat(retVal).Concat(retValCompany).ToList(); } else { retVal = retValKeyword.Concat(retVal).ToList(); } } else if (map.Companies.Count > 0) { retVal = retVal.Concat(retValCompany).ToList(); } } } else if ((map.Plays.Count > 0 || map.Regions.Count > 0) && (string.IsNullOrEmpty(map.Keyword) || string.IsNullOrEmpty(map.TimeRange)) && map.WhichDb == "PORTFOLIOTAB") { List <IMapIndexData> vals = new List <IMapIndexData>(data.Count); foreach (T d in data) { vals.Add((IMapIndexData)d); } List <IMapIndexData> retValPlay = vals; List <IMapIndexData> retValRegion = vals; retValPlay = PlaySearch(sb.ToString(), retValPlay, map); retValRegion = RegionSearch(sb.ToString(), retValRegion, map); if (map.Plays.Count > 0 && map.Regions.Count > 0) { retVal = retValPlay.Concat(retValRegion).ToList(); } else if (map.Plays.Count > 0 && map.Regions.Count == 0) { retVal = retValPlay; } else if (map.Plays.Count == 0 && map.Regions.Count > 0) { retVal = retValRegion; } if (!string.IsNullOrEmpty(map.Keyword)) { retVal = KeywordSearch(sb.ToString(), retVal.Count > 0 ? retVal : vals, map); } //retVal = PlaySearch(sb.ToString(), vals, map); } else if (!string.IsNullOrEmpty(map.Keyword) || !string.IsNullOrEmpty(map.TimeRange)) { List <IMapIndexData> vals = new List <IMapIndexData>(data.Count); foreach (T d in data) { vals.Add((IMapIndexData)d); } if (map.Plays.Count > 0) { retVal = PlaySearch(sb.ToString(), vals, map); } if (!string.IsNullOrEmpty(map.TimeRange)) { retVal = TimeRange(sb.ToString(), vals, map); } if (!string.IsNullOrEmpty(map.Keyword)) { retVal = KeywordSearch(sb.ToString(), retVal.Count > 0 ? retVal : vals, map); } } else { List <IMapIndexData> vals = new List <IMapIndexData>(data.Count); foreach (T d in data) { vals.Add((IMapIndexData)d); } retVal = TimeRange(sb.ToString(), vals, map); } return(retVal); }
internal virtual List <string> GetDealTypeFilters(List <string> theQueryString, MapSearch map) { try { if (map.Entities != null) { if (map.Entities.Count > 0) { theQueryString.AddRange(BuildEqualQuery("DealTypeId", map.Entities)); } } } catch (Exception ex) { } return(theQueryString); }
internal virtual List <string> GetRecordIdFilters(List <string> theQueryString, MapSearch map) { return(theQueryString); }
public List <Company> GetBaseCompanies(List <DfsData> dfs, MapSearch r, DataTable dt) { StringBuilder cacheKey = new StringBuilder(); cacheKey.Append("CACHE_KEY_DFS_COMPANIES"); if (r.Companies.Count == 0) { if (r.Regions != null && r.Regions.Count > 0) { cacheKey.Append("_").Append("REGIONS").Append("_").Append(string.Join(",", r.Regions)); } if (r.Plays != null && r.Plays.Count > 0) { cacheKey.Append("_").Append("PLAYS").Append("_").Append(string.Join(",", r.Plays)); } if (r.Entities != null && r.Entities.Count > 0) { cacheKey.Append("_").Append("DEALTYPES").Append("_").Append(string.Join(",", r.Entities)); } if (!string.IsNullOrEmpty(r.TimeRange)) { cacheKey.Append("_").Append("TIMERANGE").Append("_").Append(r.TimeRange); } cacheKey.Append("_").Append("SESSIONID").Append(r.TheSessionId); //if (r.ReloadCompanies) //{ cacheKey.Append("_").Append("RELOADCOMPANIES").Append(r.ReloadCompanies.ToString()); //} r.RefreshCompany = ""; } else if (r.Companies.Count > 0) { if (r.Regions != null && r.Regions.Count > 0) { cacheKey.Append("_").Append("REGIONS").Append("_").Append(string.Join(",", r.Regions)); } if (r.Plays != null && r.Plays.Count > 0) { cacheKey.Append("_").Append("PLAYS").Append("_").Append(string.Join(",", r.Plays)); } if (r.Entities != null && r.Entities.Count > 0) { cacheKey.Append("_").Append("DEALTYPES").Append("_").Append(string.Join(",", r.Entities)); } if (!string.IsNullOrEmpty(r.TimeRange)) { cacheKey.Append("_").Append("TIMERANGE").Append("_").Append(r.TimeRange); } if (r.ReloadCompanies == false) { cacheKey.Append("_").Append("RELOADCOMPANIES").Append(true.ToString()); } else { cacheKey.Append("_").Append("RELOADCOMPANIES").Append(r.ReloadCompanies.ToString()); } cacheKey.Append("_").Append("SESSIONID").Append(r.TheSessionId); r.RefreshCompany = "true"; } var items = _cacheProvider.Retrieve <List <Company> >(cacheKey.ToString()); if (items == null || !items.Any()) { items = _commonRepository.GetBaseCompanies(dfs, r, dt); if (items.Any()) { _cacheProvider.Store(cacheKey.ToString(), items, int.MaxValue); } } return(items); }
internal abstract List <IMapIndexData> QueryData(List <T> data, MapSearch map, string query);
internal virtual List <string> GetCompanyFilters(List <string> theQueryString, MapSearch map) { List <string> andQueryList = new List <string>(); if (map.Companies != null) { if (map.Companies.Count > 0) { try { if (theQueryString.Count > 0) { theQueryString.AddRange(BuildContainsQuery("BuyerIdsString", map.Companies)); theQueryString.AddRange(BuildContainsQuery("SellerIdsString", map.Companies)); } else { theQueryString.AddRange(BuildContainsQuery("BuyerIdsString", map.Companies)); theQueryString.AddRange(BuildContainsQuery("SellerIdsString", map.Companies)); } } catch (Exception ex) { } } } return(theQueryString); }
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); }
internal virtual List <string> GetRegionFilters(List <string> theQueryString, MapSearch map) { try { if (map.Regions != null) { if (map.Regions.Count > 0) { theQueryString.AddRange(BuildEqualQuery("RegionId", map.Regions)); } } } catch (Exception ex) { } return(theQueryString); }