private void btnConnect_Click(object sender, EventArgs e) { try { if (rdoWebService.Checked) { txtGrinGlobalUrl.Text = autoFormatUrl(txtGrinGlobalUrl.Text); } else { } syncConnectionInfoToGUI(null); var proxy = new HostProxy(_conn); var connReason = proxy.TestDatabaseConnection(); if (!String.IsNullOrEmpty(connReason)) { MessageBox.Show(this, getDisplayMember("connect{failed_body}", "Connection failed: {0}", connReason), getDisplayMember("connect{failed_title}", "Connection Failed"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string login = proxy.Login(); if (String.IsNullOrEmpty(login)) { 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); } else { syncConnectionInfoToGUI(login); // we get here, we have a valid user w/ admin rights. HostProxy = proxy; this.DialogResult = DialogResult.OK; this.Close(); } } } 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 to import data."), 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 to import data."), 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); } }
private void btnDatabaseEngineTestConnection_Click(object sender, EventArgs e) { try { syncConnectionInfoToGUI(null); var proxy = new HostProxy(_conn); string failureReason = proxy.TestDatabaseConnection(); if (!String.IsNullOrEmpty(failureReason)) { MessageBox.Show(this, failureReason, getDisplayMember("testDbConnection{failed_title}", "Connection Failed"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { string invalidLogin = proxy.Login(); if (!String.IsNullOrEmpty(invalidLogin)) { MessageBox.Show(this, getDisplayMember("testDbConnection{success_noadmin_body}", "Successfully connected to database engine.\n\nHowever, you must also specify a valid GRIN-Global Login to import data."), getDisplayMember("testDbConnection{success_noadmin_title}", "Database Engine Connection Success")); txtGrinGlobalUserName.Focus(); txtGrinGlobalUserName.Select(); } 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 to import data."), 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); } }