More in this section
Forums / Developing with Sitefinity / Schedued tasks are not executing in sitefinity 8.1

Schedued tasks are not executing in sitefinity 8.1

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Mihail
    Mihail avatar
    0 posts
    Registered:
    15 Feb 2016
    20 Oct 2017
    Link to this post

    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: https://docs.sitefinity.com/81/for-developers-scheduled-tasks

    Articles: https://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/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:

    • The method ExecuteTask() of my task is never executed
    • After the execution date-time passed, the "IsRunning" is true and the "status" is started
    • The task isn't rescheduled for next time

    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.

     

     

     

1 posts, 0 answered