Loading the Config


Overview

Rather than hardcoding the values for all the variables needed for a process, it is often best practice to define them all up front, in a config file. That way they are easier to find and update. To make it even easier, the config file in the DU Template is an Excel spreadsheet, Data\Config.xlsx. Let’s just open it now and see its structure.

There are about 150 settings in this file, under 6 different tabs. But let’s take it slowly, and learn about each setting as it is used in the template.

Loading Config In A Nutshell
  • Call Read Config File Workflow passing in Excel config file path and sheet names
  • All settings returned in dictionary argument except 2 numerical values
Workflow 0: Read Config File
In Arguments
ArgumentTypeDefault
in_ConfigFileString“Data\config.xlsx”
in_ConfigSheetsArray{“Settings”, “Constants”, “AutocorrectOcrMistakes”, “InvoicePostProcessing”,”ReceiptPostProcessing”}

What Happens
  1. Log message that process is starting
  2. Initialize out_Config dictionary
  3. Add global unique id (GUID) to dictionary for this particular run –> out_config(“LogKey”)
  4. For each sheet in config file:
    • Read sheet into data table configDT
    • For each row in configDT:
      • skip if row is empty
      • add Name column as key, Value column as value to out_Config
  5. Separate out_Config(“MaxExecutionAttempts”) and convert it to integer –> out_MaxAttempts
  6. Separate out_Config(“RetryInterval”) and convert it to TimeSpan –> out_RetryInterval

Out Arguments
ArgumentTypeSaved To (Main)
out_ConfigDict<String, String>config
out_MaxAttemptsInt32maxAttempts
out_RetryIntervalTimeSpanretryInterval

We’ve finished the Read Config Phase and now will move into the Fetch Phase. What we have loaded into memory so far:

  • in_UseQueue
  • in_TargetFile
  • config
  • maxAttempts
  • retryInterval

These have been loaded, but haven’t been used yet. Let’s keep going.

Next: Fetch Phase (coming soon)