protected static bool ExecSqlFile(string tbl) { string TableName = tbl.Replace(SQL_FILE_LOCATION, string.Empty); bool success = false; try { string sql = GetSQLResource(tbl); success = DataSystem.ExecSql(sql); } catch (Exception ex) { Error.WriteError(ex); } return(success); }
public static bool Deploy() { bool success = false; string[] TableList = new string[] { //Tables "TableVersions", "Activity", "Errors", "Menus", "MenuNodes", "MenuAdmins", "MenuNodeAdmins", "Messages", "Modules", "Roles", "SecurityGroups", "Users", "SecurityGroupMemberships", "Settings", "Tabs", "DROP_PROC_UpdateTabDisplayIndex", "CREATE_PROC_UpdateTabDisplayIndex", "TimeZones", "Transactions", "Applications", "DROP_PROC_UpdateApplicationDisplayIndex", "CREATE_PROC_UpdateApplicationDisplayIndex", "ServerEnvironments", "ServerFunctions", "ServerPorts", "ServerStatuses", "ServerTypes", "ServerVersions", "Servers" }; string ErrorList = string.Empty; success = DataSystem.CreateDatabase(); if (success) { foreach (string tbl in TableList) { if (!ExecSqlFile(string.Format("{0}.{1}.sql", SQL_FILE_LOCATION, tbl))) { success = false; ErrorList += string.Format("\\tt_{0}\\n", tbl); } } if (success) { if (!Framework.UpdateVersion()) { success = false; ErrorList += "\\Framework Version\\n"; } } } if (!success) { int Errors = ErrorList.Replace("\\n", "|").Split('|').Length; _ErrorMessage = string.Format("Failed to update database {0}: \\n\\n{1}\\nDelete any existing constraints for {2}\\nand run the configuration utility again.", Errors > 2 ? "tables" : "table", ErrorList, Errors > 2 ? "these tables" : "this table"); } return(success); }