From abd268e3f0828925fcb3fae92706e5da2d680dc5 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 10 Nov 2014 16:36:14 +0000 Subject: [PATCH] added backup class for getting information from database, and adding code for retreival from database --- Saviour Backup System/databaseTools.cs | 64 +++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/Saviour Backup System/databaseTools.cs b/Saviour Backup System/databaseTools.cs index 3ea0add..2a8bbdf 100644 --- a/Saviour Backup System/databaseTools.cs +++ b/Saviour Backup System/databaseTools.cs @@ -13,7 +13,7 @@ namespace Saviour_Backup_System class databaseTools { internal static string databaseName = "saviour.sdf"; - private static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName + "; password=12a712d7e6f71ed07822c219318da2c0"); //password is a hash + internal static SqlCeConnection conn = new SqlCeConnection("Data Source = " + databaseName + "; password=12a712d7e6f71ed07822c219318da2c0"); //password is a hash private static SqlCeCommand cmd = conn.CreateCommand(); private static void copyDatabase() @@ -27,5 +27,67 @@ namespace Saviour_Backup_System copyDatabase(); } } + internal static backup[] getBackups() + { + List backups = null; + conn.Open(); + cmd.CommandText = ""; + SqlCeDataReader reader = cmd.ExecuteReader(); + int index = 0; + while (reader.Read()) + { + backup temp = new backup(); + temp.create(reader.GetString(0), + reader.GetString(1), + reader.GetInt64(1) + backups.Add(temp); + temp = null; + index++; + } + if (backups == null) + { + return new backup[0]; + } + return backups.ToArray(); + } + } + + + class backup + { + internal string driveID; + internal string name; + internal Int64 startDate; + internal string hash; + internal Int32 duration; + + internal void store() + { + SqlCeCommand cmd = databaseTools.conn.CreateCommand(); + cmd.CommandText = ""; + cmd.ExecuteNonQuery(); + cmd.Dispose(); + } + + internal void update() + { + databaseTools.conn.Open(); + SqlCeCommand cmd = databaseTools.conn.CreateCommand(); + cmd.CommandText = ""; + //execute reader or whatever it is + databaseTools.conn.Close(); + cmd.Dispose(); + } + + internal void create(string Drive_ID, string Backup_Name, Int64 Start_Date, string Hash, Int32 Duration ) { + driveID = Drive_ID; + name = Backup_Name; + startDate = Start_Date; + hash = Hash; + duration = Duration; + } + } + + }