added backup class for getting information from database, and adding code for retreival from database
This commit is contained in:
parent
afd1b9843c
commit
abd268e3f0
1 changed files with 63 additions and 1 deletions
|
@ -13,7 +13,7 @@ namespace Saviour_Backup_System
|
||||||
class databaseTools
|
class databaseTools
|
||||||
{
|
{
|
||||||
internal static string databaseName = "saviour.sdf";
|
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 SqlCeCommand cmd = conn.CreateCommand();
|
||||||
|
|
||||||
private static void copyDatabase()
|
private static void copyDatabase()
|
||||||
|
@ -27,5 +27,67 @@ namespace Saviour_Backup_System
|
||||||
copyDatabase();
|
copyDatabase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal static backup[] getBackups()
|
||||||
|
{
|
||||||
|
List<backup> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue