Categories

Task Plugin

1 Introduction

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.

2 Necessary Changes

During plugin installation, insert directly to IRepository<ScheduleTask> new record.
You can copy values of ScheduleTask Properties from CodeFirstInstallationService.

step1

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.
Grand.Plugin.Task.EBay.Tasks.EBayTaskUpdateStock

step2

step3

The second part is a name of plugin itself
Grand.Plugin.Task.EBay

step4

3 Extra Feature

Your task class needs inherit from ScheduleTask class and IScheduleTask interface

Inside Execute() you can write any code you wish.

step5

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.

step6

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.

step7

I have set the task to run every one minute. As we can see, our task runs properly.

step8

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.

back to top