SPRunningJob 类
速率为每台服务器一个正在执行的作业的每个实例创建一个正在运行的作业对象。
继承层次结构
System.Object
Microsoft.SharePoint.Administration.SPRunningJob
命名空间: Microsoft.SharePoint.Administration
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public NotInheritable Class SPRunningJob
用法
Dim instance As SPRunningJob
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public sealed class SPRunningJob
备注
如果活动服务器场中的至少一台服务器上正在运行的作业,则将它标记为活动。
从正在运行的作业表中删除成功完成一次性作业。也将删除其作业定义。
示例
下面的代码示例循环访问SharePoint Foundation场来显示每个作业当前正在运行的每个服务的信息服务。对于SPRunningJob对象,所有的编程交互是使用属性 ;有方法允许实施者与SPRunningJob对象的特定实例进行交互的SPRunningJobCollection对象中可用。
[C#]
SPFarm farm = SPFarm.Local.Farm;
SPServiceCollection services = SPFarm.Local.Services;
int rand_job;
Guid jobdefid;
SPRunningJob rj;
string servername;
string svc_name = string.Empty;
foreach (SPService service in services) {
SPRunningJobCollection runningJobs = service.RunningJobs;
if (runningJobs.Count > 0) {
if (svc_name == string.Empty) {
svc_name = service.Name;
}
Console.WriteLine("****Job Collection Count is " + runningJobs.Count);
Console.WriteLine("****Job Collection Parent is " + runningJobs.Parent);
Console.WriteLine("****Job Collection Service is " + runningJobs.Service);
Console.WriteLine("****Job Collection Web App is " + runningJobs.WebApplication);
// For the GetInstance method, save off job information at random
rand_job = runningJobs.Count / 2;
Console.WriteLine("****Collection member " + rand_job + " is " + runningJobs[rand_job].JobDefinition);
jobdefid = runningJobs[rand_job].JobDefinitionId;
servername = runningJobs[rand_job].ServerName;
}
else {
jobdefid = Guid.Empty;
servername = null;
}
foreach (SPRunningJob runningJob in runningJobs) {
Console.WriteLine("****Job Definition is " + runningJob.JobDefinition);
Console.WriteLine("****Job Id is " + runningJob.JobDefinitionId);
Console.WriteLine("****Job Title is " + runningJob.JobDefinitionTitle);
Console.WriteLine("****Parent is " + runningJob.Parent);
Console.WriteLine("****Percentage Done is " + runningJob.PercentageDone);
Console.WriteLine("****Server Name is " + runningJob.ServerName);
Console.WriteLine("****Service Id is " + runningJob.ServiceId);
Console.WriteLine("****Start Time is " + runningJob.StartTime);
Console.WriteLine("****Status is " + runningJob.Status);
Console.WriteLine("****Web App Id is " + runningJob.WebApplicationId);
Console.WriteLine("****");
}
if (jobdefid != Guid.Empty) {
// random jobdef from collection
// getinstance method
rj = runningJobs.GetInstance(jobdefid, servername);
Console.WriteLine("*@@* Job Definition is " + rj.JobDefinition);
Console.WriteLine("*@@* Job Id is " + rj.JobDefinitionId);
Console.WriteLine("*@@* Job Title is " + rj.JobDefinitionTitle);
}
}
线程安全性
该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。
另请参阅
引用
Microsoft.SharePoint.Administration 命名空间
其他资源
创建 Windows SharePoint Services 3.0 中的自定义的计时器作业