private bool PopulateEmptyDatabase(GenConnection con, String databaseType) { DDL DDL; if (databaseType == "MySql") if (GlobalSettings.ApplicationSettings.DatabaseVersion == "5.6") DDL = new MySql_5_6_DDL(); else DDL = new MySql_DDL(); else if (databaseType == "Jet") DDL = new Jet_DDL(); else if (databaseType == "SQLite") DDL = new SQLite_DDL(); else if (databaseType == "SQL Server") DDL = new SQLServer_DDL(); else throw new Exception("Unexpected database type: " + databaseType); bool success = true; if (success && !RelationExists(con, "devicetype")) success &= CreateRelation(DDL.CurrentTable_devicetype, con); if (success && !RelationExists(con, "device")) success &= CreateRelation(DDL.CurrentTable_device, con); if (success && !RelationExists(con, "devicefeature")) success &= CreateRelation(DDL.CurrentTable_devicefeature, con); if (success && !RelationExists(con, "devicereading_energy")) success &= CreateRelation(DDL.CurrentTable_devicereading_energy, con); if (success && !RelationExists(con, "devicedayoutput_v")) success &= CreateRelation(DDL.CurrentView_devicedayoutput_v, con); if (success && !RelationExists(con, "pvoutputlog")) success &= CreateRelation(DDL.CurrentTable_pvoutputlog, con); if (success && !RelationExists(con, "version")) success &= CreateRelation(DDL.CurrentTable_version, con); if (success) UpdateVersion("2", "0", "0", "0", con); return success; }
private DDL SelectDDL(String databaseType) { DDL DDL; if (databaseType == "MySql") if (GlobalSettings.ApplicationSettings.DatabaseVersion == "5.6") DDL = new MySql_5_6_DDL(); else DDL = new MySql_DDL(); else if (databaseType == "Jet") DDL = new Jet_DDL(); else if (databaseType == "SQLite") DDL = new SQLite_DDL(); else if (databaseType == "SQL Server") DDL = new SQLServer_DDL(); else throw new Exception("Unexpected database type: " + databaseType); return DDL; }
public bool UpdateTo_1_4_1_9(GenConnection con, String databaseType) { DDL DDL; int res; res = Version.CompareVersion("1", "4", "1", "9"); if (res >= 0) return false; bool success = true; if (databaseType == "Jet") { DDL = new Jet_DDL(); GlobalSettings.LogMessage("UpdateTo_1_4_1_9", "Updating database structure to suit version 1.4.1.9", LogEntryType.Information); AlterRelation(DDL.Alter_pvoutputlog_1400b, con); AlterRelation(((Jet_DDL)DDL).Alter_pvoutputlog_1400b2, con); } if (success) UpdateVersion("1", "4", "1", "9", con); return success; }