Developer forum

Forum » Development » RE: Scheduled tasks - Dw 8.3.1.9

RE: Scheduled tasks - Dw 8.3.1.9

Marco Santos
Reply

Hello.

I am having some trouble with scheduled tasks and since this is the first time I am trying to do this I might be missing something. So this is my setup at the minute:

I have a ScheduledTask class, derived from BaseScheduledTaskAddIn . This does not do much at the moment, it just runs an update statement on the database and returns true, if no exceptions are raised. Otherwise it will return false.

I tried adding a scheduled task from the Dw interface, but I am unable to since the add button is disabled. Also tried impersonation and it fails. So I went ahead and created a record in the database in the ScheduleTask table and it shows up in the task list. In this record I set the task assembly to "eBooking", and also set the namespace and the task name (among other things). Also, although It does not save the values for the task, when I edit the details for the task I can see that my task is selected.

However, the task is not run. Neither periodically not if I start it with Run now. Any ideias? Is this related to the fact that I cannot create/edit tasks?

Marco


Replies

 
Morten Bengtson
Reply
This post has been marked as an answer

"If the tasks you have created are not runnning, you may need special security permissions."

http://manual.dynamicweb-cms.com/Dynamicweb-On-line-Manual/Management-Center/System/Scheduled-tasks.aspx

Also, see the thread here: http://developer.dynamicweb-cms.com/forum/development/scheduled-tasks-on-custom-solution.aspx

So, if you just provide correct credentials in Impersonation > Custom credentials before adding the task then it should work. Specify the credentials of an administrator on the server, not an administrator in DW.

Here is a very basic scheduled task add-in that you can use for testing...

namespace ScheduledTaskTest
{
    using System;

    using Dynamicweb;
    using Dynamicweb.Extensibility;
    using Dynamicweb.Extensibility.Editors;
    using Dynamicweb.Extensibility.ScheduledTaskAddins;

    [AddInName("ScheduledTaskTest"), AddInLabel("ScheduledTaskTest"), AddInDescription("Example scheduled task add-in"), AddInIgnore(false), AddInActive(true)]
    public class ExampleScheduledTaskAddin : BaseScheduledTaskAddIn
    {
        [AddInParameter("Test parameter"), AddInParameterEditor(typeof(TextParameterEditor), "inputClass=NewUIinput;")]
        public string TestParameter { get; set; }        

        public override bool Run()
        {
            var success = false;

            try
            {
                // do something
                LogToFile.Log(TestParameter, "ScheduledTaskTest", LogToFile.LogType.ManyEntriesPerFile);

                success = true;
            }
            catch (Exception ex)
            {
                LogToFile.Log(ex.ToString(), "ScheduledTaskTest", LogToFile.LogType.ManyEntriesPerFile);
            }

            return success;
        }
    }
}

 

/Morten

Votes for this answer: 1
 
Morten Bengtson
Reply

 

You must be logged in to post in the forum