Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
        }