예제 #1
0
파일: Program.cs 프로젝트: locbet/sneal
        private static int Main(string[] args)
        {
            try
            {
                CommandLineParser parser = new CommandLineParser(args);
                parser.RegisterPropertySetter(new ListPropertySetter <DbObjectName>(delegate(string argPart)
                {
                    return(new DbObjectName(argPart));
                }));
                parser.RegisterPropertySetter(new ListPropertySetter <IScriptFile>(delegate(string argPart)
                {
                    return(new ScriptFile(argPart));
                }));

                CmdLineScriptingOptions  scriptOptions      = parser.BuildOptions(new CmdLineScriptingOptions());
                SourceConnectionSettings srcConnSettings    = parser.BuildOptions(new SourceConnectionSettings());
                TargetConnectionSettings targetConnSettings = parser.BuildOptions(new TargetConnectionSettings());

                Log4NetConfigurator.ConfigureLog4Net(scriptOptions.Log4netConfigPath);
#if DEBUG
                Log4NetConfigurator.SetLevel(Log, "DEBUG");
#endif

                if (scriptOptions.ShowHelp || args.Length == 0)
                {
                    ShowUsage(scriptOptions, srcConnSettings, targetConnSettings);
                    return(Success);
                }

                MigrationConsole app = new MigrationConsole();
                return(app.Run(scriptOptions, srcConnSettings, targetConnSettings));
            }
            catch (SqlMigrationException ex)
            {
                Log.Error(ex.Message);
                Log.Debug(ex);

                return(MigrationError);
            }
            catch (Exception ex)
            {
                Log.Error(ex);

                return(UnknownError);
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: locbet/sneal
        private static void ShowUsage(
            CmdLineScriptingOptions scriptOptions,
            SourceConnectionSettings srcConnSettings,
            TargetConnectionSettings targetConnSettings)
        {
            using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                       "Sneal.SqlMigration.Console.Usage.txt"))
            {
                using (StreamReader reader = new StreamReader(s))
                {
                    Log.Info(reader.ReadToEnd());
                }
            }

            PrintUsageLines(scriptOptions);
            PrintUsageLines(srcConnSettings);
            PrintUsageLines(targetConnSettings);
        }
예제 #3
0
        public int Run(CmdLineScriptingOptions scriptingOptions, IConnectionSettings srcConnSettings,
                       IConnectionSettings targetConnSettings)
        {
            MigrationEngine engine = new MigrationEngine(new SqlServerScriptBuilder());

            engine.MessageManager = messageMgr;

            if (string.IsNullOrEmpty(targetConnSettings.Database) && scriptingOptions.ExecutorScripts.Count == 0)
            {
                engine.Script(srcConnSettings, scriptingOptions);
            }
            else if (scriptingOptions.ExecutorScripts.Count > 0)
            {
                engine.Execute(srcConnSettings, scriptingOptions.ExecutorScripts);
            }
            else if (!string.IsNullOrEmpty(targetConnSettings.Database))
            {
                engine.ScriptDifferences(srcConnSettings, targetConnSettings, scriptingOptions);
            }

            return(0);
        }