@@ -364,34 +364,23 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
364364 var botId = null ;
365365 var botRemoteServerDetails = { } ;
366366 var bots = [ ] ;
367- var taskId = null ;
367+ var taskId = 'xxxxxx' ;
368368 var cryptoConfig = appConfig . cryptoSettings ;
369369 var cryptography = new Cryptography ( cryptoConfig . algorithm , cryptoConfig . password ) ;
370370 logger . info ( "Entering WF" ) ;
371+ if ( reqBody . data ) {
372+ if ( reqBody . data . sysid ) {
373+ logger . info ( "SYS ID" , reqBody . data . sysid )
374+ taskId = reqBody . data . sysid
375+ }
376+ }
371377 async . waterfall ( [
372378 function ( next ) {
373379 botDao . getBotsByBotId ( botsId , next ) ;
374380 } ,
375381 function ( botList , next ) {
376382 bots = botList ;
377383 logger . info ( "Got Bots " + JSON . stringify ( bots ) ) ;
378- if ( bots . length > 0 ) {
379- if ( bots [ 0 ] . params ) {
380- if ( bot [ 0 ] . params . data ) {
381- if ( bot [ 0 ] . params . data . sysid ) {
382- sysId = bot [ 0 ] . params . data . sysid
383- logger . info ( "Task ID" , sysId )
384- var decryptedTaskId = cryptography . decryptText ( sysId , cryptoConfig . decryptionEncoding ,
385- cryptoConfig . encryptionEncoding ) ;
386- logger . info ( "Decrypted Task ID" , decryptedTaskId )
387- taskId = decryptedTaskId
388- logger . info ( taskId )
389- } else {
390- logger . info ( "Task ID does not exist" )
391- }
392- }
393- }
394- }
395384 if ( schedulerCallCheck )
396385 scheduledBots . getScheduledBotsByBotId ( botsId , next ) ;
397386 else next ( null , [ ] ) ;
@@ -437,7 +426,8 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
437426 encryptedParam ( reqBody , next ) ;
438427 } else {
439428 var error = new Error ( ) ;
440- error . message = 'task_id' + taskId + ' BOTs Remote Engine is not configured or not in running mode' ;
429+ logger . error ( "task_id" + taskId + " BOTs Remote Engine is not configured or not in running mode" )
430+ error . message = 'BOTs Remote Engine is not configured or not in running mode' ;
441431 error . status = 403 ;
442432 //next(error, null);
443433 encryptedParam ( reqBody , next ) ;
@@ -448,7 +438,8 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
448438
449439 } else {
450440 var error = new Error ( ) ;
451- error . message = 'task_id' + taskId + ' There is no record available in DB against BOT : ' + botsId ;
441+ logger . error ( "task_id" + taskId + " There is no record available in DB against BOT :" + botsId )
442+ error . message = 'There is no record available in DB against BOT : ' + botsId ;
452443 error . status = 403 ;
453444 next ( error , null ) ;
454445 }
@@ -507,7 +498,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
507498 date : startHour ,
508499 } , { $inc : { "runningCount" : 1 } } , { upsert : true } , function ( err , data ) {
509500 if ( err ) logger . error ( JSON . stringify ( err ) )
510- else logger . info ( "Running count of bot " , botDetails [ 0 ] . name , "incremented successfully" )
501+ else logger . info ( "task_id" + taskId + " Running count of bot ", botDetails [ 0 ] . name , "incremented successfully" )
511502 } )
512503 auditTrailService . insertAuditTrail ( botDetails [ 0 ] , auditTrailObj , actionObj , next ) ;
513504 } ,
@@ -556,6 +547,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
556547 botDao . updateBotsDetail ( botId , botUpdateObj , callback ) ;
557548 } else {
558549 var err = new Error ( 'Invalid BOT Type' ) ;
550+ logger . error ( "task_id" + taskId + " Invalid BOT Type" )
559551 err . status = 400 ;
560552 err . msg = 'Invalid BOT Type' ;
561553 callback ( err , null ) ;
0 commit comments