Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 2641185..7de2919 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa3b7=['desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','apply','reject','save','then','error','stack','name','send','index','map','Dynamics365Configuration','fieldName','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','catch','show','params','rawAttributes','create','body','update','find','getFields','findOne','Dynamics365Field','order','getSubjects','nolimit','getDescriptions','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce'];(function(_0x5c66a9,_0x2eb507){var _0x4783b1=function(_0x4f5db5){while(--_0x4f5db5){_0x5c66a9['push'](_0x5c66a9['shift']());}};_0x4783b1(++_0x2eb507);}(_0xa3b7,0xf4));var _0x7a3b=function(_0x238830,_0x545f75){_0x238830=_0x238830-0x0;var _0x5917f0=_0xa3b7[_0x238830];return _0x5917f0;};'use strict';var emlformat=require(_0x7a3b('0x0'));var rimraf=require(_0x7a3b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x7a3b('0x2'));var rp=require(_0x7a3b('0x3'));var moment=require(_0x7a3b('0x4'));var BPromise=require(_0x7a3b('0x5'));var Mustache=require(_0x7a3b('0x6'));var util=require(_0x7a3b('0x7'));var path=require(_0x7a3b('0x8'));var sox=require(_0x7a3b('0x9'));var csv=require(_0x7a3b('0xa'));var ejs=require(_0x7a3b('0xb'));var fs=require('fs');var fs_extra=require(_0x7a3b('0xc'));var _=require(_0x7a3b('0xd'));var squel=require(_0x7a3b('0xe'));var crypto=require(_0x7a3b('0xf'));var jsforce=require(_0x7a3b('0x10'));var deskjs=require(_0x7a3b('0x11'));var toCsv=require(_0x7a3b('0xa'));var querystring=require(_0x7a3b('0x12'));var Papa=require(_0x7a3b('0x13'));var Redis=require(_0x7a3b('0x14'));var authService=require(_0x7a3b('0x15'));var qs=require(_0x7a3b('0x16'));var as=require(_0x7a3b('0x17'));var hardwareService=require(_0x7a3b('0x18'));var logger=require(_0x7a3b('0x19'))(_0x7a3b('0x1a'));var utils=require(_0x7a3b('0x1b'));var config=require(_0x7a3b('0x1c'));var licenseUtil=require(_0x7a3b('0x1d'));var db=require(_0x7a3b('0x1e'))['db'];function respondWithStatusCode(_0x1a1311,_0x1e9e7c){_0x1e9e7c=_0x1e9e7c||0xcc;return function(_0x448595){if(_0x448595){return _0x1a1311[_0x7a3b('0x1f')](_0x1e9e7c);}return _0x1a1311[_0x7a3b('0x20')](_0x1e9e7c)[_0x7a3b('0x21')]();};}function respondWithResult(_0x24ca86,_0x5a7a66){_0x5a7a66=_0x5a7a66||0xc8;return function(_0x2cc782){if(_0x2cc782){return _0x24ca86[_0x7a3b('0x20')](_0x5a7a66)['json'](_0x2cc782);}};}function respondWithFilteredResult(_0xbcf3e8,_0x4676dd){return function(_0x4c7640){if(_0x4c7640){var _0x256b5d=typeof _0x4676dd[_0x7a3b('0x22')]===_0x7a3b('0x23')&&typeof _0x4676dd[_0x7a3b('0x24')]==='undefined';var _0x3eab64=_0x4c7640[_0x7a3b('0x25')];var _0x339447=_0x256b5d?0x0:_0x4676dd[_0x7a3b('0x22')];var _0x999d55=_0x256b5d?_0x4c7640['count']:_0x4676dd[_0x7a3b('0x22')]+_0x4676dd[_0x7a3b('0x24')];var _0x5d6cef;if(_0x999d55>=_0x3eab64){_0x999d55=_0x3eab64;_0x5d6cef=0xc8;}else{_0x5d6cef=0xce;}_0xbcf3e8[_0x7a3b('0x20')](_0x5d6cef);return _0xbcf3e8[_0x7a3b('0x26')]('Content-Range',_0x339447+'-'+_0x999d55+'/'+_0x3eab64)['json'](_0x4c7640);}return null;};}function patchUpdates(_0x3db348){return function(_0x7f951f){try{jsonpatch[_0x7a3b('0x27')](_0x7f951f,_0x3db348,!![]);}catch(_0xf5ed53){return BPromise[_0x7a3b('0x28')](_0xf5ed53);}return _0x7f951f[_0x7a3b('0x29')]();};}function saveUpdates(_0x11d907,_0x47b61c){return function(_0x35f313){if(_0x35f313){return _0x35f313['update'](_0x11d907)[_0x7a3b('0x2a')](function(_0x662259){return _0x662259;});}return null;};}function removeEntity(_0xfa8425,_0x4c2880){return function(_0x47a199){if(_0x47a199){return _0x47a199['destroy']()['then'](function(){_0xfa8425[_0x7a3b('0x20')](0xcc)[_0x7a3b('0x21')]();});}};}function handleEntityNotFound(_0x3a6006,_0x5ed5f6){return function(_0x1aca4c){if(!_0x1aca4c){_0x3a6006[_0x7a3b('0x1f')](0x194);}return _0x1aca4c;};}function handleError(_0x588a7c,_0x4aa686){_0x4aa686=_0x4aa686||0x1f4;return function(_0x413082){logger[_0x7a3b('0x2b')](_0x413082[_0x7a3b('0x2c')]);if(_0x413082[_0x7a3b('0x2d')]){delete _0x413082[_0x7a3b('0x2d')];}_0x588a7c[_0x7a3b('0x20')](_0x4aa686)[_0x7a3b('0x2e')](_0x413082);};}exports[_0x7a3b('0x2f')]=function(_0x2b46cc,_0x1276b4){var _0x23143e={},_0x4b5552={},_0xa5b603={'count':0x0,'rows':[]};var _0xe465dc=_[_0x7a3b('0x30')](db[_0x7a3b('0x31')]['rawAttributes'],function(_0x1209f1){return{'name':_0x1209f1[_0x7a3b('0x32')],'type':_0x1209f1[_0x7a3b('0x33')][_0x7a3b('0x34')]};});_0x4b5552[_0x7a3b('0x35')]=_[_0x7a3b('0x30')](_0xe465dc,_0x7a3b('0x2d'));_0x4b5552['query']=_[_0x7a3b('0x36')](_0x2b46cc[_0x7a3b('0x37')]);_0x4b5552[_0x7a3b('0x38')]=_['intersection'](_0x4b5552['model'],_0x4b5552[_0x7a3b('0x37')]);_0x23143e[_0x7a3b('0x39')]=_[_0x7a3b('0x3a')](_0x4b5552[_0x7a3b('0x35')],qs[_0x7a3b('0x3b')](_0x2b46cc['query'][_0x7a3b('0x3b')]));_0x23143e[_0x7a3b('0x39')]=_0x23143e[_0x7a3b('0x39')][_0x7a3b('0x3c')]?_0x23143e[_0x7a3b('0x39')]:_0x4b5552['model'];if(!_0x2b46cc[_0x7a3b('0x37')][_0x7a3b('0x3d')]('nolimit')){_0x23143e[_0x7a3b('0x24')]=qs['limit'](_0x2b46cc[_0x7a3b('0x37')][_0x7a3b('0x24')]);_0x23143e[_0x7a3b('0x22')]=qs[_0x7a3b('0x22')](_0x2b46cc[_0x7a3b('0x37')]['offset']);}_0x23143e['order']=qs[_0x7a3b('0x3e')](_0x2b46cc[_0x7a3b('0x37')][_0x7a3b('0x3e')]);_0x23143e[_0x7a3b('0x3f')]=qs[_0x7a3b('0x38')](_[_0x7a3b('0x40')](_0x2b46cc['query'],_0x4b5552[_0x7a3b('0x38')]),_0xe465dc);if(_0x2b46cc[_0x7a3b('0x37')][_0x7a3b('0x41')]){_0x23143e[_0x7a3b('0x3f')]=_[_0x7a3b('0x42')](_0x23143e[_0x7a3b('0x3f')],{'$or':_[_0x7a3b('0x30')](_0xe465dc,function(_0x4686ec){if(_0x4686ec[_0x7a3b('0x33')]!==_0x7a3b('0x43')){var _0x2ec40c={};_0x2ec40c[_0x4686ec['name']]={'$like':'%'+_0x2b46cc['query']['filter']+'%'};return _0x2ec40c;}})});}_0x23143e=_[_0x7a3b('0x42')]({},_0x23143e,_0x2b46cc[_0x7a3b('0x44')]);var _0x5f2629={'where':_0x23143e['where']};return db[_0x7a3b('0x31')][_0x7a3b('0x25')](_0x5f2629)[_0x7a3b('0x2a')](function(_0x5e59dd){_0xa5b603['count']=_0x5e59dd;if(_0x2b46cc['query'][_0x7a3b('0x45')]){_0x23143e[_0x7a3b('0x46')]=[{'all':!![]}];}return db[_0x7a3b('0x31')][_0x7a3b('0x47')](_0x23143e);})[_0x7a3b('0x2a')](function(_0x72b6bb){_0xa5b603['rows']=_0x72b6bb;return _0xa5b603;})[_0x7a3b('0x2a')](respondWithFilteredResult(_0x1276b4,_0x23143e))[_0x7a3b('0x48')](handleError(_0x1276b4,null));};exports[_0x7a3b('0x49')]=function(_0x480d48,_0x24e3d4){var _0x3acbf6={'raw':![],'where':{'id':_0x480d48[_0x7a3b('0x4a')]['id']}},_0x2fe912={};_0x2fe912['model']=_[_0x7a3b('0x36')](db[_0x7a3b('0x31')][_0x7a3b('0x4b')]);_0x2fe912['query']=_[_0x7a3b('0x36')](_0x480d48[_0x7a3b('0x37')]);_0x2fe912[_0x7a3b('0x38')]=_[_0x7a3b('0x3a')](_0x2fe912[_0x7a3b('0x35')],_0x2fe912[_0x7a3b('0x37')]);_0x3acbf6[_0x7a3b('0x39')]=_[_0x7a3b('0x3a')](_0x2fe912[_0x7a3b('0x35')],qs[_0x7a3b('0x3b')](_0x480d48[_0x7a3b('0x37')]['fields']));_0x3acbf6[_0x7a3b('0x39')]=_0x3acbf6['attributes'][_0x7a3b('0x3c')]?_0x3acbf6[_0x7a3b('0x39')]:_0x2fe912[_0x7a3b('0x35')];if(_0x480d48[_0x7a3b('0x37')][_0x7a3b('0x45')]){_0x3acbf6['include']=[{'all':!![]}];}_0x3acbf6=_[_0x7a3b('0x42')]({},_0x3acbf6,_0x480d48[_0x7a3b('0x44')]);return db[_0x7a3b('0x31')]['find'](_0x3acbf6)['then'](handleEntityNotFound(_0x24e3d4,null))[_0x7a3b('0x2a')](respondWithResult(_0x24e3d4,null))[_0x7a3b('0x48')](handleError(_0x24e3d4,null));};exports[_0x7a3b('0x4c')]=function(_0x3d5c12,_0x426c0f){return db['Dynamics365Configuration'][_0x7a3b('0x4c')](_0x3d5c12[_0x7a3b('0x4d')],{})['then'](respondWithResult(_0x426c0f,0xc9))[_0x7a3b('0x48')](handleError(_0x426c0f,null));};exports[_0x7a3b('0x4e')]=function(_0x42f992,_0x3bd6af){if(_0x42f992['body']['id']){delete _0x42f992[_0x7a3b('0x4d')]['id'];}return db['Dynamics365Configuration']['find']({'where':{'id':_0x42f992[_0x7a3b('0x4a')]['id']}})[_0x7a3b('0x2a')](handleEntityNotFound(_0x3bd6af,null))[_0x7a3b('0x2a')](saveUpdates(_0x42f992[_0x7a3b('0x4d')],null))[_0x7a3b('0x2a')](respondWithResult(_0x3bd6af,null))[_0x7a3b('0x48')](handleError(_0x3bd6af,null));};exports['destroy']=function(_0x3da354,_0x28bb1e){return db[_0x7a3b('0x31')][_0x7a3b('0x4f')]({'where':{'id':_0x3da354[_0x7a3b('0x4a')]['id']}})[_0x7a3b('0x2a')](handleEntityNotFound(_0x28bb1e,null))[_0x7a3b('0x2a')](removeEntity(_0x28bb1e,null))[_0x7a3b('0x48')](handleError(_0x28bb1e,null));};exports[_0x7a3b('0x50')]=function(_0x5cb9c1,_0x1e7e8a,_0x4a204e){var _0x21fc18={};var _0xb5727e={};var _0x263487;var _0x2b5ce3;return db['Dynamics365Configuration'][_0x7a3b('0x51')]({'where':{'id':_0x5cb9c1['params']['id']}})[_0x7a3b('0x2a')](handleEntityNotFound(_0x1e7e8a,null))['then'](function(_0x5cba96){if(_0x5cba96){_0x263487=_0x5cba96;_0xb5727e[_0x7a3b('0x35')]=_[_0x7a3b('0x36')](db[_0x7a3b('0x52')][_0x7a3b('0x4b')]);_0xb5727e[_0x7a3b('0x37')]=_[_0x7a3b('0x36')](_0x5cb9c1['query']);_0xb5727e[_0x7a3b('0x38')]=_['intersection'](_0xb5727e[_0x7a3b('0x35')],_0xb5727e[_0x7a3b('0x37')]);_0x21fc18[_0x7a3b('0x39')]=_[_0x7a3b('0x3a')](_0xb5727e['model'],qs[_0x7a3b('0x3b')](_0x5cb9c1[_0x7a3b('0x37')][_0x7a3b('0x3b')]));_0x21fc18['attributes']=_0x21fc18['attributes'][_0x7a3b('0x3c')]?_0x21fc18[_0x7a3b('0x39')]:_0xb5727e[_0x7a3b('0x35')];_0x21fc18[_0x7a3b('0x53')]=qs[_0x7a3b('0x3e')](_0x5cb9c1['query'][_0x7a3b('0x3e')]);_0x21fc18[_0x7a3b('0x3f')]=qs['filters'](_[_0x7a3b('0x40')](_0x5cb9c1[_0x7a3b('0x37')],_0xb5727e['filters']));if(_0x5cb9c1[_0x7a3b('0x37')][_0x7a3b('0x41')]){_0x21fc18['where']=_[_0x7a3b('0x42')](_0x21fc18['where'],{'$or':_[_0x7a3b('0x30')](_0x21fc18['attributes'],function(_0x32500d){var _0x416c48={};_0x416c48[_0x32500d]={'$like':'%'+_0x5cb9c1[_0x7a3b('0x37')][_0x7a3b('0x41')]+'%'};return _0x416c48;})});}_0x21fc18=_['merge']({},_0x21fc18,_0x5cb9c1[_0x7a3b('0x44')]);return _0x263487[_0x7a3b('0x50')](_0x21fc18);}})['then'](function(_0x27c100){if(_0x27c100){_0x2b5ce3=_0x27c100[_0x7a3b('0x3c')];if(!_0x5cb9c1['query'][_0x7a3b('0x3d')]('nolimit')){_0x21fc18[_0x7a3b('0x24')]=qs[_0x7a3b('0x24')](_0x5cb9c1['query'][_0x7a3b('0x24')]);_0x21fc18[_0x7a3b('0x22')]=qs[_0x7a3b('0x22')](_0x5cb9c1[_0x7a3b('0x37')][_0x7a3b('0x22')]);}return _0x263487[_0x7a3b('0x50')](_0x21fc18);}})[_0x7a3b('0x2a')](function(_0x23332e){if(_0x23332e){return _0x23332e?{'count':_0x2b5ce3,'rows':_0x23332e}:null;}})['then'](respondWithResult(_0x1e7e8a,null))[_0x7a3b('0x48')](handleError(_0x1e7e8a,null));};exports[_0x7a3b('0x54')]=function(_0x39dae7,_0x558117,_0x47ddb7){var _0x185e65={};var _0x37367d={};var _0x3a5286;var _0x4754b0;return db[_0x7a3b('0x31')]['findOne']({'where':{'id':_0x39dae7[_0x7a3b('0x4a')]['id']}})[_0x7a3b('0x2a')](handleEntityNotFound(_0x558117,null))[_0x7a3b('0x2a')](function(_0xbf09b8){if(_0xbf09b8){_0x3a5286=_0xbf09b8;_0x37367d[_0x7a3b('0x35')]=_['keys'](db[_0x7a3b('0x52')][_0x7a3b('0x4b')]);_0x37367d['query']=_[_0x7a3b('0x36')](_0x39dae7[_0x7a3b('0x37')]);_0x37367d[_0x7a3b('0x38')]=_[_0x7a3b('0x3a')](_0x37367d['model'],_0x37367d['query']);_0x185e65[_0x7a3b('0x39')]=_['intersection'](_0x37367d[_0x7a3b('0x35')],qs[_0x7a3b('0x3b')](_0x39dae7[_0x7a3b('0x37')][_0x7a3b('0x3b')]));_0x185e65['attributes']=_0x185e65['attributes'][_0x7a3b('0x3c')]?_0x185e65[_0x7a3b('0x39')]:_0x37367d[_0x7a3b('0x35')];_0x185e65[_0x7a3b('0x53')]=qs[_0x7a3b('0x3e')](_0x39dae7[_0x7a3b('0x37')][_0x7a3b('0x3e')]);_0x185e65[_0x7a3b('0x3f')]=qs[_0x7a3b('0x38')](_[_0x7a3b('0x40')](_0x39dae7[_0x7a3b('0x37')],_0x37367d['filters']));if(_0x39dae7[_0x7a3b('0x37')]['filter']){_0x185e65['where']=_[_0x7a3b('0x42')](_0x185e65[_0x7a3b('0x3f')],{'$or':_[_0x7a3b('0x30')](_0x185e65[_0x7a3b('0x39')],function(_0x3a1d8d){var _0x3873a0={};_0x3873a0[_0x3a1d8d]={'$like':'%'+_0x39dae7['query'][_0x7a3b('0x41')]+'%'};return _0x3873a0;})});}_0x185e65=_[_0x7a3b('0x42')]({},_0x185e65,_0x39dae7[_0x7a3b('0x44')]);return _0x3a5286[_0x7a3b('0x54')](_0x185e65);}})[_0x7a3b('0x2a')](function(_0x51968c){if(_0x51968c){_0x4754b0=_0x51968c['length'];if(!_0x39dae7[_0x7a3b('0x37')][_0x7a3b('0x3d')](_0x7a3b('0x55'))){_0x185e65[_0x7a3b('0x24')]=qs['limit'](_0x39dae7[_0x7a3b('0x37')][_0x7a3b('0x24')]);_0x185e65['offset']=qs[_0x7a3b('0x22')](_0x39dae7['query'][_0x7a3b('0x22')]);}return _0x3a5286[_0x7a3b('0x54')](_0x185e65);}})['then'](function(_0x21985c){if(_0x21985c){return _0x21985c?{'count':_0x4754b0,'rows':_0x21985c}:null;}})[_0x7a3b('0x2a')](respondWithResult(_0x558117,null))[_0x7a3b('0x48')](handleError(_0x558117,null));};exports[_0x7a3b('0x56')]=function(_0x1ccc3b,_0x7750bc,_0x4824f3){var _0x377d9b={};var _0x168e2d={};var _0x59e11d;var _0xfe9a22;return db[_0x7a3b('0x31')][_0x7a3b('0x51')]({'where':{'id':_0x1ccc3b[_0x7a3b('0x4a')]['id']}})[_0x7a3b('0x2a')](handleEntityNotFound(_0x7750bc,null))['then'](function(_0x18d7af){if(_0x18d7af){_0x59e11d=_0x18d7af;_0x168e2d[_0x7a3b('0x35')]=_[_0x7a3b('0x36')](db[_0x7a3b('0x52')][_0x7a3b('0x4b')]);_0x168e2d[_0x7a3b('0x37')]=_[_0x7a3b('0x36')](_0x1ccc3b[_0x7a3b('0x37')]);_0x168e2d['filters']=_[_0x7a3b('0x3a')](_0x168e2d[_0x7a3b('0x35')],_0x168e2d['query']);_0x377d9b[_0x7a3b('0x39')]=_[_0x7a3b('0x3a')](_0x168e2d[_0x7a3b('0x35')],qs[_0x7a3b('0x3b')](_0x1ccc3b['query'][_0x7a3b('0x3b')]));_0x377d9b['attributes']=_0x377d9b[_0x7a3b('0x39')]['length']?_0x377d9b['attributes']:_0x168e2d['model'];_0x377d9b[_0x7a3b('0x53')]=qs[_0x7a3b('0x3e')](_0x1ccc3b[_0x7a3b('0x37')][_0x7a3b('0x3e')]);_0x377d9b[_0x7a3b('0x3f')]=qs[_0x7a3b('0x38')](_['pick'](_0x1ccc3b[_0x7a3b('0x37')],_0x168e2d[_0x7a3b('0x38')]));if(_0x1ccc3b[_0x7a3b('0x37')]['filter']){_0x377d9b[_0x7a3b('0x3f')]=_['merge'](_0x377d9b[_0x7a3b('0x3f')],{'$or':_['map'](_0x377d9b['attributes'],function(_0x40dcf6){var _0x638aec={};_0x638aec[_0x40dcf6]={'$like':'%'+_0x1ccc3b[_0x7a3b('0x37')][_0x7a3b('0x41')]+'%'};return _0x638aec;})});}_0x377d9b=_[_0x7a3b('0x42')]({},_0x377d9b,_0x1ccc3b[_0x7a3b('0x44')]);return _0x59e11d[_0x7a3b('0x56')](_0x377d9b);}})[_0x7a3b('0x2a')](function(_0x4767f0){if(_0x4767f0){_0xfe9a22=_0x4767f0[_0x7a3b('0x3c')];if(!_0x1ccc3b[_0x7a3b('0x37')][_0x7a3b('0x3d')](_0x7a3b('0x55'))){_0x377d9b['limit']=qs['limit'](_0x1ccc3b[_0x7a3b('0x37')][_0x7a3b('0x24')]);_0x377d9b[_0x7a3b('0x22')]=qs['offset'](_0x1ccc3b[_0x7a3b('0x37')]['offset']);}return _0x59e11d[_0x7a3b('0x56')](_0x377d9b);}})['then'](function(_0x16d6b8){if(_0x16d6b8){return _0x16d6b8?{'count':_0xfe9a22,'rows':_0x16d6b8}:null;}})['then'](respondWithResult(_0x7750bc,null))[_0x7a3b('0x48')](handleError(_0x7750bc,null));};
\ No newline at end of file
+var _0x3c8b=['where','filters','pick','filter','merge','VIRTUAL','name','options','count','then','includeAll','include','findAll','rows','catch','show','params','create','body','find','getFields','findOne','Dynamics365Field','hasOwnProperty','getSubjects','getDescriptions','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','offset','limit','undefined','Content-Range','json','apply','reject','save','update','destroy','end','stack','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','nolimit','order','sort'];(function(_0x159235,_0x6c7f91){var _0x5345de=function(_0xf7aa28){while(--_0xf7aa28){_0x159235['push'](_0x159235['shift']());}};_0x5345de(++_0x6c7f91);}(_0x3c8b,0x67));var _0xb3c8=function(_0x152c79,_0x521f52){_0x152c79=_0x152c79-0x0;var _0x5d08eb=_0x3c8b[_0x152c79];return _0x5d08eb;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb3c8('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb3c8('0x1'));var rp=require(_0xb3c8('0x2'));var moment=require(_0xb3c8('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xb3c8('0x4'));var util=require(_0xb3c8('0x5'));var path=require(_0xb3c8('0x6'));var sox=require(_0xb3c8('0x7'));var csv=require(_0xb3c8('0x8'));var ejs=require(_0xb3c8('0x9'));var fs=require('fs');var fs_extra=require(_0xb3c8('0xa'));var _=require(_0xb3c8('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xb3c8('0xc'));var Papa=require(_0xb3c8('0xd'));var Redis=require('ioredis');var authService=require(_0xb3c8('0xe'));var qs=require(_0xb3c8('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb3c8('0x10'));var logger=require('../../config/logger')(_0xb3c8('0x11'));var utils=require(_0xb3c8('0x12'));var config=require(_0xb3c8('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0xb3c8('0x14'))['db'];function respondWithStatusCode(_0x898559,_0x1eb167){_0x1eb167=_0x1eb167||0xcc;return function(_0x3938d8){if(_0x3938d8){return _0x898559[_0xb3c8('0x15')](_0x1eb167);}return _0x898559[_0xb3c8('0x16')](_0x1eb167)['end']();};}function respondWithResult(_0x4f7b73,_0x165c61){_0x165c61=_0x165c61||0xc8;return function(_0x32844f){if(_0x32844f){return _0x4f7b73[_0xb3c8('0x16')](_0x165c61)['json'](_0x32844f);}};}function respondWithFilteredResult(_0x25b426,_0x2c4a8d){return function(_0x175116){if(_0x175116){var _0x43dfc2=typeof _0x2c4a8d[_0xb3c8('0x17')]==='undefined'&&typeof _0x2c4a8d[_0xb3c8('0x18')]===_0xb3c8('0x19');var _0x13bb07=_0x175116['count'];var _0xaf0822=_0x43dfc2?0x0:_0x2c4a8d[_0xb3c8('0x17')];var _0x305fae=_0x43dfc2?_0x175116['count']:_0x2c4a8d[_0xb3c8('0x17')]+_0x2c4a8d[_0xb3c8('0x18')];var _0x437327;if(_0x305fae>=_0x13bb07){_0x305fae=_0x13bb07;_0x437327=0xc8;}else{_0x437327=0xce;}_0x25b426[_0xb3c8('0x16')](_0x437327);return _0x25b426['set'](_0xb3c8('0x1a'),_0xaf0822+'-'+_0x305fae+'/'+_0x13bb07)[_0xb3c8('0x1b')](_0x175116);}return null;};}function patchUpdates(_0x40b886){return function(_0x26be5f){try{jsonpatch[_0xb3c8('0x1c')](_0x26be5f,_0x40b886,!![]);}catch(_0x4d1c58){return BPromise[_0xb3c8('0x1d')](_0x4d1c58);}return _0x26be5f[_0xb3c8('0x1e')]();};}function saveUpdates(_0x311de6,_0xbce116){return function(_0x4d1b5c){if(_0x4d1b5c){return _0x4d1b5c[_0xb3c8('0x1f')](_0x311de6)['then'](function(_0x31b032){return _0x31b032;});}return null;};}function removeEntity(_0x30ff0d,_0x588c24){return function(_0x50a7df){if(_0x50a7df){return _0x50a7df[_0xb3c8('0x20')]()['then'](function(){_0x30ff0d['status'](0xcc)[_0xb3c8('0x21')]();});}};}function handleEntityNotFound(_0x57607b,_0xa80aaa){return function(_0x267001){if(!_0x267001){_0x57607b['sendStatus'](0x194);}return _0x267001;};}function handleError(_0x4aec78,_0x247c17){_0x247c17=_0x247c17||0x1f4;return function(_0x2180ab){logger['error'](_0x2180ab[_0xb3c8('0x22')]);if(_0x2180ab['name']){delete _0x2180ab['name'];}_0x4aec78[_0xb3c8('0x16')](_0x247c17)['send'](_0x2180ab);};}exports['index']=function(_0xc95642,_0x2a57b2){var _0x54ede1={},_0x34c34b={},_0x597ff0={'count':0x0,'rows':[]};var _0x1d3699=_[_0xb3c8('0x23')](db[_0xb3c8('0x24')][_0xb3c8('0x25')],function(_0x472787){return{'name':_0x472787[_0xb3c8('0x26')],'type':_0x472787[_0xb3c8('0x27')][_0xb3c8('0x28')]};});_0x34c34b[_0xb3c8('0x29')]=_['map'](_0x1d3699,'name');_0x34c34b[_0xb3c8('0x2a')]=_[_0xb3c8('0x2b')](_0xc95642[_0xb3c8('0x2a')]);_0x34c34b['filters']=_[_0xb3c8('0x2c')](_0x34c34b[_0xb3c8('0x29')],_0x34c34b[_0xb3c8('0x2a')]);_0x54ede1[_0xb3c8('0x2d')]=_[_0xb3c8('0x2c')](_0x34c34b[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x54ede1[_0xb3c8('0x2d')]=_0x54ede1[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x54ede1[_0xb3c8('0x2d')]:_0x34c34b[_0xb3c8('0x29')];if(!_0xc95642[_0xb3c8('0x2a')]['hasOwnProperty'](_0xb3c8('0x30'))){_0x54ede1[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x18')]);_0x54ede1[_0xb3c8('0x17')]=qs['offset'](_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}_0x54ede1[_0xb3c8('0x31')]=qs['sort'](_0xc95642['query'][_0xb3c8('0x32')]);_0x54ede1[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_[_0xb3c8('0x35')](_0xc95642[_0xb3c8('0x2a')],_0x34c34b[_0xb3c8('0x34')]),_0x1d3699);if(_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x54ede1[_0xb3c8('0x33')]=_[_0xb3c8('0x37')](_0x54ede1['where'],{'$or':_['map'](_0x1d3699,function(_0x27d11d){if(_0x27d11d[_0xb3c8('0x27')]!==_0xb3c8('0x38')){var _0x435e90={};_0x435e90[_0x27d11d[_0xb3c8('0x39')]]={'$like':'%'+_0xc95642[_0xb3c8('0x2a')][_0xb3c8('0x36')]+'%'};return _0x435e90;}})});}_0x54ede1=_[_0xb3c8('0x37')]({},_0x54ede1,_0xc95642[_0xb3c8('0x3a')]);var _0x4183e5={'where':_0x54ede1['where']};return db['Dynamics365Configuration'][_0xb3c8('0x3b')](_0x4183e5)[_0xb3c8('0x3c')](function(_0x10e460){_0x597ff0[_0xb3c8('0x3b')]=_0x10e460;if(_0xc95642['query'][_0xb3c8('0x3d')]){_0x54ede1[_0xb3c8('0x3e')]=[{'all':!![]}];}return db[_0xb3c8('0x24')][_0xb3c8('0x3f')](_0x54ede1);})[_0xb3c8('0x3c')](function(_0x5ddaaa){_0x597ff0[_0xb3c8('0x40')]=_0x5ddaaa;return _0x597ff0;})['then'](respondWithFilteredResult(_0x2a57b2,_0x54ede1))[_0xb3c8('0x41')](handleError(_0x2a57b2,null));};exports[_0xb3c8('0x42')]=function(_0x1f9e5e,_0x3b414d){var _0x304e74={'raw':![],'where':{'id':_0x1f9e5e[_0xb3c8('0x43')]['id']}},_0x425ffd={};_0x425ffd[_0xb3c8('0x29')]=_[_0xb3c8('0x2b')](db[_0xb3c8('0x24')]['rawAttributes']);_0x425ffd[_0xb3c8('0x2a')]=_['keys'](_0x1f9e5e[_0xb3c8('0x2a')]);_0x425ffd[_0xb3c8('0x34')]=_[_0xb3c8('0x2c')](_0x425ffd[_0xb3c8('0x29')],_0x425ffd[_0xb3c8('0x2a')]);_0x304e74['attributes']=_['intersection'](_0x425ffd[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0x1f9e5e[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x304e74['attributes']=_0x304e74[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x304e74[_0xb3c8('0x2d')]:_0x425ffd[_0xb3c8('0x29')];if(_0x1f9e5e[_0xb3c8('0x2a')][_0xb3c8('0x3d')]){_0x304e74[_0xb3c8('0x3e')]=[{'all':!![]}];}_0x304e74=_[_0xb3c8('0x37')]({},_0x304e74,_0x1f9e5e[_0xb3c8('0x3a')]);return db[_0xb3c8('0x24')]['find'](_0x304e74)[_0xb3c8('0x3c')](handleEntityNotFound(_0x3b414d,null))['then'](respondWithResult(_0x3b414d,null))[_0xb3c8('0x41')](handleError(_0x3b414d,null));};exports['create']=function(_0x5b94cf,_0x24dfa0){return db[_0xb3c8('0x24')][_0xb3c8('0x44')](_0x5b94cf[_0xb3c8('0x45')],{})[_0xb3c8('0x3c')](respondWithResult(_0x24dfa0,0xc9))[_0xb3c8('0x41')](handleError(_0x24dfa0,null));};exports[_0xb3c8('0x1f')]=function(_0x182d38,_0x56302e){if(_0x182d38[_0xb3c8('0x45')]['id']){delete _0x182d38['body']['id'];}return db['Dynamics365Configuration'][_0xb3c8('0x46')]({'where':{'id':_0x182d38[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x56302e,null))['then'](saveUpdates(_0x182d38['body'],null))[_0xb3c8('0x3c')](respondWithResult(_0x56302e,null))[_0xb3c8('0x41')](handleError(_0x56302e,null));};exports['destroy']=function(_0x134653,_0x39a972){return db[_0xb3c8('0x24')][_0xb3c8('0x46')]({'where':{'id':_0x134653[_0xb3c8('0x43')]['id']}})['then'](handleEntityNotFound(_0x39a972,null))[_0xb3c8('0x3c')](removeEntity(_0x39a972,null))['catch'](handleError(_0x39a972,null));};exports[_0xb3c8('0x47')]=function(_0x336a80,_0x243641,_0x1b2b6d){var _0x373e9c={};var _0x1d3e76={};var _0x3b3db4;var _0xc6797c;return db[_0xb3c8('0x24')][_0xb3c8('0x48')]({'where':{'id':_0x336a80[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x243641,null))[_0xb3c8('0x3c')](function(_0x35d238){if(_0x35d238){_0x3b3db4=_0x35d238;_0x1d3e76['model']=_[_0xb3c8('0x2b')](db[_0xb3c8('0x49')]['rawAttributes']);_0x1d3e76[_0xb3c8('0x2a')]=_[_0xb3c8('0x2b')](_0x336a80[_0xb3c8('0x2a')]);_0x1d3e76[_0xb3c8('0x34')]=_['intersection'](_0x1d3e76['model'],_0x1d3e76['query']);_0x373e9c[_0xb3c8('0x2d')]=_[_0xb3c8('0x2c')](_0x1d3e76[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0x336a80['query'][_0xb3c8('0x2e')]));_0x373e9c[_0xb3c8('0x2d')]=_0x373e9c[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x373e9c[_0xb3c8('0x2d')]:_0x1d3e76['model'];_0x373e9c[_0xb3c8('0x31')]=qs['sort'](_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x32')]);_0x373e9c[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_[_0xb3c8('0x35')](_0x336a80[_0xb3c8('0x2a')],_0x1d3e76[_0xb3c8('0x34')]));if(_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x373e9c['where']=_[_0xb3c8('0x37')](_0x373e9c[_0xb3c8('0x33')],{'$or':_[_0xb3c8('0x23')](_0x373e9c[_0xb3c8('0x2d')],function(_0xe7166e){var _0xfdd074={};_0xfdd074[_0xe7166e]={'$like':'%'+_0x336a80['query'][_0xb3c8('0x36')]+'%'};return _0xfdd074;})});}_0x373e9c=_[_0xb3c8('0x37')]({},_0x373e9c,_0x336a80[_0xb3c8('0x3a')]);return _0x3b3db4[_0xb3c8('0x47')](_0x373e9c);}})[_0xb3c8('0x3c')](function(_0x47c111){if(_0x47c111){_0xc6797c=_0x47c111['length'];if(!_0x336a80['query'][_0xb3c8('0x4a')]('nolimit')){_0x373e9c[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x18')]);_0x373e9c['offset']=qs[_0xb3c8('0x17')](_0x336a80[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}return _0x3b3db4[_0xb3c8('0x47')](_0x373e9c);}})['then'](function(_0x12e6fd){if(_0x12e6fd){return _0x12e6fd?{'count':_0xc6797c,'rows':_0x12e6fd}:null;}})['then'](respondWithResult(_0x243641,null))[_0xb3c8('0x41')](handleError(_0x243641,null));};exports[_0xb3c8('0x4b')]=function(_0x1e14a1,_0x37ae5e,_0x58c4e3){var _0x26f433={};var _0x24b984={};var _0x21c556;var _0x367cee;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x1e14a1[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x37ae5e,null))[_0xb3c8('0x3c')](function(_0x4f1f8c){if(_0x4f1f8c){_0x21c556=_0x4f1f8c;_0x24b984[_0xb3c8('0x29')]=_['keys'](db['Dynamics365Field'][_0xb3c8('0x25')]);_0x24b984[_0xb3c8('0x2a')]=_['keys'](_0x1e14a1[_0xb3c8('0x2a')]);_0x24b984[_0xb3c8('0x34')]=_[_0xb3c8('0x2c')](_0x24b984[_0xb3c8('0x29')],_0x24b984[_0xb3c8('0x2a')]);_0x26f433[_0xb3c8('0x2d')]=_['intersection'](_0x24b984[_0xb3c8('0x29')],qs['fields'](_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x26f433[_0xb3c8('0x2d')]=_0x26f433[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x26f433[_0xb3c8('0x2d')]:_0x24b984['model'];_0x26f433['order']=qs[_0xb3c8('0x32')](_0x1e14a1['query'][_0xb3c8('0x32')]);_0x26f433[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_[_0xb3c8('0x35')](_0x1e14a1[_0xb3c8('0x2a')],_0x24b984['filters']));if(_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x26f433[_0xb3c8('0x33')]=_[_0xb3c8('0x37')](_0x26f433['where'],{'$or':_['map'](_0x26f433['attributes'],function(_0x4a499e){var _0x1071dd={};_0x1071dd[_0x4a499e]={'$like':'%'+_0x1e14a1['query'][_0xb3c8('0x36')]+'%'};return _0x1071dd;})});}_0x26f433=_[_0xb3c8('0x37')]({},_0x26f433,_0x1e14a1[_0xb3c8('0x3a')]);return _0x21c556[_0xb3c8('0x4b')](_0x26f433);}})[_0xb3c8('0x3c')](function(_0x2999c4){if(_0x2999c4){_0x367cee=_0x2999c4['length'];if(!_0x1e14a1['query'][_0xb3c8('0x4a')](_0xb3c8('0x30'))){_0x26f433[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x18')]);_0x26f433['offset']=qs['offset'](_0x1e14a1[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}return _0x21c556[_0xb3c8('0x4b')](_0x26f433);}})[_0xb3c8('0x3c')](function(_0x520054){if(_0x520054){return _0x520054?{'count':_0x367cee,'rows':_0x520054}:null;}})[_0xb3c8('0x3c')](respondWithResult(_0x37ae5e,null))[_0xb3c8('0x41')](handleError(_0x37ae5e,null));};exports[_0xb3c8('0x4c')]=function(_0x3184d5,_0x5acd43,_0x47cc90){var _0x39cb2c={};var _0x56095f={};var _0x35b358;var _0x39298f;return db[_0xb3c8('0x24')][_0xb3c8('0x48')]({'where':{'id':_0x3184d5[_0xb3c8('0x43')]['id']}})[_0xb3c8('0x3c')](handleEntityNotFound(_0x5acd43,null))[_0xb3c8('0x3c')](function(_0x59d097){if(_0x59d097){_0x35b358=_0x59d097;_0x56095f[_0xb3c8('0x29')]=_[_0xb3c8('0x2b')](db['Dynamics365Field']['rawAttributes']);_0x56095f[_0xb3c8('0x2a')]=_[_0xb3c8('0x2b')](_0x3184d5[_0xb3c8('0x2a')]);_0x56095f[_0xb3c8('0x34')]=_[_0xb3c8('0x2c')](_0x56095f[_0xb3c8('0x29')],_0x56095f[_0xb3c8('0x2a')]);_0x39cb2c[_0xb3c8('0x2d')]=_[_0xb3c8('0x2c')](_0x56095f[_0xb3c8('0x29')],qs[_0xb3c8('0x2e')](_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x2e')]));_0x39cb2c[_0xb3c8('0x2d')]=_0x39cb2c[_0xb3c8('0x2d')][_0xb3c8('0x2f')]?_0x39cb2c[_0xb3c8('0x2d')]:_0x56095f['model'];_0x39cb2c[_0xb3c8('0x31')]=qs[_0xb3c8('0x32')](_0x3184d5[_0xb3c8('0x2a')]['sort']);_0x39cb2c[_0xb3c8('0x33')]=qs[_0xb3c8('0x34')](_['pick'](_0x3184d5['query'],_0x56095f[_0xb3c8('0x34')]));if(_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x36')]){_0x39cb2c[_0xb3c8('0x33')]=_[_0xb3c8('0x37')](_0x39cb2c[_0xb3c8('0x33')],{'$or':_[_0xb3c8('0x23')](_0x39cb2c[_0xb3c8('0x2d')],function(_0x5db6d7){var _0x51ef5b={};_0x51ef5b[_0x5db6d7]={'$like':'%'+_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x36')]+'%'};return _0x51ef5b;})});}_0x39cb2c=_[_0xb3c8('0x37')]({},_0x39cb2c,_0x3184d5['options']);return _0x35b358[_0xb3c8('0x4c')](_0x39cb2c);}})[_0xb3c8('0x3c')](function(_0x353823){if(_0x353823){_0x39298f=_0x353823[_0xb3c8('0x2f')];if(!_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x4a')](_0xb3c8('0x30'))){_0x39cb2c[_0xb3c8('0x18')]=qs[_0xb3c8('0x18')](_0x3184d5[_0xb3c8('0x2a')]['limit']);_0x39cb2c[_0xb3c8('0x17')]=qs['offset'](_0x3184d5[_0xb3c8('0x2a')][_0xb3c8('0x17')]);}return _0x35b358[_0xb3c8('0x4c')](_0x39cb2c);}})[_0xb3c8('0x3c')](function(_0x1928d5){if(_0x1928d5){return _0x1928d5?{'count':_0x39298f,'rows':_0x1928d5}:null;}})['then'](respondWithResult(_0x5acd43,null))[_0xb3c8('0x41')](handleError(_0x5acd43,null));};
\ No newline at end of file