Process Functions

This commit is contained in:
Luis Fernando Molina committed 2020-11-27 13:36:25 +01:00
1 parent da5e50bf85
commit 658dc4714a
8 files changed
+74 -57

No files matched your search

+8 -1
View File
@@ -339,7 +339,14 @@
"fileName": "StandardResponses.js"
}
],
"functionLibraries": [],
"functionLibraries": [
{
"name": "Process Functions",
"propertyName": "processFunctions",
"functionName": "newSuperalgosFunctionLibrariesProcessFunctions",
"fileName": "ProcessFunctions.js"
}
],
"utilities": [],
"botClasses": []
},
@@ -0,0 +1,61 @@
exports.newSuperalgosFunctionLibrariesProcessFunctions = function () {
let thisObject = {
processError: processError,
processWarning: processWarning,
processInfo: processInfo
}
return thisObject
function processError (processKey, node, errorMessage) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
errorMessage: errorMessage
}
} else {
event = {
errorMessage: errorMessage
}
}
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Error', event)
}
function processWarning (processKey, node, warningMessage) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
warningMessage: warningMessage
}
} else {
event = {
warningMessage: warningMessage
}
}
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Warning', event)
}
function processInfo (processKey, node, infoMessage) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
infoMessage: infoMessage
}
} else {
event = {
infoMessage: infoMessage
}
}
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Info', event)
}
}
-51
View File
@@ -38,57 +38,6 @@ exports.newGlobals = function newGlobals() {
return new Date(date.getUTCFullYear() + "-" + (date.getUTCMonth() + 1) + "-" + date.getUTCDate() + " " + "00:00" + GMT_SECONDS);
}
global.PROCESS_ERROR = function (processKey, node, errorMessage) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
errorMessage: errorMessage
}
} else {
event = {
errorMessage: errorMessage
}
}
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Error', event)
}
global.PROCESS_WARNING = function (processKey, node, warningMessage) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
warningMessage: warningMessage
}
} else {
event = {
warningMessage: warningMessage
}
}
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Warning', event)
}
global.PROCESS_INFO = function (processKey, node, infoMessage) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
infoMessage: infoMessage
}
} else {
event = {
infoMessage: infoMessage
}
}
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(processKey, 'Info', event)
}
global.NODE_BRANCH_TO_ARRAY = function (node, nodeType) {
let resultArray = []
scanNodeBranch(node, nodeType)
+1 -1
View File
@@ -767,7 +767,7 @@
function processStopped() {
if (global.unexpectedError !== undefined) {
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
TS.projects.superalgos.functionLibraries.processFunctions.processError(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
} else {
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
}
@@ -653,7 +653,7 @@ exports.newLearningBot = function newLearningBot(bot, parentLogger) {
function processStopped() {
if (global.unexpectedError !== undefined) {
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
TS.projects.superalgos.functionLibraries.processFunctions.processError(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
} else {
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
}
+1 -1
View File
@@ -576,7 +576,7 @@
function processStopped() {
if (global.unexpectedError !== undefined) {
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
TS.projects.superalgos.functionLibraries.processFunctions.processError(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
} else {
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
}
+1 -1
View File
@@ -83,7 +83,7 @@
function validationFailed(errorInNode, errorMessage) {
let nodeString = JSON.stringify(errorInNode)
logger.write(MODULE_NAME, "[ERROR] initialize -> " + errorMessage + ' -> nodeString = ' + nodeString)
global.PROCESS_ERROR(bot.processKey, errorInNode, errorMessage)
TS.projects.superalgos.functionLibraries.processFunctions.processError(bot.processKey, errorInNode, errorMessage)
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE)
}
+1 -1
View File
@@ -653,7 +653,7 @@
function processStopped() {
if (global.unexpectedError !== undefined) {
global.PROCESS_ERROR(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
TS.projects.superalgos.functionLibraries.processFunctions.processError(bot.processKey, undefined, "An unexpected error caused the Process to stop.")
} else {
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(bot.processKey, 'Stopped')
}