Built motion from commit (unavailable).|2.2.0
[motion2.git] / server / config / schedule / index.js
index d0091cf..abe1acd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xeaf5=['run','path','lodash','moment','cron-job-manager','jayson/promise','../logger','schedule','../../api/analyticDefaultReport/analyticDefaultReport.controller','client','http','info','Try\x20to\x20send\x20a\x20mail\x20to','email','MailAccount','Smtp','service','host','port','secure','authentication','auth','user','pass','format','\x22%s\x22\x20<%s>','name','subtractUnit','../../files/reports','%s.%s','basename','savename','extname','zip','join','existsSync','status','message','attachments','text','Sent','sendIfEmpty','empty\x20file,\x20email\x20not\x20sent','request','SendMail','then','error','error\x20mail','stringify','email\x20sent','catch','isNil','subtractNumber','subtractNumber\x20null\x20or\x20undefined','subtractUnit\x20null\x20or\x20undefined','YYYY-MM-DD\x20HH:mm:ss','scheduled','output','DefaultReportId','CustomReportId','exec\x20custom\x20report\x20id:%s','runReport','no\x20report\x20id','Schedule','findAll','MailServerOut','keys','keyBy','toString','intersection','length','exists','stop','delete\x20cron','toRun','my\x20id','run\x20job','cron','active','isBetween','startAt','endAt','add','start','add\x20cron','stop\x20cron','update','update\x20cron','deleteJob'];(function(_0x2673a4,_0x4d0b8d){var _0x5e3a6a=function(_0x59e268){while(--_0x59e268){_0x2673a4['push'](_0x2673a4['shift']());}};_0x5e3a6a(++_0x4d0b8d);}(_0xeaf5,0x165));var _0x5eaf=function(_0x3bef2c,_0x5a86fd){_0x3bef2c=_0x3bef2c-0x0;var _0x331503=_0xeaf5[_0x3bef2c];return _0x331503;};'use strict';var fs=require('fs');var util=require('util');var path=require(_0x5eaf('0x0'));var _=require(_0x5eaf('0x1'));var moment=require(_0x5eaf('0x2'));var CronJobManager=require(_0x5eaf('0x3'));var jayson=require(_0x5eaf('0x4'));var BPromise=require('bluebird');var logger=require(_0x5eaf('0x5'))(_0x5eaf('0x6'));var db=require('../../mysqldb')['db'];var analyticCustomReportController=require('../../api/analyticCustomReport/analyticCustomReport.controller');var analyticDefaultReportController=require(_0x5eaf('0x7'));var client=jayson[_0x5eaf('0x8')][_0x5eaf('0x9')]({'port':0x232b});var manager=new CronJobManager();function handleSendEmail(_0x58a27f,_0x1cae5c){return function(){logger[_0x5eaf('0xa')](_0x5eaf('0xb'),_0x58a27f[_0x5eaf('0xc')]);var _0x3e426b=!![];var _0x27eeee={'tls':{'rejectUnauthorized':![]}};if(_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0xf')]){_0x27eeee[_0x5eaf('0xf')]=_0x58a27f['MailAccount'][_0x5eaf('0xe')][_0x5eaf('0xf')];}else{_0x27eeee['host']=_0x58a27f['MailAccount']['Smtp'][_0x5eaf('0x10')];_0x27eeee[_0x5eaf('0x11')]=_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0x11')];_0x27eeee['secure']=_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0x12')];}if(_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0x13')]){_0x27eeee[_0x5eaf('0x14')]={'user':_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0x15')],'pass':_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0x16')]};}var _0x537a34={'account':_0x27eeee,'message':{'from':util[_0x5eaf('0x17')](_0x5eaf('0x18'),_0x58a27f['MailAccount']['name'],_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xc')]||_0x58a27f[_0x5eaf('0xd')][_0x5eaf('0xe')][_0x5eaf('0x15')]),'to':_0x58a27f[_0x5eaf('0xc')],'cc':_0x58a27f['cc'],'bcc':_0x58a27f['bcc'],'subject':util[_0x5eaf('0x17')]('Report\x20%s\x20last\x20%s\x20%s',_0x1cae5c[_0x5eaf('0x19')],_0x58a27f['subtractNumber'],_0x58a27f[_0x5eaf('0x1a')])}};var _0x3bef6f=path['join'](__dirname,_0x5eaf('0x1b'));var _0x6a0cfe=_0x1cae5c['savename'];var _0x3148f5=util['format'](_0x5eaf('0x1c'),path[_0x5eaf('0x1d')](_0x1cae5c[_0x5eaf('0x1e')],path[_0x5eaf('0x1f')](_0x1cae5c[_0x5eaf('0x1e')])),_0x5eaf('0x20'));var _0x5ab1de=path[_0x5eaf('0x21')](_0x3bef6f,_0x6a0cfe);var _0x43e83e=path['join'](_0x3bef6f,_0x3148f5);if(fs[_0x5eaf('0x22')](_0x5ab1de)){_0x1cae5c[_0x5eaf('0x23')]='Sent';_0x537a34[_0x5eaf('0x24')][_0x5eaf('0x25')]=[{'filename':_0x6a0cfe,'path':_0x5ab1de}];_0x537a34[_0x5eaf('0x24')][_0x5eaf('0x26')]=util[_0x5eaf('0x17')]('Info\x20report:\x0a%s\x0aPlease\x20see\x20the\x20attachments\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20it.\x0a\x0a',JSON['stringify'](_0x1cae5c,null,0x2));}else if(fs[_0x5eaf('0x22')](_0x43e83e)){_0x1cae5c['status']=_0x5eaf('0x27');_0x537a34['message'][_0x5eaf('0x25')]=[{'filename':_0x3148f5,'path':_0x43e83e}];}else{_0x537a34[_0x5eaf('0x24')][_0x5eaf('0x26')]='Report\x20empty\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20this\x20email.\x0a\x0a';if(!_0x58a27f[_0x5eaf('0x28')]){_0x3e426b=![];logger[_0x5eaf('0xa')](_0x5eaf('0x29'));}}if(_0x3e426b){return client[_0x5eaf('0x2a')](_0x5eaf('0x2b'),_0x537a34)[_0x5eaf('0x2c')](function(_0x276a71){if(_0x276a71[_0x5eaf('0x2d')]){return logger[_0x5eaf('0x2d')](_0x5eaf('0x2e'),JSON[_0x5eaf('0x2f')](_0x276a71));}return logger[_0x5eaf('0xa')](_0x5eaf('0x30'));})[_0x5eaf('0x31')](function(_0x459930){return logger[_0x5eaf('0x2d')](_0x5eaf('0x2e'),JSON[_0x5eaf('0x2f')](_0x459930));});}};}function handleError(){return function(_0xc61b49){return logger[_0x5eaf('0x2d')](JSON[_0x5eaf('0x2f')](_0xc61b49));};}function handleResult(_0x13d805){return function(_0x102e32){logger['info']('data',JSON['stringify'](_0x102e32));if(_0x13d805[_0x5eaf('0xd')]&&_0x13d805[_0x5eaf('0xd')][_0x5eaf('0xe')]&&!_[_0x5eaf('0x32')](_0x13d805[_0x5eaf('0xc')])){setTimeout(handleSendEmail(_0x13d805,_0x102e32),0x3c*0x3e8);}};}function handleJob(_0x143755){return function(){try{if(_[_0x5eaf('0x32')](_0x143755[_0x5eaf('0x33')])){return logger[_0x5eaf('0xa')](_0x5eaf('0x34'));}if(_[_0x5eaf('0x32')](_0x143755['subtractUnit'])){return logger[_0x5eaf('0xa')](_0x5eaf('0x35'));}var _0x3fc896={'startDate':moment()['subtract'](_0x143755[_0x5eaf('0x33')],_0x143755[_0x5eaf('0x1a')])[_0x5eaf('0x17')](_0x5eaf('0x36')),'endDate':moment()[_0x5eaf('0x17')](_0x5eaf('0x36')),'type':_0x5eaf('0x37'),'output':_0x143755[_0x5eaf('0x38')],'name':_0x143755[_0x5eaf('0x19')]};if(!_['isNil'](_0x143755[_0x5eaf('0x39')])){logger[_0x5eaf('0xa')]('exec\x20defaul\x20report\x20id:%s',_0x143755['DefaultReportId']);return analyticDefaultReportController['runReport']({'id':_0x143755['DefaultReportId']},_0x3fc896)[_0x5eaf('0x2c')](handleResult(_0x143755))[_0x5eaf('0x31')](handleError());}if(!_[_0x5eaf('0x32')](_0x143755[_0x5eaf('0x3a')])){logger[_0x5eaf('0xa')](_0x5eaf('0x3b'),_0x143755[_0x5eaf('0x3a')]);return analyticCustomReportController[_0x5eaf('0x3c')]({'id':_0x143755['CustomReportId']},_0x3fc896)[_0x5eaf('0x2c')](handleResult(_0x143755))[_0x5eaf('0x31')](handleError());}}catch(_0x200b40){logger[_0x5eaf('0x2d')](JSON[_0x5eaf('0x2f')](_0x200b40));}return logger[_0x5eaf('0xa')](_0x5eaf('0x3d'));};}function getJobs(_0x42bee5){var _0x15d356={};if(_0x42bee5){_0x15d356['id']=_0x42bee5;}return db[_0x5eaf('0x3e')][_0x5eaf('0x3f')]({'where':_0x15d356,'include':[{'model':db[_0x5eaf('0xd')],'attributes':['id',_0x5eaf('0x19'),'email'],'include':[{'model':db[_0x5eaf('0x40')],'as':_0x5eaf('0xe')}]}]})['then'](function(_0x810463){var _0x1c6689=_[_0x5eaf('0x41')](manager['jobs']);var _0x459489=_['map'](_0x810463,function(_0x5ede62){return _0x5ede62['id']['toString']();});var _0xf397a4=_[_0x5eaf('0x42')](_0x810463,function(_0x4857dc){return _0x4857dc['id'][_0x5eaf('0x43')]();});var _0x27b34a=_0x42bee5?_0x459489:_['difference'](_0x459489,_0x1c6689);var _0x1077af=_[_0x5eaf('0x44')](_0x459489,_0x1c6689);var _0x3782d2=_['difference'](_0x1c6689,_0x459489);var _0x6f07a0;var _0x4db24c;for(_0x6f07a0=0x0;_0x6f07a0<_0x3782d2[_0x5eaf('0x45')]&&!_0x42bee5;_0x6f07a0+=0x1){_0x4db24c=_0x3782d2[_0x6f07a0]['toString']();if(manager[_0x5eaf('0x46')](_0x4db24c)){manager[_0x5eaf('0x47')](_0x4db24c);manager['deleteJob'](_0x4db24c);logger['info'](_0x5eaf('0x48'),_0x4db24c);}}logger[_0x5eaf('0xa')](_0x5eaf('0x49'),JSON[_0x5eaf('0x2f')](_0x27b34a));for(_0x6f07a0=0x0;_0x6f07a0<_0x27b34a['length'];_0x6f07a0+=0x1){_0x4db24c=_0x27b34a[_0x6f07a0][_0x5eaf('0x43')]();logger['info']('index',_0x4db24c);if(_0x42bee5){logger[_0x5eaf('0xa')](_0x5eaf('0x4a'),_0x42bee5);logger[_0x5eaf('0xa')](JSON[_0x5eaf('0x2f')](_0xf397a4[_0x4db24c]));BPromise['resolve']()[_0x5eaf('0x2c')](handleJob(_0xf397a4[_0x4db24c]));logger['info'](_0x5eaf('0x4b'),_0xf397a4[_0x4db24c][_0x5eaf('0x19')],_0xf397a4[_0x4db24c][_0x5eaf('0x4c')]);}else if(_0xf397a4[_0x4db24c][_0x5eaf('0x4c')]&&_0xf397a4[_0x4db24c][_0x5eaf('0x4d')]&&moment()[_0x5eaf('0x4e')](_0xf397a4[_0x4db24c][_0x5eaf('0x4f')],_0xf397a4[_0x4db24c][_0x5eaf('0x50')])){manager[_0x5eaf('0x51')](_0x4db24c,_0xf397a4[_0x4db24c][_0x5eaf('0x4c')],handleJob(_0xf397a4[_0x4db24c]));manager[_0x5eaf('0x52')](_0x4db24c);logger[_0x5eaf('0xa')](_0x5eaf('0x53'),_0xf397a4[_0x4db24c]['name'],_0xf397a4[_0x4db24c][_0x5eaf('0x4c')]);}else if(manager['exists'](_0x4db24c)){manager[_0x5eaf('0x47')](_0x4db24c);manager['deleteJob'](_0x4db24c);logger[_0x5eaf('0xa')](_0x5eaf('0x54'),_0xf397a4[_0x4db24c][_0x5eaf('0x19')],_0xf397a4[_0x4db24c][_0x5eaf('0x4c')]);}}for(_0x6f07a0=0x0,_0x4db24c;_0x6f07a0<_0x1077af[_0x5eaf('0x45')]&&!_0x42bee5;_0x6f07a0+=0x1){_0x4db24c=_0x1077af[_0x6f07a0][_0x5eaf('0x43')]();if(manager['exists'](_0x4db24c)){if(_0xf397a4[_0x4db24c]['cron']&&_0xf397a4[_0x4db24c][_0x5eaf('0x4d')]&&moment()['isBetween'](_0xf397a4[_0x4db24c]['startAt'],_0xf397a4[_0x4db24c][_0x5eaf('0x50')])){manager[_0x5eaf('0x55')](_0x4db24c,_0xf397a4[_0x4db24c][_0x5eaf('0x4c')],handleJob(_0xf397a4[_0x4db24c]));logger['info'](_0x5eaf('0x56'),_0xf397a4[_0x4db24c][_0x5eaf('0x19')],_0xf397a4[_0x4db24c][_0x5eaf('0x4c')]);}else{manager[_0x5eaf('0x47')](_0x4db24c);manager[_0x5eaf('0x57')](_0x4db24c);logger['info'](_0x5eaf('0x54'),_0xf397a4[_0x4db24c]['name'],_0xf397a4[_0x4db24c][_0x5eaf('0x4c')]);}}}})[_0x5eaf('0x31')](function(_0x25d72c){logger[_0x5eaf('0x2d')](JSON[_0x5eaf('0x2f')](_0x25d72c));});}exports[_0x5eaf('0x58')]=function(_0x13198a){return getJobs(_0x13198a);};exports[_0x5eaf('0x52')]=function(){setInterval(function(){return getJobs();},0x3c*0x3e8);return getJobs();};
\ No newline at end of file
+var _0x0ccd=['lodash','moment','jayson/promise','bluebird','../logger','../../mysqldb','../../api/analyticCustomReport/analyticCustomReport.controller','client','http','info','email','Smtp','service','MailAccount','host','port','secure','authentication','auth','format','\x22%s\x22\x20<%s>','user','bcc','Report\x20%s\x20last\x20%s\x20%s','name','subtractNumber','subtractUnit','../../files/reports','%s.%s','basename','extname','savename','zip','join','existsSync','status','message','attachments','text','stringify','Report\x20empty\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20this\x20email.\x0a\x0a','empty\x20file,\x20email\x20not\x20sent','SendMail','then','error','error\x20mail','email\x20sent','catch','data','isNil','subtractNumber\x20null\x20or\x20undefined','subtractUnit\x20null\x20or\x20undefined','subtract','scheduled','output','DefaultReportId','exec\x20defaul\x20report\x20id:%s','runReport','CustomReportId','exec\x20custom\x20report\x20id:%s','findAll','MailServerOut','map','toString','keyBy','difference','length','exists','stop','index','my\x20id','run\x20job','cron','isBetween','startAt','endAt','start','add\x20cron','stop\x20cron','active','update','update\x20cron','deleteJob','run','path'];(function(_0x413feb,_0x10477f){var _0x40ee88=function(_0x32a3f6){while(--_0x32a3f6){_0x413feb['push'](_0x413feb['shift']());}};_0x40ee88(++_0x10477f);}(_0x0ccd,0x1a8));var _0xd0cc=function(_0x373f3c,_0x44e12b){_0x373f3c=_0x373f3c-0x0;var _0x555326=_0x0ccd[_0x373f3c];return _0x555326;};'use strict';var fs=require('fs');var util=require('util');var path=require(_0xd0cc('0x0'));var _=require(_0xd0cc('0x1'));var moment=require(_0xd0cc('0x2'));var CronJobManager=require('cron-job-manager');var jayson=require(_0xd0cc('0x3'));var BPromise=require(_0xd0cc('0x4'));var logger=require(_0xd0cc('0x5'))('schedule');var db=require(_0xd0cc('0x6'))['db'];var analyticCustomReportController=require(_0xd0cc('0x7'));var analyticDefaultReportController=require('../../api/analyticDefaultReport/analyticDefaultReport.controller');var client=jayson[_0xd0cc('0x8')][_0xd0cc('0x9')]({'port':0x232b});var manager=new CronJobManager();function handleSendEmail(_0x3097f1,_0x33b53c){return function(){logger[_0xd0cc('0xa')]('Try\x20to\x20send\x20a\x20mail\x20to',_0x3097f1[_0xd0cc('0xb')]);var _0x3dd6dc=!![];var _0x462477={'tls':{'rejectUnauthorized':![]}};if(_0x3097f1['MailAccount'][_0xd0cc('0xc')]['service']){_0x462477[_0xd0cc('0xd')]=_0x3097f1[_0xd0cc('0xe')][_0xd0cc('0xc')][_0xd0cc('0xd')];}else{_0x462477[_0xd0cc('0xf')]=_0x3097f1[_0xd0cc('0xe')][_0xd0cc('0xc')][_0xd0cc('0xf')];_0x462477[_0xd0cc('0x10')]=_0x3097f1[_0xd0cc('0xe')][_0xd0cc('0xc')][_0xd0cc('0x10')];_0x462477[_0xd0cc('0x11')]=_0x3097f1[_0xd0cc('0xe')][_0xd0cc('0xc')]['secure'];}if(_0x3097f1[_0xd0cc('0xe')]['Smtp'][_0xd0cc('0x12')]){_0x462477[_0xd0cc('0x13')]={'user':_0x3097f1[_0xd0cc('0xe')][_0xd0cc('0xc')]['user'],'pass':_0x3097f1[_0xd0cc('0xe')]['Smtp']['pass']};}var _0x3a3779={'account':_0x462477,'message':{'from':util[_0xd0cc('0x14')](_0xd0cc('0x15'),_0x3097f1['MailAccount']['name'],_0x3097f1[_0xd0cc('0xe')][_0xd0cc('0xb')]||_0x3097f1['MailAccount']['Smtp'][_0xd0cc('0x16')]),'to':_0x3097f1[_0xd0cc('0xb')],'cc':_0x3097f1['cc'],'bcc':_0x3097f1[_0xd0cc('0x17')],'subject':util['format'](_0xd0cc('0x18'),_0x33b53c[_0xd0cc('0x19')],_0x3097f1[_0xd0cc('0x1a')],_0x3097f1[_0xd0cc('0x1b')])}};var _0x736be3=path['join'](__dirname,_0xd0cc('0x1c'));var _0x5e5408=_0x33b53c['savename'];var _0x11600b=util[_0xd0cc('0x14')](_0xd0cc('0x1d'),path[_0xd0cc('0x1e')](_0x33b53c['savename'],path[_0xd0cc('0x1f')](_0x33b53c[_0xd0cc('0x20')])),_0xd0cc('0x21'));var _0x20c55e=path[_0xd0cc('0x22')](_0x736be3,_0x5e5408);var _0x3ef935=path[_0xd0cc('0x22')](_0x736be3,_0x11600b);if(fs[_0xd0cc('0x23')](_0x20c55e)){_0x33b53c[_0xd0cc('0x24')]='Sent';_0x3a3779[_0xd0cc('0x25')][_0xd0cc('0x26')]=[{'filename':_0x5e5408,'path':_0x20c55e}];_0x3a3779[_0xd0cc('0x25')][_0xd0cc('0x27')]=util[_0xd0cc('0x14')]('Info\x20report:\x0a%s\x0aPlease\x20see\x20the\x20attachments\x0aThis\x20is\x20an\x20automatically\x20generated\x20email\x20–\x20please\x20do\x20not\x20reply\x20to\x20it.\x0a\x0a',JSON[_0xd0cc('0x28')](_0x33b53c,null,0x2));}else if(fs['existsSync'](_0x3ef935)){_0x33b53c[_0xd0cc('0x24')]='Sent';_0x3a3779[_0xd0cc('0x25')][_0xd0cc('0x26')]=[{'filename':_0x11600b,'path':_0x3ef935}];}else{_0x3a3779[_0xd0cc('0x25')][_0xd0cc('0x27')]=_0xd0cc('0x29');if(!_0x3097f1['sendIfEmpty']){_0x3dd6dc=![];logger['info'](_0xd0cc('0x2a'));}}if(_0x3dd6dc){return client['request'](_0xd0cc('0x2b'),_0x3a3779)[_0xd0cc('0x2c')](function(_0x78dc38){if(_0x78dc38[_0xd0cc('0x2d')]){return logger[_0xd0cc('0x2d')](_0xd0cc('0x2e'),JSON['stringify'](_0x78dc38));}return logger[_0xd0cc('0xa')](_0xd0cc('0x2f'));})[_0xd0cc('0x30')](function(_0x32d3c0){return logger[_0xd0cc('0x2d')](_0xd0cc('0x2e'),JSON[_0xd0cc('0x28')](_0x32d3c0));});}};}function handleError(){return function(_0x2a760b){return logger[_0xd0cc('0x2d')](JSON[_0xd0cc('0x28')](_0x2a760b));};}function handleResult(_0x29b227){return function(_0x492a3a){logger[_0xd0cc('0xa')](_0xd0cc('0x31'),JSON[_0xd0cc('0x28')](_0x492a3a));if(_0x29b227[_0xd0cc('0xe')]&&_0x29b227['MailAccount']['Smtp']&&!_[_0xd0cc('0x32')](_0x29b227[_0xd0cc('0xb')])){setTimeout(handleSendEmail(_0x29b227,_0x492a3a),0x3c*0x3e8);}};}function handleJob(_0x48f255){return function(){try{if(_[_0xd0cc('0x32')](_0x48f255[_0xd0cc('0x1a')])){return logger['info'](_0xd0cc('0x33'));}if(_[_0xd0cc('0x32')](_0x48f255['subtractUnit'])){return logger[_0xd0cc('0xa')](_0xd0cc('0x34'));}var _0x2dc620={'startDate':moment()[_0xd0cc('0x35')](_0x48f255['subtractNumber'],_0x48f255[_0xd0cc('0x1b')])[_0xd0cc('0x14')]('YYYY-MM-DD\x20HH:mm:ss'),'endDate':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'type':_0xd0cc('0x36'),'output':_0x48f255[_0xd0cc('0x37')],'name':_0x48f255[_0xd0cc('0x19')]};if(!_[_0xd0cc('0x32')](_0x48f255[_0xd0cc('0x38')])){logger[_0xd0cc('0xa')](_0xd0cc('0x39'),_0x48f255[_0xd0cc('0x38')]);return analyticDefaultReportController[_0xd0cc('0x3a')]({'id':_0x48f255['DefaultReportId']},_0x2dc620)[_0xd0cc('0x2c')](handleResult(_0x48f255))[_0xd0cc('0x30')](handleError());}if(!_['isNil'](_0x48f255[_0xd0cc('0x3b')])){logger['info'](_0xd0cc('0x3c'),_0x48f255[_0xd0cc('0x3b')]);return analyticCustomReportController['runReport']({'id':_0x48f255[_0xd0cc('0x3b')]},_0x2dc620)['then'](handleResult(_0x48f255))['catch'](handleError());}}catch(_0x502be9){logger[_0xd0cc('0x2d')](JSON[_0xd0cc('0x28')](_0x502be9));}return logger[_0xd0cc('0xa')]('no\x20report\x20id');};}function getJobs(_0x48faa7){var _0x1a949f={};if(_0x48faa7){_0x1a949f['id']=_0x48faa7;}return db['Schedule'][_0xd0cc('0x3d')]({'where':_0x1a949f,'include':[{'model':db[_0xd0cc('0xe')],'attributes':['id',_0xd0cc('0x19'),_0xd0cc('0xb')],'include':[{'model':db[_0xd0cc('0x3e')],'as':_0xd0cc('0xc')}]}]})[_0xd0cc('0x2c')](function(_0xe58fba){var _0x5b303a=_['keys'](manager['jobs']);var _0x377e96=_[_0xd0cc('0x3f')](_0xe58fba,function(_0xcdd817){return _0xcdd817['id'][_0xd0cc('0x40')]();});var _0x1f4985=_[_0xd0cc('0x41')](_0xe58fba,function(_0xcdae1c){return _0xcdae1c['id'][_0xd0cc('0x40')]();});var _0x3148a4=_0x48faa7?_0x377e96:_[_0xd0cc('0x42')](_0x377e96,_0x5b303a);var _0x14489c=_['intersection'](_0x377e96,_0x5b303a);var _0x722c20=_[_0xd0cc('0x42')](_0x5b303a,_0x377e96);var _0x3943cd;var _0x5f181c;for(_0x3943cd=0x0;_0x3943cd<_0x722c20[_0xd0cc('0x43')]&&!_0x48faa7;_0x3943cd+=0x1){_0x5f181c=_0x722c20[_0x3943cd][_0xd0cc('0x40')]();if(manager[_0xd0cc('0x44')](_0x5f181c)){manager[_0xd0cc('0x45')](_0x5f181c);manager['deleteJob'](_0x5f181c);logger[_0xd0cc('0xa')]('delete\x20cron',_0x5f181c);}}logger[_0xd0cc('0xa')]('toRun',JSON[_0xd0cc('0x28')](_0x3148a4));for(_0x3943cd=0x0;_0x3943cd<_0x3148a4['length'];_0x3943cd+=0x1){_0x5f181c=_0x3148a4[_0x3943cd][_0xd0cc('0x40')]();logger[_0xd0cc('0xa')](_0xd0cc('0x46'),_0x5f181c);if(_0x48faa7){logger[_0xd0cc('0xa')](_0xd0cc('0x47'),_0x48faa7);logger[_0xd0cc('0xa')](JSON['stringify'](_0x1f4985[_0x5f181c]));BPromise['resolve']()['then'](handleJob(_0x1f4985[_0x5f181c]));logger[_0xd0cc('0xa')](_0xd0cc('0x48'),_0x1f4985[_0x5f181c][_0xd0cc('0x19')],_0x1f4985[_0x5f181c][_0xd0cc('0x49')]);}else if(_0x1f4985[_0x5f181c][_0xd0cc('0x49')]&&_0x1f4985[_0x5f181c]['active']&&moment()[_0xd0cc('0x4a')](_0x1f4985[_0x5f181c][_0xd0cc('0x4b')],_0x1f4985[_0x5f181c][_0xd0cc('0x4c')])){manager['add'](_0x5f181c,_0x1f4985[_0x5f181c][_0xd0cc('0x49')],handleJob(_0x1f4985[_0x5f181c]));manager[_0xd0cc('0x4d')](_0x5f181c);logger[_0xd0cc('0xa')](_0xd0cc('0x4e'),_0x1f4985[_0x5f181c][_0xd0cc('0x19')],_0x1f4985[_0x5f181c][_0xd0cc('0x49')]);}else if(manager[_0xd0cc('0x44')](_0x5f181c)){manager[_0xd0cc('0x45')](_0x5f181c);manager['deleteJob'](_0x5f181c);logger['info'](_0xd0cc('0x4f'),_0x1f4985[_0x5f181c]['name'],_0x1f4985[_0x5f181c][_0xd0cc('0x49')]);}}for(_0x3943cd=0x0,_0x5f181c;_0x3943cd<_0x14489c[_0xd0cc('0x43')]&&!_0x48faa7;_0x3943cd+=0x1){_0x5f181c=_0x14489c[_0x3943cd][_0xd0cc('0x40')]();if(manager[_0xd0cc('0x44')](_0x5f181c)){if(_0x1f4985[_0x5f181c]['cron']&&_0x1f4985[_0x5f181c][_0xd0cc('0x50')]&&moment()[_0xd0cc('0x4a')](_0x1f4985[_0x5f181c]['startAt'],_0x1f4985[_0x5f181c][_0xd0cc('0x4c')])){manager[_0xd0cc('0x51')](_0x5f181c,_0x1f4985[_0x5f181c][_0xd0cc('0x49')],handleJob(_0x1f4985[_0x5f181c]));logger['info'](_0xd0cc('0x52'),_0x1f4985[_0x5f181c][_0xd0cc('0x19')],_0x1f4985[_0x5f181c][_0xd0cc('0x49')]);}else{manager[_0xd0cc('0x45')](_0x5f181c);manager[_0xd0cc('0x53')](_0x5f181c);logger[_0xd0cc('0xa')](_0xd0cc('0x4f'),_0x1f4985[_0x5f181c]['name'],_0x1f4985[_0x5f181c][_0xd0cc('0x49')]);}}}})[_0xd0cc('0x30')](function(_0x45cfd2){logger[_0xd0cc('0x2d')](JSON[_0xd0cc('0x28')](_0x45cfd2));});}exports[_0xd0cc('0x54')]=function(_0x40365f){return getJobs(_0x40365f);};exports[_0xd0cc('0x4d')]=function(){setInterval(function(){return getJobs();},0x3c*0x3e8);return getJobs();};
\ No newline at end of file