KNxSF Function ProcessSalesforceHeartbeat
This is the backbone of the salesforce integration. This function handles the error warnings of the entire library to reduce the amount of error emails that would otherwise be sent to the alert address if connections were to fail.
Breakdown
Start logging file using process name, time and date. Add the start of logging process to log.
Fetch Db context to check System task matching user, process, time and date. If there is a duplicate task already running then update log file and quit.
Log that the process is running on a system task.
Fetch mail settings. If the current company has no configured email address, throw an exception.
Fetch address for error reports, throwing an exception of empty.
Test each SF connection, make a list of successes and failures. Log the results and send an email if there are any failures to the error alert email.
Log the end of the process.