private void Refresh_ManagedPaths()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPServiceCollection services = SPFarm.Local.Services;

                GridPanel panel = new GridPanel();
                IList <SPManagedPathEntity> list = new List <SPManagedPathEntity>();

                foreach (SPService service in services)
                {
                    if (service is SPWebService)
                    {
                        SPWebService webservice = (SPWebService)service;

                        foreach (SPWebApplication webapp in webservice.WebApplications)
                        {
                            foreach (SPPrefix p in webapp.Prefixes)
                            {
                                list.Add(new SPManagedPathEntity(p)
                                {
                                    ParentWebApplication = webapp.DisplayName
                                });
                            }
                        }
                    }
                }

                panel.Title          = "Managed Paths";
                panel.GridColumns    = GridColumns_ManagedPaths;
                panel.GridDataSource = list;

                AddPanel(panel);
            });
        }
        private void Refresh_ContentDatabases()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPServiceCollection services = SPFarm.Local.Services;

                GridPanel panel = new GridPanel();
                IList <SPContentDatabaseEntity> list = new List <SPContentDatabaseEntity>();

                foreach (SPService service in services)
                {
                    if (service is SPWebService)
                    {
                        SPWebService webservice = (SPWebService)service;

                        foreach (SPWebApplication webapp in webservice.WebApplications)
                        {
                            foreach (SPContentDatabase cd in webapp.ContentDatabases)
                            {
                                list.Add(new SPContentDatabaseEntity(cd));
                            }
                        }
                    }
                }

                panel.Title          = "Content Databases";
                panel.GridColumns    = GridColumns_ContentDatabases;
                panel.GridDataSource = list;

                AddPanel(panel);
            });
        }
Пример #3
0
        private XmlNode GetFarmServicesNode(SPServiceCollection farmServices, XmlNode farmServicesNode)
        {
            XmlNode countAttribute = FarmXml.CreateAttribute("Count");

            countAttribute.Value = farmServices.Count.ToString();
            farmServicesNode.Attributes.SetNamedItem(countAttribute);

            foreach (SPService service in farmServices)
            {
                XmlNode serviceNode = FarmXml.CreateElement("FarmService");

                List <AttributeValuePair> serviceAttributes = SPAttributes.GetSPServiceAttributes(service);
                foreach (AttributeValuePair serviceAttribute in serviceAttributes)
                {
                    serviceNode.Attributes.SetNamedItem(GetXmlAttribute(serviceAttribute));
                }

                // Get the service's Job Definitions if it has any
                SPJobDefinitionCollection serviceJobDefinitions = service.JobDefinitions;
                serviceNode.AppendChild(GetJobDefinitionsNode(serviceJobDefinitions, "ServiceJobDefinitions"));

                farmServicesNode.AppendChild(serviceNode);
            }

            return(farmServicesNode);
        }
Пример #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //load sitecollections unto list
            lstSiteCollections.Items.Clear();

            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                SPServiceCollection services = SPFarm.Local.Services;
                foreach (SPService curService in services)
                {
                    if (curService is SPWebService)
                    {
                        SPWebService webService = (SPWebService)curService;

                        foreach (SPWebApplication webApp in webService.WebApplications)
                        {
                            foreach (SPSite sc in webApp.Sites)
                            {
                                try
                                {
                                    lstSiteCollections.Items.Add(sc.Url);
                                }
                                catch (Exception ex)
                                {
                                    //Console.WriteLine("Exception occured: {0}\r\n{1}", ex.Message, ex.StackTrace);
                                }
                            }
                        }
                    }
                }
            });

            ChangeToolStripTextInAnotherThread("Ready");
        }
