Difference between revisions of "Scheduler"

From ADF Docs
Jump to: navigation, search
(Code Update - 2011-09-27)
(Code Update - 2011-09-27)
Line 23: Line 23:
 
Now to access the task information stored within the 'application.ADFscheduler' variable from within your Apps and/or Site code it is a '''best practice''' to call this Scheduler LIB method: application.ADF.scheduler.getSchedulerVars();
 
Now to access the task information stored within the 'application.ADFscheduler' variable from within your Apps and/or Site code it is a '''best practice''' to call this Scheduler LIB method: application.ADF.scheduler.getSchedulerVars();
 
 
<pre>NOTE: Using the getSchedulerVars() method call from within Apps and Site Code will insure
+
<pre>
 +
NOTE: Using the getSchedulerVars() method call from within Apps and Site Code will insure
 
that your code remains compatible even if this variable name changes or is moved in the future.  
 
that your code remains compatible even if this variable name changes or is moved in the future.  
Also this scheduler variable may be included in a common ADF variable scope
+
<!-- Also this scheduler variable may be included in a common ADF variable scope
 
location along with other application level ADF variables that are stored outside of the
 
location along with other application level ADF variables that are stored outside of the
standard 'application.ADF' scope.</pre>  
+
standard 'application.ADF' scope.-->
 +
</pre>  
 
 
 
*It is recommended that you update any App code that uses the Scheduler to reflect these changes before the ADF 1.5 truck code is updated with these updates.
 
*It is recommended that you update any App code that uses the Scheduler to reflect these changes before the ADF 1.5 truck code is updated with these updates.

Revision as of 17:45, 27 September 2011


Attention: Do not change any text in the description, properties, and functions sections.

Return to Library (API)

Code Update - 2011-09-27

!!! IMPORTANT: NEW CODE UPDATE MAY BREAK CURRENT SCHEDULER IMPLEMENTATIONS !!!

Scheduler_1_0 Modifications:

application.schedule:

  1. The variable scope 'application.schedule' has been removed
  2. 'application.schedule' has been replaced with the variable scope 'application.ADFscheduler'

application.ADFscheduler:

  1. The Scheduler LIB now creates a persistent variable name that can be identified as a variable that was created by a component of the ADF.
  2. Reduces the risk of conflicting with other custom code
  3. Added a getSchedulerVars() method

Now to access the task information stored within the 'application.ADFscheduler' variable from within your Apps and/or Site code it is a best practice to call this Scheduler LIB method: application.ADF.scheduler.getSchedulerVars();

NOTE: Using the getSchedulerVars() method call from within Apps and Site Code will insure
that your code remains compatible even if this variable name changes or is moved in the future. 
<!-- Also this scheduler variable may be included in a common ADF variable scope
location along with other application level ADF variables that are stored outside of the
standard 'application.ADF' scope.-->
  • It is recommended that you update any App code that uses the Scheduler to reflect these changes before the ADF 1.5 truck code is updated with these updates.
  • When the ADF 1.5 trunk is updated to include these changes it is also recommended that you update any Customers that use the Scheduler components in Apps or in Site code to reflect these updates.

Usage

The scheduler can be used to call URLS directly or can run commands using ADF.utils.runCommand style arguments.

To schedule a process call the scheduleProcess command with the following arguments:

  • scheduleName - Required - which we use later, if you use a duplicate name the existing schedule gets overriden and stops wherever it was running.
  • commands - Required - Array of URL's or array of structures
    • If using structures the layout looks like so:
scheduleItem = StructNew();
scheduleItem.bean = "csContent";
scheduleItem.method = "populateContent";
scheduleItem.args.elementName = "My Test Element";
scheduleItem.args.data.fieldName = "fieldValue";
  • scheduleParams - Optional - Structure of parameters to override.
scheduleParams = StructNew();//Default Values
scheduleParams.delay = 5; //minutes till next schedule item
scheduleParams.tasksPerBatch = 1; //how many tasks to do per iteration
scheduleParams.scheduleStart = 1; //Where in the command list to start processing
scheduleParams.scheduleStop = ArrayLen(commands); //When to stop processing (say stop at position 11)
  • startProcessNow - Optional - By default the process will run its first step immediately in the current request, for faster response time to the scheduler simply change this value to false.

Now that you have the parameters that you need to know, see an example of a schedule to call http://www.google.com 4 times. You would typically have this hit a URL that does some sort of processing.

commands = ArrayNew(1);
commands[1] = "http://www.google.com";
commands[2] = "http://www.google.com";
commands[3] = "http://www.google.com";
commands[4] = "http://www.google.com";
application.ADF.scheduler.scheduleProcess("Call Google",commands);

We can also have it call a custom function:

commands = ArrayNew(1);
commands[1] = StructNew();
commands[1].bean = "myCustomBean";
commands[1].method = "myCustomMethod";
commands[1].args = StructNew();
commands[1].args.argName1 = "argValue1";
commands[2] = StructNew();
commands[2].bean = "myCustomBean";
commands[2].method = "myCustomMethod";
commands[2].args = StructNew();
commands[2].args.argName1 = "argValue1";
application.ADF.scheduler.scheduleProcess("Call Custom Command",commands);

Now that is all fine and dandy, however, how do you get a response that allows you to monitor the process? Simply add this to your output:

#application.ADF.scheduler.getScheduleHTML("Call Google")#

It will render a progress bar and give you the ability to pause/resume the process.

Description

Properties

Functions