Пример #1
0
        /// <summary>
        /// Checks that MSMQ is installed, configured correctly, and started, and if not
        /// takes the necessary corrective actions to make it so.
        /// </summary>
        public static bool StartMsmqIfNecessary()
        {
            Console.WriteLine("Entering StartMsmqIfNecessary in NServiceBus.Setup.Windows.Msmq.MsmqSetup");

            if (!InstallMsmqIfNecessary())
            {
                return(false);
            }

            try
            {
                using (var controller = new ServiceController("MSMQ"))
                {
                    if (IsStopped(controller))
                    {
                        ProcessUtil.ChangeServiceStatus(controller, ServiceControllerStatus.Running, controller.Start);
                    }
                }
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("MSMQ windows service not found! You may need to reboot after MSMQ has been installed.");
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Checks that the MSDTC service is running and configured correctly, and if not
        /// takes the necessary corrective actions to make it so.
        /// </summary>
        public static void StartDtcIfNecessary()
        {
            if (DoesSecurityConfigurationRequireRestart(true))
            {
                ProcessUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Stopped, Controller.Stop);
            }

            ProcessUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Running, Controller.Start);
        }
Пример #3
0
        /// <summary>
        /// Checks that MSMQ is installed, configured correctly, and started, and if not
        /// takes the necessary corrective actions to make it so.
        /// </summary>
        public static bool StartMsmqIfNecessary(bool allowReinstall = false)
        {
            if (!InstallMsmqIfNecessary(allowReinstall))
            {
                return(false);
            }

            var controller = new ServiceController {
                ServiceName = "MSMQ", MachineName = "."
            };

            if (IsStopped(controller))
            {
                ProcessUtil.ChangeServiceStatus(controller, ServiceControllerStatus.Running, controller.Start);
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Checks that the MSDTC service is running and configured correctly, and if not
        /// takes the necessary corrective actions to make it so.
        /// </summary>
        public static bool StartDtcIfNecessary(bool allowReconfiguration = false)
        {
            if (DoesSecurityConfigurationRequireRestart(allowReconfiguration))
            {
                if (!allowReconfiguration)
                {
                    return(false);
                }

                ProcessUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Stopped, Controller.Stop);
            }

            if (!allowReconfiguration && Controller.Status != ServiceControllerStatus.Running)
            {
                Console.Out.WriteLine("MSDTC isn't currently running and needs to be started");
                return(false);
            }

            ProcessUtil.ChangeServiceStatus(Controller, ServiceControllerStatus.Running, Controller.Start);

            return(true);
        }