【问题标题】:My custom sharepoint 2010 Timer job not running我的自定义 sharepoint 2010 计时器作业未运行
【发布时间】:2015-09-10 04:08:28
【问题描述】:

我创建了一个自定义计时器服务来创建一个列表。它使用 FeatureActivated 事件在几分钟内安排。我可以在全球范围内部署该解决方案。但是我的计时器作业没有运行。它显示上次运行时间不适用。有什么解决办法吗?

我的执行方法

    public override void Execute(Guid targetInstanceId)
    {
        ClientContext clientContext = new ClientContext("http://mymachine:0909");
        Web site = clientContext.Web;

        ListCreationInformation listCreationInfo = new ListCreationInformation();
        listCreationInfo.Title = "Test Mailer List";
        listCreationInfo.TemplateType = (int)ListTemplateType.GenericList;
        List list = site.Lists.Add(listCreationInfo);

        Field field1 = list.Fields.AddFieldAsXml(
                  @"<Field Type='Choice'
                  DisplayName='Category'
                  Format='Dropdown'>
             <Default>Specification</Default>
             <CHOICES>
               <CHOICE>Specification</CHOICE>
               <CHOICE>Development</CHOICE>
               <CHOICE>Test</CHOICE>
               <CHOICE>Documentation</CHOICE>
             </CHOICES>
           </Field>", true, AddFieldOptions.DefaultValue);
        Field field2 = list.Fields.AddFieldAsXml(
            @"<Field Type='Number'
                  DisplayName='Estimate'/>", true, AddFieldOptions.DefaultValue);
        clientContext.ExecuteQuery();
    }

和事件接收类

public class Feature1EventReceiver : SPFeatureReceiver
{


    public const string jobName = "BdayTimer";
    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
        DeleteJob(webApp.JobDefinitions);
        TimerJobTest myJob = new TimerJobTest(webApp);

        SPMinuteSchedule schedule = new SPMinuteSchedule();
        schedule.BeginSecond = 0;
        schedule.EndSecond = 59;
        schedule.Interval = 1;

        myJob.Schedule = schedule;
        myJob.Update();

    }


    // Uncomment the method below to handle the event raised before a feature is deactivated.

    public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
    {
        SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
        DeleteJob(webApp.JobDefinitions);
    }

    public void DeleteJob(SPJobDefinitionCollection job1)
    {
        foreach (SPJobDefinition job in job1)
        {
            if (job.Name.Equals(jobName))
                job.Delete();
        }
    }

【问题讨论】:

  • 你有没有得到这个工作?我也有同样的问题。

标签: c# sharepoint sharepoint-2010 sharepoint-timer-job


【解决方案1】:

部署 SharePoint 项目时,应始终重新启动 sptimer 进程。尝试进入命令提示符(具有管理员权限)并输入:

net stop sptimerv4

然后

net start sptimerv4

您的代码现在应该可以正常工作了。

【讨论】:

  • @user1805285 您是否确保在重置sptimer 之前首先部署您的代码?
  • 是的。我先部署了,然后重启了定时器服务。
  • @user1805285 嗯...那么您的代码可能有问题
  • 它在另一台服务器上工作正常。我不知道这里有什么问题。
【解决方案2】:

重置Internet Information Services 上的Central Administration Pool。看来工作被卡住了。重置池后,一切都重新开始工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多