开发者

Sitecore Scheduling Parameters

Problem

I'm currently trying to setup a Sitecore scheduled task in the database using Schedules and Commands.

So far I've followed http://sdn.sitecore.net/FAQ/Administration/Scheduled%20tasks.aspx for most of what I've needed. Their method uses:public void WriteToLogFile(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduledItem). I'm assuming that is the items passed in the schedule item, the command item itself, and the schedule item itself.

I have a run function which follows the same syntax: protected void run(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduleditem). I've recieveing an exception as it runs in my logs though. Linked is the exception stack: http://pastie.org/1847345, but here is the nested exception:

Exception: System.NullReferenceException 
Message: Object reference not set to an instance of an object. 
Source: fhservices at fhservices.twitterPull.run(Item[] itemArray, CommandItem commandItem, ScheduleItem scheduleditem)

I've tried a few different combinations of parameters to accept with no luck.

Scheduling web.config Section:

 <scheduling>
  <!-- Time between checking for scheduled tasks waiting to execute -->
  <frequency>00:01:00</frequency>
  <!-- Agent to process schedules embedded as items in a database -->
  <agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:02:00">
    <param desc="database">core</param>
    <param desc="schedule root">/sitecore/system/tasks/schedules</param>
    <L开发者_Go百科ogActivity>true</LogActivity>
  </agent>
 ...

Would anyone know the parameters that sitecore sends with methods which are invoked through this method of starting jobs?


According to the snippet you linked to on the SDN, I think you create your own method, similar to WriteToLogFile but not Run(). Step 4 says:

Fill in the necessary fields:

Type: CustomScheduleTasks.Task1, CustomScheduleTasks

Method: WriteToLogFile

The Type indicates the namespace and assembly file. The Method indicates the method to call on the specified class.

Your command is now ready for use as a scheduled task.

So instead of your Run() method, name it something else and set it in the Method field of the command in Sitecore. Run() is the method in the DatabaseAgent from Sitecore that runs.


It looks like your task is actually running. The exception doesn't mention anything about not being able to find your method and the exception comes from your tasks method. Try setting a breakpoint inside the method and checking what object is null.

Just for reference, the parameters passed to a scheduled task are the items specified in the items field of the command, the command definition item and the schedule definition item.


Well... your method definition says "run", little r. But in web.config you've got Run, big R. Sitecore is using .Net reflection here to find the method, so it will be case-sensitive.

I have my scheduled tasks set up in System/Tasks rather than web.config. Works like a charm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