Automate the reporting layer updates

Executive Dashboard comes with two Python scripts used to automate the update process for the reporting layers. These scripts update the incident features and stats information in a previously published service. Create a copy of these scripts for each performance indicator you'd like to schedule to updated automatically and store these copies in separate folders. Do not change the names of either script.

The following scripts must exist in the same directory:

indicator_constants.py The configuration file containing all the parameters required to configure the scripts to process your data.
executive_dashboard.py The main script that processes the incident data and updates the service.

Configure the scripts

The configuration file for this script uses Python. Python is case sensitive and has specific requirements for file paths. When using a file path in Python, it must be enclosed in quotation marks and one of the following strategies must be used:

  • Each \ character must be substituted with \\. For example, "C:\\arcgisserver\\directories\\arcgiscache".
  • Each \ character must be substituted with /. For example, "C:/arcgisserver/directories/arcgiscache".
  • The entire file path must be preceded by the letter r. For example, r"C:\arcgisserver\directories\arcgiscache".

To configure the scripts to update the Executive Dashboard services, complete the following steps:

  1. In Windows Explorer, browse to Application\ExecutiveReportingScript and open the script in a Python editor.
  2. Define the parameters required to update your PerformanceIndicator service. Some parameters are only required for services hosted in ArcGIS Online or Portal for ArcGIS, and others are only required for services published with ArcGIS for Server.
    org_url URL of the organization hosting the layers. This value is only required for services hosted in ArcGIS Online or Portal.
    org_username Username for an account in the organization with administrative access to the PerformanceIndicators layer. This value is only required for services hosted in ArcGIS Online or Portal.
    org_password Password for the username provided above.
    ags_username Username for accessing secured ArcGIS server services. Leave blank if service is unsecured.
    ags_password Password corresponding to the username listed above for accessign secured ArcGIS server services. Leave blank if service is unsecured.
    ags_token_url URL for generating tokens to access secured ArcGIS Server services. For example, http://gisserver.domain.com:6080/arcgis/tokens/generateToken. Leave blank is service is unsecured.Password corresponding to the username listed above for accessign secured ArcGIS server services. Leave blank if service is unsecured.
    map_id The GUID found in the URL of the map used to present this indicator. For example, 1234ab5cd6e78f90g1234h56ijk7l890.
    data_service_type Specify if the data service was published using ArcGIS Online (AGOL), Portal for ArcGIS (Portal), or ArcGIS for Server (Server).
    data_layer_name The name of the data layer in the map. For example, AnimalControl, Potholes, or StreetLights.
    date_field Field in the data layer containing the date of the incident or report. For example, REQUESTDATE.
    auto_update_date_query Currently, date filters on the map layers show only values from within a defined date range. To update the query to reflect the current reporting period, set this value to True. This will update the range of values in the query to show features with date values between the current date and the starting date of the reporting period, calculated from the next two parameter values.
    report_duration Value in the units of the next parameter used to calculate the start of the current reporting period.
    report_time_unit Unit of time used to calculate the starting date of the reporting period. Valid values are minutes, hours, days, and weeks. For example, if your reporting period is every 4 weeks, set the value of report_duration to 4 and the value of report_time_unit to weeks.
    stats_service_type Specify if the stats service was published using ArcGIS Online (AGOL), Portal for ArcGIS (Portal), or ArcGIS for Server (Server).
    stats_layer_name The name of the stats layer in the map. For example, AnimalControlStats, PotholeStats, or StreetLightStats.
  3. Optionally, update the field names to match the fields found in your stats layer using the parameters at the bottom of indicator_constants.py.

Schedule updates

The reporting layer updates can be scheduled using Windows Task Scheduler. The datasets, map documents, and services must exist before the scripts can run.

Multiple performance indicators cannot be updated at the same time. To avoid editing conflicts, consider one of the following strategies:

  • Schedule the updates with sufficient time in between for the first one to finish updating before the second one begins.
  • Task Scheduler 2.0, available at Windows 7, offers the ability to schedule sequential tasks so when one update is completed, the next begins.

To schedule updates to the reporting layers, complete the following steps:

  1. Open the Task Scheduler on the computer containing the data and scripts.
  2. Click Action > Create Task and name your task.
  3. Click the Action tab and click New.
  4. Set Action to Start a Program.
  5. Browse to the location of your Python installation (for example, <default directory>\Python27\ArcGIS10.2\python.exe).
  6. In the Add arguments text box, type the name of the script (executive_dashboard.py).
  7. In the Start in text box type the path to the folder where your script is and click OK.
  8. To schedule sequential tasks using Task Scheduler 2.0, click New on the Actions tab and repeat steps 5 through 8.
  9. Click the Trigger tab > New and set a schedule for your task.
  10. Click OK. When the trigger occurs, the scripts will begin updating the reporting layers.
Top