private void btnDatabaseEngineTestConnection_Click(object sender, EventArgs e) { try { syncConnectionInfoToGUI(null); var proxy = new AdminHostProxy(_conn, true); string failureReason = proxy.TestDatabaseConnection(); if (!String.IsNullOrEmpty(failureReason)) { MessageBox.Show(this, failureReason, getDisplayMember("testDbConnection{failed_title}", "Connection Failed"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show(this, getDisplayMember("testDbConnection{success_body}", "Connection Succeeded."), getDisplayMember("testDbConnection{success_title}", "Valid Connection"), MessageBoxButtons.OK, MessageBoxIcon.None); } } catch (InvalidCredentialException ice) { Debug.WriteLine(ice.Message); MessageBox.Show(this, getDisplayMember("testDbConnection{noadmin_body}", "Successfully connected to database engine.\n\nHowever, you must also specify a valid GRIN-Global Login with administrative rights to perform administrative tasks."), getDisplayMember("testDbConnection{noadmin_title}", "Database Engine Connection Success")); txtGrinGlobalUserName.Focus(); txtGrinGlobalUserName.Select(); } catch (Exception ex) { MessageBox.Show(this, getDisplayMember("testDbConnection{completefail_body}", "Unable to contact the database engine. Please verify the connection information is correct and your credentials are valid.\n\n{0}", ex.Message), getDisplayMember("testDbConnection{noadmin_title}", "Unable to Contact Database Engine"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnConnect_Click(object sender, EventArgs e) { try { if (rdoWebService.Checked) { txtGrinGlobalUrl.Text = autoFormatUrl(txtGrinGlobalUrl.Text); } else { } syncConnectionInfoToGUI(null); var proxy = new AdminHostProxy(_conn); string login = proxy.Login(); if (!String.IsNullOrEmpty(login)) { syncConnectionInfoToGUI(login); // make sure they're an admin if (!proxy.GetRoles(0).Contains("admins")) { MessageBox.Show(getDisplayMember("connect{notadmin}", "The GRIN-Global user '{0}' is a valid login, but does not have permission to perform administrative tasks.", _conn.GrinGlobalUserName)); txtGrinGlobalUserName.Focus(); txtGrinGlobalUserName.SelectAll(); return; } // we get here, we have a valid user w/ admin rights. if (this.MdiParent != null) { MainFormSaveConnections(_conn); return; } else { this.DialogResult = DialogResult.OK; this.Close(); } MainFormUpdateStatus(getDisplayMember("connect{saved}", "Saved connection settings for {0}", _conn.DatabaseEngineServerName), true); } else { MessageBox.Show(this, getDisplayMember("connect{invalidlogin_body}", "Invalid username or password.\nPlease alter your credentials and try again."), getDisplayMember("connect{invalidlogin_title}", "Invalid Credentials"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (InvalidCredentialException ice) { Debug.WriteLine(ice.Message); MessageBox.Show(this, getDisplayMember("connect{gooddbnoadmin_body}", "Successfully connected to database engine.\n\nHowever, you must also specify a valid GRIN-Global Login with administrative rights to perform administrative tasks."), getDisplayMember("connect{gooddbnoadmin_title}", "Database Engine Connection Success, Login Failure")); txtGrinGlobalUserName.Focus(); txtGrinGlobalUserName.Select(); } catch (EndpointNotFoundException epnfe) { Debug.WriteLine(epnfe.Message); MessageBox.Show(this, getDisplayMember("connect{badurl_body}", "The specified url does not seem to point to a valid GRIN-Global server. Please alter it as needed and try again."), getDisplayMember("connect{badurl_title}", "Connection Failed - Invalid URL")); txtGrinGlobalUrl.Focus(); txtGrinGlobalUrl.Select(); } catch (FaultException <ExceptionDetail> feed) { Debug.WriteLine(feed.Message); MessageBox.Show(this, getDisplayMember("connect{goodwebnoadmin_body}", "Successfully connected to web service.\n\nHowever, you must also specify a valid GRIN-Global Login with administrative rights to perform administrative tasks."), getDisplayMember("connect{goodwebnoadmin_title}", "Web Service Connection Success, Login Failure")); txtGrinGlobalUserName.Focus(); txtGrinGlobalUserName.Select(); } catch (Exception ex) { Debug.WriteLine(ex.Message); MessageBox.Show(this, ex.Message, getDisplayMember("connect{failed_title}", "Connection Failed"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public DialogResult ShowDialog(mdiParent parent, AdminHostProxy proxy) { _parent = parent; _proxy = proxy; return(this.ShowDialog(parent)); }