/// <summary> /// Handles the Click event of the butAddLocator control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void butAddLocator_Click(object sender, EventArgs e) { try { ConfigureLocatorForm configureLocatorForm = new ConfigureLocatorForm(); List <string> names = new List <string>(); foreach (OnlineLocator loc in _Locators) { names.Add(loc.Name); } configureLocatorForm.LocatorNamesAlreadyInUse = names; if (configureLocatorForm.ShowDialog() == DialogResult.OK) { try { OnlineLocator newloc = configureLocatorForm.ConfiguredLocator; LocatorHub.LocatorHub client = LocatorManager.CreateClient(newloc); LocatorCapabilities locatorCapabilities = client.Capabilities(newloc.GazId); newloc.Target = locatorCapabilities.TargetElements[0].TargetElementIdentity; _Locators.Add(newloc); lstLocators.Refresh(); lstLocators.SelectedItem = newloc; lstLocators.Refresh(); this.lstLocators_SelectedIndexChanged(this, null); } catch (Exception) { } } } catch (Exception exv) { DataHubExtension.ShowError(exv); } }
/// <summary> /// Configures the UI. /// </summary> private void ConfigureUI() { try { butConnect.Enabled = ((_Locators == null) && (string.IsNullOrEmpty(cboUrl.Text) == false)); pnlHub.Visible = radHubConnection.Checked; pnlDataHub.Visible = radOnline.Checked; } catch (Exception exv) { DataHubExtension.ShowError(exv); } }
/// <summary> /// Handles the Click event of the butOK control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void butOK_Click(object sender, EventArgs e) { try { foreach (int i in lstMaps.SelectedIndices) { DataHubExtension.Current.AddAGSLayer(DataHubConfiguration.Current.UserName, DataHubConfiguration.Current.Password, _BaseData.Rows[i]["NAME"].ToString(), _BaseData.Rows[i]["MAP_URL"].ToString()); } } catch (Exception ex) { DataHubExtension.ShowError(ex); } }
/// <summary> /// Handles the Click event of the butMoveLocatorDown control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void butMoveLocatorDown_Click(object sender, EventArgs e) { try { int currentindex = lstLocators.SelectedIndex; OnlineLocator onlineLocator = _Locators[currentindex]; _Locators.RemoveAt(currentindex); _Locators.Insert(currentindex + 1, onlineLocator); _Locators.ResetBindings(); lstLocators.Refresh(); lstLocators.SelectedIndex = currentindex + 1; } catch (Exception ex) { DataHubExtension.ShowError(ex); } }
/// <summary> /// Initializes a new instance of the <see cref="frmConfigureLocator"/> class. /// </summary> /// <param name="inSettings">The in settings.</param> public ConfigureLocatorForm() { try { InitializeComponent(); pnlDataHub.Location = new System.Drawing.Point(pnlHub.Location.X, pnlHub.Location.Y); pnlDataHub.Size = new Size(pnlHub.Size.Width, pnlHub.Size.Height); this.LocatorNamesAlreadyInUse = new List <string>(); //Setup Local Locators this.InvalidateWebService(); cboUrl.Items.Clear(); cboLocator.DisplayMember = "LocatorName"; cboLocator.ValueMember = "LocatorId"; //Setup DataHub Locators _DHubLocators = new BindingList <OnlineLocator>(); try { _DHubLocators = OnlineManager.ListLocatorsWithSubscriptions(); } catch (Exception) { } cboDhubLocator.DataSource = _DHubLocators; cboDhubLocator.DisplayMember = "Name"; cboDhubLocator.ValueMember = "Id"; // Configure the Default State of the Locator radAuthNone.Checked = true; ConfigureUI(); } catch (Exception exv) { Cursor.Current = Cursors.Default; DataHubExtension.ShowError(exv); } finally { Cursor.Current = Cursors.Default; } }
private DataTable ConvertToDataTable(MatchResult matchResult) { //Create a new Datatable DataTable dataTable = new DataTable(); try { //Add Columns dataTable.Columns.Add("Drill", typeof(Bitmap)); dataTable.Columns.Add("Score"); dataTable.Columns.Add("Description"); //add a new row for each item in the picklist foreach (PickItem pickItem in matchResult.PickListItems) { //Create a new DataRow DataRow dataRow = dataTable.NewRow(); //Add Data To Row if (pickItem.HasChildren) { Bitmap bitmap = new Bitmap(GetType().Assembly.GetManifestResourceStream("DataHubServicesAddin.Images.Drill.bmp")); dataRow[0] = bitmap; } else { Bitmap bitmap = new Bitmap(GetType().Assembly.GetManifestResourceStream("DataHubServicesAddin.Images.Search.bmp")); dataRow[0] = bitmap; } dataRow[1] = pickItem.Score; dataRow[2] = pickItem.Description; //Add Row to Datatable dataTable.Rows.Add(dataRow); } } catch (Exception ex) { DataHubExtension.ShowError(ex); } //return the Datatable - all filled up and ready to bind return(dataTable); }
/// <summary> /// Handles the SelectedIndexChanged event of the cboTarget control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void cboTarget_SelectedIndexChanged(object sender, EventArgs e) { try { if (lstLocators.SelectedItem == null) { return; } if (cboTarget.SelectedItem == null) { return; } OnlineLocator onlineLocator = lstLocators.SelectedItem as OnlineLocator; Target target = cboTarget.SelectedItem as Target; onlineLocator.Target = target.Id; ConfigureUI(); } catch (Exception ex) { DataHubExtension.ShowError(ex); } }
/// <summary> /// Handles the Click event of the butOK control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void butOK_Click(object sender, EventArgs e) { try { this.DialogResult = DialogResult.OK; this.ConfiguredLocators = this._Locators.ToList(); int zoomScale; int.TryParse(this.textBox1.Text, out zoomScale); if (zoomScale <= 0) { zoomScale = 1250; } this.ConfiguredZoomScale = zoomScale; this.Close(); } catch (Exception exv) { DataHubExtension.ShowError(exv); } }
/// <summary> /// Runs the match. /// </summary> /// <param name="inLocatorId">The in locator id.</param> /// <param name="inMatchType">Type of the in match.</param> /// <param name="inQuery">The in query.</param> /// <param name="inFuzzy">if set to <c>true</c> [in fuzzy].</param> /// <param name="indrillDown">if set to <c>true</c> [indrill down].</param> /// <param name="inSelectedItem">The in selected item.</param> private void RunMatch(string inLocatorId, String inMatchType, String inQuery, bool inFuzzy, bool indrillDown, int inSelectedItem) { try { //set RoecordID & CacheID to be empty String RecordID = ""; String CacheID = ""; //if its a drill down then grab the RecordId and CacheID if (indrillDown) { RecordID = _MatchCache.Peek().PickListItems[inSelectedItem].RecordId.ToString(); CacheID = _MatchCache.Peek().CacheIdentifier; } //Run First Query and Pop results onto stack MatchResult matchResult = this.Client.Match(inLocatorId, inMatchType, inQuery, inFuzzy, RecordID, _SpatialReference, CacheID); switch (matchResult.TypeOfResult) { case MatchResultCodes.PickList: //Produce a DataTable for the Datagrid to show _CurrentDataTable = ConvertToDataTable(matchResult); //cache query for drilldown _MatchCache.Push(matchResult); break; case MatchResultCodes.SingleMatch: //code for case where show if parent haschildren but Singlerecord is returned if (_MatchCache.Count != 0) { if (_MatchCache.Peek().PickListItems[inSelectedItem].HasChildren) { //show in datgrid as a single record DataTable dataTable = new DataTable(); dataTable.Columns.Add("Drill", typeof(Bitmap)); dataTable.Columns.Add("Score"); dataTable.Columns.Add("Description"); DataRow dataRow = dataTable.NewRow(); Bitmap bitmap = new Bitmap(GetType().Assembly.GetManifestResourceStream("DataHubServicesAddin.Images.Search.bmp")); dataRow[0] = bitmap; dataRow[1] = matchResult.MatchedRecordScore; dataRow[2] = matchResult.MatchedRecord.R.V[2 /*"LOCATOR_DESCRIPTION"*/].Replace("|LOCATOR_SEPARATOR|", ","); dataTable.Rows.Add(dataRow); _CurrentDataTable = dataTable; _MatchCache.Push(matchResult); } else { //set the found item this.FoundRecord = matchResult; BuildColumnLookup(); //inform all that the dialog has been closed with OK DialogResult = DialogResult.OK; } } else { //set the found item this.FoundRecord = matchResult; BuildColumnLookup(); //inform all that the dialog has been closed with OK DialogResult = DialogResult.OK; } break; default: this.FailReason = matchResult.TypeOfResult; this.DialogResult = DialogResult.Abort; break; } } catch (Exception ex) { DataHubExtension.ShowError(ex); } }
/// <summary> /// Handles the Click event of the butEditLocatorDefinition control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void butEditLocatorDefinition_Click(object sender, EventArgs e) { try { if (lstLocators.SelectedItem == null) { return; } OnlineLocator currentItem = lstLocators.SelectedItem as OnlineLocator; if (currentItem == null) { return; } ConfigureLocatorForm configureLocatorForm = new ConfigureLocatorForm(currentItem); List <string> names = new List <string>(); foreach (OnlineLocator loc in _Locators) { names.Add(loc.Name); } names.Remove(currentItem.Name); configureLocatorForm.LocatorNamesAlreadyInUse = names; if (configureLocatorForm.ShowDialog() == DialogResult.OK) { try { //remove old item from the list _Locators.Remove(lstLocators.SelectedItem as OnlineLocator); //pickup the new item from the dialog and try to add to the list OnlineLocator newloc = configureLocatorForm.ConfiguredLocator; LocatorHub.LocatorHub client = LocatorManager.CreateClient(newloc); LocatorCapabilities locatorCapabilities = client.Capabilities(newloc.GazId); newloc.Target = locatorCapabilities.TargetElements[0].TargetElementIdentity; _Locators.Add(newloc); lstLocators.Refresh(); lstLocators.SelectedItem = newloc; lstLocators.Refresh(); this.lstLocators_SelectedIndexChanged(this, null); } catch (Exception) { } } } catch (Exception exv) { DataHubExtension.ShowError(exv); } try { //using (ConfigureLocatorDialog cd = new ConfigureLocatorDialog()) //{ // LocatorConfig loc = (LocatorConfig)lstLocators.SelectedItem; // List<string> names = new List<string>(); // foreach (LocatorConfig tloc in _Locators) // { // names.Add(tloc.Name); // } // names.Remove(loc.Name); // cd.ConfiguredLocator = loc; // cd.LocatorNamesAlreadyInUse = names; // if (cd.ShowDialog() == DialogResult.OK) // { // try // { // _Locators.ResetBindings(); // lstLocators.Refresh(); // } // finally // { // } // } //} } catch (Exception ex) { DataHubExtension.ShowError(ex); } }