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
Argument | Type | Default |
---|---|---|
in_ConfigFile | String | “Data\config.xlsx” |
in_ConfigSheets | Array | {“Settings”, “Constants”, “AutocorrectOcrMistakes”, “InvoicePostProcessing”,”ReceiptPostProcessing”} |
What Happens
- Log message that process is starting
- Initialize out_Config dictionary
- Add global unique id (GUID) to dictionary for this particular run –> out_config(“LogKey”)
- 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
- Separate out_Config(“MaxExecutionAttempts”) and convert it to integer –> out_MaxAttempts
- Separate out_Config(“RetryInterval”) and convert it to TimeSpan –> out_RetryInterval
Out Arguments
Argument | Type | Saved To (Main) |
---|---|---|
out_Config | Dict<String, String> | config |
out_MaxAttempts | Int32 | maxAttempts |
out_RetryInterval | TimeSpan | retryInterval |
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)