private HtmlAgilityPack.HtmlDocument GetLayerObjectFromPointClick(GeoLayerParams datObject) { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); string layers = null; StringBuilder sb = new StringBuilder(); var request = new GeoLayerNoCql(); try { using (var client = new System.Net.WebClient()) { //var deserializedGeoParamObject = Newtonsoft.Json.JsonConvert.DeserializeObject<GeoLayerParams>(datObject); sb.AppendLine("Deserialized Geo Param Object: " + datObject).AppendLine(); client.Headers["X-Credentials"] = "private-user="******"&private-pw=" + ConfigurationFactory.Instance.Configuration().GeoserverWebuserPassword; sb.AppendLine("Headers").AppendLine(); sb.AppendLine().AppendLine("URL: " + ConfigurationFactory.Instance.Configuration().GeoServerBaseUrl + "/geoserver/gwc/service/wms?" + datObject.ToString() + "&authKey=" + ConfigurationFactory.Instance.Configuration().GeoserverAuthKey).AppendLine(); if (datObject.cql_filter == null || datObject.cql_filter == "") { datObject.cql_filter = null; request = JsonConvert.DeserializeObject <GeoLayerNoCql>(JsonConvert.SerializeObject(datObject, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); layers = System.Web.HttpUtility.HtmlDecode(client.DownloadString(ConfigurationFactory.Instance.Configuration().GeoServerBaseUrl + "/wms?" + request.ToString() + "&authKey=" + ConfigurationFactory.Instance.Configuration().GeoserverAuthKey)); } else { layers = System.Web.HttpUtility.HtmlDecode(client.DownloadString(ConfigurationFactory.Instance.Configuration().GeoServerBaseUrl + "/wms?" + datObject.ToString() + "&authKey=" + ConfigurationFactory.Instance.Configuration().GeoserverAuthKey)); } doc.LoadHtml(layers); } } catch (Exception ex) { //Infrastructure.Logging.LogFactory.Instance.Log().GenerateEmail("Error Getting GetLayerObjectFromPointClick", ex.Message); } return(doc); }
private string DfsPopupDetails(GeoLayerParams geoLayer, List <string> dealIds) { List <Data.IMapIndexData> dfs = iDfsService.GetDfsData(); List <DfsData> vals = CollectionHelpers.CollectionHelper <DfsData> .GetProperList(dfs); vals = vals.Where(s => dealIds.Contains(s.theId)).ToList(); //vals = vals.Take(5).ToList(); StringBuilder sb = new StringBuilder(); StringBuilder ul = new StringBuilder(); sb.Append("<div>"); ul.Append("<ul style='margin-left:22% !important;' class='pagination'>"); int i = 1; foreach (var item in vals) { if (i != 1) { sb.Append("<div style='display:none;' id='popupData_").Append(i).Append("'>").AppendLine(); } else { sb.Append("<div id='popupData_").Append(i).Append("'>").AppendLine(); } sb.Append(iMaDataGeoService.GeneratePopup(item, ConfigurationFactory.Instance.Configuration().CacheKeyDfsPopup + "_" + "ID" + "_" + item.theId, ConfigurationFactory.Instance.Configuration().CacheKeyDfsPopupPath)).AppendLine(); ul.Append("<li class='page-item'><a style='color:" + item.HexColor + " !important;font-weight:bold;' class='page-link' onclick='ShowPopup(" + i + "," + vals.Count + 1 + ")'").Append(">" + i + "</a>").Append("</li>"); sb.Append("</div>"); i++; } ul.Append("</ul>").AppendLine(); string result = sb.ToString() + ul.ToString(); result += "</div>"; //string popup = GeoserverHelpers.GeoserverPopupHelper.GeneratePopupPortfolio(vals.FirstOrDefault()); return(result); }
public IHttpActionResult WfsRequestPopup(GeoLayerParams datObject) { List <string> dealIds = GetPopupDealIds(datObject); dynamic result = null; if (datObject.Layers.IndexOf("listing") != -1) { result = DfsPopupDetails(datObject, dealIds); } else if (datObject.Layers.IndexOf("maGeometry") != -1) { result = MaPopupDetails(datObject, dealIds); } else { result = PortfolioPopupDetails(datObject, dealIds); } return(Ok(result)); }
private List <string> GetPopupDealIds(GeoLayerParams geoLayer) { List <string> dealIds = new List <string>(); string layers = null; string layerObject = GetLayerObject()[geoLayer.QUERY_LAYERS]; StringBuilder sb = new StringBuilder(); try { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); if (layerObject.ToLower().IndexOf("ma") != -1) { doc = iMaGeoService.GetLayerDocOnClick(geoLayer); } else if (layerObject.ToLower().IndexOf("dfs") != -1) { doc = iDfsGeoService.GetLayerDocOnClick(geoLayer); } else if (layerObject.ToLower().IndexOf("initial") != -1) { doc = iPortGeoService.GetLayerDocOnClick(geoLayer); } else { doc = iPortGeoService.GetLayerDocOnClick(geoLayer); } // HtmlAgilityPack.HtmlNodeCollection rows = doc.DocumentNode.SelectNodes("//table//tr"); Dictionary <string, string> dealIdList = new Dictionary <string, string>(); StringBuilder tableResults = new StringBuilder(); int idNumber = GetCellIdFromLayerObject()[layerObject]; //foreach (var item in rows) //{ // LogFactory.Instance.Log().GenerateEmail("GeoserverRequest", item.InnerHtml); //} for (int i = 1; i < rows.Count + 1; i++) { string dealId = null; try { string xpathToDealId = "/html[1]/body[1]/table[1]/tr[" + (i + 1).ToString() + "]/td[" + idNumber.ToString() + "]"; dealId = doc.DocumentNode.SelectSingleNode(xpathToDealId).InnerText; //dealId = rows[i + 1].SelectSingleNode("//td[" + idNumber.ToString() + "]").InnerText; if (!dealIds.Contains(dealId)) { dealIds.Add(dealId); } } catch (Exception ex) { } } sb.AppendLine("Layers: " + layers).AppendLine(); } catch (Exception ex) { // Infrastructure.Logging.LogFactory.Instance.Log().GenerateEmail("Error Getting GetPopupDealIds", ex.Message); } return(dealIds); }