예제 #1
0
        private static void Exit(string message = null, int code = 0)
        {
            if (message != null)
            {
                if (code == 0)
                {
                    Log.Info(message);
                }
                else
                {
                    Log.Error(message);
                }
            }

            if (!Settings.Silent)
            {
                // If the Debugger is Attached or there was an error
                // make sure the user has time to read the messages.
                if (Debugger.IsAttached || code != 0)
                {
                    Console.WriteLine(@"Press enter to continue...");
                    Console.ReadLine();
                }
            }
            else
            {
                // Restore the Console so we don't strand a window in the background.
                WindowsInterop.ShowConsole();
            }

            Environment.Exit(code);
        }
예제 #2
0
        /// <summary>
        /// Process the incoming arguments
        /// </summary>
        private static void ProcessArguments(Dictionary <string, string> arguments)
        {
            // Load Settings
            Settings.LoadFromArguments(arguments);

            // Set the Context Connection Strings
            ContextConnectionStringManager.SetupDefaultConnections(Settings.Target);

            // Silent mode will hide the console window.
            if (Settings.Silent)
            {
                WindowsInterop.HideConsole();
                Log.Info("Running Silent");
            }

            // Make sure we have proper options to continue.
            var validTarget         = !string.IsNullOrWhiteSpace(Settings.Target);
            var validApplication    = !string.IsNullOrWhiteSpace(Settings.AppPoolIdentity);
            var validImplementation = !string.IsNullOrWhiteSpace(Settings.Implementation);

            if (!validTarget)
            {
                Exit("Invalid target.", 1);
            }
            if (!validApplication)
            {
                Exit("Application is required.", 1);
            }
            if (!validImplementation)
            {
                Exit("Implementation is required.", 1);   // Is it? (yes for the Meta)
            }
            // Log Current Settings
            Settings.LogCurrentValues();

            // If we are dropping databases ask to make sure.
            if (!Settings.Silent && Settings.Reinstall)
            {
                Log.Info("");
                Log.Info(@"Reinstalling will drop any existing databases.");

                // Console Interaction
                Console.Write(@"Are you sure you want to continue? (y/n): _");
                Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
                var answer = Console.ReadLine();
                if (answer != null &&
                    !string.Equals(answer.Trim(), "y", StringComparison.InvariantCultureIgnoreCase))
                {
                    Exit("Installation was aborted!");
                }
            }
        }