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
43 changes: 25 additions & 18 deletions server/app/services/botsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,38 @@ botsService.updateBotsScheduler = function updateBotsScheduler(botId,botObj,call
logger.error(err);
} else if(botsData.length > 0){
if (botsData[0].isBotScheduled === true) {
var catalystSync = require('_pr/cronjobs/catalyst-scheduler/catalystScheduler.js');
catalystSync.executeScheduledBots();
if(botsData[0].botLinkedCategory === 'Task'){
tasks.getTaskById(botId,function(err,task){
if(err){
logger.error("Error in fetching Task details",err);
}else if(task.isTaskScheduled === true){
tasks.updateTaskScheduler(botId,function(err,updateData){
if(err){
logger.error("Error in Updating Task details",err);
var schedulerService = require('_pr/services/schedulerService.js');
schedulerService.executeScheduledBots(botsData[0],function(err,data){
if(err){
logger.error("Error in executing BOTs Scheduler");
}
});
if (botsData[0].botLinkedCategory === 'Task') {
tasks.getTaskById(botId, function (err, task) {
if (err) {
logger.error("Error in fetching Task details", err);
} else if (task.isTaskScheduled === true) {
tasks.updateTaskScheduler(botId, function (err, updateData) {
if (err) {
logger.error("Error in Updating Task details", err);
}
});
if(task.cronJobId && task.cronJobId !== null){
if (task.cronJobId && task.cronJobId !== null) {
var cronTab = require('node-crontab');
cronTab.cancelJob(task.cronJobId);
}
}
});
}
} else if (botsData[0].cronJobId && botsData[0].cronJobId !== null) {
var cronTab = require('node-crontab');
cronTab.cancelJob(botsData[0].cronJobId);
} else {
logger.debug("There is no cron job associated with Bot ");
}else{
var schedulerService = require('_pr/services/schedulerService.js');
schedulerService.executeScheduledBots(botsData[0],function(err,data){
if(err){
logger.error("Error in executing BOTs Scheduler");
}
});
}

} else{
logger.debug("There is no Bots ");
}
Expand Down Expand Up @@ -327,7 +334,7 @@ botsService.getPerticularBotsHistory = function getPerticularBotsHistory(botId,h
botsService.executeBots = function executeBots(botId,reqBody,callback){
async.waterfall([
function(next){
if(typeof reqBody !== 'undefined' && reqBody !== null
if(reqBody !== null
&& reqBody.paramOptions
&& reqBody.paramOptions.scriptParams
&& reqBody.paramOptions.scriptParams !== null){
Expand Down Expand Up @@ -365,7 +372,7 @@ botsService.executeBots = function executeBots(botId,reqBody,callback){
function(bots,next){
if(bots.length > 0){
if(bots[0].botLinkedCategory === 'Task'){
if(typeof reqBody === 'undefined') {
if(reqBody === null) {
taskService.executeTask(botId, 'system', 'undefined', 'undefined', 'undefined', 'undefined', 'undefined', callback);
}else{
taskService.executeTask(botId, reqBody.userName ? reqBody.userName : 'system', reqBody.hostProtocol ? reqBody.hostProtocol : 'undefined',
Expand Down
25 changes: 18 additions & 7 deletions server/app/services/schedulerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,25 @@ schedulerService.executeScheduledBots = function executeScheduledBots(bots,callb
logger.error("Error in updating cron job Ids. "+err);
}
})
botsService.executeBots(bots.botId,bots.runTimeParams,function(err, historyData) {
if (err) {
logger.error("Failed to execute Bots.", err);
if(bots.botLinkedCategory === 'Blueprint') {
botsService.executeBots(bots.botId, bots.runTimeParams, function (err, historyData) {
if (err) {
logger.error("Failed to execute Bots.", err);
return;
}
logger.debug("Bots Execution Success for - ", bots.botName);
return;
}
logger.debug("Bots Execution Success for - ", bots.botName);
return;
});
});
}else{
botsService.executeBots(bots.botId,null,function (err, historyData) {
if (err) {
logger.error("Failed to execute Bots.", err);
return;
}
logger.debug("Bots Execution Success for - ", bots.botName);
return;
});
}
});
}
}
Expand Down
13 changes: 0 additions & 13 deletions server/app/services/taskService.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,6 @@ taskService.executeTask = function executeTask(taskId, user, hostProtocol, choic
logger.error("Error while updating Bot Execution Count");
}
});
var reqBody = {
userName: user,
hostProtocol: hostProtocol,
choiceParam: choiceParam,
appData: appData,
tagServer: botTagServer,
paramOptions: paramOptions
}
bots.updateBotsDetail(task._id, {runTimeParams: reqBody}, function (err, data) {
if (err) {
logger.error("Error while updating Bots Configuration");
}
});
}
}else{
logger.debug("There is no BOTs data present in DB");
Expand Down