private bool PopulateConnection(AGSConnection connection) { if (!connection.LoadConnectionProperties()) { return(false); } if (!connection.FoldersLoaded) { connection.LoadChildren(); } return(connection.FoldersLoaded); }
private void Next_Click(object sender, RoutedEventArgs e) { base.Visibility = Visibility.Collapsed; this.tbServerName.Text = AGSConnection.FixName(this.tbServerName.Text); AGSConnection aGSConnection = null; try { aGSConnection = new AGSConnection(this.tbServerName.Text, this.tbServerURL.Text); } catch { ErrorReport.ShowErrorMessage(AfaStrings.ErrorConnectingToServer); base.Visibility = Visibility.Visible; this.Succeeded = false; } if (aGSConnection != null && !aGSConnection.ConnectionFailed) { aGSConnection.UserName = this.tbUserName.Text; aGSConnection.Password = this.tbPassword.Password; Mouse.OverrideCursor = Cursors.Wait; if (!aGSConnection.LoadConnectionProperties()) { Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(aGSConnection.ErrorMessage); base.Visibility = Visibility.Visible; this.Succeeded = false; return; } Mouse.OverrideCursor = null; base.Close(); Mouse.OverrideCursor = Cursors.Wait; if (!aGSConnection.LoadChildren()) { Mouse.OverrideCursor = null; string text = aGSConnection.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = AfaStrings.ErrorConnectingToServer; } ErrorReport.ShowErrorMessage(text); return; } Mouse.OverrideCursor = null; if (aGSConnection.FoldersLoaded && !aGSConnection.ConnectionFailed) { this.Succeeded = true; aGSConnection.SaveToFile(); App.Connections.Add(aGSConnection); SelectService selectService = new SelectService(aGSConnection); if (selectService.IsValid) { Autodesk.AutoCAD.ApplicationServices.Core.Application.ShowModalWindow(selectService); if (selectService.DialogResult.HasValue) { bool arg_165_0 = selectService.DialogResult.Value; } } } } }
public object ESRI_AddConnection(ResultBuffer rb) { object result; try { TypedValue[] array = rb.AsArray(); if (array.Count <TypedValue>() < 2) { result = null; } else { string text = null; string text2 = null; string text3 = null; string text4 = null; string text5 = null; string text6 = null; bool promptForCredentials = true; object obj = null; object obj2 = null; TypedValue[] array2 = array; for (int i = 0; i < array2.Length; i++) { TypedValue typedValue = array2[i]; if (typedValue.TypeCode == 5016) { obj = null; obj2 = null; } else if (typedValue.TypeCode == 5017) { obj = null; obj2 = null; } else if (typedValue.TypeCode == 5018) { if (obj != null && obj2 != null) { TypedValue typedValue2 = (TypedValue)obj; TypedValue typedValue3 = (TypedValue)obj2; string a = typedValue2.Value.ToString(); if (string.Equals(a, "Name", StringComparison.CurrentCultureIgnoreCase)) { text = typedValue3.Value.ToString(); } else if (string.Equals(a, "URL", StringComparison.CurrentCultureIgnoreCase)) { text2 = typedValue3.Value.ToString(); } else if (string.Equals(a, "tokenUser", StringComparison.CurrentCultureIgnoreCase)) { text3 = typedValue3.Value.ToString(); } else if (string.Equals(a, "tokenPassword", StringComparison.CurrentCultureIgnoreCase)) { text4 = typedValue3.Value.ToString(); } else if (string.Equals(a, "ServerUser", StringComparison.CurrentCultureIgnoreCase)) { text5 = typedValue3.Value.ToString(); } else if (string.Equals(a, "ServerPassword", StringComparison.CurrentCultureIgnoreCase)) { text6 = typedValue3.Value.ToString(); } else if (string.Equals(a, "PromptCredentials", StringComparison.CurrentCultureIgnoreCase)) { string a2 = typedValue3.Value.ToString(); if (string.Equals(a2, "No", StringComparison.CurrentCultureIgnoreCase)) { promptForCredentials = false; } } } obj2 = (obj = null); } else if (obj == null) { obj = typedValue; } else { obj2 = typedValue; } } if (string.IsNullOrEmpty(text)) { result = null; } else if (string.IsNullOrEmpty(text2)) { result = null; } else if (!Uri.IsWellFormedUriString(text2, UriKind.Absolute)) { result = null; } else { if (!AGSConnection.bConnectionsLoaded) { AGSConnection.LoadConnections(); } if (!string.IsNullOrEmpty(text2) && !Uri.IsWellFormedUriString(text2, UriKind.Absolute)) { result = null; } else { AGSConnection aGSConnection = new AGSConnection(text, text2); if (!string.IsNullOrEmpty(text3)) { aGSConnection.UserName = text3; } if (!string.IsNullOrEmpty(text4)) { aGSConnection.Password = text4; } if (!string.IsNullOrEmpty(text5)) { if (string.IsNullOrEmpty(text6)) { text6 = ""; } NetworkCredential credentials = new NetworkCredential(text5, text6); aGSConnection.Credentials = credentials; } aGSConnection.PromptForCredentials = promptForCredentials; if (!aGSConnection.LoadConnectionProperties()) { result = null; } else if (!aGSConnection.LoadChildren()) { result = null; } else { aGSConnection.PromptForCredentials = true; if (aGSConnection.FoldersLoaded) { aGSConnection.SaveToFile(); App.Connections.Add(aGSConnection); ResultBuffer resultBuffer = new ResultBuffer(); resultBuffer.Add(new TypedValue(5005, text)); result = this.ESRI_GetConnection(resultBuffer); } else { result = null; } } } } } } catch { result = null; } return(result); }