LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

C#取得iis站点子站点和应用程序池的信息

admin
2018年9月8日 15:46 本文热度 5231
/// <summary>
/// 获取当前IIS站点列表
/// </summary>
/// <returns></returns>
public static List<IISStationInfo> GetLocalIISStations()
{
    List<IISStationInfo> re = new List<IISStationInfo>();
    string entPath = "IIS://localhost/w3svc";
    DirectoryEntry ent = new DirectoryEntry(entPath);
    foreach (DirectoryEntry child in ent.Children)
    {
        if (child.SchemaClassName == "IIsWebServer")
        {
            IISStationInfo item = new IISStationInfo();
            item.ID = child.Name;
            item.Name = child.Properties["ServerComment"].Value.ToString();
            DirectoryEntry root = new DirectoryEntry(entPath + "/" + item.ID + "/ROOT");
            item.Path = root.Properties["Path"].Value.ToString();
            item.AppList = new List<IISAppInfo>(16);
            foreach (DirectoryEntry app in root.Children)
            {
                if (app.SchemaClassName == "IIsWebVirtualDir")
                {
                    IISAppInfo appitem = new IISAppInfo();
                    appitem.Name = app.Name;
                    appitem.ID = app.NativeGuid;
                    appitem.Path = app.Properties["Path"].Value.ToString();
                    appitem.AppName = app.Properties["AppPoolId"].Value.ToString();
                    item.AppList.Add(appitem);
                }
            }
            re.Add(item);
        }
    }
    return re;
}
/// <summary>
/// IIS站点数据封装
/// </summary>
public class IISStationInfo
{
 /// <summary>
 /// 站点名
 /// </summary>
 public string Name { get; set; }
 /// <summary>
 /// 站点指定路径
 /// </summary>
 public string Path { get; set; }
 /// <summary>
 /// 站点标识符
 /// </summary>
 public string ID { get; set; }
 /// <summary>
 /// 站点包含的应用程序,虚拟路径等
 /// </summary>
 public List<IISAppInfo> AppList { get; set; }
}
/// <summary>
/// IIS应用程序子站点数据封装
/// </summary>
public class IISAppInfo
{
 /// <summary>
 /// 站点
 /// </summary>
 public string Name { get; set; }
 /// <summary>
 /// 站点的制定路径
 /// </summary>
 public string Path { get; set; }
 /// <summary>
 /// 站点的站点标识符
 /// </summary>
 public string ID { get; set; }
 /// <summary>
 /// 站点的应用程序名称
 /// </summary>
 public string AppName { get; set; }
}

该文章在 2018/9/8 15:46:34 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved