Beispiel #1
0
        public static Dictionary <string, WebAllInfo> GetAllWebInfoDict()
        {
            MetaBaseSave();
            XmlDocument doc = new XmlDocument();

            doc.Load(Comm.MetaBasePath());
            XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);

            xnm.AddNamespace("mxh", "urn:microsoft-catalog:XML_Metabase_V64_0");
            string Default_AppPoolId = doc.SelectSingleNode("/mxh:configuration/mxh:MBProperty/mxh:IIsWebService", xnm).Attributes["AppPoolId"].Value;

            XmlNodeList IIsWebServer     = doc.SelectNodes("/mxh:configuration/mxh:MBProperty/mxh:IIsWebServer", xnm);
            XmlNodeList IIsWebVirtualDir = doc.SelectNodes("/mxh:configuration/mxh:MBProperty/mxh:IIsWebVirtualDir", xnm);

            Dictionary <string, WebAllInfo> _WebAllInfo = new Dictionary <string, WebAllInfo>();

            foreach (XmlNode item in IIsWebServer)
            {
                Match m = Regex.Match(item.Attributes["Location"].Value, "/LM/W3SVC/(\\d+)", RegexOptions.IgnoreCase);
                if (!m.Success)
                {
                    continue;
                }
                string Id = m.Groups[1].Value;

                WebAllInfo info = new WebAllInfo();
                info.Id              = Convert.ToInt32(Id);
                info.Web             = item.Attributes["ServerComment"].Value;
                info.ServerAutoStart = item.Attributes["ServerAutoStart"] == null ? true : Convert.ToBoolean(item.Attributes["ServerAutoStart"].Value);
                info.ServerBindings  = item.Attributes["ServerBindings"].Value.Replace("\r\n", ",");
                _WebAllInfo.Add(Id, info);
            }

            foreach (XmlNode item in IIsWebVirtualDir)
            {
                Match m = Regex.Match(item.Attributes["Location"].Value, "/LM/W3SVC/(\\d+)/root", RegexOptions.IgnoreCase);
                if (!m.Success)
                {
                    continue;
                }
                string Id = m.Groups[1].Value;

                _WebAllInfo[Id].AppPoolId = item.Attributes["AppPoolId"] == null ? Default_AppPoolId : item.Attributes["AppPoolId"].Value;
                _WebAllInfo[Id].Path      = item.Attributes["Path"].Value;
            }
            return(_WebAllInfo);
        }
Beispiel #2
0
        public static Dictionary<string, WebAllInfo> GetAllWebInfoDict()
        {
            MetaBaseSave();
            XmlDocument doc = new XmlDocument();
            doc.Load(Comm.MetaBasePath());
            XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);
            xnm.AddNamespace("mxh", "urn:microsoft-catalog:XML_Metabase_V64_0");
            string Default_AppPoolId = doc.SelectSingleNode("/mxh:configuration/mxh:MBProperty/mxh:IIsWebService", xnm).Attributes["AppPoolId"].Value;

            XmlNodeList IIsWebServer = doc.SelectNodes("/mxh:configuration/mxh:MBProperty/mxh:IIsWebServer", xnm);
            XmlNodeList IIsWebVirtualDir = doc.SelectNodes("/mxh:configuration/mxh:MBProperty/mxh:IIsWebVirtualDir", xnm);

            Dictionary<string, WebAllInfo> _WebAllInfo = new Dictionary<string, WebAllInfo>();

            foreach (XmlNode item in IIsWebServer)
            {
                Match m = Regex.Match(item.Attributes["Location"].Value, "/LM/W3SVC/(\\d+)", RegexOptions.IgnoreCase);
                if (!m.Success)
                {
                    continue;
                }
                string Id = m.Groups[1].Value;

                WebAllInfo info = new WebAllInfo();
                info.Id = Convert.ToInt32(Id);
                info.Web = item.Attributes["ServerComment"].Value;
                info.ServerAutoStart = item.Attributes["ServerAutoStart"] == null ? true : Convert.ToBoolean(item.Attributes["ServerAutoStart"].Value);
                info.ServerBindings = item.Attributes["ServerBindings"].Value.Replace("\r\n", ",");
                _WebAllInfo.Add(Id, info);
            }

            foreach (XmlNode item in IIsWebVirtualDir)
            {
                Match m = Regex.Match(item.Attributes["Location"].Value, "/LM/W3SVC/(\\d+)/root", RegexOptions.IgnoreCase);
                if (!m.Success)
                {
                    continue;
                }
                string Id = m.Groups[1].Value;

                _WebAllInfo[Id].AppPoolId = item.Attributes["AppPoolId"] == null ? Default_AppPoolId : item.Attributes["AppPoolId"].Value;
                _WebAllInfo[Id].Path = item.Attributes["Path"].Value;

            }
            return _WebAllInfo;
        }