diff --git a/server/app/engine/bots/scriptExecutor.js b/server/app/engine/bots/scriptExecutor.js index bec54f223..196158961 100644 --- a/server/app/engine/bots/scriptExecutor.js +++ b/server/app/engine/bots/scriptExecutor.js @@ -121,8 +121,21 @@ scriptExecutor.execute = function execute(botsDetails,auditTrail,userName,execut function executeScriptOnLocal(botsScriptDetails,auditTrail,userName,botHostDetails,callback) { + logger.info("Bot script details",JSON.stringify(botsScriptDetails)) var cryptoConfig = appConfig.cryptoSettings; var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password); + var taskId = 'xxxxxx'; + if (botsScriptDetails.params){ + if(botsScriptDetails.params.data){ + if(botsScriptDetails.params.data.sysid){ + sysId = botsScriptDetails.params.data.sysid + var decryptedText = cryptography.decryptText(sysId, cryptoConfig.decryptionEncoding, + cryptoConfig.encryptionEncoding); + taskId = decryptedText + logger.info("Task ID",taskId) + } + } + } var actionId = uuid.v4(); var logsReferenceIds = [botsScriptDetails.id, actionId]; var replaceTextObj = { @@ -208,7 +221,8 @@ function executeScriptOnLocal(botsScriptDetails,auditTrail,userName,botHostDetai }); request.post(options, function (err, res, body) { if (err) { - logger.error(err); + logger.error("task_id"+taskId+" "+JSON.stringify(err)) + logger.error("Error: task_id"+taskId+" Configure appropriate bot executor with proper osType ") var timestampEnded = new Date().getTime(); logsDao.insertLog({ referenceId: logsReferenceIds, diff --git a/server/app/services/botService.js b/server/app/services/botService.js index 0be9e8877..820e006db 100755 --- a/server/app/services/botService.js +++ b/server/app/services/botService.js @@ -364,7 +364,16 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi var botId = null; var botRemoteServerDetails = {}; var bots = []; + var taskId = 'xxxxxx'; + var cryptoConfig = appConfig.cryptoSettings; + var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password); logger.info("Entering WF"); + if (reqBody.data){ + if(reqBody.data.sysid){ + logger.info("SYS ID",reqBody.data.sysid) + taskId = reqBody.data.sysid + } + } async.waterfall([ function (next) { botDao.getBotsByBotId(botsId, next); @@ -417,6 +426,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi encryptedParam(reqBody, next); } else { var error = new Error(); + logger.error("task_id"+taskId+" BOTs Remote Engine is not configured or not in running mode") error.message = 'BOTs Remote Engine is not configured or not in running mode'; error.status = 403; //next(error, null); @@ -428,6 +438,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi } else { var error = new Error(); + logger.error("task_id"+taskId+" There is no record available in DB against BOT :"+botsId) error.message = 'There is no record available in DB against BOT : ' + botsId; error.status = 403; next(error, null); @@ -487,7 +498,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi date: startHour, }, { $inc: { "runningCount": 1 } }, { upsert: true }, function (err, data) { if (err) logger.error(JSON.stringify(err)) - else logger.info("Running count of bot ", botDetails[0].name, "incremented successfully") + else logger.info("task_id"+taskId+" Running count of bot ", botDetails[0].name, "incremented successfully") }) auditTrailService.insertAuditTrail(botDetails[0], auditTrailObj, actionObj, next); }, @@ -536,6 +547,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi botDao.updateBotsDetail(botId, botUpdateObj, callback); } else { var err = new Error('Invalid BOT Type'); + logger.error("task_id"+taskId+" Invalid BOT Type") err.status = 400; err.msg = 'Invalid BOT Type'; callback(err, null);