With Apps you can build and manage your own scripted extensions for the VehicleTracker application.
To be able to create Apps, you need to enable _EditScriptApp privilege. If you previously enabled Click Scripts or Web Service Scripts and had privileges for editing them enabled, you will have the _EditScriptApp privilege enabled automatically after the upgrade. Otherwise, follow these steps:
- Login to SiteAdmin.
- Go to Applications tab. Click Search and Manage.
- Click on the application for which you want to enable Apps.
- In Privileges and Roles section, under ScriptApp, check _EditScriptApp, _EditClickScript and _EditWebServiceScript privileges and click Save.
- Login to Vehicle Tracker Application. From the main menu, go to Admin>Roles.
- In Roles window, click on the role for which you want to enable Apps.
- Under Privileges, enable Apps in the same way you did for the application.
After this, a new App Builder menu option will be available in the Admin menu of the VehicleTracker application. Clicking it will take you to a list of existing Apps. If you previously used Click Scripts or Web Service Scripts, you will notice that the old “Click Script” and “Web Service Script” menu options are gone. Instead, an App has been created for each of the existing scripts. Otherwise, this list will be empty.
Click on Add new App to create a new App. Click on an entry in the list to edit an existing App.
Specify a name for the App and assign some roles to it. These roles determine which actions are permitted to the Click Scripts in this App.
Click Save to save the App and move on to adding scripts to it. Apps for old Click / Web Service Scripts will have one script in the corresponding list. These scripts will run as before. Creating a new App with a single script allows you to work with Click / Web Service Scripts as before. Apps make these scripts easier to manage by enabling you to group the scripts by functionality. If several scripts are needed to achieve a specific goal, they can be created in the same App. Scripts in the same App may also interact. You can see how in the following example.
In this example, we want to send a particular command to a particular group of users once per day.
Let us assume that the command is named “HelloCommand” and the relevant users are in a Tag called “Relevant Users”.
First we will create an App called “ExampleApp” and assign it _Administrator role.
Now add a Click Script named SendCommandOnTimer. Choose Timer kind, and specify the time of the first run. If hours/minutes/seconds fields are left at 0, this script will run once per day at the specified time.
Edit the script to:Now save the script and we’re done - at 5 PM, the script will send a command to all connected devices.
You can export Apps separately, too, by using the Export context menu option of the App.
Import them via “Import Template” option in VehicleTracker. An App will be exported together with all the objects required by the script definitions. For example, if you create a Notifier Click Script, the Event Rule that it is connected to will be exported as well. Any objects that are not automatically included, yet are needed for the scripts in the App to function correctly (such as ‘RelevantUsers’ tag accessed from a script in the example above) can be manually added to the App in the References section.
Enable Logging at Runtime
You may also log to a file with the log function and logging of errors from Click Scripts at runtime by editing the NLog.config file in the IIS folder under the GpsGate Server installation folder (if you are not hosting your own server, you may contact support for access to files). Under <targets>, you should add a new target entry like this: where TARGET_NAME is an unique name for the file target and FILE_NAME is the name of the log file you wish to be created with full path to the file. Under <rules>, add an entry like this: where NAME_OF_CLICK_SCRIPT is the name of the click script which you want logged to the file, and TARGET_NAME is the unique name of the target you added above. Errors and data logged through log method in that Click Script will then be written to the specified file.
Discuss this blog post on the forum please