private static int Main(string[] args) { try { // // Check input parameters. // if (args.Length == 0) { PrintHelp(); return(1); } string command = args[0]; if (string.Compare(command, "addnonsplitobjects", true) == 0) { if (args.Length != 2) { PrintHelp(); return(1); } string productionDatabaseName = args[1]; AddNonSplitObjects(productionDatabaseName); } else if (string.Compare(command, "generatebackup", true) == 0) { GenerateBackup(); } else if (string.Compare(command, "generateupdate", true) == 0) { if (args.Length != 2) { PrintHelp(); return(1); } string productionDatabaseName = args[1]; var dbEngine = new DatabaseEngine(); //dbEngine.CreateBackup("ConfirmitCATI", @"C:\_Grigoriy\ConfirmitCATI.bak"); //dbEngine.CreateDatabaseFromBackupFile("ConfirmitCATI", @"c:\_Grigoriy\UpdateDatabaseProject\ConfirmitCATI for Restore.bak"); //dbEngine.CreateDatabaseFromBackupFile("PtBvDb1", @"c:\_Grigoriy\PtBvDb1_10"); if (dbEngine.IsDatabaseExists(Configuration.Default.DefaultDatabaseName) == false) { Console.WriteLine( "Default database {0} does not exists or access denied", Configuration.Default.DefaultDatabaseName); return(1); } ConsoleKeyInfo key; if (productionDatabaseName == "*") { // // Update all databases by name pattern mode. // if (Configuration.Default.IsTestModeEnabled) { Console.WriteLine( "Test mode cannot be used with '*' as database name."); return(1); } } else { // // Update single database mode. // if (Configuration.Default.IsTestModeEnabled) { Console.WriteLine( "UpdateDatabase.exe started in the test mode.\r\n" + "Test mode drops and creates production database ({0}) from the backup file.\r\n" + "Are you sure you want use test mode and drop database {0}?\r\n" + "Press Y to continue or N to exit", productionDatabaseName); key = Console.ReadKey(); if ((key.KeyChar != 'y') && (key.KeyChar != 'Y')) { return(1); } Console.WriteLine(); } if (dbEngine.IsDatabaseExists(productionDatabaseName) == false) { Console.WriteLine( "Database {0} does not exists or access denied", productionDatabaseName); return(1); } } // if (productionDatabaseName == "*") var confirmation = new StringBuilder(); confirmation.Append( "Following databases will be updated, are you sure?\r\n" + "Press Y to continue or N to exit\r\n"); foreach (string databaseFoUpdate in dbEngine.GetDatabasesForUpgrade(productionDatabaseName)) { confirmation.AppendFormat("* {0}\r\n", databaseFoUpdate); } Console.Write(confirmation.ToString()); key = Console.ReadKey(); if ((key.KeyChar != 'y') && (key.KeyChar != 'Y')) { return(1); } Console.WriteLine(); if (Configuration.Default.UpdateDefaultDatabaseBackup) { Console.Write( "\r\n" + "Database utility will update default database backup file. " + "So you don't need update it manually. " + "All newly created instances will use new, updated database.\r\n" + "Default database name: {0}\r\n" + "Default database backup file path: {1}\r\n" + "\r\n" + "Please check settings are correct.\r\n" + "If something is wrong press N, correct configuration file and restart utility.\r\n" + "\r\n" + "Would you like to continue?\r\n" + "Press Y to continue or N to exit\r\n", Configuration.Default.DefaultDatabaseName, Configuration.Default.DefaultDatabaseBackupFilePath); key = Console.ReadKey(); if ((key.KeyChar != 'y') && (key.KeyChar != 'Y')) { return(1); } Console.WriteLine(); } else { Console.Write( "\r\n" + "Default database name: {0}\r\n" + "\r\n" + "Please check settings are correct.\r\n" + "If something is wrong press N, correct configuration file and restart utility.\r\n" + "\r\n" + "Would you like to continue?\r\n" + "Press Y to continue or N to exit\r\n", Configuration.Default.DefaultDatabaseName); key = Console.ReadKey(); if ((key.KeyChar != 'y') && (key.KeyChar != 'Y')) { return(1); } Console.WriteLine(); } GenerateUpdate(productionDatabaseName); } else { Console.WriteLine("Unknown command {0}", command); PrintHelp(); return(1); } return(0); } catch (Exception ex) { Trace.TraceError( ex.ToString()); return(1); } }