C# 操作IIS
2017-11-01 17:47
183 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Web.Administration;
namespace NetBrain.Utility
{
public class IIS_Parser
{
public static string GetIISPoolEnabel32BitApp(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
return pool.Enable32BitAppOnWin64.ToString();
}
else
{
return "false";
}
}
public static string GetIISPoolQueueLen(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
return pool.QueueLength.ToString();
}
else
{
return "false";
}
}
public static string GetIISPoolIdentity(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
return pool.ProcessModel.IdentityType.ToString();
}
else
{
return "false";
}
}
public static string GetIISPoolRegularTimeInterval(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
string PPTT = pool.Recycling.PeriodicRestart.Time.TotalMinutes.ToString();
return PPTT;
}
else
{
return "false";
}
}
public static string GetIISAttribute(string attributeName, string poolName)
{
string value = null;
switch (attributeName)
{
case "Identity":
value = IIS_Parser.GetIISPoolIdentity(poolName);
break;
case "Queue Length":
value = IIS_Parser.GetIISPoolQueueLen(poolName);
break;
case "Enable 32-Bits Applicantions":
value = IIS_Parser.GetIISPoolEnabel32BitApp(poolName);
break;
case "Regular Time Interval(minutes)":
value = IIS_Parser.GetIISPoolRegularTimeInterval(poolName);
break;
}
if (value.Equals("false"))
{
LogUtility.Information("BAT_logResult", string.Format("Coding Error Get IIS pool {1} attribute {2} value Fail!!!", poolName, attributeName));
}
return value;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Web.Administration;
namespace NetBrain.Utility
{
public class IIS_Parser
{
public static string GetIISPoolEnabel32BitApp(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
return pool.Enable32BitAppOnWin64.ToString();
}
else
{
return "false";
}
}
public static string GetIISPoolQueueLen(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
return pool.QueueLength.ToString();
}
else
{
return "false";
}
}
public static string GetIISPoolIdentity(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
return pool.ProcessModel.IdentityType.ToString();
}
else
{
return "false";
}
}
public static string GetIISPoolRegularTimeInterval(string PoolName)
{
ServerManager manager = new ServerManager();
ApplicationPool pool = manager.ApplicationPools[PoolName];
if (pool != null)
{
string PPTT = pool.Recycling.PeriodicRestart.Time.TotalMinutes.ToString();
return PPTT;
}
else
{
return "false";
}
}
public static string GetIISAttribute(string attributeName, string poolName)
{
string value = null;
switch (attributeName)
{
case "Identity":
value = IIS_Parser.GetIISPoolIdentity(poolName);
break;
case "Queue Length":
value = IIS_Parser.GetIISPoolQueueLen(poolName);
break;
case "Enable 32-Bits Applicantions":
value = IIS_Parser.GetIISPoolEnabel32BitApp(poolName);
break;
case "Regular Time Interval(minutes)":
value = IIS_Parser.GetIISPoolRegularTimeInterval(poolName);
break;
}
if (value.Equals("false"))
{
LogUtility.Information("BAT_logResult", string.Format("Coding Error Get IIS pool {1} attribute {2} value Fail!!!", poolName, attributeName));
}
return value;
}
}
}
相关文章推荐
- C#操作IIS方法集合
- C# 操作IIS方法集合
- 在Asp.net中操作IIS的虚拟目录(C#)
- C#操作IIS完整解析
- C#操作IIS的代码
- C# 操作IIS方法集合
- C# 操作IIS方法集合
- C#操作IIS完整解析
- c#操作IIS之IISHelper
- C#操作IIS完整解析
- C#使用DirectoryEntry操作IIS创建网站和虚拟路径
- C#操作IIS站点 Microsoft.Web.Administration.dll
- C#操作IIS
- 关于C#操作IIS问题
- 用C#操作IIS创建虚拟目录和网站
- c#操作IIS站点
- C#操作IIS创建应用程序池出现异常:无效索引(Exception from HRESULT:0x80070585)
- C# 操作IIS方法集合
- 在Asp.net中操作IIS的虚拟目录(C#)
- C#操作IIS站点 Microsoft.Web.Administration.dll