private void btnUpdate_Click(object sender, EventArgs e) { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); LoadAllData(); UpdateAll(); qdLoader.Close(); }
private void Submit() { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); if (masterPassword == QDLib.HashPassword(txbMasterPassword.Text)) { pnlSettings.BringToFront(); } else { MessageBox.Show("Password not valid.", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Warning); } qdLoader.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 void SubmitSA2() { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); alwaysPromptPassword = chbSA2PromptPassword.Checked; if (alwaysPromptPassword) { // Check if both passwords are valid if (QDLib.ValidatePasswords(txbSA2Password.Text, txbSA2ConfirmPassword.Text)) { localPassword = txbSA2Password.Text; } else { qdLoader.Close(); return; } } // (Try to) save the QD-Config and create DBs SaveConfiguration(localConnection); // Check if an error occured and show error-page if (!errorEncountered) { pnlS3Finish.BringToFront(); } else { pnlS3Error.BringToFront(); btnS3ErrorClose.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); }
private void UpdateDatagrid() { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); BrowserSort sort = BrowserSort.None; if (!QDLib.ManagedDBOpen(mysql)) { QDLib.DBOpenFailed(); qdLoader.Close(); return; } totalEntryCount = mysql.ExecuteScalar <int>("SELECT COUNT(*) FROM qd_conlog"); bool abort = false; if (string.IsNullOrEmpty(SelectedObjectID)) { sort = BrowserSort.AllEntries; } else if (SelectedObjectID.StartsWith("ACT=")) { sort = BrowserSort.SortedByActionType; } else if (mysql.ExecuteScalar <int>("SELECT COUNT(*) FROM qd_users WHERE ID = ?", SelectedObjectID) != 0) { sort = BrowserSort.SortedByUsers; } else if (mysql.ExecuteScalar <int>("SELECT COUNT(*) FROM qd_devices WHERE ID = ?", SelectedObjectID) != 0) { sort = BrowserSort.SortedByDevice; } else { abort = true; } mysql.Close(); if (abort) { qdLoader.Close(); return; } switch (cbxEntryLimit.SelectedIndex) { case 0: listLimitSize = 50; break; case 1: listLimitSize = 100; break; case 2: listLimitSize = 250; break; case 3: listLimitSize = 500; break; case 4: listLimitSize = 1000; break; case 5: listLimitSize = 5000; break; default: listLimitSize = -1; break; } if (listOffset <= 0 || listLimitSize == -1) { btnJumpToFirst.Enabled = false; btnJumpToFirst.BackColor = Color.DarkGray; } else { btnJumpToFirst.Enabled = true; btnJumpToFirst.BackColor = Color.Gainsboro; } if (listOffset <= 0 || listLimitSize == -1) { btnJumpBack.Enabled = false; btnJumpBack.BackColor = Color.DarkGray; } else { btnJumpBack.Enabled = true; btnJumpBack.BackColor = Color.Gainsboro; } if (listOffset + listLimitSize > totalEntryCount || listLimitSize == -1) { btnJumpToNext.Enabled = false; btnJumpToNext.BackColor = Color.DarkGray; } else { btnJumpToNext.Enabled = true; btnJumpToNext.BackColor = Color.Gainsboro; } maxOffset = 0; while (listLimitSize + maxOffset < totalEntryCount) { maxOffset += listLimitSize; } if (listOffset >= maxOffset) { btnJumpToLast.Enabled = false; btnJumpToLast.BackColor = Color.DarkGray; } else { btnJumpToLast.Enabled = true; btnJumpToLast.BackColor = Color.Gainsboro; } string limitString; if (listLimitSize == -1) { limitString = ""; } else { limitString = $"LIMIT {listOffset},{listLimitSize}"; } string sqlQuery = ""; switch (sort) { case BrowserSort.AllEntries: sqlQuery = $"SELECT " + $"*, " + $"qd_conlog.ID AS MainID, " + $"CONCAT(qd_users.Name, ' (', qd_users.Username, ')') AS UserDisplay, " + $"CONCAT(qd_devices.LogonName, ' @ ', qd_devices.DeviceName) AS DeviceDisplay " + $"FROM qd_conlog " + $"INNER JOIN qd_users ON qd_conlog.UserID = qd_users.ID " + $"INNER JOIN qd_devices ON qd_conlog.DeviceID = qd_devices.ID " + $"ORDER BY LogTime DESC " + limitString; lblActionDescriptor.Text = "Showing all recorded actions."; break; case BrowserSort.SortedByActionType: sqlQuery = $"SELECT " + $"*, " + $"qd_conlog.ID AS MainID, " + $"CONCAT(qd_users.Name, ' (', qd_users.Username, ')') AS UserDisplay, " + $"CONCAT(qd_devices.LogonName, ' @ ', qd_devices.DeviceName) AS DeviceDisplay " + $"FROM qd_conlog " + $"INNER JOIN qd_users ON qd_conlog.UserID = qd_users.ID " + $"INNER JOIN qd_devices ON qd_conlog.DeviceID = qd_devices.ID " + $"WHERE qd_conlog.LogAction = ? " + $"ORDER BY LogTime DESC " + limitString; lblActionDescriptor.Text = $"Showing all recorded actions of type \"{(QDLogAction)Convert.ToInt32(SelectedObjectID.Replace("ACT=", ""))}\"."; break; case BrowserSort.SortedByDevice: sqlQuery = $"SELECT " + $"*, " + $"qd_conlog.ID AS MainID, " + $"CONCAT(qd_users.Name, ' (', qd_users.Username, ')') AS UserDisplay, " + $"CONCAT(qd_devices.LogonName, ' @ ', qd_devices.DeviceName) AS DeviceDisplay " + $"FROM qd_conlog " + $"INNER JOIN qd_users ON qd_conlog.UserID = qd_users.ID " + $"INNER JOIN qd_devices ON qd_conlog.DeviceID = qd_devices.ID " + $"WHERE qd_devices.ID = ? " + $"ORDER BY LogTime DESC " + limitString; lblActionDescriptor.Text = $"Showing all recorded actions of device \"{mysql.ExecuteScalarACon<string>("SELECT CONCAT(LogonName, ' @ ', DeviceName) FROM qd_devices WHERE ID = ?", SelectedObjectID)}\"."; break; case BrowserSort.SortedByUsers: sqlQuery = $"SELECT " + $"*, " + $"qd_conlog.ID AS MainID, " + $"CONCAT(qd_users.Name, ' (', qd_users.Username, ')') AS UserDisplay, " + $"CONCAT(qd_devices.LogonName, ' @ ', qd_devices.DeviceName) AS DeviceDisplay " + $"FROM qd_conlog " + $"INNER JOIN qd_users ON qd_conlog.UserID = qd_users.ID " + $"INNER JOIN qd_devices ON qd_conlog.DeviceID = qd_devices.ID " + $"WHERE qd_users.ID = ? " + $"ORDER BY LogTime DESC " + limitString; lblActionDescriptor.Text = $"Showing all recorded actions of user \"{mysql.ExecuteScalarACon<string>("SELECT CONCAT(Name, ' (', Username, ')') FROM qd_users WHERE ID = ?", SelectedObjectID)}\"."; break; } dgvActionBrowser.Rows.Clear(); if (!QDLib.ManagedDBOpen(mysql)) { QDLib.DBOpenFailed(); qdLoader.Close(); return; } using (MySqlDataReader reader = (MySqlDataReader)mysql.ExecuteQuery(sqlQuery, SelectedObjectID.Replace("ACT=", ""))) { while (reader.Read()) { dgvActionBrowser.Rows.Add(new string[] { Convert.ToString(reader["MainID"]), Convert.ToString(reader["LogTime"]), Convert.ToString(reader["UserDisplay"]), Convert.ToString(reader["DeviceDisplay"]), Convert.ToString((QDLogAction)Convert.ToInt32(reader["LogAction"])), }); } } mysql.Close(); lblResultRange.Text = $"Showing entries {listOffset + 1} to {listOffset + dgvActionBrowser.Rows.Count} ({totalEntryCount} entries in total)"; qdLoader.Close(); }
private void SubmitSB2B() { QDLoader qdLoader = new QDLoader(); qdLoader.Show(); if (rbnSB2ExistingDB.Checked) { if (!QDLib.VerifyMasterPassword(txbSB2ExistingDBPassword.Text, onlineDBConDat)) { qdLoader.Close(); MessageBox.Show("Master-Password is not valid. Please enter the corrent Master-Password, which has been set when the database was first initialised.", "Invalid Master-Password", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { onlineMasterPassword = txbSB2ExistingDBPassword.Text; } } else { if (QDLib.ValidatePasswords(txbSB2NewDBPassword.Text, txbSB2NewDBConfirmPassword.Text)) { onlineMasterPassword = txbSB2NewDBPassword.Text; } else { qdLoader.Close(); return; } if (onlineAlreadyConfigured) { if (MessageBox.Show("The given database has already been initialised before. Do you really want to delete the existing database and configure it as a new one?", "Database already initialised", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { VerifyMasterPW verify = new VerifyMasterPW() { DBData = onlineDBConDat }; if (verify.ShowDialog() != DialogResult.OK) { qdLoader.Close(); return; } } else { qdLoader.Close(); return; } } } alwaysPromptPassword = chbS2B2PromptUserPassword.Checked; onlineConfigureAsNewDB = rbnSB2NewDB.Checked; SaveConfiguration(localConnection); if (!errorEncountered) { pnlS3Finish.BringToFront(); } else { pnlS3Error.BringToFront(); btnS3ErrorClose.Focus(); } qdLoader.Close(); }