private void btnTestConnection_Click(object sender, EventArgs e) => QDLib.TestConnection(new WrapMySQLData() { Hostname = txbHostname.Text, Database = txbName.Text, Username = txbUsername.Text, Password = txbPassword.Text, Pooling = false });
private void Submit() { dbConDat = new WrapMySQLData() { Hostname = txbHostname.Text, Database = txbName.Text, Username = txbUsername.Text, Password = txbPassword.Text, Pooling = false }; if (QDLib.TestConnection(dbConDat, false)) { this.DialogResult = DialogResult.Cancel; this.Close(); } }
private void SubmitSB2A() { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); onlineDBConDat = new WrapMySQLData() { Hostname = txbSB2DBHostname.Text, Database = txbSB2DBName.Text, Username = txbSB2DBUsername.Text, Password = txbSB2DBPassword.Text, Pooling = false }; if (QDLib.TestConnection(onlineDBConDat, false)) { onlineAlreadyConfigured = IsConfiguredDB(); rbnSB2ExistingDB.Enabled = onlineAlreadyConfigured; txbSB2ExistingDBPassword.Enabled = onlineAlreadyConfigured; lblSB2AExistingMasterPW.Enabled = onlineAlreadyConfigured; if (onlineAlreadyConfigured) { rbnSB2ExistingDB.Checked = true; } else { rbnSB2NewDB.Checked = true; } pnlS2OnlineConnectionB.BringToFront(); } else { qdLoader.Close(); return; } rbnSB2ExistingDB.Focus(); qdLoader.Close(); }
private bool SaveChanges() { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); bool successOnline = false; bool successLocal = false; if (!QDLib.ManagedDBOpen(mysql)) { QDLib.DBOpenFailed(); return(false); } mysql.TransactionBegin(); try { mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglUserCanToggleKeepLoggedIn.ToggleState == ToggleButtonState.Active, QDInfo.DBO.UserCanToggleKeepLoggedIn); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglUserCanSelfRegister.ToggleState == ToggleButtonState.Active, QDInfo.DBO.UserCanSelfRegister); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglUserCanAddPublicDrives.ToggleState == ToggleButtonState.Active, QDInfo.DBO.UserCanAddPublicDrive); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglUserCanAddPrivateDrives.ToggleState == ToggleButtonState.Active, QDInfo.DBO.UserCanAddPrivateDrive); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglUseLoginAsDriveAuthentication.ToggleState == ToggleButtonState.Active, QDInfo.DBO.UseLoginAsDriveAuthentication); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglForceLoginAsDriveAuthentication.ToggleState == ToggleButtonState.Active, QDInfo.DBO.ForceLoginAsDriveAuthentication); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglDisconnectDrivesAtShutdown.ToggleState == ToggleButtonState.Active, QDInfo.DBO.DisconnectDrivesAtShutdown); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglLogUserActions.ToggleState == ToggleButtonState.Active, QDInfo.DBO.LogUserActions); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", tglUserCanChangeManagerSettings.ToggleState == ToggleButtonState.Active, QDInfo.DBO.UserCanChangeManagerSettings); mysql.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", txbDefaultDomain.Text, QDInfo.DBO.DefaultDomain); mysql.TransactionCommit(); successOnline = true; } catch { mysql.TransactionRollback(); } mysql.Close(); WrapMySQLData newDBConnection = new WrapMySQLData() { Hostname = txbDBHostname.Text, Database = txbDBDatabase.Text, Username = txbDBUsername.Text, Password = txbDBPassword.Text, Pooling = false }; using (WrapSQLite sqlite = new WrapSQLite(QDInfo.ConfigFile)) { if (QDLib.TestConnection(newDBConnection, false)) { if (!QDLib.ManagedDBOpen(sqlite)) { QDLib.DBOpenFailed(); return(false); } sqlite.TransactionBegin(); try { sqlite.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", Cipher.Encrypt(newDBConnection.Hostname, QDInfo.LocalCipherKey), QDInfo.DBL.DBHost); sqlite.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", Cipher.Encrypt(newDBConnection.Database, QDInfo.LocalCipherKey), QDInfo.DBL.DBName); sqlite.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", Cipher.Encrypt(newDBConnection.Username, QDInfo.LocalCipherKey), QDInfo.DBL.DBUsername); sqlite.ExecuteNonQuery("UPDATE qd_info SET QDValue = ? WHERE QDKey = ?", Cipher.Encrypt(newDBConnection.Password, QDInfo.LocalCipherKey), QDInfo.DBL.DBPassword); sqlite.TransactionCommit(); successLocal = true; } catch { sqlite.TransactionRollback(); } sqlite.Close(); } } if (!successOnline || !successLocal) { if (MessageBox.Show("Could not save the changes made. Please check your MySQL-Connection and try again. \r\n\r\nDo you want to close the admin-console anyway?", "Could not save settins", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { successOnline = true; } } qdLoader.Close(); return(successOnline && successLocal); }