Schedued tasks are not executing in sitefinity 8.1
Hi,
I am using Scheduling API to create a "crontab" task. The problem is that the code is never executed.
From I sitefinity custom widget (inherits SimpleView) I am creating scheduled task with execution time after 5 mins:
Widget Code:
private void TheButton_Click(object sender, EventArgs e) RssFeedScheduledTask theRssTask = new RssFeedScheduledTask(); theRssTask.ExecuteTime = DateTime.UtcNow.AddMinutes(5); theRssTask.Title = "RssFeedScheduledTask"; theRssTask.Description = "Crontab tab"; theRssTask.ScheduleSpec = "5 * * * * *"; theRssTask.ScheduleSpecType = "crontab"; theRssTask.IsRecurring = true; this.scheduleManager.AddTask(theRssTask); //SchedulingManager.RescheduleNextRun(); this.scheduleManager.SaveChanges(); this.BindRepeater();
The scheduled task code:
public class RssFeedScheduledTask : ScheduledTask private const string TaskKey = "F5C8088A-992D-4969-ABC7-5C1AE4B9EB78"; private const string TaskNameText = "RssFeedTask9"; public RssFeedScheduledTask() this.Key = TaskKey; public override void ExecuteTask() var newsManager = NewsManager.GetManager(); var newsItem = newsManager.CreateNewsItem(); newsItem.Title = "Scheduled task"; newsItem.Description = "Scheduled task description"; newsItem.Content = "Scheduled task Content"; newsItem.DateCreated = DateTime.UtcNow; newsItem.LastModified = DateTime.UtcNow; newsItem.PublicationDate = DateTime.UtcNow; newsItem.UrlName = "scheduled-task"; newsManager.RecompileAndValidateUrls(newsItem); newsManager.SaveChanges(); var bag = new Dictionary<string, string>(); bag.Add("ContentType", typeof(NewsItem).FullName); WorkflowManager.MessageWorkflow(newsItem.Id, typeof(NewsItem), null, "Publish", false, bag); public override string TaskName get return TaskNameText; protected override bool CanReschedule() return true;
The sf_scheduled_tasks table in database
type_of_schedule: crontab
title: RssFeedScheduledTask
task_name: RssFeedTask9
task_data
subscr_lst_id: 00000000-0000-0000-0000-000000000000
status_message: NULL
status: 1
schedule_data: 5 * * * * *
progress: 0
last_modified: 2017-10-20 12:23:02.733
last_executed_time: NULL
language: NULL
ky: 9197E787-5596-6A35-BC85-FF000067CA56
is_running: 1
is_recurring : 0
instance_name: NULL
id: 9197E787-5596-6A35-BC85-FF000067CA56
execute_time: 2017-10-20 12:22:56.730
enabled: 1
description: "Crontab tab"
application_name: /Scheduling
voa_version: 2
Docs: docs.sitefinity.com/.../for-developers-scheduled-tasks
Articles: www.sitefinity.com/.../how-do-i-create-a-reoccuring-scheduled-task
and I've read other knowledgebase articles - didn't help.
Sitefinity version 8.1.5824.0
The issues that I've detected so far:
Why the ExecuteTask() is never executed ?
Any help is appreciated.
I have experience with Scheduling API is another SF project 9.2 Version and it works with no problems.