/// <summary> /// Process IIS websites. /// </summary> private static void ProcessWebsites(Models.Site site, bool up) { foreach (var websiteName in site.Websites) { var iisWebsite = ServerManager.Sites[websiteName]; if (iisWebsite == null) { continue; } // Start the website. if (up) { if (!new[] { ObjectState.Started, ObjectState.Starting }.Contains(iisWebsite.State)) { Log.InfoFormat("Starting Website '{0}'", iisWebsite.Name); iisWebsite.Start(); } else { Log.InfoFormat("Website '{0}' is already {1}.", iisWebsite.Name, iisWebsite.State); } } else { // Stop the website. if (!new[] { ObjectState.Stopping, ObjectState.Stopped }.Contains(iisWebsite.State)) { Log.InfoFormat("Stopping Website '{0}'", iisWebsite.Name); iisWebsite.Stop(); } else { Log.InfoFormat("Website '{0}' is already {1}.", iisWebsite.Name, iisWebsite.State); } } } }