Built motion from commit c738b9ac.|2.6.25
[motion2.git] / server / services / agi / project.js
index 8b428c8..182ef65 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x7dc5=['mxGraphModel','root','inspect','start','debug','stringify','joinAt','format','YYYY-MM-DD\x20HH:mm:ss','info','arg_1','calleridname','dnid','uniqueid','traverseBFS','clear','vertex','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','code','result','evtHangup','response','isUndefined','toString','agicommand\x20not\x20found','finally','[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','callerid','[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','continueAt','Project\x20%s\x20not\x20found','close','Project\x20%s\x20not\x20published','exports','moment','util','agi','./rpc','./mailRpc','./graph','./vertices','getSquareProjects','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','agicommand','hasOwnProperty','retry','maxRetry','addVertex','omit','mxCell','isArray','length','source','addEdge','target','value','toJson'];(function(_0xf5d71c,_0x2613a6){var _0x5af672=function(_0x191f52){while(--_0x191f52){_0xf5d71c['push'](_0xf5d71c['shift']());}};_0x5af672(++_0x2613a6);}(_0x7dc5,0x167));var _0x57dc=function(_0xf9431c,_0x4754b5){_0xf9431c=_0xf9431c-0x0;var _0x53fc33=_0x7dc5[_0xf9431c];return _0x53fc33;};'use strict';var _=require('lodash');var moment=require(_0x57dc('0x0'));var parser=require('xml2json');var util=require(_0x57dc('0x1'));var logger=require('../../config/logger')(_0x57dc('0x2'));var rpc=require(_0x57dc('0x3'));var mailRpc=require(_0x57dc('0x4'));var Graph=require(_0x57dc('0x5'));var Vertices=require(_0x57dc('0x6'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc[_0x57dc('0x7')]()['catch'](function(_0x2e4e54){logger[_0x57dc('0x8')](_0x57dc('0x9'),_0x2e4e54[_0x57dc('0xa')]);return[];});}function addVertex(_0x591792,_0x28308a,_0x199323){_0x28308a[_0x57dc('0xb')]=_0x199323;if(_0x28308a[_0x57dc('0xc')](_0x57dc('0xd'))){_0x28308a[_0x57dc('0xe')]=parseInt(_0x28308a[_0x57dc('0xd')],0xa);}_0x591792[_0x57dc('0xf')](_[_0x57dc('0x10')](_0x28308a,_0x57dc('0x11')));}function initGraph(_0x52b3d0,_0x3f45f5){var _0x2f41cc=new Graph();for(var _0xbc7493 in _0x52b3d0){if(_0x52b3d0[_0x57dc('0xc')](_0xbc7493)){if(_[_0x57dc('0x12')](_0x52b3d0[_0xbc7493])){for(var _0x4c1fcc=0x0;_0x4c1fcc<_0x52b3d0[_0xbc7493]['length'];_0x4c1fcc+=0x1){addVertex(_0x2f41cc,_0x52b3d0[_0xbc7493][_0x4c1fcc],_0xbc7493);}}else{addVertex(_0x2f41cc,_0x52b3d0[_0xbc7493],_0xbc7493);}}}for(var _0x269c1b=0x0;_0x269c1b<_0x3f45f5[_0x57dc('0x13')];_0x269c1b+=0x1){if(_0x3f45f5[_0x269c1b][_0x57dc('0x14')]&&_0x3f45f5[_0x269c1b]['target']){_0x2f41cc[_0x57dc('0x15')](_0x3f45f5[_0x269c1b]['source'],_0x3f45f5[_0x269c1b][_0x57dc('0x16')],_0x3f45f5[_0x269c1b][_0x57dc('0x17')]);}}return _0x2f41cc;}function getRoot(_0x4af601){return parser[_0x57dc('0x18')](_0x4af601,{'object':!![]})[_0x57dc('0x19')][_0x57dc('0x1a')];}function inspect(_0x28f21b){return util[_0x57dc('0x1b')](_0x28f21b,{'showHidden':![],'depth':null});}function initialize(_0x3ed0b2,_0x4f0821){var _0x238e1a=getRoot(_0x3ed0b2['production']);if(!_0x238e1a||!_0x238e1a[_0x57dc('0x1c')])return;var _0x1deeab,_0xdc47dc,_0x4e47f2;logger[_0x57dc('0x1d')](_0x57dc('0x1a'),JSON[_0x57dc('0x1e')](_0x238e1a,null,0x2));_0x4f0821[_0x57dc('0x1f')]=moment()[_0x57dc('0x20')](_0x57dc('0x21'));_0x1deeab=initGraph(_[_0x57dc('0x10')](_0x238e1a,'mxCell'),_0x238e1a['mxCell']);_0xdc47dc=new Vertices(_0x4f0821,rpc,mailRpc);logger[_0x57dc('0x22')](util[_0x57dc('0x20')]('[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x4f0821[_0x57dc('0x23')],_0x4f0821[_0x57dc('0x24')],_0x4f0821['callerid'],_0x4f0821[_0x57dc('0x25')],_0x4f0821[_0x57dc('0x26')]));_0x1deeab[_0x57dc('0x27')](_0x238e1a[_0x57dc('0x1c')]['id'],function(_0x23f46d){try{_0x23f46d=_0xdc47dc[_0x57dc('0x28')](_0x23f46d);logger[_0x57dc('0x1d')](_0x57dc('0x29'),JSON[_0x57dc('0x1e')](_0x23f46d,null,0x2));if(_0x23f46d[_0x57dc('0xb')]===_0x57dc('0x2a')){logger['info'](_0x57dc('0x2b'));_0x4f0821[_0x57dc('0x2c')]=_0x23f46d[_0x57dc('0x2c')]||_0x4f0821['context'];_0x4f0821[_0x57dc('0x2d')]=_0x23f46d[_0x57dc('0x2d')];_0x4f0821['priority']=_0x23f46d[_0x57dc('0x2e')]?_0x23f46d['priority']-0x1:0x1;return null;}else if(_0x23f46d&&_0xdc47dc[_0x23f46d[_0x57dc('0xb')]]){_0x4e47f2=_0xdc47dc[_0x23f46d['agicommand']](_0x23f46d);logger['info']('response',JSON[_0x57dc('0x1e')](_0x4e47f2,null,0x2));if(_0x4e47f2&&_0x4e47f2[_0x57dc('0x2f')]===AGI_CODE_SUCCESS&&_0x4e47f2[_0x57dc('0x30')]!==AGI_RESULT_ERROR&&!_0x4f0821[_0x57dc('0x31')]){logger['debug'](_0x57dc('0x32'),inspect(_0x4e47f2));return _[_0x57dc('0x33')](_0x4e47f2[_0x57dc('0x30')])?null:_0x4e47f2[_0x57dc('0x30')][_0x57dc('0x34')]();}else{logger[_0x57dc('0x8')]('response',inspect(_0x4e47f2));return null;}}else{logger[_0x57dc('0x8')](_0x57dc('0x35'));return null;}}catch(_0x1d7b53){logger[_0x57dc('0x8')](_0x1d7b53[_0x57dc('0xa')]);return null;}});if(_0x238e1a[_0x57dc('0x36')]){logger[_0x57dc('0x22')](util[_0x57dc('0x20')](_0x57dc('0x37'),_0x4f0821['arg_1'],_0x4f0821['calleridname'],_0x4f0821[_0x57dc('0x38')],_0x4f0821[_0x57dc('0x25')],_0x4f0821['uniqueid']));_0x1deeab[_0x57dc('0x27')](_0x238e1a[_0x57dc('0x36')]['id'],function(_0x33fc32){try{_0x33fc32=_0xdc47dc[_0x57dc('0x28')](_0x33fc32);logger[_0x57dc('0x1d')](_0x57dc('0x29'),JSON['stringify'](_0x33fc32,null,0x2));if(_0x33fc32&&_0xdc47dc[_0x33fc32[_0x57dc('0xb')]]){_0x4e47f2=_0xdc47dc[_0x33fc32[_0x57dc('0xb')]](_0x33fc32);if(_0x4e47f2){logger['debug']('response',inspect(_0x4e47f2));return _[_0x57dc('0x33')](_0x4e47f2[_0x57dc('0x30')])?null:_0x4e47f2[_0x57dc('0x30')]['toString']();}else{logger[_0x57dc('0x8')](_0x57dc('0x32'),inspect(_0x4e47f2));return null;}}else{logger[_0x57dc('0x8')](_0x57dc('0x35'));return null;}}catch(_0x48619c){logger[_0x57dc('0x8')](_0x48619c[_0x57dc('0xa')]);return null;}});}logger[_0x57dc('0x22')](util[_0x57dc('0x20')](_0x57dc('0x39'),_0x4f0821[_0x57dc('0x23')],_0x4f0821['calleridname'],_0x4f0821['callerid'],_0x4f0821[_0x57dc('0x25')],_0x4f0821[_0x57dc('0x26')]));logger[_0x57dc('0x22')](util[_0x57dc('0x20')](_0x57dc('0x3a'),_0x4f0821[_0x57dc('0x2c')],_0x4f0821[_0x57dc('0x2d')],parseInt(_0x4f0821['priority'],0xa)+0x1));_0x4f0821[_0x57dc('0x3b')](_0x4f0821[_0x57dc('0x2c')],_0x4f0821[_0x57dc('0x2d')],parseInt(_0x4f0821[_0x57dc('0x2e')],0xa)+0x1);_0x4f0821['close']();}function handleNotFound(_0x10b346){logger['error'](util[_0x57dc('0x20')](_0x57dc('0x3c'),_0x10b346[_0x57dc('0x23')]));_0x10b346[_0x57dc('0x3b')](_0x10b346[_0x57dc('0x2c')],_0x10b346['extension'],parseInt(_0x10b346[_0x57dc('0x2e')],0xa)+0x1);_0x10b346[_0x57dc('0x3d')]();}function handleUnpublished(_0x221388){logger[_0x57dc('0x8')](util['format'](_0x57dc('0x3e'),_0x221388[_0x57dc('0x23')]));_0x221388[_0x57dc('0x3b')](_0x221388['context'],_0x221388['extension'],parseInt(_0x221388[_0x57dc('0x2e')],0xa)+0x1);_0x221388[_0x57dc('0x3d')]();}module[_0x57dc('0x3f')]={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file
+var _0xcbd6=['info','[START\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s','arg_1','callerid','dnid','traverseBFS','debug','vertex','gotoc','gotoc\x20block\x20stop\x20traverse\x20BFS','context','extension','priority','response','code','result','evtHangup','isUndefined','toString','agicommand\x20not\x20found','finally','format','calleridname','uniqueid','clear','continueAt','close','Project\x20%s\x20not\x20found','Project\x20%s\x20not\x20published','lodash','moment','xml2json','util','agi','./rpc','./mailRpc','./graph','./vertices','error','Unable\x20to\x20download\x20CallySquare\x20projects','stack','agicommand','hasOwnProperty','maxRetry','retry','omit','mxCell','length','source','target','value','toJson','inspect','production','start','stringify','joinAt','YYYY-MM-DD\x20HH:mm:ss'];(function(_0x5c9307,_0x5b97e4){var _0x373e29=function(_0xefebbd){while(--_0xefebbd){_0x5c9307['push'](_0x5c9307['shift']());}};_0x373e29(++_0x5b97e4);}(_0xcbd6,0x1ed));var _0x6cbd=function(_0x2a0753,_0x169edf){_0x2a0753=_0x2a0753-0x0;var _0xccbbf6=_0xcbd6[_0x2a0753];return _0xccbbf6;};'use strict';var _=require(_0x6cbd('0x0'));var moment=require(_0x6cbd('0x1'));var parser=require(_0x6cbd('0x2'));var util=require(_0x6cbd('0x3'));var logger=require('../../config/logger')(_0x6cbd('0x4'));var rpc=require(_0x6cbd('0x5'));var mailRpc=require(_0x6cbd('0x6'));var Graph=require(_0x6cbd('0x7'));var Vertices=require(_0x6cbd('0x8'));var AGI_CODE_SUCCESS=0xc8;var AGI_RESULT_ERROR=-0x1;function getAll(){return rpc['getSquareProjects']()['catch'](function(_0x2e7bd7){logger[_0x6cbd('0x9')](_0x6cbd('0xa'),_0x2e7bd7[_0x6cbd('0xb')]);return[];});}function addVertex(_0x3d89cc,_0x1b5eca,_0x3bd2f9){_0x1b5eca[_0x6cbd('0xc')]=_0x3bd2f9;if(_0x1b5eca[_0x6cbd('0xd')]('retry')){_0x1b5eca[_0x6cbd('0xe')]=parseInt(_0x1b5eca[_0x6cbd('0xf')],0xa);}_0x3d89cc['addVertex'](_[_0x6cbd('0x10')](_0x1b5eca,_0x6cbd('0x11')));}function initGraph(_0x41135e,_0x2c218b){var _0x5a7dbc=new Graph();for(var _0x35a29b in _0x41135e){if(_0x41135e[_0x6cbd('0xd')](_0x35a29b)){if(_['isArray'](_0x41135e[_0x35a29b])){for(var _0x24742b=0x0;_0x24742b<_0x41135e[_0x35a29b][_0x6cbd('0x12')];_0x24742b+=0x1){addVertex(_0x5a7dbc,_0x41135e[_0x35a29b][_0x24742b],_0x35a29b);}}else{addVertex(_0x5a7dbc,_0x41135e[_0x35a29b],_0x35a29b);}}}for(var _0x433297=0x0;_0x433297<_0x2c218b['length'];_0x433297+=0x1){if(_0x2c218b[_0x433297][_0x6cbd('0x13')]&&_0x2c218b[_0x433297]['target']){_0x5a7dbc['addEdge'](_0x2c218b[_0x433297][_0x6cbd('0x13')],_0x2c218b[_0x433297][_0x6cbd('0x14')],_0x2c218b[_0x433297][_0x6cbd('0x15')]);}}return _0x5a7dbc;}function getRoot(_0x153d35){return parser[_0x6cbd('0x16')](_0x153d35,{'object':!![]})['mxGraphModel']['root'];}function inspect(_0x637f18){return util[_0x6cbd('0x17')](_0x637f18,{'showHidden':![],'depth':null});}function initialize(_0x18c3dc,_0x458282){var _0x592529=getRoot(_0x18c3dc[_0x6cbd('0x18')]);if(!_0x592529||!_0x592529[_0x6cbd('0x19')])return;var _0x86da13,_0x3ae0cf,_0x17e02a;logger['debug']('root',JSON[_0x6cbd('0x1a')](_0x592529,null,0x2));_0x458282[_0x6cbd('0x1b')]=moment()['format'](_0x6cbd('0x1c'));_0x86da13=initGraph(_[_0x6cbd('0x10')](_0x592529,_0x6cbd('0x11')),_0x592529[_0x6cbd('0x11')]);_0x3ae0cf=new Vertices(_0x458282,rpc,mailRpc);logger[_0x6cbd('0x1d')](util['format'](_0x6cbd('0x1e'),_0x458282[_0x6cbd('0x1f')],_0x458282['calleridname'],_0x458282[_0x6cbd('0x20')],_0x458282[_0x6cbd('0x21')],_0x458282['uniqueid']));_0x86da13[_0x6cbd('0x22')](_0x592529[_0x6cbd('0x19')]['id'],function(_0x52de0b){try{_0x52de0b=_0x3ae0cf['clear'](_0x52de0b);logger[_0x6cbd('0x23')](_0x6cbd('0x24'),JSON[_0x6cbd('0x1a')](_0x52de0b,null,0x2));if(_0x52de0b[_0x6cbd('0xc')]===_0x6cbd('0x25')){logger[_0x6cbd('0x1d')](_0x6cbd('0x26'));_0x458282['context']=_0x52de0b[_0x6cbd('0x27')]||_0x458282['context'];_0x458282[_0x6cbd('0x28')]=_0x52de0b[_0x6cbd('0x28')];_0x458282[_0x6cbd('0x29')]=_0x52de0b[_0x6cbd('0x29')]?_0x52de0b[_0x6cbd('0x29')]-0x1:0x1;return null;}else if(_0x52de0b&&_0x3ae0cf[_0x52de0b[_0x6cbd('0xc')]]){_0x17e02a=_0x3ae0cf[_0x52de0b['agicommand']](_0x52de0b);logger[_0x6cbd('0x1d')](_0x6cbd('0x2a'),JSON[_0x6cbd('0x1a')](_0x17e02a,null,0x2));if(_0x17e02a&&_0x17e02a[_0x6cbd('0x2b')]===AGI_CODE_SUCCESS&&_0x17e02a[_0x6cbd('0x2c')]!==AGI_RESULT_ERROR&&!_0x458282[_0x6cbd('0x2d')]){logger[_0x6cbd('0x23')]('response',inspect(_0x17e02a));return _[_0x6cbd('0x2e')](_0x17e02a[_0x6cbd('0x2c')])?null:_0x17e02a['result'][_0x6cbd('0x2f')]();}else{logger['error'](_0x6cbd('0x2a'),inspect(_0x17e02a));return null;}}else{logger[_0x6cbd('0x9')](_0x6cbd('0x30'));return null;}}catch(_0x36d0cc){logger[_0x6cbd('0x9')](_0x36d0cc[_0x6cbd('0xb')]);return null;}});if(_0x592529[_0x6cbd('0x31')]){logger[_0x6cbd('0x1d')](util[_0x6cbd('0x32')]('[FINALLY\x20TRAVERSE]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x458282[_0x6cbd('0x1f')],_0x458282[_0x6cbd('0x33')],_0x458282[_0x6cbd('0x20')],_0x458282['dnid'],_0x458282[_0x6cbd('0x34')]));_0x86da13['traverseBFS'](_0x592529[_0x6cbd('0x31')]['id'],function(_0x311059){try{_0x311059=_0x3ae0cf[_0x6cbd('0x35')](_0x311059);logger[_0x6cbd('0x23')](_0x6cbd('0x24'),JSON[_0x6cbd('0x1a')](_0x311059,null,0x2));if(_0x311059&&_0x3ae0cf[_0x311059[_0x6cbd('0xc')]]){_0x17e02a=_0x3ae0cf[_0x311059[_0x6cbd('0xc')]](_0x311059);if(_0x17e02a){logger[_0x6cbd('0x23')](_0x6cbd('0x2a'),inspect(_0x17e02a));return _[_0x6cbd('0x2e')](_0x17e02a[_0x6cbd('0x2c')])?null:_0x17e02a['result']['toString']();}else{logger['error'](_0x6cbd('0x2a'),inspect(_0x17e02a));return null;}}else{logger[_0x6cbd('0x9')](_0x6cbd('0x30'));return null;}}catch(_0x3aff35){logger[_0x6cbd('0x9')](_0x3aff35[_0x6cbd('0xb')]);return null;}});}logger[_0x6cbd('0x1d')](util[_0x6cbd('0x32')]('[END]\x20%s\x20project:\x20from\x20\x22%s\x22\x20<%s>\x20to\x20extension\x20%s\x20with\x20uniqueid\x20%s',_0x458282[_0x6cbd('0x1f')],_0x458282[_0x6cbd('0x33')],_0x458282[_0x6cbd('0x20')],_0x458282[_0x6cbd('0x21')],_0x458282[_0x6cbd('0x34')]));logger[_0x6cbd('0x1d')](util[_0x6cbd('0x32')]('[GOTO]\x20context:\x20%s\x20extension:\x20%s\x20priority:\x20%s',_0x458282['context'],_0x458282[_0x6cbd('0x28')],parseInt(_0x458282[_0x6cbd('0x29')],0xa)+0x1));_0x458282[_0x6cbd('0x36')](_0x458282[_0x6cbd('0x27')],_0x458282[_0x6cbd('0x28')],parseInt(_0x458282[_0x6cbd('0x29')],0xa)+0x1);_0x458282[_0x6cbd('0x37')]();}function handleNotFound(_0x35281b){logger[_0x6cbd('0x9')](util[_0x6cbd('0x32')](_0x6cbd('0x38'),_0x35281b[_0x6cbd('0x1f')]));_0x35281b[_0x6cbd('0x36')](_0x35281b[_0x6cbd('0x27')],_0x35281b[_0x6cbd('0x28')],parseInt(_0x35281b['priority'],0xa)+0x1);_0x35281b['close']();}function handleUnpublished(_0x5ced34){logger['error'](util[_0x6cbd('0x32')](_0x6cbd('0x39'),_0x5ced34[_0x6cbd('0x1f')]));_0x5ced34[_0x6cbd('0x36')](_0x5ced34[_0x6cbd('0x27')],_0x5ced34[_0x6cbd('0x28')],parseInt(_0x5ced34['priority'],0xa)+0x1);_0x5ced34[_0x6cbd('0x37')]();}module['exports']={'getAll':getAll,'handleNotFound':handleNotFound,'handleUnpublished':handleUnpublished,'initialize':initialize};
\ No newline at end of file