app pool restart thing out of the way and force dedicated app pool thing that I approved

This commit is contained in:
dev_amdtel 2013-05-03 17:59:19 +04:00
parent 580a898523
commit cfd0b39673
14 changed files with 767 additions and 396 deletions

View file

@ -348,6 +348,91 @@ namespace WebsitePanel.Providers.Web.Iis.WebObjects
return siteState;
}
// AppPool
public void ChangeAppPoolState(string siteId, AppPoolState state)
{
// del
File.AppendAllText(@"c:\websitepanel\test.log", "ChangeAppPoolState " + siteId + " state " + state.ToString() + "\r\n");
using (var srvman = GetServerManager())
{
var site = srvman.Sites[siteId];
//
if (site == null)
return;
string AppPoolName = site.ApplicationDefaults.ApplicationPoolName;
foreach (Application app in site.Applications)
AppPoolName = app.ApplicationPoolName;
if (string.IsNullOrEmpty(AppPoolName))
return;
ApplicationPool pool = srvman.ApplicationPools[AppPoolName];
if (pool == null) return;
//
switch (state)
{
case AppPoolState.Start:
pool.Start();
pool.AutoStart = true;
break;
case AppPoolState.Stop:
pool.Stop();
pool.AutoStart = false;
break;
case AppPoolState.Recycle:
pool.Recycle();
pool.AutoStart = true;
break;
}
//
srvman.CommitChanges();
}
}
public AppPoolState GetAppPoolState(ServerManager srvman, string siteId)
{
Site site = srvman.Sites[siteId];
// ensure website exists
if (site == null)
return AppPoolState.Unknown;
string AppPoolName = site.ApplicationDefaults.ApplicationPoolName;
foreach (Application app in site.Applications)
AppPoolName = app.ApplicationPoolName;
if (string.IsNullOrEmpty(AppPoolName))
return AppPoolState.Unknown;
ApplicationPool pool = srvman.ApplicationPools[AppPoolName];
if (pool == null) return AppPoolState.Unknown;
AppPoolState state = AppPoolState.Unknown;
switch (pool.State)
{
case ObjectState.Started:
state = AppPoolState.Start;
break;
case ObjectState.Starting:
state = AppPoolState.Start;
break;
case ObjectState.Stopped:
state = AppPoolState.Stop;
break;
case ObjectState.Stopping:
state = AppPoolState.Stop;
break;
}
return state;
}
public bool SiteExists(ServerManager srvman, string siteId)
{
return (srvman.Sites[siteId] != null);