Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesConfigure Schedule Item on Module InstallConfigure Schedule Item on Module Install
Previous
 
Next
New Post
10/19/2015 4:59 AM
 
Hi All

 

I'm currently developing a module which requires some background processing.  I was wondering what the recommended approach was for configuring a Scheduled task upon installing an extension package.

 

I know I can install the job manually through Host > Schedule, I'm more looking for a way to do this through the [MODULENAME].dnn package file or something similar.

 

Thanks in advance.

 

Chris

 

 
New Post
10/19/2015 7:24 AM
 

Chris,

I do it this way (in the IUpgradeable interface implementation, in the business controller class):

      public string UpgradeModule(string version)
      {
         if (version == "3.0.0") // Put your version number here - the one you are upgrading to
         {
            // Create Scheduler Task
            try
            {
               ScheduleItem si = SchedulingProvider.Instance().GetSchedule("my.DNN.Module.Scheduler, My_Module", String.Empty);
               if (si == null)
               {
                  si = new ScheduleItem();
                  si.CatchUpEnabled = false;
                  si.Enabled = true;
                  si.NextStart = DateTime.Now.AddMinutes(4);
                  si.RetainHistoryNum = 100;
                  si.RetryTimeLapse = 5;
                  si.RetryTimeLapseMeasurement = "m";
                  si.ScheduleSource = ScheduleSource.NOT_SET;
                  si.TimeLapse = 7;
                  si.TimeLapseMeasurement = "d";
                  si.TypeFullName = "my.DNN.Module.Scheduler";
                  si.FriendlyName = "Short description of what the task is doing";
                  SchedulingProvider.Instance().AddSchedule(si);
               }
            }
            catch (Exception ex)
            {
               Exceptions.LogException(ex);
            }
         }
         return String.Format("Upgrading to version {0}", version);
      }

Consider my.DNN.Module.Scheduler is the class name of the scheduled task, and My_Module is the module's friendly name. Hope it helps!

Happy DNNing!
Michael


Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
10/20/2015 7:20 PM
 
Thanks Michael!
 
New Post
10/21/2015 11:55 AM
 

Chris,

you're welcome. Hope this was helpful.

Happy DNNing!
Michael


Michael Tobisch
DNN★MVP
dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
10/21/2015 10:42 PM
 

Hi Michael

I've followed your advice unfortunately the task never appears in the Scheduler.  Here is my dnn package file section with installer code in that class below. 

 

    ...

 

<components>
        <component type="ResourceFile">
          <resourceFiles>
            <basePath>DesktopModules/Module1</basePath>
            <resourceFile>
              <name>Resources.zip</name>
            </resourceFile>
          </resourceFiles>
        </component>

        <component type="Module">
          <desktopModule>
            <moduleName>Module1</moduleName>
            <foldername>Module1</foldername>
            <businessControllerClass>Module1.Components.FeatureController,Module1</businessControllerClass>

 

   ...
 

 

namespace Module1.Components
{

 

public class FeatureController : IUpgradeable
{
public string UpgradeModule(string Version)
{           
            try
            {
                ScheduleItem si = SchedulingProvider.Instance().GetSchedule($"{typeof(BackgroundTask).FullName}, {nameof(Module1)}", string.Empty);

                if (si == null)
                {
                    si = new ScheduleItem();
                    si.CatchUpEnabled = false;
                    si.Enabled = true;
                    si.NextStart = DateTime.Now.AddMinutes(5);
                    si.RetainHistoryNum = 10;
                    si.RetryTimeLapse = 5;
                    si.RetryTimeLapseMeasurement = "m";
                    si.ScheduleSource = ScheduleSource.NOT_SET;
                    si.TimeLapse = 7;
                    si.TimeLapseMeasurement = "d";
                    si.Servers = string.Empty;
                    si.TypeFullName = typeof(BackgroundTask).FullName;
                    si.FriendlyName = "Module1 Task";

                    SchedulingProvider.Instance().AddSchedule(si);
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
            return $"Upgrading to version: {Version}";
}
}

 

}

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesConfigure Schedule Item on Module InstallConfigure Schedule Item on Module Install


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2017 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out