A specific example where I have used agents, was to schedule a custom class which synced data into Sitecore from a third party system.
Defining the Sitecore Agent
In your web.config file, locate the /configuration/sitecore/scheduling/ section, here you will notice several agent items. Insert a new agent into this section as follows:
<agent type="MyProject.Jobs.DataSync" method="DoSync" interval="06:00:00" />In this example, the DoSync method of the MyProject.Jobs.DataSync class will run every 6 hours.
Defining the class
The example class for the above agent would look like follows:
namespace MyProject.Jobs { public class DataSync { public void DoSync() { // code goes here } } }
Using parameters
It's also possible to pass parameters into the class you are calling, this would be done using the following example.
<agent type="MyProject.Jobs.DataSync" method="DoSync" interval="06:00:00">
<param>Test Value</param>
</agent>
namespace MyProject.Jobs { public string param {get; set;} public class DataSync { public void DoSync() { // code goes here } } }
No comments:
Post a Comment