This document is a guide for developers to the Schedule Task of GrandNode.
Schedule Task engine enables to run chosen piece of code every predetermined time.
For example, you can send sales raport to chosen e-mail every 2 weeks.
During plugin installation, insert directly to IRepository<ScheduleTask> new record.
You can copy values of ScheduleTask Properties from CodeFirstInstallationService.
Most essential Property is Type, it is used to identify the Type, and has 2 parts seprated by comma.
The first part is a full path of task class.
The second part is a name of plugin itself
Your task class needs inherit from ScheduleTask class and IScheduleTask interface
Inside Execute() you can write any code you wish.
Execute() should call Service object, but it is not necessarily (it depends on what you want to do).
If you want to use other application Services, you should implement new Service, so integration with application infrastructure will be easygoing.
Example Service can contain Method named with prefix “Task_”. By using registered in Autofac Service, you can access any other Service in application, what is pretty convenient and elegant architecture sugar.
I have set the task to run every one minute. As we can see, our task runs properly.
Remember that you need to restart application after any change in ScheduleTask registry.
It is because all tasks are registered basing on records stored in database, shortly after application run by FluentScheduler library (https://www.nuget.org/packages/FluentScheduler/) and any further change in these records doesn’t change the values inside FluentScheduler registry.
FluentScheduler runs task on non-main thread, so even huge task shouldn’t burden the application.