Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion server/app/engine/bots/scriptExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 13 additions & 1 deletion server/app/services/botService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
},
Expand Down Expand Up @@ -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);
Expand Down