Пример #1
0
        public void File()
        {
            string sql_file_path_relative = "..\\sql\\" + String.Join("_", GenerateColumns().Keys);
            string sql_file_path          = Path.Combine(_settings.MigrationsFolder(), sql_file_path_relative);

            if (!sql_file_path.ToUpperInvariant().EndsWith(".SQL"))
            {
                sql_file_path          += ".sql";
                sql_file_path_relative += ".sql";
            }
            int counter = 0;

            while (_file_writer.FileExists(sql_file_path))  // TODO: This is messy and unreadable, come back and make nice.
            {
                if (counter == 0)
                {
                    sql_file_path          = sql_file_path.Replace(".sql", ++counter + ".sql");
                    sql_file_path_relative = sql_file_path_relative.Replace(".sql", counter + ".sql");
                }
                else
                {
                    sql_file_path          = sql_file_path.Replace(counter++ + ".sql", counter + ".sql");
                    sql_file_path_relative = sql_file_path_relative.Replace((counter - 1) + ".sql", counter + ".sql");
                }
            }
            string  text_path     = sql_file_path_relative.Replace("..\\", "");
            dynamic up            = new { file = sql_file_path_relative };
            dynamic output_object = new { up };

            _file_writer.WriteFile(sql_file_path, "-- Execute SQLFile Migration " + text_path);
            CreateFile("SQLFile_" + String.Join("_", GenerateColumns().Keys), output_object);
            SourceEditor.OpenFileInDefaultEditor(sql_file_path); // open sql file to edit right away.
            Console.WriteLine("Generating Migration " + text_path);
            Console.WriteLine(Helpers.Json(output_object));
        }
Пример #2
0
 public void SetLog(string filePath, LogLevel level)
 {
     lock (_lock)
     {
         if (_fileWriter.FileExists(filePath))
         {
             _fileWriter.DeleteFile(filePath);
         }
         _filePath     = filePath;
         _enabledLevel = level;
     }
 }