Пример #5
0
        private void Refresh_Sites()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPServiceCollection services = SPFarm.Local.Services;

                foreach (SPService service in services)
                {
                    if (service is SPWebService)
                    {
                        SPWebService webservice = (SPWebService)service;

                        foreach (SPWebApplication webapp in webservice.WebApplications)
                        {
                            foreach (SPSite sitec in webapp.Sites)
                            {
                                GridPanel panel          = new GridPanel();
                                IList <SPWebEntity> list = new List <SPWebEntity>();

                                foreach (SPWeb web in sitec.AllWebs)
                                {
                                    list.Add(new SPWebEntity(web));
                                }

                                panel.Title          = "Sites under Site Collection " + sitec.HostName + " (" + sitec.Url + ")";
                                panel.GridColumns    = GridColumns_Sites;
                                panel.GridDataSource = list;

                                AddPanel(panel);
                            }
                        }
                    }
                }
            });
        }
Пример #6
0
        public static bool IsJobRunning(SPFarm farm, Guid jobId)
        {
            SPServiceCollection services = farm.Services;

            return
                (services.SelectMany(service => service.RunningJobs.Cast <SPRunningJob>()).Any(
                     job => job.JobDefinitionId.Equals(jobId)));
        }
Пример #7
0
        /// <summary>
        /// Determines whether the specified timer job is currently running (or
        /// scheduled to run).
        /// </summary>
        /// <param name="farm">The farm to check if the job is running on.</param>
        /// <param name="jobTitle">The title of the timer job.</param>
        /// <returns><c>true</c> if the specified timer job is currently running
        /// (or scheduled to run); otherwise <c>false</c>.</returns>
        public static bool IsJobRunning(SPFarm farm, string jobTitle)
        {
            SPServiceCollection services = farm.Services;

            return
                (services.SelectMany(service => service.RunningJobs.Cast <SPRunningJob>()).Any(
                     job => string.Compare(job.JobDefinitionTitle, jobTitle, StringComparison.OrdinalIgnoreCase) == 0));
        }
Пример #8
0
        public static bool IsJobDefined(SPFarm farm, string jobName)
        {
            SPServiceCollection services = farm.Services;

            return
                (services.SelectMany(service => service.JobDefinitions).Any(
                     job => string.Compare(job.Title, jobName, StringComparison.OrdinalIgnoreCase) == 0 ||
                     string.Compare(job.Name, jobName, StringComparison.InvariantCulture) == 0));
        }
        public SPServiceCollectionInstance(ObjectInstance prototype, SPServiceCollection serviceCollection)
            : this(prototype)
        {
            if (serviceCollection == null)
            {
                throw new ArgumentNullException("serviceCollection");
            }

            m_serviceCollection = serviceCollection;
        }
Пример #10
0
        public ServiceCollectionNode(SPFarm farm)
        {
            this.Text = SPMLocalization.GetString("Services_Text");
            this.ToolTipText = SPMLocalization.GetString("Services_ToolTip");
            this.Name = "ServiceCollection";
            this.Tag = farm.Services;
            this.Services = farm.Services;
            this.SPParent = farm;

            int index = Program.Window.Explorer.AddImage(this.ImageUrl());
            this.ImageIndex = index;
            this.SelectedImageIndex = index;

            this.Nodes.Add(new ExplorerNodeBase("Dummy"));
        }
Пример #11
0
        public ServiceCollectionNode(SPFarm farm)
        {
            this.Text        = SPMLocalization.GetString("Services_Text");
            this.ToolTipText = SPMLocalization.GetString("Services_ToolTip");
            this.Name        = "ServiceCollection";
            this.Tag         = farm.Services;
            this.Services    = farm.Services;
            this.SPParent    = farm;

            int index = Program.Window.Explorer.AddImage(this.ImageUrl());

            this.ImageIndex         = index;
            this.SelectedImageIndex = index;

            this.Nodes.Add(new ExplorerNodeBase("Dummy"));
        }
        private static bool IsJobDefined(
            SPFarm farm,
            string jobTitle)
        {
            Debug.Assert(farm != null);
            Debug.Assert(string.IsNullOrEmpty(jobTitle) == false);

            SPServiceCollection services = farm.Services;
            string pattern = "job-webconfig";

            foreach (SPService service in services)
            {
                foreach (SPJobDefinition job in service.JobDefinitions)
                {
                    return(Regex.IsMatch(job.Title, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase));
                }
            }

            return(false);
        }
        /// <summary>
        /// Determines whether the specified timer job is currently running (or
        /// scheduled to run).
        /// </summary>
        /// <param name="farm">The farm to check if the job is running on.</param>
        /// <param name="jobTitle">The title of the timer job.</param>
        /// <returns><c>true</c> if the specified timer job is currently running
        /// (or scheduled to run); otherwise <c>false</c>.</returns>
        public static bool IsJobRunning(
            SPFarm farm,
            string jobTitle)
        {
            Debug.Assert(farm != null);
            Debug.Assert(string.IsNullOrEmpty(jobTitle) == false);

            SPServiceCollection services = farm.Services;
            string pattern = "Web.Config";

            foreach (SPService service in services)
            {
                foreach (SPRunningJob job in service.RunningJobs)
                {
                    return(Regex.IsMatch(job.JobDefinitionTitle, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase));
                }
            }

            return(false);
        }
