Sales, Inventory, & Operations Planning API - Flat File Processor
Looking for the API Reference?
Introduction
As an alternative to pushing data directly to the API, we provide this flat file processor for you to install and run on your network. The program will digest flat files in Comma Separated Value (CSV) format and upload the data using the API. At this time, only CSV format is supported, with the .csv file extension, and we recommend UTF-8 encoding.


Download
Download the program archive for your operating system and decompress in your desired installation location.

Windows
Linux


Configuration
config.json
Found alongside the oregon-tool-SIOP-flat-file-processor executable will be a config.json file which you may edit to affect some customization for your environment. Here is an example of the content of that file:
{ "RuntimeParameters": { "Verbosity": "normal", "LogFilePath": "./oregon-tool-siop-flat-file-processor.log", "FileInputDirectoryPath": "./input", "RecurseFileInputDirectory": false, "FileOutputDirectoryPath": "./processed", "ApiEndpointURL": "https://siop.api.oregontool.com/v1", "ApiKey": "<your-api-key>" }, "FieldNameMappings": { "SoldToId": "Customer Number", "ShipToId": "Ship Location", "MaterialId": "Item Num", "OregonToolMaterialId": "Vend Item Num", "Year": "YR", "Month": "Mnth", "Day": "Day", "UnitsSold": "YTD Unit Sales", "OnHand": "OnHand", "UnitsOnHand": "Qty OH", "UnitsOnShelf": "Qty Avail", "UnitsOnOrder": "Qty On Order", "UnitsInTransit": "UnitsInTransit", "UnitOfMeasure": "UM Buy", "TargetInventory": "Target Inv", "MinimumStock": "Order Pt", "MaximumStock": "Line Pt", "SafetyStock": "Safety Stk" } }

RuntimeParameters
Collection of properties to configure program behavior

Verbosity
Controls the level of output to the console and log file
normal
default; All relevant information output to the console and the log file
quiet
All relevant information output to the log file only
debug
All relevant information output to the console and the log file, including extended exception information, like stack traces...

LogFilePath
File system path where the log file will be stored
relative or absolute path
default is a file named "oregon-tool-SIOP-flat-file-processor.log" which is relative to the program working directory (not necessarially where the program is installed)

FileInputDirectoryPath
File system path to directory where the program should look for CSV files to process
relative or absolute path
default is a directory named "import" which is relative to the program working directory (not necessarially where the program is installed)

RecurseFileInputDirectory
A flag to tell the processor to look for CSV files in subfolders of the input path
false
default; Do not recursively search FileInputDirectoryPath
true
Recursively search FileInputDirectoryPath

FileOutputDirectoryPath
File system path to directory where the program should move successfully processed CSV files
relative or absolute path
default is a directory named "processed" which is relative to the program working directory (not necessarially where the program is installed)

ApiEndpointURL
URL / FQDN of the Oregon Tool SIOP API push endpoint
may be changed to https://siop.dev.api.oregontool.com/v1 if you want to perform testing in the development environment

ApiKey
Your API Key for authentication to the API

FieldNameMappings
Collection of siop.dataItem properties allowing you to map the field names in your files to the field names expected by the API; edit the values (yellow strings shown in example above) for your field names


Execution
Once you have downloaded and extracted the program, configured for your environment by editing the config.json file, and created the input and output directories as necessary, you may execute the program. The program will output an exit code of zero for successful processing, and a non-zero code for warnings and errors; this may be used to determine a successful vs. failed execution if you automate the process.


Automation
There are many ways to automate this process. On Windows you could use Task Scheduler or PowerShell. On Linux you can use cron.

Task Scheduler on Windows is simple, but does not by itself, provide any feedback on success or failure of the process:

You could wrap the execution in a PowerShell script and leverage PowerShell to realize success or failure and notify someone upon failure:
$programFilePath = "C:\OT-SIOP-ffp\oregon-tool-SIOP-flat-file-processor.exe"; $workingDirectory = "C:\OT-SIOP-ffp\working"; $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.FileName = $programFilePath $pinfo.RedirectStandardError = $true $pinfo.RedirectStandardOutput = $true $pinfo.UseShellExecute = $false $process = New-Object System.Diagnostics.Process $process.StartInfo = $pinfo $process.Start() | Out-Null $output = $process.StandardOutput.ReadToEnd() $process.WaitForExit() Switch($process.ExitCode) { 0 {} default { $message = new-object Net.Mail.MailMessage; $message.From = "<sender-email-address>"; $message.To.Add("<your-email-address>"); $message.Subject = "Oregon Tool SIOP Upload Failed"; $message.Body = $output; $smtp = new-object Net.Mail.SmtpClient("<your-smpt-host>", "<your-smtp-port>"); $smtp.EnableSSL = $true; $smtp.Credentials = New-Object System.Net.NetworkCredential("<smtp-username>", "<smtp-password>"); $smtp.send($message); } }