예제 #1
0
        static void Main(string[] args)
        {
            SetupArgs        setupArgs = new SetupArgs();
            DBRampUpProvider setup     = null;

            try
            {
                Parameters parms = Parameters.CreateParameters(setupArgs, args);

                if (parms.IsHelpNeeded)
                {
                    string helpString = "";
                    switch (parms.HelpChars)
                    {
                    case "?":
                        helpString = parms.GetUsageString(Assembly.GetExecutingAssembly(), 10);
                        Console.WriteLine("\nUsage:");
                        Console.WriteLine(helpString);
                        Console.WriteLine("Note: For detailed help, use -??, -h, or -help.");
                        break;

                    case "h":
                    case "help":
                    case "??":
                        helpString = parms.GetDetailedHelp(Assembly.GetExecutingAssembly());
                        Console.WriteLine();
                        Console.WriteLine(helpString);
                        break;
                    }
                    return;
                }
                if (parms.BeenSetCount == 0)
                {
                    // No parameters set at commandline, so display help.
                    // This could mean something else to your program.
                    string helpString = parms.GetUsageString(Assembly.GetExecutingAssembly(), 10);
                    Console.WriteLine("\nUsage:");
                    Console.WriteLine(helpString);
                    Console.WriteLine("Note: For detailed help, use -??, -h, or -help.");
                    Console.ReadLine();
                    return;
                }

                if (setupArgs.Debug)
                {
                    Console.WriteLine("Press enter after you've attached");
                    Console.ReadLine();
                }
                setup = DBRampUpProvider.Instance();
                System.Environment.ExitCode = setup.Execute(setupArgs);
            }
            catch (Exception ex)
            {
                System.Environment.ExitCode = 1;
                Console.WriteLine(ex.ToString());
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            SetupArgs setupArgs = new SetupArgs();
            DBRampUpProvider setup = null;
            try
            {
                Parameters parms = Parameters.CreateParameters(setupArgs, args);

                if (parms.IsHelpNeeded)
                {
                    string helpString = "";
                    switch (parms.HelpChars)
                    {
                        case "?":
                            helpString = parms.GetUsageString(Assembly.GetExecutingAssembly(), 10);
                            Console.WriteLine("\nUsage:");
                            Console.WriteLine(helpString);
                            Console.WriteLine("Note: For detailed help, use -??, -h, or -help.");
                            break;
                        case "h":
                        case "help":
                        case "??":
                            helpString = parms.GetDetailedHelp(Assembly.GetExecutingAssembly());
                            Console.WriteLine();
                            Console.WriteLine(helpString);
                            break;
                    }
                    return;
                }
                if (parms.BeenSetCount == 0)
                {
                    // No parameters set at commandline, so display help.
                    // This could mean something else to your program.
                    string helpString = parms.GetUsageString(Assembly.GetExecutingAssembly(), 10);
                    Console.WriteLine("\nUsage:");
                    Console.WriteLine(helpString);
                    Console.WriteLine("Note: For detailed help, use -??, -h, or -help.");
                    Console.ReadLine();
                    return;
                }

                if (setupArgs.Debug)
                {
                    Console.WriteLine("Press enter after you've attached");
                    Console.ReadLine();
                }
                setup = DBRampUpProvider.Instance();
                System.Environment.ExitCode = setup.Execute(setupArgs);

            }
            catch (Exception ex)
            {
                System.Environment.ExitCode = 1;
                Console.WriteLine(ex.ToString());
            }
        }
예제 #3
0
        public virtual int Execute(SetupArgs args)
        {
            try
            {
                // Get the context
                context.SetupArgs = args;
                context.EventHub  = new DBRampUpEventHub();

                // Be the first to attach events to the hub
                context.EventHub.PreserveContent    += new DBRampUpEventHandler(EventHub_PreserveContent);
                context.EventHub.TearDown           += new DBRampUpEventHandler(EventHub_TearDown);
                context.EventHub.BuildDatabase      += new DBRampUpEventHandler(EventHub_BuildDatabase);
                context.EventHub.RestoreContent     += new DBRampUpEventHandler(EventHub_RestoreContent);
                context.EventHub.CustomSiteSettings += new DBRampUpEventHandler(EventHub_CustomSiteSettings);
                context.EventHub.BuildTestData      += new DBRampUpEventHandler(EventHub_BuildTestData);
                context.EventHub.UpdateSql          += new DBRampUpEventHandler(EventHub_UpdateSql);

                // Update the logging state
                DBRampUpLogging.LogToFile = context.SetupArgs.Log;

                // Initialize the site builder provider
                Initialize();

                //Implement a IDBRampUpModule in any of your external assemblies to attach to DBRampUp execution events

                // Find all the site builder extenders and intialize them
                List <IDBRampUpModule> modules = LoadModules(context);

                WriteLine("DBRampUp modules loaded and initialized");

                // Run the post initialize event
                context.EventHub.ExecuteEvent(DBRampUpEventHub.EventPostInitialize, context);

                // See if we are to preserve content
                if (context.SetupArgs.PreserveContent)
                {
                    // Run the preserve content events
                    OnPreserveContent();
                    WriteLine("Content preserved");
                }

                // See if we are to tear down the database
                if (context.SetupArgs.TearDownDB)
                {
                    OnTearDownDB();
                    WriteLine("Database torn down");
                }

                // See if we are to build the database
                if (context.SetupArgs.BuildDB)
                {
                    OnBuildDatabase();
                    WriteLine("Database built");
                }


                if (context.SetupArgs.PreserveContent)
                {
                    OnRestoreContent();
                    WriteLine("Content restored");
                }

                if (context.SetupArgs.CustomSettings)
                {
                    OnCustomSiteSettings();
                    WriteLine("Custom site settings added.");
                }

                if (context.SetupArgs.Test)
                {
                    OnBuildTestData();
                    WriteLine("Test data built.");
                }

                OnExecuteSqlUpdate();

                // Execute the pre-finalize event
                context.EventHub.ExecuteEvent(DBRampUpEventHub.EventPreFinalize, context);

                // Finalize all modules
                foreach (IDBRampUpModule module in modules)
                {
                    module.Finalize(context);
                }

                WriteLine("DBRampUp finalized");
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                return(1);
            }
            finally
            {
                CleanUp();
            }

            return(0);
        }
예제 #4
0
        public virtual int Execute(SetupArgs args)
        {
            try
            {
                // Get the context
                context.SetupArgs = args;
                context.EventHub = new DBRampUpEventHub();

                // Be the first to attach events to the hub
                context.EventHub.PreserveContent += new DBRampUpEventHandler(EventHub_PreserveContent);
                context.EventHub.TearDown += new DBRampUpEventHandler(EventHub_TearDown);
                context.EventHub.BuildDatabase += new DBRampUpEventHandler(EventHub_BuildDatabase);
                context.EventHub.RestoreContent += new DBRampUpEventHandler(EventHub_RestoreContent);
                context.EventHub.CustomSiteSettings += new DBRampUpEventHandler(EventHub_CustomSiteSettings);
                context.EventHub.BuildTestData += new DBRampUpEventHandler(EventHub_BuildTestData);
                context.EventHub.UpdateSql += new DBRampUpEventHandler(EventHub_UpdateSql);

                // Update the logging state
                DBRampUpLogging.LogToFile = context.SetupArgs.Log;

                // Initialize the site builder provider
                Initialize();

                //Implement a IDBRampUpModule in any of your external assemblies to attach to DBRampUp execution events

                // Find all the site builder extenders and intialize them
                List<IDBRampUpModule> modules = LoadModules(context);

                WriteLine("DBRampUp modules loaded and initialized");

                // Run the post initialize event
                context.EventHub.ExecuteEvent(DBRampUpEventHub.EventPostInitialize, context);

                // See if we are to preserve content
                if (context.SetupArgs.PreserveContent)
                {
                    // Run the preserve content events
                    OnPreserveContent();
                    WriteLine("Content preserved");
                }

                // See if we are to tear down the database
                if (context.SetupArgs.TearDownDB)
                {
                    OnTearDownDB();
                    WriteLine("Database torn down");
                }

                // See if we are to build the database
                if (context.SetupArgs.BuildDB)
                {
                    OnBuildDatabase();
                    WriteLine("Database built");
                }

                if (context.SetupArgs.PreserveContent)
                {
                    OnRestoreContent();
                    WriteLine("Content restored");
                }

                if (context.SetupArgs.CustomSettings)
                {
                    OnCustomSiteSettings();
                    WriteLine("Custom site settings added.");
                }

                if (context.SetupArgs.Test)
                {
                    OnBuildTestData();
                    WriteLine("Test data built.");
                }

                OnExecuteSqlUpdate();

                // Execute the pre-finalize event
                context.EventHub.ExecuteEvent(DBRampUpEventHub.EventPreFinalize, context);

                // Finalize all modules
                foreach (IDBRampUpModule module in modules)
                {
                    module.Finalize(context);
                }

                WriteLine("DBRampUp finalized");
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                return 1;
            }
            finally
            {
                CleanUp();
            }

            return 0;
        }