Exporter (0) Imprimer
Développer tout

SPService, classe (Microsoft.SharePoint.Administration)

Windows SharePoint Services 3
Represents a farm-wide service.

Espace de noms : Microsoft.SharePoint.Administration
Assembly : Microsoft.SharePoint (dans microsoft.sharepoint.dll)

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel=true)] 
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel=true)] 
public class SPService : SPPersistedUpgradableObject

To return the parent service of a service instance, use the Service property of the SPServiceInstance class. Use the Services property of the SPFarm class to return an SPServiceCollection object that represents the collection of services on the server farm. Use an indexer to return a single service from the collection. For example, if the collection is assigned to a variable named myServices, use myServices[index] in C#, or myServices(index) in Visual Basic, where index is either the GUID or the name that identifies the service.

The following example iterates through the running jobs of all services on the server farm and modifies the schedule of jobs that failed and that started after a specified date.

SPServiceCollection services = SPFarm.Local.Services;

System.DateTime myDateTime = new DateTime(2007,1,28);

foreach (SPService service in services)
{
   SPRunningJobCollection runningJobs = service.RunningJobs;

   foreach (SPRunningJob runningJob in runningJobs)
   {

      if (runningJob.Status == SPRunningJobStatus.Failed && runningJob.StartTime > myDateTime)
      {
         SPJobDefinition job = runningJob.JobDefinition;
         job.Schedule = SPSchedule.FromString("every 5 minutes between 0 and 59");

         job.Update();
      }
   }
}

Les membres statiques publics de ce type (Shared en Visual Basic) sont sécurisés au niveau des threads. Il n'est pas garanti que les membres d'instance soient sécurisés au niveau des threads.
Afficher:
© 2014 Microsoft