Exemplo n.º 1
0
        /// <summary>
        /// Restart IIS on all messaging servers in BizTalk group.
        /// </summary>
        /// <returns>Returns the result of execution as string.</returns>
        public static string RestartIIS()
        {
            StringBuilder sb = new StringBuilder();
            int           result;

            foreach (string computerName in GlobalProperties.MessagingServers)
            {
                try
                {
                    result = IIsWebService.Restart(computerName);
                    if (result == 0)
                    {
                        sb.Append(String.Format("IISRestart done with code :{0} for computer {1}", result, computerName) + Environment.NewLine);
                    }
                    else
                    {
                        sb.Append(String.Format("IISRestart done with error, code :{0} for computer {1}. Please verify and restart manually if required. Or re-run the action again.", result, computerName) + Environment.NewLine);
                    }
                }
                catch (Exception exe)
                {
                    sb.Append(String.Format("WMI method error for computer {0}: {1}", computerName, exe.Message) + Environment.NewLine);
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Restart IIS on specified machine.
        /// </summary>
        /// <param name="computerName">Server on which to restart IIS.</param>
        /// <returns>Returns the result of execution as string.</returns>
        public static bool RestartIIS(string computerName, out string message)
        {
            bool result = false;

            try
            {
                result = IIsWebService.Restart2(computerName, out message);
            }
            catch (Exception exe)
            {
                message = (String.Format("Error for computer {0}: {1}", computerName, exe.Message) + Environment.NewLine);
            }
            return(result);
        }