我有一个计时器作业,我正在尝试在特定服务器上运行此计时器作业,下面是我试图用来比较服务器名称和在FeatureActivated事件上创建计时器作业实例的代码。我不知道该怎么做。如果我完全错了,请帮助我并纠正我。
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
// Get an instance of the SharePoint farm.
//SPFarm farm = SPFarm.Local;
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
// Remove job if it exists.
DeleteJobAndSettings(webApp);
var serverName = SPServer.Local.DisplayName;
if (string.Equals("sp2013", serverName, StringComparison.OrdinalIgnoreCase))
{
// Create the job.
MyReportNew job = new MyReportNew(webApp, SPServer.Local);
//Other code
}
}
答案 0 :(得分:1)