Пример #14
0
        private void Refresh_Items()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPServiceCollection services = SPFarm.Local.Services;

                foreach (SPService service in services)
                {
                    if (service is SPWebService)
                    {
                        SPWebService webservice = (SPWebService)service;

                        foreach (SPWebApplication webapp in webservice.WebApplications)
                        {
                            foreach (SPSite sitec in webapp.Sites)
                            {
                                foreach (SPWeb web in sitec.AllWebs)
                                {
                                    foreach (SPList l in web.Lists)
                                    {
                                        GridPanel panel           = new GridPanel();
                                        IList <SPItemEntity> list = new List <SPItemEntity>();

                                        foreach (SPListItem item in l.Items)
                                        {
                                            list.Add(new SPItemEntity(item));
                                        }

                                        panel.Title          = "Items under " + GetListOrLibrary(l) + " " + l.Title + " (" + _utility.GetUrl(l) + ")";
                                        panel.GridColumns    = GridColumns_Items;
                                        panel.GridDataSource = list;

                                        AddPanel(panel);
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
Пример #15
0
        public Collection <SPWebApplication> GetAllWebApplications()
        {
            Collection <SPWebApplication> result = new Collection <SPWebApplication>();

            SPServiceCollection services = SPFarm.Local.Services;

            foreach (SPService s in services)
            {
                if (s is SPWebService)
                {
                    SPWebService webService = (SPWebService)s;

                    foreach (SPWebApplication webApp in webService.WebApplications)
                    {
                        result.Add(webApp);
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Determines whether the specified timer job is currently running (or
        /// scheduled to run).
        /// </summary>
        /// <param name="farm">The farm to check if the job is running on.</param>
        /// <param name="jobTitle">The title of the timer job.</param>
        /// <returns><c>true</c> if the specified timer job is currently running
        /// (or scheduled to run); otherwise <c>false</c>.</returns>
        private static bool IsJobRunning(
            SPFarm farm,
            string jobTitle)
        {
            SPServiceCollection services = farm.Services;

            foreach (SPService service in services)
            {
                foreach (SPRunningJob job in service.RunningJobs)
                {
                    if (string.Compare(
                            job.JobDefinitionTitle,
                            jobTitle,
                            StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        private void Refresh_UserSolutions()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPServiceCollection services = SPFarm.Local.Services;
                GridPanel panel = new GridPanel();
                IList <SPUserSolutionEntity> list = new List <SPUserSolutionEntity>();

                foreach (SPService service in services)
                {
                    if (service is SPWebService)
                    {
                        SPWebService webservice = (SPWebService)service;

                        foreach (SPWebApplication webapp in webservice.WebApplications)
                        {
                            foreach (SPSite sitec in webapp.Sites)
                            {
                                foreach (SPUserSolution s in sitec.Solutions)
                                {
                                    list.Add(new SPUserSolutionEntity(s)
                                    {
                                        DeployedSiteCollectionUrl = _utility.GetUrl(sitec)
                                    });
                                }
                            }
                        }
                    }
                }

                panel.Title          = "User Solutions";
                panel.GridColumns    = GridColumns_UserSolutions;
                panel.GridDataSource = list;

                AddPanel(panel);
            });
        }