Logi Info includes Process definitions, a special type of definition that lets you create subroutine-like tasks that can include conditional processing, branching, error handling, and other advanced features.
The following topics discuss Process Definitions and Tasks:
- Calling and Completing a Task
- If-Then Branching in a Task
- Setting Variables in a Task
- File System Interactions from a Task
- Exporting from a Task
- Using Local Data in Tasks
- SQL Database Interactions from Tasks
- Running Datalayer and Data Table Rows
- Sending Email from a Task
- Web Service Interactions
- Error Handling in Tasks
About Process Definitions and Tasks
Process definitions are similar to Report definitions and they're created and managed in Logi Studio in the same way. They contain element groups called Tasks, which are created in Logi Studio using elements in a manner similar to creating a Report definition. Unlike Report definitions, tasks run at the web server and don't present anything visual in the browser.
In the file system, Process definition files are physically stored in your application folder, as shown above, in the _Definitions_Processes folder. They're .lgx type files and use the same XML source code found in Report definition files.
In Logi Studio, Process definitions appear in the Application panel listed under the Processes folder, as shown above. You can add a new process definition by selecting and right-clicking the Processes folder and manage them in Studio like any other definition.
Each Process definition file contains one or more tasks. So, you may decide to use multiple Process definition files in your application. You may prefer to put all of your tasks in a single definition file, or to group tasks, by function for example, in separate Process definition files. The choice is to yours; the Logi Server Engine will include all Process definition files when it runs the application.
Tasks are created in a Process definition by adding a Task element to the definition root. The example shown above includes three tasks.
The top-to-bottom order of Task elements in a Process definition does not matter (a suggestion: alphabetical order makes them easier to find). However, within a task the position of its child elements is important because they're processed in a top-to-bottom sequence.
The example above shows some of the elements available for use in a task; they can perform a variety of operations. Some look similar to those used in Report definitions while other are unique to Procedure definitions.
Tasks can accomplish many things that cannot be done in a Report definition. For example,
- Direct interaction with the web server file system (to save, copy, or delete folders and files)
- Conditional processing using If-Then branching of processing flow
- Row-by-row processing of datalayer or Data Table contents
- "Write back" to databases, to insert and update records
- Generic and error-specific error handling (including SQL errors)
- Send email, SMS messages, and Twitter tweets
- Save file uploads and the state of super-elements
- Set and clear client-side cookies
- Create and manage Logi Scheduler tasks
- Terminate server session
and they can do many of the same things, such as exports, plug-in calls, database operations, and more.
When using Logi Security, the Task element's Security Right ID attribute, shown below, provides greater security control over the running of tasks.
The Unsafe Script Allowed attribute, pictured above, controls whether the Procedure.Script element throws an 'Unsafe class reference' error when accessing the file system object. To overcome this error when running a procedure, set the Unsafe Script Allowed attribute to 'True'. For more information about scripting objects and functions, see Scripting.
Tasks are essential to use of the Logi Scheduler: when the Scheduler runs a scheduled event, it calls a Process task, which then runs the desired report and manages its output. For more information about this, see Logi Scheduler.
You can use a Default Request Parameters element in a Process definition, as you would in a Report definition, and you can also use it within individual tasks. For more information, see Using Request Parameters.
Process definitions and tasks extend the capabilities of Logi Info apps in many ways, and provide with tremendous functionality. The remainder of this topic provides examples of some of these capabilities in use.