Home Network fully implemented
This commit is contained in:
1 parent
2ed86e0118
commit
a3efd3eaf0
19 files changed
+401
-74
No files matched your search
+60
-13
@@ -13,9 +13,11 @@
|
||||
let bot = BOT;
|
||||
|
||||
let thisObject = {
|
||||
networkNode: undefined,
|
||||
mainUtility: undefined,
|
||||
file: undefined, // Here we have the JSON object representing the file content.
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
load: load,
|
||||
save: save,
|
||||
status: undefined
|
||||
@@ -30,7 +32,7 @@
|
||||
/* Storage account to be used here. */
|
||||
|
||||
const FILE_STORAGE = require('./FileStorage.js');
|
||||
let fileStorage = FILE_STORAGE.newFileStorage(logger);
|
||||
let fileStorage
|
||||
|
||||
let sessionPath = ''
|
||||
|
||||
@@ -93,17 +95,6 @@
|
||||
statusDependencyNode.bottype = statusDependencyNode.referenceParent.parentNode.parentNode.type
|
||||
statusDependencyNode.dataMine = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.code.codeName
|
||||
|
||||
/* Let's see if the process is run monthly or not. */
|
||||
if (statusDependencyNode.referenceParent.parentNode.code.startMode !== undefined) {
|
||||
if (statusDependencyNode.referenceParent.parentNode.code.startMode.allMonths !== undefined) {
|
||||
if (statusDependencyNode.referenceParent.parentNode.code.startMode.oneMonth !== undefined) {
|
||||
if (statusDependencyNode.referenceParent.parentNode.code.startMode.allMonths.run === "true" || statusDependencyNode.referenceParent.parentNode.code.startMode.oneMonth.run === "true") {
|
||||
statusDependencyNode.processRunMonthly = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We retrieve the report main utility */
|
||||
if (statusDependencyNode.code !== undefined) {
|
||||
if (statusDependencyNode.code.mainUtility !== undefined) {
|
||||
@@ -122,7 +113,55 @@
|
||||
sessionPath = bot.SESSION.folderName + "/"
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
/* Now we will see where do we need to fetch this status report from. */
|
||||
let network = global.TASK_NETWORK
|
||||
let processThisDependsOn = statusDependencyNode.referenceParent.parentNode
|
||||
|
||||
for (let i = 0; i < network.networkNodes.length; i++) {
|
||||
let networkNode = network.networkNodes[i]
|
||||
if (networkNode.dataMining !== undefined) {
|
||||
for (let j = 0; j < networkNode.dataMining.exchangeTasks.length; j++) {
|
||||
let exchangeTasks = networkNode.dataMining.exchangeTasks[j]
|
||||
for (let k = 0; k < exchangeTasks.taskManagers.length; k++) {
|
||||
let taskManager = exchangeTasks.taskManagers[k]
|
||||
for (let m = 0; m < taskManager.tasks.length; m++) {
|
||||
let task = taskManager.tasks[m]
|
||||
if (task.bot !== undefined) {
|
||||
for (let n = 0; n < task.bot.processes.length; n++) {
|
||||
let process = task.bot.processes[n]
|
||||
if (process.marketReference !== undefined) {
|
||||
if (process.marketReference.referenceParent !== undefined) {
|
||||
let market = process.marketReference.referenceParent
|
||||
let currentProcessMarket = bot.processNode.marketReference.referenceParent
|
||||
if (currentProcessMarket.id === market.id) {
|
||||
if (process.referenceParent !== undefined) {
|
||||
let processDefinition = process.referenceParent
|
||||
if (processThisDependsOn.id === processDefinition.id) {
|
||||
|
||||
/* We found where the task that runs the process definition this status report depends on and where it is located on the network. */
|
||||
|
||||
thisObject.networkNode = networkNode
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.code.host + ' -> port = ' + networkNode.code.webPort + '.'); }
|
||||
|
||||
fileStorage = FILE_STORAGE.newFileStorage(logger, networkNode.code.host, networkNode.code.webPort);
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
logger.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because we could not find where the data of this status report is located within the network. Check the logs for more info.");
|
||||
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] initialize -> err = "+ err.stack);
|
||||
@@ -130,6 +169,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
fileStorage = undefined
|
||||
thisObject.networkNode = undefined
|
||||
bot = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
|
||||
function load(callBackFunction) {
|
||||
|
||||
try {
|
||||
@@ -212,6 +258,7 @@
|
||||
*/
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> Error Parsing the Status report. -> Err = " + err.message);
|
||||
logger.write(MODULE_NAME, "[WARN] load -> onFileReceived -> Error Parsing the Status report. -> text = " + text);
|
||||
|
||||
let customFail = {
|
||||
result: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
|
||||
Reference in new issue
Block a user