/// <summary> /// Create a new OnlineLocator instance by cloning this one /// </summary> /// <returns>A clone of this OnlineLocator</returns> public OnlineLocator Clone() { OnlineLocator l = new OnlineLocator(); l.Id = this.Id; l.Name = this.Name; l.Url = this.Url; l.GazId = this.GazId; l.Description = this.Description; l.Target = this.Target; l.Authentication = this.Authentication; l.Username = this.Username; l.Password = this.Password; l.TokenUrl = this.TokenUrl; l.FieldNames = this.FieldNames; return(l); }
/// <summary> /// List the Locators with an indication of Subscription /// </summary> /// <returns></returns> internal static BindingList <OnlineLocator> ListLocatorsWithSubscriptions() { BindingList <OnlineLocator> blist = new BindingList <OnlineLocator>(); foreach (DataRow datarow in ListDataHubDatasetsWithSubscriptions().Rows) { if ((datarow["IS_SUBSCRIBED"].ToString() == "Y") && (datarow["SERVICETYPE"].ToString().Equals("GAZ", StringComparison.InvariantCultureIgnoreCase))) { OnlineLocator onlineLocator = new OnlineLocator(); onlineLocator.Name = datarow["NAME"].ToString(); onlineLocator.Url = datarow["GAZURL"].ToString(); onlineLocator.Id = datarow["ID"].ToString(); onlineLocator.GazId = datarow["GAZID"].ToString(); blist.Add(onlineLocator); } } return(blist); }
/// <summary> /// Creates the client. /// </summary> /// <param name="onlineLocator">The online locator.</param> /// <returns></returns> public static LocatorHub.LocatorHub CreateClient(OnlineLocator onlineLocator) { return(LocatorManager.CreateClient(onlineLocator.Url, onlineLocator.Username, onlineLocator.Password, onlineLocator.Authentication, onlineLocator.TokenUrl)); }
/// <summary> /// Run LocatorHub Search /// </summary> internal void RunSearch() { try { if (LocatorCombo.Current.SelectedIndex == -1) { return; } //Get locator OnlineLocator onlineLocator = DataHubConfiguration.Current.Locators[LocatorCombo.Current.SelectedIndex]; //Get Query String String Query = LocatorSearchQuery.Current.TextValue; //Get use Fuzzy bool UseFuzzy = DataHubConfiguration.Current.UseFuzzy; //create popup form LocatorHub.LocatorHub client = LocatorManager.CreateClient(onlineLocator); LocatorPopupForm locatorPopupForm = new LocatorPopupForm(client); int factcode = -1; try { IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument; //get map IMap map = mxDocument.FocusMap; factcode = map.SpatialReference.FactoryCode; } catch (Exception) { factcode = -1; } //Setup form locatorPopupForm.Setup(onlineLocator.Target, Query, onlineLocator.GazId, UseFuzzy, LocatorCombo.Current.TextValue, factcode); //Show popup if multiple records if (locatorPopupForm.FoundRecord == null && locatorPopupForm.FailReason == MatchResultCodes.PickList) { //Show Dialog locatorPopupForm.ShowDialog(); } if (locatorPopupForm.DialogResult == DialogResult.OK) { //get the matchresult from the popupform MatchResult matchResult = locatorPopupForm.FoundRecord; ClearGraphics(); string[] values = matchResult.MatchedRecord.R.V; string[] point = values[locatorPopupForm.ColumnLookup["LOCATOR_POINT"]].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); // string description = values[locatorPopupForm.ColumnLookup["LOCATOR_DESCRIPTION"]]; string[] fieldNames = onlineLocator.FieldList(); StringBuilder sb = new StringBuilder(values[locatorPopupForm.ColumnLookup[fieldNames[0]]]); for (int i = 1; i < fieldNames.Length; i++) { sb.Append("|LOCATOR_SEPARATOR|"); sb.Append(values[locatorPopupForm.ColumnLookup[fieldNames[i]]]); } string description = sb.ToString(); string[] extent = values[locatorPopupForm.ColumnLookup["LOCATOR_ENVELOPE"]].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); AddPoint(point[0].ToDouble(), point[1].ToDouble(), matchResult.ReturnedCoordinateSystem, description, extent[0].ToDouble(), extent[1].ToDouble(), extent[2].ToDouble(), extent[3].ToDouble()); } else if (locatorPopupForm.DialogResult == DialogResult.Abort) { switch (locatorPopupForm.FailReason) { case MatchResultCodes.NoMatchNoResult: MessageBox.Show("No Match. There were no matches for the specified query.", "Query"); break; case MatchResultCodes.NoMatchTooVague: MessageBox.Show("Query too vague. There were too many possible matches for the specified query.", "Query"); break; } } locatorPopupForm = null; } catch (Exception ex) { ShowError(ex); } }
/// <summary> /// Creates the client. /// </summary> /// <param name="onlineLocator">The online locator.</param> /// <returns></returns> public static LocatorHub.LocatorHub CreateClient(OnlineLocator onlineLocator) { return LocatorManager.CreateClient(onlineLocator.Url, onlineLocator.Username, onlineLocator.Password, onlineLocator.Authentication, onlineLocator.TokenUrl); }
/// <summary> /// Load /// </summary> internal void Load() { try { XmlDocument dom = new XmlDocument(); string filename = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + CONFIG_SAVE_PATH + CONFIG_FILE_NAME; if (File.Exists(filename) == true) { dom.Load(filename); XmlNode dhub = dom.SelectSingleNode("./DataHubConfiguration/DataHub"); if (dhub != null) { this.UserName = dhub.Attributes.GetNamedItem("user").InnerText; this.Password = dhub.Attributes.GetNamedItem("password").InnerText; } XmlNode lh = dom.SelectSingleNode("./DataHubConfiguration/LocatorHub"); if (lh != null) { this.UsePan = System.Convert.ToBoolean(lh.Attributes.GetNamedItem("usepan").InnerText); this.UseFuzzy = System.Convert.ToBoolean(lh.Attributes.GetNamedItem("usefuzzy").InnerText); LastLocatorId = FetchAttributeValue(lh, "lastlocatorid"); } XmlNode locator = dom.SelectSingleNode("./DataHubConfiguration/Locators"); this.Locators = new List<OnlineLocator>(); foreach (XmlNode xmlNode in locator.SelectNodes("./Locator")) { OnlineLocator onlineLocator = new OnlineLocator(); onlineLocator.Name = FetchAttributeValue(xmlNode, "Name"); onlineLocator.Description = FetchAttributeValue(xmlNode, "Description"); onlineLocator.GazId = FetchAttributeValue(xmlNode, "LocatorId"); onlineLocator.Url = FetchAttributeValue(xmlNode, "Url"); onlineLocator.Target = FetchAttributeValue(xmlNode, "Target"); onlineLocator.Authentication = (AuthenticationMode)Enum.Parse(typeof(AuthenticationMode), FetchAttributeValue(xmlNode, "Authentication")); onlineLocator.Username = FetchAttributeValue(xmlNode, "Username"); onlineLocator.Password = FetchAttributeValue(xmlNode, "Password"); onlineLocator.TokenUrl = FetchAttributeValue(xmlNode, "TokenUrl"); this.Locators.Add(onlineLocator); } } else { //never run before. set things up to be empty this.LastLocatorId = String.Empty; this.Locators = new List<OnlineLocator>(); } } catch (Exception ex) { DataHubExtension.ShowError(ex); } }
/// <summary> /// Create a new OnlineLocator instance by cloning this one /// </summary> /// <returns>A clone of this OnlineLocator</returns> public OnlineLocator Clone() { OnlineLocator l = new OnlineLocator(); l.Id = this.Id; l.Name = this.Name; l.Url = this.Url; l.GazId = this.GazId; l.Description = this.Description; l.Target = this.Target; l.Authentication = this.Authentication; l.Username = this.Username; l.Password = this.Password; l.TokenUrl = this.TokenUrl; l.FieldNames = this.FieldNames; return l; }
/// <summary> /// List the Locators with an indication of Subscription /// </summary> /// <returns></returns> internal static BindingList<OnlineLocator> ListLocatorsWithSubscriptions() { BindingList<OnlineLocator> blist = new BindingList<OnlineLocator>(); foreach (DataRow datarow in ListDataHubDatasetsWithSubscriptions().Rows) { if ((datarow["IS_SUBSCRIBED"].ToString() == "Y") && (datarow["SERVICETYPE"].ToString().Equals("GAZ", StringComparison.InvariantCultureIgnoreCase))) { OnlineLocator onlineLocator = new OnlineLocator(); onlineLocator.Name = datarow["NAME"].ToString(); onlineLocator.Url = datarow["GAZURL"].ToString(); onlineLocator.Id = datarow["ID"].ToString(); onlineLocator.GazId = datarow["GAZID"].ToString(); blist.Add(onlineLocator); } } return blist; }
/// <summary> /// Load /// </summary> internal void Load() { try { XmlDocument dom = new XmlDocument(); string filename = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + CONFIG_SAVE_PATH + CONFIG_FILE_NAME; if (File.Exists(filename) == true) { dom.Load(filename); XmlNode dhubhttp = dom.SelectSingleNode("./DataHubConfiguration/DataHubHttp"); if (dhubhttp != null) { this.DataHubHttp = dhubhttp.Attributes.GetNamedItem("url").InnerText; } XmlNode dhubhttps = dom.SelectSingleNode("./DataHubConfiguration/DataHubHttps"); if (dhubhttps != null) { this.DataHubHttps = dhubhttps.Attributes.GetNamedItem("url").InnerText; } XmlNode dhub = dom.SelectSingleNode("./DataHubConfiguration/DataHub"); if (dhub != null) { this.UserName = dhub.Attributes.GetNamedItem("user").InnerText; this.Password = dhub.Attributes.GetNamedItem("password").InnerText; } XmlNode lh = dom.SelectSingleNode("./DataHubConfiguration/LocatorHub"); if (lh != null) { this.UsePan = System.Convert.ToBoolean(lh.Attributes.GetNamedItem("usepan").InnerText); this.UseFuzzy = System.Convert.ToBoolean(lh.Attributes.GetNamedItem("usefuzzy").InnerText); LastLocatorId = FetchAttributeValue(lh, "lastlocatorid"); string zoomStr = FetchAttributeValue(lh, "zoomscale"); this.ZoomScale = String.IsNullOrEmpty(zoomStr) ? CONFIG_DEFAULT_ZOOM : int.Parse(zoomStr); } this.Locators = new List <OnlineLocator>(); XmlNode locator = dom.SelectSingleNode("./DataHubConfiguration/Locators"); if (locator != null) { foreach (XmlNode xmlNode in locator.SelectNodes("./Locator")) { OnlineLocator onlineLocator = new OnlineLocator(); onlineLocator.Name = FetchAttributeValue(xmlNode, "Name"); onlineLocator.Description = FetchAttributeValue(xmlNode, "Description"); onlineLocator.GazId = FetchAttributeValue(xmlNode, "LocatorId"); onlineLocator.Url = FetchAttributeValue(xmlNode, "Url"); onlineLocator.Target = FetchAttributeValue(xmlNode, "Target"); onlineLocator.Authentication = (AuthenticationMode)Enum.Parse(typeof(AuthenticationMode), FetchAttributeValue(xmlNode, "Authentication")); onlineLocator.Username = FetchAttributeValue(xmlNode, "Username"); onlineLocator.Password = FetchAttributeValue(xmlNode, "Password"); onlineLocator.TokenUrl = FetchAttributeValue(xmlNode, "TokenUrl"); string fieldNames = FetchAttributeValue(xmlNode, "FieldNames"); if (string.IsNullOrEmpty(fieldNames)) { fieldNames = "LOCATOR_DESCRIPTION"; } onlineLocator.FieldNames = fieldNames; this.Locators.Add(onlineLocator); } } } else { //never run before. set things up to be empty this.LastLocatorId = String.Empty; this.Locators = new List <OnlineLocator>(); this.ZoomScale = CONFIG_DEFAULT_ZOOM; } } catch (Exception ex) { DataHubExtension.ShowError(ex); } }