public static void DeleteRun(string runid) { using (var cmd = new SqliteCommand(SQL_GET_RESULT_TYPES_SINGLE, DatabaseManager.Connection, DatabaseManager.Transaction)) { cmd.Parameters.AddWithValue("@run_id", runid); using (var reader = cmd.ExecuteReader()) { if (!reader.HasRows) { Log.Warning("That Run ID wasn't found in the database"); return; } while (reader.Read()) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_RUN, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } if (reader["type"].ToString() == "monitor") { if ((int.Parse(reader["file_system"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_FILES_MONITORED, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } } else { if ((int.Parse(reader["file_system"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_FILES, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } if ((int.Parse(reader["ports"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_PORTS, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } if ((int.Parse(reader["users"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_USERS, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } if ((int.Parse(reader["services"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_SERVICES, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } if ((int.Parse(reader["registry"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_REGISTRY, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } if ((int.Parse(reader["certificates"].ToString()) != 0)) { using (var inner_cmd = new SqliteCommand(SQL_TRUNCATE_CERTIFICATES, DatabaseManager.Connection, DatabaseManager.Transaction)) { inner_cmd.Parameters.AddWithValue("@run_id", runid); inner_cmd.ExecuteNonQuery(); } } } } } } DatabaseManager.Commit(); }