Script Condition
A Script Condition is a condition that executes a script. The result of the script determines whether the condition is satisfied.
Use a Script Condition to provide your own condition checks when none of the condition types provided with adTempus meets your needs.
For example, you want a job to execute only if a specified file contains certain text. The adTempus File Condition can detect the presence of the file but does not read its contents. Using a Script Condition you can create a script (using a scripting language like VB.NET) that looks for the file and then checks it for the required text.
Script Implementation Guidelines
Your condition script performs whatever processing is necessary to determine whether the condition is met, and then returns either a True (condition met) or False (condition not met) result to adTempus.
Waiting/Polling
All adTempus conditions, including the Script Condition, work on the principle of polling: each condition is checked repeatedly at an interval until it is met or the wait time limit expires. Therefore if your script determines that the condition is not met, it should return False to adTempus. adTempus will run your script again when the polling interval elapses, at which point the script should repeat the check.
Your script should not do any waiting itself. For example, suppose your script is making a call to a web service to see if remote processing has completed. Your script should not wait/loop if it finds that remote processing is not complete. Instead it should return immediately and allow adTempus to call it again when the polling interval elapses.
State Persistence
If your script needs to keep track of information between calls, you can do this using Job Variables. Any variables your script sets will be available the next time the script is called.
For example, the following VB.NET code fragment shows how to use a Job Variable named "CallCount" to track how many times the script has been called for the current job instance:
Dim callCount As Integer = 1 Dim variable As IJobVariable variable=adTempus.JobVariables.GetVariable("CallCount") If variable Is Nothing Then 'script hasn't been called before 'create the variable and set it to 1 variable=adTempus.JobVariables.Add("CallCount") variable.IntegerValue=1 Else 'get the previous value and increment it callCount=variable.IntegerValue.GetValueOrDefault() + 1 variable.IntegerValue=callCount End If
Reporting Additional Status Information
The Conditions page of the Instance Details window shows the status of each condition for the job or step ("Satisfied," "Waiting," etc.) and can also display an additional message about the status. Your script can specify the message to be displayed here by calling the SetConditionStatus method that is exposed by your script's base class:
For example, if your script determines that the condition is not yet met, it can set a status message indicating why (e.g., "Remote processing has not completed.")
The status is only updated when your script returns control to adTempus (the status is not updated immediately when you call the method). Therefore your script cannot report more than one status messages during a single execution of the script.