From 2ce2d8b800ed50ee67ebc1d72ce7f4cede8bc74a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 4 Feb 2020 18:21:37 +0100 Subject: [PATCH] Restarting Sessions --- .../FunctionLibraries/UiObjectsFromNodes.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 5df4ecd6a..40466a029 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -10,12 +10,14 @@ function newUiObjectsFromNodes () { let mapOfReferenceChildren = new Map() let mapOfNodes let tasksToRun + let sessionsToRun return thisObject function recreateWorkspace (node, replacingCurrentWorkspace) { mapOfNodes = new Map() tasksToRun = [] + sessionsToRun = [] /* Create the workspace UI OBject and then continue with the root nodes. */ createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace') @@ -29,9 +31,14 @@ function newUiObjectsFromNodes () { tryToConnectChildrenWithReferenceParents() if (replacingCurrentWorkspace === true) { - setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop + // We need to wait all tasks that were potentially running to stop + setTimeout(runTasks, 70000) + // We give a few seconds for the tasks to start + setTimeout(runSessions, 80000) } else { runTasks() + // We give a few seconds for the tasks to start + setTimeout(runSessions, 10000) } } @@ -43,6 +50,14 @@ function newUiObjectsFromNodes () { tasksToRun = undefined } + function runSessions () { + for (let i = 0; i < sessionsToRun.length; i++) { + let node = sessionsToRun[i] + node.payload.uiObject.menu.internalClick('Run Session') + } + sessionsToRun = undefined + } + function tryToConnectChildrenWithReferenceParents () { /* We reconstruct here the reference relationships. */ for (const [key, node] of mapOfNodes) { @@ -379,10 +394,20 @@ function newUiObjectsFromNodes () { mapOfNodes.set(node.id, node) + /* Check if there are tasks to run */ if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) { if (node.savedPayload.uiObject.isRunning === true) { tasksToRun.push(node) } + } + + /* Check if there are sessions to run */ + if (userAddingNew === false && node.savedPayload !== undefined) { + if (uiObjectType === 'Live Trading Session' || uiObjectType === 'Fordward Testing Session' || uiObjectType === 'Backtesting Session' || uiObjectType === 'Paper Trading Session') { + if (node.savedPayload.uiObject.isRunning === true) { + sessionsToRun.push(node) + } + } } } }