public static void OpenSqlFileRetry(this SqlPreCommand command) { SafeConsole.WriteLineColor(ConsoleColor.Yellow, "There are changes!"); var fileName = "Sync {0:dd-MM-yyyy HH_mm_ss}.sql".FormatWith(DateTime.Now); Save(command, fileName); SafeConsole.WriteLineColor(ConsoleColor.DarkYellow, command.PlainSql()); Console.WriteLine("Script saved in: " + Path.Combine(Directory.GetCurrentDirectory(), fileName)); var answer = SafeConsole.AskRetry("Open or run?", "open", "run", "exit"); if (answer == "open") { Thread.Sleep(1000); Open(fileName); if (SafeConsole.Ask("run now?")) { ExecuteRetry(fileName); } } else if (answer == "run") { ExecuteRetry(fileName); } }
public static SqlPreCommand PlainSqlCommand(this SqlPreCommand command) { if (command == null) { return(null); } return(command.PlainSql().SplitNoEmpty("GO\r\n") .Select(s => new SqlPreCommandSimple(s)) .Combine(Spacing.Simple)); }
public static void Save(this SqlPreCommand command, string fileName) { string content = command.PlainSql(); File.WriteAllText(fileName, content, Encoding.GetEncoding(1252)); }