Exemple #1
0
 public static bool AppPoolExists(string Pool)
 {
     if (GetWebServerVersion().Major > MINIMUM_WEBSERVER_MAJOR_VERSION)
     {
         return(WebUtils.IIS7ApplicationPoolExists(Pool));
     }
     else
     {
         return(WebUtils.ApplicationPoolExists(Pool));
     }
 }
        void IUninstallAction.Run(SetupVariables vars)
        {
            try
            {
                var appPoolName = String.Format(AppPoolNameFormatString, vars.ComponentFullName);
                var iisVersion  = vars.IISVersion;
                var iis7        = (iisVersion.Major == 7);
                var poolExists  = false;
                //
                Log.WriteStart(LogStartUninstallMessage);
                //
                vars.WebApplicationPoolName = appPoolName;

                // Maintain backward compatibility
                if (iis7)
                {
                    poolExists = WebUtils.IIS7ApplicationPoolExists(appPoolName);
                }
                else
                {
                    poolExists = WebUtils.ApplicationPoolExists(appPoolName);
                }

                if (!poolExists)
                {
                    Log.WriteInfo(LogUninstallAppPoolNotFoundMessage);
                    return;
                }
                //
                if (iis7)
                {
                    WebUtils.DeleteIIS7ApplicationPool(appPoolName);
                }
                else
                {
                    WebUtils.DeleteApplicationPool(appPoolName);
                }
                //update install log
                InstallLog.AppendLine(String.Format("- Removed application pool named \"{0}\"", appPoolName));
            }
            finally
            {
                //update log
                //Log.WriteEnd(LogEndUninstallMessage);
            }
        }
        void IInstallAction.Run(SetupVariables vars)
        {
            var appPoolName   = String.Format(AppPoolNameFormatString, vars.ComponentFullName);
            var userDomain    = vars.UserDomain;
            var netbiosDomain = userDomain;
            var userName      = vars.UserAccount;
            var userPassword  = vars.UserPassword;
            var identity      = GetWebIdentity(vars);
            var componentId   = vars.ComponentId;
            var iisVersion    = vars.IISVersion;
            var iis7          = (iisVersion.Major == 7);
            var poolExists    = false;

            //
            vars.WebApplicationPoolName = appPoolName;

            // Maintain backward compatibility
            if (iis7)
            {
                poolExists = WebUtils.IIS7ApplicationPoolExists(appPoolName);
            }
            else
            {
                poolExists = WebUtils.ApplicationPoolExists(appPoolName);
            }

            // This flag is the opposite of poolExists flag
            vars.NewWebApplicationPool = !poolExists;

            if (poolExists)
            {
                //update app pool
                Log.WriteStart("Updating application pool");
                Log.WriteInfo(String.Format("Updating application pool \"{0}\"", appPoolName));
                //
                if (iis7)
                {
                    WebUtils.UpdateIIS7ApplicationPool(appPoolName, userName, userPassword);
                }
                else
                {
                    WebUtils.UpdateApplicationPool(appPoolName, userName, userPassword);
                }

                //
                //update log
                Log.WriteEnd("Updated application pool");

                //update install log
                InstallLog.AppendLine(String.Format("- Updated application pool named \"{0}\"", appPoolName));
            }
            else
            {
                // create app pool
                Log.WriteStart("Creating application pool");
                Log.WriteInfo(String.Format("Creating application pool \"{0}\"", appPoolName));
                //
                if (iis7)
                {
                    WebUtils.CreateIIS7ApplicationPool(appPoolName, userName, userPassword);
                }
                else
                {
                    WebUtils.CreateApplicationPool(appPoolName, userName, userPassword);
                }

                //update log
                Log.WriteEnd("Created application pool");

                //update install log
                InstallLog.AppendLine(String.Format("- Created a new application pool named \"{0}\"", appPoolName));
            }
        }