ConfigurationTask Scheduler

Task Scheduler

Sana Commerce 8.1
Your provider

Task Scheduler Configuration

The scheduled tasks are configured in the 'sanaCommerce' configuration section of the backoffice 'web.config' file:

<tasks taskStateConnectionStringName="LocalSqlServer">
   <task name="TaskTaskScheduler1"
      type="Sana.Commerce.Tasks.TestTask, Sana.Commerce.Tasks.TaskScheduler"
      interval="10"
      enabled="true"
    allowManualStart="true"
    sortNumber="1"
/>
   <task name="TaskTaskScheduler2"
       type="Sana.Commerce.Tasks.TestTask, Sana.Commerce.Tasks.TaskScheduler"
       time="15:02"
       enabled="true"
    allowManualStart="true"
    sortNumber="2"
/>
   <task name="KeepAliveTask"
       type="Sana.Commerce.Tasks.KeepAliveTask, Sana.Commerce.Tasks.TaskScheduler"
       interval="600"
       enabled="false"
       testURL="~/KeepAlive.aspx"
    allowManualStart="false"
    sortNumber="3"
/>
</tasks>

To create a new task:

Step 1: Copy the *.dll file of a task in the backoffice 'Bin' folder.

Step 2: Add the new task to the 'web.config' file. 

Every task is configured individually. The following parameters can be set for the task (all of them are required):

  • name: the name of the task. Note: The task name should be unique for every task;
  • type: the name of a class which implements the ITask interface;
  • time/interval: advanced scheduling allows a task to be performed daily at a fixed time or every X seconds. The type of activity depends on the type of the variable specified for a task:

    For fixed time: time="15:02"
    For interval: interval="600"

    For fixed time the daytime of a server is used. The interval is set in seconds and specifies the period after which the task will be performed again.

  • enabled: activates or deactivates the task;
  • allowManualStart: this parameter is 'true' by default and it specifies that the task can be started manually in the backoffice;
  • sortNumber: the sort order in which the scheduled tasks are arranged in the backoffice.

The scheduled tasks support the 'keep alive' mechanism that periodically sends the request to the backoffice to keep the connection between the scheduled tasks and the backoffice.

The 'keep alive' mechanism will not run automatically, if the IIS has been restarted. It will run only after the first request to the webshop.

The 'keep alive' task has the additional parameter 'testURL' that specifies the target page for sending a request.

The name 'KeepAliveTask' is used in the scheduled tasks so it cannot be changed for the 'keep alive' task.

Logging is configured in the 'loggingConfiguration' section of the backoffice 'web.config' file. For the scheduled tasks the 'logging in a log file' method is used. You can read about it in the 'Enable logging' chapter.

ConfigurationTask Scheduler