Esempio n. 1
0
        private XmlNode GetFarmApplicationPoolsNode(SPWebServiceCollection webServices)
        {
            XmlNode farmApplicationPoolsNode = FarmXml.CreateElement("FarmApplicationPools");
            int     appPoolCount             = 0;

            foreach (SPWebService webService in webServices)
            {
                foreach (SPApplicationPool appPool in webService.ApplicationPools)
                {
                    appPoolCount++;
                    XmlNode AppPoolNode = FarmXml.CreateElement("FarmApplicationPool");

                    List <AttributeValuePair> appPoolAttributes = SPAttributes.GetSPApplicationPoolAttributes(appPool);
                    foreach (AttributeValuePair appPoolAttribute in appPoolAttributes)
                    {
                        AppPoolNode.Attributes.SetNamedItem(GetXmlAttribute(appPoolAttribute));
                    }

                    farmApplicationPoolsNode.AppendChild(AppPoolNode);
                }
            }
            XmlNode countAttribute = FarmXml.CreateAttribute("Count");

            countAttribute.Value = appPoolCount.ToString();
            farmApplicationPoolsNode.Attributes.SetNamedItem(countAttribute);

            return(farmApplicationPoolsNode);
        }
Esempio n. 2
0
        private XmlNode GetFarmWebApplicationsNode(SPWebServiceCollection webServices)
        {
            XmlNode farmWebApplicationsNode = FarmXml.CreateElement("FarmWebApplications");
            int     webAppCount             = 0;

            foreach (SPWebService webService in webServices)
            {
                foreach (SPWebApplication webApplication in webService.WebApplications)
                {
                    webAppCount++;
                    XmlNode WebAppNode = FarmXml.CreateElement("WebApplication");
                    List <AttributeValuePair> webAppAttributes = SPAttributes.GetSPWebApplicationAttributes(webApplication);
                    foreach (AttributeValuePair webAppAttribute in webAppAttributes)
                    {
                        WebAppNode.Attributes.SetNamedItem(GetXmlAttribute(webAppAttribute));
                    }

                    // Get the Application Pool for the Web Application
                    XmlNode           webAppApplicationPool = FarmXml.CreateElement("ApplicationPool");
                    SPApplicationPool appPool = webApplication.ApplicationPool;

                    List <AttributeValuePair> appPoolAttributes = SPAttributes.GetSPApplicationPoolAttributes(appPool);
                    foreach (AttributeValuePair appPoolAttribute in appPoolAttributes)
                    {
                        webAppApplicationPool.Attributes.SetNamedItem(GetXmlAttribute(appPoolAttribute));
                    }
                    WebAppNode.AppendChild(webAppApplicationPool);

                    // Get the site collections for the Web Application
                    XmlNode siteCollectionsNode = GetSiteCollectionsNode(webApplication.Sites, true);
                    WebAppNode.AppendChild(siteCollectionsNode);

                    // Get the content databases for the web application
                    XmlNode contentDatabasesNode = GetContentDatabasesNode(webApplication.ContentDatabases);
                    WebAppNode.AppendChild(contentDatabasesNode);

                    farmWebApplicationsNode.AppendChild(WebAppNode);
                }
            }
            XmlNode countAttribute = FarmXml.CreateAttribute("Count");

            countAttribute.Value = webAppCount.ToString();
            farmWebApplicationsNode.Attributes.SetNamedItem(countAttribute);

            return(farmWebApplicationsNode);
        }