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>
<LogActivity>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
WriteToLogFilebut notRun(). Step 4 says:So instead of your
Run()method, name it something else and set it in theMethodfield of the command in Sitecore.Run()is the method in the DatabaseAgent from Sitecore that runs.