Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / services / agi / project.js
index 534a277..2caf09b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4911=['hasOwnProperty','isArray','length','source','target','addEdge','value','toJson','mxGraphModel','inspect','production','start','root','stringify','joinAt','format','YYYY-MM-DD\x20HH:mm:ss','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','calleridname','callerid','dnid','uniqueid','traverseBFS','clear','debug','vertex','agicommand','info','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','response','code','evtHangup','isUndefined','result','toString','agicommand\x20not\x20found','[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s','close','Project\x20%s\x20not\x20found','continueAt','Project\x20%s\x20not\x20published','exports','moment','xml2json','../../config/logger','agi','./mailRpc','./graph','getSquareProjects','catch','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','retry','omit','mxCell'];(function(_0x1dbb52,_0x17df00){var _0x1a3ab7=function(_0x36e21b){while(--_0x36e21b){_0x1dbb52['push'](_0x1dbb52['shift']());}};_0x1a3ab7(++_0x17df00);}(_0x4911,0x160));var _0x1491=function(_0x184a95,_0x500731){_0x184a95=_0x184a95-0x0;var _0x55eadf=_0x4911[_0x184a95];return _0x55eadf;};'use strict';var _=require('lodash');var moment=require(_0x1491('0x0'));var parser=require(_0x1491('0x1'));var util=require('util');var logger=require(_0x1491('0x2'))(_0x1491('0x3'));var rpc=require('./rpc');var mailRpc=require(_0x1491('0x4'));var Graph=require(_0x1491('0x5'));var Vertices=require('./vertices');var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0x1491('0x6')]()[_0x1491('0x7')](function(_0x3b6250){logger[_0x1491('0x8')](_0x1491('0x9'),_0x3b6250[_0x1491('0xa')]);return[];});}function addVertex(_0x102996,_0x173bdb,_0x412c3b){_0x173bdb['agicommand']=_0x412c3b;if(_0x173bdb['hasOwnProperty'](_0x1491('0xb'))){_0x173bdb['maxRetry']=parseInt(_0x173bdb[_0x1491('0xb')],0xa);}_0x102996['addVertex'](_[_0x1491('0xc')](_0x173bdb,_0x1491('0xd')));}function initGraph(_0xe904e,_0x3233bc){var _0x301062=new Graph();for(var _0x56abbc in _0xe904e){if(_0xe904e[_0x1491('0xe')](_0x56abbc)){if(_[_0x1491('0xf')](_0xe904e[_0x56abbc])){for(var _0x269450=0x0;_0x269450<_0xe904e[_0x56abbc][_0x1491('0x10')];_0x269450+=0x1){addVertex(_0x301062,_0xe904e[_0x56abbc][_0x269450],_0x56abbc);}}else{addVertex(_0x301062,_0xe904e[_0x56abbc],_0x56abbc);}}}for(var _0x5666da=0x0;_0x5666da<_0x3233bc[_0x1491('0x10')];_0x5666da+=0x1){if(_0x3233bc[_0x5666da][_0x1491('0x11')]&&_0x3233bc[_0x5666da][_0x1491('0x12')]){_0x301062[_0x1491('0x13')](_0x3233bc[_0x5666da][_0x1491('0x11')],_0x3233bc[_0x5666da][_0x1491('0x12')],_0x3233bc[_0x5666da][_0x1491('0x14')]);}}return _0x301062;}function getRoot(_0x2577a6){return parser[_0x1491('0x15')](_0x2577a6,{'object':!![]})[_0x1491('0x16')]['root'];}function inspect(_0x22c806){return util[_0x1491('0x17')](_0x22c806,{'showHidden':![],'depth':null});}function initialize(_0x17c672,_0x10531f){var _0x3f27d3=getRoot(_0x17c672[_0x1491('0x18')]);if(!_0x3f27d3||!_0x3f27d3[_0x1491('0x19')])return;var _0x1ef9be,_0xe7659e,_0x30508b;logger['debug'](_0x1491('0x1a'),JSON[_0x1491('0x1b')](_0x3f27d3,null,0x2));_0x10531f[_0x1491('0x1c')]=moment()[_0x1491('0x1d')](_0x1491('0x1e'));_0x1ef9be=initGraph(_[_0x1491('0xc')](_0x3f27d3,_0x1491('0xd')),_0x3f27d3[_0x1491('0xd')]);_0xe7659e=new Vertices(_0x10531f,rpc,mailRpc);logger['info'](util[_0x1491('0x1d')](_0x1491('0x1f'),_0x10531f[_0x1491('0x20')],_0x10531f[_0x1491('0x21')],_0x10531f[_0x1491('0x22')],_0x10531f[_0x1491('0x23')],_0x10531f[_0x1491('0x24')]));_0x1ef9be[_0x1491('0x25')](_0x3f27d3[_0x1491('0x19')]['id'],function(_0x2ea284){try{_0x2ea284=_0xe7659e[_0x1491('0x26')](_0x2ea284);logger[_0x1491('0x27')](_0x1491('0x28'),JSON[_0x1491('0x1b')](_0x2ea284,null,0x2));if(_0x2ea284[_0x1491('0x29')]==='gotoc'){logger[_0x1491('0x2a')](_0x1491('0x2b'));_0x10531f[_0x1491('0x2c')]=_0x2ea284[_0x1491('0x2c')]||_0x10531f[_0x1491('0x2c')];_0x10531f[_0x1491('0x2d')]=_0x2ea284[_0x1491('0x2d')];_0x10531f[_0x1491('0x2e')]=_0x2ea284[_0x1491('0x2e')]?_0x2ea284[_0x1491('0x2e')]-0x1:0x1;return null;}else if(_0x2ea284&&_0xe7659e[_0x2ea284[_0x1491('0x29')]]){_0x30508b=_0xe7659e[_0x2ea284[_0x1491('0x29')]](_0x2ea284);logger[_0x1491('0x2a')](_0x1491('0x2f'),JSON[_0x1491('0x1b')](_0x30508b,null,0x2));if(_0x30508b&&_0x30508b[_0x1491('0x30')]===AGI_CODE_SUCCESS&&_0x30508b['result']!==AGI_RESULT_ERROR&&!_0x10531f[_0x1491('0x31')]){logger['debug'](_0x1491('0x2f'),inspect(_0x30508b));return _[_0x1491('0x32')](_0x30508b[_0x1491('0x33')])?null:_0x30508b[_0x1491('0x33')][_0x1491('0x34')]();}else{logger[_0x1491('0x8')](_0x1491('0x2f'),inspect(_0x30508b));return null;}}else{logger[_0x1491('0x8')](_0x1491('0x35'));return null;}}catch(_0x243754){logger['error'](_0x243754[_0x1491('0xa')]);return null;}});if(_0x3f27d3['finally']){logger[_0x1491('0x2a')](util[_0x1491('0x1d')]('[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x10531f[_0x1491('0x20')],_0x10531f[_0x1491('0x21')],_0x10531f[_0x1491('0x22')],_0x10531f[_0x1491('0x23')],_0x10531f[_0x1491('0x24')]));_0x1ef9be[_0x1491('0x25')](_0x3f27d3['finally']['id'],function(_0x515996){try{_0x515996=_0xe7659e[_0x1491('0x26')](_0x515996);logger[_0x1491('0x27')](_0x1491('0x28'),JSON[_0x1491('0x1b')](_0x515996,null,0x2));if(_0x515996&&_0xe7659e[_0x515996[_0x1491('0x29')]]){_0x30508b=_0xe7659e[_0x515996['agicommand']](_0x515996);if(_0x30508b){logger[_0x1491('0x27')](_0x1491('0x2f'),inspect(_0x30508b));return _[_0x1491('0x32')](_0x30508b['result'])?null:_0x30508b[_0x1491('0x33')]['toString']();}else{logger[_0x1491('0x8')](_0x1491('0x2f'),inspect(_0x30508b));return null;}}else{logger['error']('agicommand\x20not\x20found');return null;}}catch(_0x10dc39){logger[_0x1491('0x8')](_0x10dc39[_0x1491('0xa')]);return null;}});}logger[_0x1491('0x2a')](util[_0x1491('0x1d')](_0x1491('0x36'),_0x10531f['arg_1'],_0x10531f[_0x1491('0x21')],_0x10531f[_0x1491('0x22')],_0x10531f[_0x1491('0x23')],_0x10531f[_0x1491('0x24')]));logger['info'](util[_0x1491('0x1d')](_0x1491('0x37'),_0x10531f[_0x1491('0x2c')],_0x10531f[_0x1491('0x2d')],parseInt(_0x10531f[_0x1491('0x2e')],0xa)+0x1));_0x10531f['continueAt'](_0x10531f[_0x1491('0x2c')],_0x10531f[_0x1491('0x2d')],parseInt(_0x10531f[_0x1491('0x2e')],0xa)+0x1);_0x10531f[_0x1491('0x38')]();}function handleNotFound(_0x4051cb){logger['error'](util[_0x1491('0x1d')](_0x1491('0x39'),_0x4051cb['arg_1']));_0x4051cb[_0x1491('0x3a')](_0x4051cb[_0x1491('0x2c')],_0x4051cb[_0x1491('0x2d')],parseInt(_0x4051cb['priority'],0xa)+0x1);_0x4051cb[_0x1491('0x38')]();}function handleUnpublished(_0x26dc07){logger[_0x1491('0x8')](util[_0x1491('0x1d')](_0x1491('0x3b'),_0x26dc07['arg_1']));_0x26dc07[_0x1491('0x3a')](_0x26dc07[_0x1491('0x2c')],_0x26dc07[_0x1491('0x2d')],parseInt(_0x26dc07[_0x1491('0x2e')],0xa)+0x1);_0x26dc07[_0x1491('0x38')]();}module[_0x1491('0x3c')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file
+var _0x1f5b=['finally','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','uniqueid','[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','calleridname','continueAt','close','Project\x20%s\x20not\x20found','Project\x20%s\x20not\x20published','exports','../../config/logger','agi','./rpc','./mailRpc','./graph','./vertices','getSquareProjects','catch','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','hasOwnProperty','retry','maxRetry','addVertex','omit','mxCell','isArray','length','source','target','addEdge','value','toJson','mxGraphModel','inspect','production','start','debug','root','stringify','joinAt','format','YYYY-MM-DD\x20HH:mm:ss','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','callerid','dnid','clear','vertex','agicommand','gotoc','info','context','extension','priority','response','result','evtHangup','isUndefined','toString'];(function(_0x5011da,_0x698ce0){var _0xd0cd45=function(_0x523d55){while(--_0x523d55){_0x5011da['push'](_0x5011da['shift']());}};_0xd0cd45(++_0x698ce0);}(_0x1f5b,0xc1));var _0xb1f5=function(_0x446a5f,_0x490261){_0x446a5f=_0x446a5f-0x0;var _0x3922f7=_0x1f5b[_0x446a5f];return _0x3922f7;};'use strict';var _=require('lodash');var moment=require('moment');var parser=require('xml2json');var util=require('util');var logger=require(_0xb1f5('0x0'))(_0xb1f5('0x1'));var rpc=require(_0xb1f5('0x2'));var mailRpc=require(_0xb1f5('0x3'));var Graph=require(_0xb1f5('0x4'));var Vertices=require(_0xb1f5('0x5'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0xb1f5('0x6')]()[_0xb1f5('0x7')](function(_0x33493f){logger[_0xb1f5('0x8')](_0xb1f5('0x9'),_0x33493f[_0xb1f5('0xa')]);return[];});}function addVertex(_0x7e98bc,_0x296c91,_0x4190fd){_0x296c91['agicommand']=_0x4190fd;if(_0x296c91[_0xb1f5('0xb')](_0xb1f5('0xc'))){_0x296c91[_0xb1f5('0xd')]=parseInt(_0x296c91[_0xb1f5('0xc')],0xa);}_0x7e98bc[_0xb1f5('0xe')](_[_0xb1f5('0xf')](_0x296c91,_0xb1f5('0x10')));}function initGraph(_0x4e5166,_0x373a33){var _0xc12fc9=new Graph();for(var _0x68f334 in _0x4e5166){if(_0x4e5166['hasOwnProperty'](_0x68f334)){if(_[_0xb1f5('0x11')](_0x4e5166[_0x68f334])){for(var _0x29bd58=0x0;_0x29bd58<_0x4e5166[_0x68f334]['length'];_0x29bd58+=0x1){addVertex(_0xc12fc9,_0x4e5166[_0x68f334][_0x29bd58],_0x68f334);}}else{addVertex(_0xc12fc9,_0x4e5166[_0x68f334],_0x68f334);}}}for(var _0x13908c=0x0;_0x13908c<_0x373a33[_0xb1f5('0x12')];_0x13908c+=0x1){if(_0x373a33[_0x13908c][_0xb1f5('0x13')]&&_0x373a33[_0x13908c][_0xb1f5('0x14')]){_0xc12fc9[_0xb1f5('0x15')](_0x373a33[_0x13908c][_0xb1f5('0x13')],_0x373a33[_0x13908c][_0xb1f5('0x14')],_0x373a33[_0x13908c][_0xb1f5('0x16')]);}}return _0xc12fc9;}function getRoot(_0x34c6f2){return parser[_0xb1f5('0x17')](_0x34c6f2,{'object':!![]})[_0xb1f5('0x18')]['root'];}function inspect(_0x432563){return util[_0xb1f5('0x19')](_0x432563,{'showHidden':![],'depth':null});}function initialize(_0x5c677c,_0x5cff05){var _0x3afb1a=getRoot(_0x5c677c[_0xb1f5('0x1a')]);if(!_0x3afb1a||!_0x3afb1a[_0xb1f5('0x1b')])return;var _0x4ea179,_0xd99879,_0x43e3eb;logger[_0xb1f5('0x1c')](_0xb1f5('0x1d'),JSON[_0xb1f5('0x1e')](_0x3afb1a,null,0x2));_0x5cff05[_0xb1f5('0x1f')]=moment()[_0xb1f5('0x20')](_0xb1f5('0x21'));_0x4ea179=initGraph(_[_0xb1f5('0xf')](_0x3afb1a,'mxCell'),_0x3afb1a[_0xb1f5('0x10')]);_0xd99879=new Vertices(_0x5cff05,rpc,mailRpc);logger['info'](util[_0xb1f5('0x20')](_0xb1f5('0x22'),_0x5cff05[_0xb1f5('0x23')],_0x5cff05['calleridname'],_0x5cff05[_0xb1f5('0x24')],_0x5cff05[_0xb1f5('0x25')],_0x5cff05['uniqueid']));_0x4ea179['traverseBFS'](_0x3afb1a['start']['id'],function(_0x1f12f6){try{_0x1f12f6=_0xd99879[_0xb1f5('0x26')](_0x1f12f6);logger[_0xb1f5('0x1c')](_0xb1f5('0x27'),JSON[_0xb1f5('0x1e')](_0x1f12f6,null,0x2));if(_0x1f12f6[_0xb1f5('0x28')]===_0xb1f5('0x29')){logger[_0xb1f5('0x2a')]('gotoc\x20block\x20stop\x20traverse\x20BFS');_0x5cff05['context']=_0x1f12f6[_0xb1f5('0x2b')]||_0x5cff05[_0xb1f5('0x2b')];_0x5cff05[_0xb1f5('0x2c')]=_0x1f12f6[_0xb1f5('0x2c')];_0x5cff05[_0xb1f5('0x2d')]=_0x1f12f6[_0xb1f5('0x2d')]?_0x1f12f6[_0xb1f5('0x2d')]-0x1:0x1;return null;}else if(_0x1f12f6&&_0xd99879[_0x1f12f6[_0xb1f5('0x28')]]){_0x43e3eb=_0xd99879[_0x1f12f6[_0xb1f5('0x28')]](_0x1f12f6);logger['info'](_0xb1f5('0x2e'),JSON[_0xb1f5('0x1e')](_0x43e3eb,null,0x2));if(_0x43e3eb&&_0x43e3eb['code']===AGI_CODE_SUCCESS&&_0x43e3eb[_0xb1f5('0x2f')]!==AGI_RESULT_ERROR&&!_0x5cff05[_0xb1f5('0x30')]){logger[_0xb1f5('0x1c')](_0xb1f5('0x2e'),inspect(_0x43e3eb));return _[_0xb1f5('0x31')](_0x43e3eb[_0xb1f5('0x2f')])?null:_0x43e3eb[_0xb1f5('0x2f')][_0xb1f5('0x32')]();}else{logger[_0xb1f5('0x8')](_0xb1f5('0x2e'),inspect(_0x43e3eb));return null;}}else{logger['error']('agicommand\x20not\x20found');return null;}}catch(_0x274789){logger['error'](_0x274789[_0xb1f5('0xa')]);return null;}});if(_0x3afb1a[_0xb1f5('0x33')]){logger[_0xb1f5('0x2a')](util[_0xb1f5('0x20')](_0xb1f5('0x34'),_0x5cff05[_0xb1f5('0x23')],_0x5cff05['calleridname'],_0x5cff05[_0xb1f5('0x24')],_0x5cff05[_0xb1f5('0x25')],_0x5cff05[_0xb1f5('0x35')]));_0x4ea179['traverseBFS'](_0x3afb1a[_0xb1f5('0x33')]['id'],function(_0x260553){try{_0x260553=_0xd99879[_0xb1f5('0x26')](_0x260553);logger['debug']('vertex',JSON[_0xb1f5('0x1e')](_0x260553,null,0x2));if(_0x260553&&_0xd99879[_0x260553[_0xb1f5('0x28')]]){_0x43e3eb=_0xd99879[_0x260553[_0xb1f5('0x28')]](_0x260553);if(_0x43e3eb){logger[_0xb1f5('0x1c')](_0xb1f5('0x2e'),inspect(_0x43e3eb));return _[_0xb1f5('0x31')](_0x43e3eb[_0xb1f5('0x2f')])?null:_0x43e3eb[_0xb1f5('0x2f')][_0xb1f5('0x32')]();}else{logger[_0xb1f5('0x8')]('response',inspect(_0x43e3eb));return null;}}else{logger[_0xb1f5('0x8')]('agicommand\x20not\x20found');return null;}}catch(_0x33043e){logger[_0xb1f5('0x8')](_0x33043e[_0xb1f5('0xa')]);return null;}});}logger[_0xb1f5('0x2a')](util[_0xb1f5('0x20')](_0xb1f5('0x36'),_0x5cff05[_0xb1f5('0x23')],_0x5cff05[_0xb1f5('0x37')],_0x5cff05[_0xb1f5('0x24')],_0x5cff05[_0xb1f5('0x25')],_0x5cff05[_0xb1f5('0x35')]));logger[_0xb1f5('0x2a')](util['format']('[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s',_0x5cff05['context'],_0x5cff05[_0xb1f5('0x2c')],parseInt(_0x5cff05[_0xb1f5('0x2d')],0xa)+0x1));_0x5cff05[_0xb1f5('0x38')](_0x5cff05[_0xb1f5('0x2b')],_0x5cff05['extension'],parseInt(_0x5cff05[_0xb1f5('0x2d')],0xa)+0x1);_0x5cff05[_0xb1f5('0x39')]();}function handleNotFound(_0xe2103f){logger[_0xb1f5('0x8')](util[_0xb1f5('0x20')](_0xb1f5('0x3a'),_0xe2103f[_0xb1f5('0x23')]));_0xe2103f[_0xb1f5('0x38')](_0xe2103f[_0xb1f5('0x2b')],_0xe2103f[_0xb1f5('0x2c')],parseInt(_0xe2103f[_0xb1f5('0x2d')],0xa)+0x1);_0xe2103f[_0xb1f5('0x39')]();}function handleUnpublished(_0xfb95f3){logger['error'](util['format'](_0xb1f5('0x3b'),_0xfb95f3[_0xb1f5('0x23')]));_0xfb95f3[_0xb1f5('0x38')](_0xfb95f3[_0xb1f5('0x2b')],_0xfb95f3[_0xb1f5('0x2c')],parseInt(_0xfb95f3['priority'],0xa)+0x1);_0xfb95f3['close']();}module[_0xb1f5('0x3c')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file