Built motion from commit 9e1399f3.|2.5.37
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index d61bdc7..4b77aca 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x84b9=['to-csv','ejs','lodash','squel','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','then','info','Dynamics365Configuration,\x20%s,\x20%s','debug','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','result','catch','sendStatus','status','json','count','offset','Content-Range','apply','reject','save','update','destroy','end','name','index','map','rawAttributes','fieldName','type','key','model','keys','filters','intersection','query','attributes','fields','length','nolimit','limit','order','sort','pick','filter','where','merge','VIRTUAL','options','Dynamics365Configuration','includeAll','findAll','find','create','body','params','getFields','hasOwnProperty','findOne','Dynamics365Field','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox'];(function(_0x152508,_0x13eba0){var _0x2772a2=function(_0x1c08e6){while(--_0x1c08e6){_0x152508['push'](_0x152508['shift']());}};_0x2772a2(++_0x13eba0);}(_0x84b9,0x1bc));var _0x984b=function(_0x43941d,_0x45fd0d){_0x43941d=_0x43941d-0x0;var _0x27b82a=_0x84b9[_0x43941d];return _0x27b82a;};'use strict';var pdf=require(_0x984b('0x0'));var emlformat=require(_0x984b('0x1'));var rimraf=require(_0x984b('0x2'));var zipdir=require(_0x984b('0x3'));var jsonpatch=require(_0x984b('0x4'));var rp=require(_0x984b('0x5'));var moment=require(_0x984b('0x6'));var BPromise=require(_0x984b('0x7'));var Mustache=require(_0x984b('0x8'));var util=require(_0x984b('0x9'));var path=require('path');var sox=require(_0x984b('0xa'));var csv=require(_0x984b('0xb'));var ejs=require(_0x984b('0xc'));var fs=require('fs');var _=require(_0x984b('0xd'));var squel=require(_0x984b('0xe'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x984b('0xb'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x984b('0xf'));var authService=require(_0x984b('0x10'));var qs=require(_0x984b('0x11'));var as=require(_0x984b('0x12'));var hardwareService=require(_0x984b('0x13'));var logger=require(_0x984b('0x14'))(_0x984b('0x15'));var utils=require(_0x984b('0x16'));var config=require(_0x984b('0x17'));var licenseUtil=require(_0x984b('0x18'));var db=require(_0x984b('0x19'))['db'];var jayson=require(_0x984b('0x1a'));var client=jayson[_0x984b('0x1b')][_0x984b('0x1c')]({'port':0x232a});function respondWithRpcPromise(_0x5cbb70,_0x1b5398,_0xdfd203,_0xbe5705){return new BPromise(function(_0x9dff93,_0x7e5323){var _0x47617a=_0xbe5705||client;return _0x47617a['request'](_0x5cbb70,_0xdfd203)[_0x984b('0x1d')](function(_0x2e192b){logger[_0x984b('0x1e')](_0x984b('0x1f'),_0x1b5398,'request\x20sent');logger[_0x984b('0x20')](_0x984b('0x21'),_0x1b5398,'request\x20sent',JSON[_0x984b('0x22')](_0x2e192b));if(_0x2e192b['error']){if(_0x2e192b[_0x984b('0x23')][_0x984b('0x24')]===0x1f4){logger[_0x984b('0x23')]('Dynamics365Configuration,\x20%s,\x20%s',_0x1b5398,_0x2e192b[_0x984b('0x23')][_0x984b('0x25')]);return _0x7e5323(_0x2e192b[_0x984b('0x23')]['message']);}logger[_0x984b('0x23')]('Dynamics365Configuration,\x20%s,\x20%s',_0x1b5398,_0x2e192b[_0x984b('0x23')]['message']);return _0x9dff93(_0x2e192b['error'][_0x984b('0x25')]);}else{logger[_0x984b('0x1e')](_0x984b('0x1f'),_0x1b5398,_0x984b('0x26'));_0x9dff93(_0x2e192b[_0x984b('0x27')][_0x984b('0x25')]);}})[_0x984b('0x28')](function(_0x386666){logger[_0x984b('0x23')](_0x984b('0x1f'),_0x1b5398,_0x386666);_0x7e5323(_0x386666);});});}function respondWithStatusCode(_0x19dfa4,_0x2fca3b){_0x2fca3b=_0x2fca3b||0xcc;return function(_0x233b80){if(_0x233b80){return _0x19dfa4[_0x984b('0x29')](_0x2fca3b);}return _0x19dfa4[_0x984b('0x2a')](_0x2fca3b)['end']();};}function respondWithResult(_0x3d67c6,_0x13a36e){_0x13a36e=_0x13a36e||0xc8;return function(_0x177ea3){if(_0x177ea3){return _0x3d67c6[_0x984b('0x2a')](_0x13a36e)[_0x984b('0x2b')](_0x177ea3);}};}function respondWithFilteredResult(_0x2e5cf8,_0x468eec){return function(_0x527887){if(_0x527887){var _0x886274=_0x527887[_0x984b('0x2c')],_0x9366dc=_0x468eec[_0x984b('0x2d')],_0x172600=_0x468eec[_0x984b('0x2d')]+_0x468eec['limit'],_0x5d8dc5;if(_0x172600>=_0x886274){_0x172600=_0x886274;_0x5d8dc5=0xc8;}else{_0x5d8dc5=0xce;}_0x2e5cf8['status'](_0x5d8dc5);return _0x2e5cf8['set'](_0x984b('0x2e'),_0x9366dc+'-'+_0x172600+'/'+_0x886274)[_0x984b('0x2b')](_0x527887);}return null;};}function patchUpdates(_0x305eb0){return function(_0x5207b3){try{jsonpatch[_0x984b('0x2f')](_0x5207b3,_0x305eb0,!![]);}catch(_0x2705b7){return BPromise[_0x984b('0x30')](_0x2705b7);}return _0x5207b3[_0x984b('0x31')]();};}function saveUpdates(_0x1df1d2,_0x5566b9){return function(_0x23ae97){if(_0x23ae97){return _0x23ae97[_0x984b('0x32')](_0x1df1d2)[_0x984b('0x1d')](function(_0x267265){return _0x267265;});}return null;};}function removeEntity(_0x6f6cb0,_0x553fa3){return function(_0x220a98){if(_0x220a98){return _0x220a98[_0x984b('0x33')]()[_0x984b('0x1d')](function(){_0x6f6cb0[_0x984b('0x2a')](0xcc)[_0x984b('0x34')]();});}};}function handleEntityNotFound(_0x393ebf,_0x5a1432){return function(_0x4b9726){if(!_0x4b9726){_0x393ebf['sendStatus'](0x194);}return _0x4b9726;};}function handleError(_0x1e947e,_0x1d3347){_0x1d3347=_0x1d3347||0x1f4;return function(_0x26f8c7){logger[_0x984b('0x23')](_0x26f8c7['stack']);if(_0x26f8c7[_0x984b('0x35')]){delete _0x26f8c7[_0x984b('0x35')];}_0x1e947e['status'](_0x1d3347)['send'](_0x26f8c7);};}exports[_0x984b('0x36')]=function(_0x4b29f4,_0x28b360){var _0x5acd11={},_0x3fbaa4={},_0x51815a={'count':0x0,'rows':[]};var _0x486871=_[_0x984b('0x37')](db['Dynamics365Configuration'][_0x984b('0x38')],function(_0xe140a2){return{'name':_0xe140a2[_0x984b('0x39')],'type':_0xe140a2[_0x984b('0x3a')][_0x984b('0x3b')]};});_0x3fbaa4[_0x984b('0x3c')]=_['map'](_0x486871,_0x984b('0x35'));_0x3fbaa4['query']=_[_0x984b('0x3d')](_0x4b29f4['query']);_0x3fbaa4[_0x984b('0x3e')]=_[_0x984b('0x3f')](_0x3fbaa4[_0x984b('0x3c')],_0x3fbaa4[_0x984b('0x40')]);_0x5acd11[_0x984b('0x41')]=_['intersection'](_0x3fbaa4[_0x984b('0x3c')],qs['fields'](_0x4b29f4[_0x984b('0x40')][_0x984b('0x42')]));_0x5acd11[_0x984b('0x41')]=_0x5acd11[_0x984b('0x41')][_0x984b('0x43')]?_0x5acd11[_0x984b('0x41')]:_0x3fbaa4['model'];if(!_0x4b29f4[_0x984b('0x40')]['hasOwnProperty'](_0x984b('0x44'))){_0x5acd11[_0x984b('0x45')]=qs[_0x984b('0x45')](_0x4b29f4[_0x984b('0x40')]['limit']);_0x5acd11[_0x984b('0x2d')]=qs[_0x984b('0x2d')](_0x4b29f4['query']['offset']);}_0x5acd11[_0x984b('0x46')]=qs[_0x984b('0x47')](_0x4b29f4[_0x984b('0x40')][_0x984b('0x47')]);_0x5acd11['where']=qs[_0x984b('0x3e')](_[_0x984b('0x48')](_0x4b29f4['query'],_0x3fbaa4[_0x984b('0x3e')]),_0x486871);if(_0x4b29f4[_0x984b('0x40')][_0x984b('0x49')]){_0x5acd11[_0x984b('0x4a')]=_[_0x984b('0x4b')](_0x5acd11[_0x984b('0x4a')],{'$or':_[_0x984b('0x37')](_0x486871,function(_0x330f9e){if(_0x330f9e[_0x984b('0x3a')]!==_0x984b('0x4c')){var _0x47c889={};_0x47c889[_0x330f9e[_0x984b('0x35')]]={'$like':'%'+_0x4b29f4[_0x984b('0x40')]['filter']+'%'};return _0x47c889;}})});}_0x5acd11=_[_0x984b('0x4b')]({},_0x5acd11,_0x4b29f4[_0x984b('0x4d')]);var _0x4c0227={'where':_0x5acd11[_0x984b('0x4a')]};return db[_0x984b('0x4e')][_0x984b('0x2c')](_0x4c0227)['then'](function(_0xeb2836){_0x51815a[_0x984b('0x2c')]=_0xeb2836;if(_0x4b29f4[_0x984b('0x40')][_0x984b('0x4f')]){_0x5acd11['include']=[{'all':!![]}];}return db[_0x984b('0x4e')][_0x984b('0x50')](_0x5acd11);})['then'](function(_0x19e273){_0x51815a['rows']=_0x19e273;return _0x51815a;})[_0x984b('0x1d')](respondWithFilteredResult(_0x28b360,_0x5acd11))[_0x984b('0x28')](handleError(_0x28b360,null));};exports['show']=function(_0x34639f,_0x432d86){var _0x314740={'raw':![],'where':{'id':_0x34639f['params']['id']}},_0x265750={};_0x265750[_0x984b('0x3c')]=_['keys'](db[_0x984b('0x4e')][_0x984b('0x38')]);_0x265750[_0x984b('0x40')]=_[_0x984b('0x3d')](_0x34639f[_0x984b('0x40')]);_0x265750[_0x984b('0x3e')]=_[_0x984b('0x3f')](_0x265750[_0x984b('0x3c')],_0x265750[_0x984b('0x40')]);_0x314740[_0x984b('0x41')]=_[_0x984b('0x3f')](_0x265750[_0x984b('0x3c')],qs[_0x984b('0x42')](_0x34639f['query'][_0x984b('0x42')]));_0x314740[_0x984b('0x41')]=_0x314740[_0x984b('0x41')][_0x984b('0x43')]?_0x314740['attributes']:_0x265750[_0x984b('0x3c')];if(_0x34639f[_0x984b('0x40')][_0x984b('0x4f')]){_0x314740['include']=[{'all':!![]}];}_0x314740=_[_0x984b('0x4b')]({},_0x314740,_0x34639f[_0x984b('0x4d')]);return db[_0x984b('0x4e')][_0x984b('0x51')](_0x314740)['then'](handleEntityNotFound(_0x432d86,null))[_0x984b('0x1d')](respondWithResult(_0x432d86,null))[_0x984b('0x28')](handleError(_0x432d86,null));};exports[_0x984b('0x52')]=function(_0x13c704,_0x4e8098){return db['Dynamics365Configuration'][_0x984b('0x52')](_0x13c704[_0x984b('0x53')],{})[_0x984b('0x1d')](respondWithResult(_0x4e8098,0xc9))[_0x984b('0x28')](handleError(_0x4e8098,null));};exports[_0x984b('0x32')]=function(_0x255bc9,_0x5a405c){if(_0x255bc9['body']['id']){delete _0x255bc9['body']['id'];}return db[_0x984b('0x4e')]['find']({'where':{'id':_0x255bc9[_0x984b('0x54')]['id']}})[_0x984b('0x1d')](handleEntityNotFound(_0x5a405c,null))[_0x984b('0x1d')](saveUpdates(_0x255bc9[_0x984b('0x53')],null))[_0x984b('0x1d')](respondWithResult(_0x5a405c,null))[_0x984b('0x28')](handleError(_0x5a405c,null));};exports[_0x984b('0x33')]=function(_0x235392,_0x20fd08){return db[_0x984b('0x4e')][_0x984b('0x51')]({'where':{'id':_0x235392[_0x984b('0x54')]['id']}})[_0x984b('0x1d')](handleEntityNotFound(_0x20fd08,null))['then'](removeEntity(_0x20fd08,null))[_0x984b('0x28')](handleError(_0x20fd08,null));};exports[_0x984b('0x55')]=function(_0x5312e0,_0x39c7de,_0xf7533c){var _0x55f8d3={};var _0x240fda={};var _0xb1e7fe;var _0x3ab2a9;return db[_0x984b('0x4e')]['findOne']({'where':{'id':_0x5312e0[_0x984b('0x54')]['id']}})[_0x984b('0x1d')](handleEntityNotFound(_0x39c7de,null))[_0x984b('0x1d')](function(_0x5d56de){if(_0x5d56de){_0xb1e7fe=_0x5d56de;_0x240fda[_0x984b('0x3c')]=_[_0x984b('0x3d')](db['Dynamics365Field'][_0x984b('0x38')]);_0x240fda[_0x984b('0x40')]=_[_0x984b('0x3d')](_0x5312e0['query']);_0x240fda[_0x984b('0x3e')]=_[_0x984b('0x3f')](_0x240fda[_0x984b('0x3c')],_0x240fda[_0x984b('0x40')]);_0x55f8d3[_0x984b('0x41')]=_[_0x984b('0x3f')](_0x240fda[_0x984b('0x3c')],qs[_0x984b('0x42')](_0x5312e0[_0x984b('0x40')][_0x984b('0x42')]));_0x55f8d3['attributes']=_0x55f8d3['attributes'][_0x984b('0x43')]?_0x55f8d3[_0x984b('0x41')]:_0x240fda[_0x984b('0x3c')];_0x55f8d3[_0x984b('0x46')]=qs[_0x984b('0x47')](_0x5312e0[_0x984b('0x40')][_0x984b('0x47')]);_0x55f8d3[_0x984b('0x4a')]=qs[_0x984b('0x3e')](_['pick'](_0x5312e0[_0x984b('0x40')],_0x240fda[_0x984b('0x3e')]));if(_0x5312e0[_0x984b('0x40')][_0x984b('0x49')]){_0x55f8d3[_0x984b('0x4a')]=_[_0x984b('0x4b')](_0x55f8d3['where'],{'$or':_['map'](_0x55f8d3['attributes'],function(_0x25e332){var _0x2f3ef1={};_0x2f3ef1[_0x25e332]={'$like':'%'+_0x5312e0[_0x984b('0x40')][_0x984b('0x49')]+'%'};return _0x2f3ef1;})});}_0x55f8d3=_[_0x984b('0x4b')]({},_0x55f8d3,_0x5312e0['options']);return _0xb1e7fe[_0x984b('0x55')](_0x55f8d3);}})['then'](function(_0x48ab0b){if(_0x48ab0b){_0x3ab2a9=_0x48ab0b[_0x984b('0x43')];if(!_0x5312e0[_0x984b('0x40')][_0x984b('0x56')](_0x984b('0x44'))){_0x55f8d3['limit']=qs[_0x984b('0x45')](_0x5312e0[_0x984b('0x40')]['limit']);_0x55f8d3[_0x984b('0x2d')]=qs[_0x984b('0x2d')](_0x5312e0[_0x984b('0x40')]['offset']);}return _0xb1e7fe[_0x984b('0x55')](_0x55f8d3);}})['then'](function(_0x34dfbd){if(_0x34dfbd){return _0x34dfbd?{'count':_0x3ab2a9,'rows':_0x34dfbd}:null;}})['then'](respondWithResult(_0x39c7de,null))[_0x984b('0x28')](handleError(_0x39c7de,null));};exports['getSubjects']=function(_0xaf347c,_0x5a97d2,_0x3ba122){var _0xd5054a={};var _0x1af077={};var _0x110c4e;var _0x5d0d99;return db[_0x984b('0x4e')][_0x984b('0x57')]({'where':{'id':_0xaf347c[_0x984b('0x54')]['id']}})['then'](handleEntityNotFound(_0x5a97d2,null))[_0x984b('0x1d')](function(_0x2356b0){if(_0x2356b0){_0x110c4e=_0x2356b0;_0x1af077[_0x984b('0x3c')]=_['keys'](db[_0x984b('0x58')][_0x984b('0x38')]);_0x1af077[_0x984b('0x40')]=_['keys'](_0xaf347c[_0x984b('0x40')]);_0x1af077[_0x984b('0x3e')]=_[_0x984b('0x3f')](_0x1af077[_0x984b('0x3c')],_0x1af077[_0x984b('0x40')]);_0xd5054a[_0x984b('0x41')]=_['intersection'](_0x1af077['model'],qs[_0x984b('0x42')](_0xaf347c['query'][_0x984b('0x42')]));_0xd5054a[_0x984b('0x41')]=_0xd5054a[_0x984b('0x41')][_0x984b('0x43')]?_0xd5054a[_0x984b('0x41')]:_0x1af077[_0x984b('0x3c')];_0xd5054a['order']=qs['sort'](_0xaf347c['query']['sort']);_0xd5054a[_0x984b('0x4a')]=qs[_0x984b('0x3e')](_[_0x984b('0x48')](_0xaf347c[_0x984b('0x40')],_0x1af077[_0x984b('0x3e')]));if(_0xaf347c[_0x984b('0x40')][_0x984b('0x49')]){_0xd5054a[_0x984b('0x4a')]=_[_0x984b('0x4b')](_0xd5054a[_0x984b('0x4a')],{'$or':_['map'](_0xd5054a['attributes'],function(_0xccdf27){var _0x3386d2={};_0x3386d2[_0xccdf27]={'$like':'%'+_0xaf347c[_0x984b('0x40')][_0x984b('0x49')]+'%'};return _0x3386d2;})});}_0xd5054a=_[_0x984b('0x4b')]({},_0xd5054a,_0xaf347c['options']);return _0x110c4e[_0x984b('0x59')](_0xd5054a);}})[_0x984b('0x1d')](function(_0x12b99c){if(_0x12b99c){_0x5d0d99=_0x12b99c[_0x984b('0x43')];if(!_0xaf347c[_0x984b('0x40')][_0x984b('0x56')](_0x984b('0x44'))){_0xd5054a[_0x984b('0x45')]=qs[_0x984b('0x45')](_0xaf347c[_0x984b('0x40')][_0x984b('0x45')]);_0xd5054a[_0x984b('0x2d')]=qs[_0x984b('0x2d')](_0xaf347c[_0x984b('0x40')][_0x984b('0x2d')]);}return _0x110c4e[_0x984b('0x59')](_0xd5054a);}})['then'](function(_0x949712){if(_0x949712){return _0x949712?{'count':_0x5d0d99,'rows':_0x949712}:null;}})[_0x984b('0x1d')](respondWithResult(_0x5a97d2,null))[_0x984b('0x28')](handleError(_0x5a97d2,null));};exports['getDescriptions']=function(_0x33f96c,_0x2195fc,_0x1f027d){var _0x386386={};var _0x34d136={};var _0x495712;var _0x323f37;return db['Dynamics365Configuration'][_0x984b('0x57')]({'where':{'id':_0x33f96c[_0x984b('0x54')]['id']}})[_0x984b('0x1d')](handleEntityNotFound(_0x2195fc,null))[_0x984b('0x1d')](function(_0x472624){if(_0x472624){_0x495712=_0x472624;_0x34d136[_0x984b('0x3c')]=_['keys'](db[_0x984b('0x58')][_0x984b('0x38')]);_0x34d136['query']=_['keys'](_0x33f96c[_0x984b('0x40')]);_0x34d136[_0x984b('0x3e')]=_[_0x984b('0x3f')](_0x34d136['model'],_0x34d136[_0x984b('0x40')]);_0x386386['attributes']=_[_0x984b('0x3f')](_0x34d136[_0x984b('0x3c')],qs[_0x984b('0x42')](_0x33f96c[_0x984b('0x40')][_0x984b('0x42')]));_0x386386[_0x984b('0x41')]=_0x386386[_0x984b('0x41')][_0x984b('0x43')]?_0x386386[_0x984b('0x41')]:_0x34d136[_0x984b('0x3c')];_0x386386[_0x984b('0x46')]=qs[_0x984b('0x47')](_0x33f96c[_0x984b('0x40')][_0x984b('0x47')]);_0x386386['where']=qs[_0x984b('0x3e')](_[_0x984b('0x48')](_0x33f96c['query'],_0x34d136[_0x984b('0x3e')]));if(_0x33f96c[_0x984b('0x40')][_0x984b('0x49')]){_0x386386[_0x984b('0x4a')]=_[_0x984b('0x4b')](_0x386386[_0x984b('0x4a')],{'$or':_[_0x984b('0x37')](_0x386386[_0x984b('0x41')],function(_0x258564){var _0xa0e86={};_0xa0e86[_0x258564]={'$like':'%'+_0x33f96c[_0x984b('0x40')][_0x984b('0x49')]+'%'};return _0xa0e86;})});}_0x386386=_[_0x984b('0x4b')]({},_0x386386,_0x33f96c['options']);return _0x495712[_0x984b('0x5a')](_0x386386);}})[_0x984b('0x1d')](function(_0xc5f257){if(_0xc5f257){_0x323f37=_0xc5f257[_0x984b('0x43')];if(!_0x33f96c[_0x984b('0x40')][_0x984b('0x56')](_0x984b('0x44'))){_0x386386['limit']=qs[_0x984b('0x45')](_0x33f96c[_0x984b('0x40')][_0x984b('0x45')]);_0x386386[_0x984b('0x2d')]=qs[_0x984b('0x2d')](_0x33f96c[_0x984b('0x40')]['offset']);}return _0x495712[_0x984b('0x5a')](_0x386386);}})['then'](function(_0x47c9f3){if(_0x47c9f3){return _0x47c9f3?{'count':_0x323f37,'rows':_0x47c9f3}:null;}})[_0x984b('0x1d')](respondWithResult(_0x2195fc,null))[_0x984b('0x28')](handleError(_0x2195fc,null));};
\ No newline at end of file
+var _0x312f=['../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','set','apply','reject','save','then','destroy','end','error','stack','name','index','map','Dynamics365Configuration','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','order','sort','filter','where','merge','type','VIRTUAL','options','include','findAll','rows','catch','show','params','includeAll','find','create','body','update','getFields','findOne','Dynamics365Field','pick','hasOwnProperty','getSubjects','getDescriptions','nolimit','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils'];(function(_0x2cf2e9,_0xd58ea1){var _0xd3670d=function(_0x272868){while(--_0x272868){_0x2cf2e9['push'](_0x2cf2e9['shift']());}};_0xd3670d(++_0xd58ea1);}(_0x312f,0x139));var _0xf312=function(_0x4b7cbf,_0x45a394){_0x4b7cbf=_0x4b7cbf-0x0;var _0x480780=_0x312f[_0x4b7cbf];return _0x480780;};'use strict';var emlformat=require(_0xf312('0x0'));var rimraf=require(_0xf312('0x1'));var zipdir=require(_0xf312('0x2'));var jsonpatch=require(_0xf312('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf312('0x4'));var Mustache=require(_0xf312('0x5'));var util=require(_0xf312('0x6'));var path=require(_0xf312('0x7'));var sox=require(_0xf312('0x8'));var csv=require(_0xf312('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf312('0xa'));var _=require(_0xf312('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xf312('0xc'));var deskjs=require(_0xf312('0xd'));var toCsv=require(_0xf312('0x9'));var querystring=require(_0xf312('0xe'));var Papa=require(_0xf312('0xf'));var Redis=require(_0xf312('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xf312('0x11'));var as=require(_0xf312('0x12'));var hardwareService=require(_0xf312('0x13'));var logger=require(_0xf312('0x14'))(_0xf312('0x15'));var utils=require(_0xf312('0x16'));var config=require(_0xf312('0x17'));var licenseUtil=require(_0xf312('0x18'));var db=require(_0xf312('0x19'))['db'];function respondWithStatusCode(_0x22d99e,_0x12b2b2){_0x12b2b2=_0x12b2b2||0xcc;return function(_0x599119){if(_0x599119){return _0x22d99e[_0xf312('0x1a')](_0x12b2b2);}return _0x22d99e[_0xf312('0x1b')](_0x12b2b2)['end']();};}function respondWithResult(_0x584d29,_0x37f786){_0x37f786=_0x37f786||0xc8;return function(_0x542ce7){if(_0x542ce7){return _0x584d29[_0xf312('0x1b')](_0x37f786)[_0xf312('0x1c')](_0x542ce7);}};}function respondWithFilteredResult(_0x198c15,_0x506ca0){return function(_0xec7c2b){if(_0xec7c2b){var _0x12f814=typeof _0x506ca0[_0xf312('0x1d')]===_0xf312('0x1e')&&typeof _0x506ca0[_0xf312('0x1f')]==='undefined';var _0x253d04=_0xec7c2b[_0xf312('0x20')];var _0x2f827d=_0x12f814?0x0:_0x506ca0[_0xf312('0x1d')];var _0x4d53bb=_0x12f814?_0xec7c2b[_0xf312('0x20')]:_0x506ca0['offset']+_0x506ca0[_0xf312('0x1f')];var _0x16ca3b;if(_0x4d53bb>=_0x253d04){_0x4d53bb=_0x253d04;_0x16ca3b=0xc8;}else{_0x16ca3b=0xce;}_0x198c15[_0xf312('0x1b')](_0x16ca3b);return _0x198c15[_0xf312('0x21')]('Content-Range',_0x2f827d+'-'+_0x4d53bb+'/'+_0x253d04)[_0xf312('0x1c')](_0xec7c2b);}return null;};}function patchUpdates(_0x4a72d9){return function(_0xa1a8fc){try{jsonpatch[_0xf312('0x22')](_0xa1a8fc,_0x4a72d9,!![]);}catch(_0x3274e2){return BPromise[_0xf312('0x23')](_0x3274e2);}return _0xa1a8fc[_0xf312('0x24')]();};}function saveUpdates(_0xa628f2,_0x44faab){return function(_0x3f642a){if(_0x3f642a){return _0x3f642a['update'](_0xa628f2)[_0xf312('0x25')](function(_0x4053b6){return _0x4053b6;});}return null;};}function removeEntity(_0x3616ef,_0x5bdbf8){return function(_0x5f07c7){if(_0x5f07c7){return _0x5f07c7[_0xf312('0x26')]()['then'](function(){_0x3616ef['status'](0xcc)[_0xf312('0x27')]();});}};}function handleEntityNotFound(_0x76e179,_0x4c053b){return function(_0x3a2123){if(!_0x3a2123){_0x76e179[_0xf312('0x1a')](0x194);}return _0x3a2123;};}function handleError(_0xcd5e6b,_0x3edf77){_0x3edf77=_0x3edf77||0x1f4;return function(_0x410580){logger[_0xf312('0x28')](_0x410580[_0xf312('0x29')]);if(_0x410580[_0xf312('0x2a')]){delete _0x410580[_0xf312('0x2a')];}_0xcd5e6b[_0xf312('0x1b')](_0x3edf77)['send'](_0x410580);};}exports[_0xf312('0x2b')]=function(_0x3aa835,_0x413a62){var _0x352603={},_0x2b4f1a={},_0x58b80b={'count':0x0,'rows':[]};var _0x1b74d3=_[_0xf312('0x2c')](db[_0xf312('0x2d')][_0xf312('0x2e')],function(_0x5ba9ae){return{'name':_0x5ba9ae[_0xf312('0x2f')],'type':_0x5ba9ae['type'][_0xf312('0x30')]};});_0x2b4f1a[_0xf312('0x31')]=_[_0xf312('0x2c')](_0x1b74d3,_0xf312('0x2a'));_0x2b4f1a[_0xf312('0x32')]=_[_0xf312('0x33')](_0x3aa835['query']);_0x2b4f1a[_0xf312('0x34')]=_[_0xf312('0x35')](_0x2b4f1a[_0xf312('0x31')],_0x2b4f1a[_0xf312('0x32')]);_0x352603[_0xf312('0x36')]=_[_0xf312('0x35')](_0x2b4f1a[_0xf312('0x31')],qs[_0xf312('0x37')](_0x3aa835[_0xf312('0x32')][_0xf312('0x37')]));_0x352603['attributes']=_0x352603[_0xf312('0x36')][_0xf312('0x38')]?_0x352603['attributes']:_0x2b4f1a[_0xf312('0x31')];if(!_0x3aa835[_0xf312('0x32')]['hasOwnProperty']('nolimit')){_0x352603['limit']=qs[_0xf312('0x1f')](_0x3aa835[_0xf312('0x32')][_0xf312('0x1f')]);_0x352603[_0xf312('0x1d')]=qs[_0xf312('0x1d')](_0x3aa835['query']['offset']);}_0x352603[_0xf312('0x39')]=qs[_0xf312('0x3a')](_0x3aa835[_0xf312('0x32')]['sort']);_0x352603['where']=qs[_0xf312('0x34')](_['pick'](_0x3aa835[_0xf312('0x32')],_0x2b4f1a['filters']),_0x1b74d3);if(_0x3aa835[_0xf312('0x32')][_0xf312('0x3b')]){_0x352603[_0xf312('0x3c')]=_[_0xf312('0x3d')](_0x352603[_0xf312('0x3c')],{'$or':_[_0xf312('0x2c')](_0x1b74d3,function(_0x543d48){if(_0x543d48[_0xf312('0x3e')]!==_0xf312('0x3f')){var _0x58964d={};_0x58964d[_0x543d48[_0xf312('0x2a')]]={'$like':'%'+_0x3aa835[_0xf312('0x32')]['filter']+'%'};return _0x58964d;}})});}_0x352603=_['merge']({},_0x352603,_0x3aa835[_0xf312('0x40')]);var _0x18ee27={'where':_0x352603[_0xf312('0x3c')]};return db[_0xf312('0x2d')][_0xf312('0x20')](_0x18ee27)[_0xf312('0x25')](function(_0x159fba){_0x58b80b[_0xf312('0x20')]=_0x159fba;if(_0x3aa835[_0xf312('0x32')]['includeAll']){_0x352603[_0xf312('0x41')]=[{'all':!![]}];}return db[_0xf312('0x2d')][_0xf312('0x42')](_0x352603);})['then'](function(_0x926b13){_0x58b80b[_0xf312('0x43')]=_0x926b13;return _0x58b80b;})[_0xf312('0x25')](respondWithFilteredResult(_0x413a62,_0x352603))[_0xf312('0x44')](handleError(_0x413a62,null));};exports[_0xf312('0x45')]=function(_0x4c26ea,_0x1485c1){var _0x37886e={'raw':![],'where':{'id':_0x4c26ea[_0xf312('0x46')]['id']}},_0x1b7f61={};_0x1b7f61[_0xf312('0x31')]=_['keys'](db[_0xf312('0x2d')][_0xf312('0x2e')]);_0x1b7f61[_0xf312('0x32')]=_[_0xf312('0x33')](_0x4c26ea[_0xf312('0x32')]);_0x1b7f61[_0xf312('0x34')]=_[_0xf312('0x35')](_0x1b7f61['model'],_0x1b7f61[_0xf312('0x32')]);_0x37886e[_0xf312('0x36')]=_['intersection'](_0x1b7f61[_0xf312('0x31')],qs[_0xf312('0x37')](_0x4c26ea[_0xf312('0x32')]['fields']));_0x37886e[_0xf312('0x36')]=_0x37886e['attributes']['length']?_0x37886e[_0xf312('0x36')]:_0x1b7f61['model'];if(_0x4c26ea[_0xf312('0x32')][_0xf312('0x47')]){_0x37886e['include']=[{'all':!![]}];}_0x37886e=_[_0xf312('0x3d')]({},_0x37886e,_0x4c26ea[_0xf312('0x40')]);return db[_0xf312('0x2d')][_0xf312('0x48')](_0x37886e)['then'](handleEntityNotFound(_0x1485c1,null))[_0xf312('0x25')](respondWithResult(_0x1485c1,null))[_0xf312('0x44')](handleError(_0x1485c1,null));};exports['create']=function(_0x14c0a0,_0x9da5bf){return db[_0xf312('0x2d')][_0xf312('0x49')](_0x14c0a0[_0xf312('0x4a')],{})[_0xf312('0x25')](respondWithResult(_0x9da5bf,0xc9))['catch'](handleError(_0x9da5bf,null));};exports[_0xf312('0x4b')]=function(_0x3c6e6f,_0x3e8594){if(_0x3c6e6f[_0xf312('0x4a')]['id']){delete _0x3c6e6f[_0xf312('0x4a')]['id'];}return db['Dynamics365Configuration'][_0xf312('0x48')]({'where':{'id':_0x3c6e6f[_0xf312('0x46')]['id']}})[_0xf312('0x25')](handleEntityNotFound(_0x3e8594,null))[_0xf312('0x25')](saveUpdates(_0x3c6e6f['body'],null))[_0xf312('0x25')](respondWithResult(_0x3e8594,null))['catch'](handleError(_0x3e8594,null));};exports['destroy']=function(_0x5b1b93,_0x465a05){return db['Dynamics365Configuration'][_0xf312('0x48')]({'where':{'id':_0x5b1b93['params']['id']}})[_0xf312('0x25')](handleEntityNotFound(_0x465a05,null))[_0xf312('0x25')](removeEntity(_0x465a05,null))['catch'](handleError(_0x465a05,null));};exports[_0xf312('0x4c')]=function(_0x23a33f,_0xfaacd2,_0x19dc7e){var _0x59af65={};var _0x39552a={};var _0x96b6e5;var _0x26d6b9;return db['Dynamics365Configuration'][_0xf312('0x4d')]({'where':{'id':_0x23a33f[_0xf312('0x46')]['id']}})[_0xf312('0x25')](handleEntityNotFound(_0xfaacd2,null))[_0xf312('0x25')](function(_0x4d39b4){if(_0x4d39b4){_0x96b6e5=_0x4d39b4;_0x39552a[_0xf312('0x31')]=_[_0xf312('0x33')](db[_0xf312('0x4e')][_0xf312('0x2e')]);_0x39552a[_0xf312('0x32')]=_['keys'](_0x23a33f[_0xf312('0x32')]);_0x39552a[_0xf312('0x34')]=_[_0xf312('0x35')](_0x39552a[_0xf312('0x31')],_0x39552a[_0xf312('0x32')]);_0x59af65['attributes']=_['intersection'](_0x39552a[_0xf312('0x31')],qs['fields'](_0x23a33f['query'][_0xf312('0x37')]));_0x59af65[_0xf312('0x36')]=_0x59af65[_0xf312('0x36')][_0xf312('0x38')]?_0x59af65[_0xf312('0x36')]:_0x39552a['model'];_0x59af65[_0xf312('0x39')]=qs[_0xf312('0x3a')](_0x23a33f[_0xf312('0x32')][_0xf312('0x3a')]);_0x59af65[_0xf312('0x3c')]=qs[_0xf312('0x34')](_[_0xf312('0x4f')](_0x23a33f[_0xf312('0x32')],_0x39552a['filters']));if(_0x23a33f[_0xf312('0x32')][_0xf312('0x3b')]){_0x59af65[_0xf312('0x3c')]=_[_0xf312('0x3d')](_0x59af65[_0xf312('0x3c')],{'$or':_[_0xf312('0x2c')](_0x59af65[_0xf312('0x36')],function(_0x58d4a1){var _0x256997={};_0x256997[_0x58d4a1]={'$like':'%'+_0x23a33f['query'][_0xf312('0x3b')]+'%'};return _0x256997;})});}_0x59af65=_[_0xf312('0x3d')]({},_0x59af65,_0x23a33f[_0xf312('0x40')]);return _0x96b6e5[_0xf312('0x4c')](_0x59af65);}})[_0xf312('0x25')](function(_0x33537c){if(_0x33537c){_0x26d6b9=_0x33537c['length'];if(!_0x23a33f[_0xf312('0x32')][_0xf312('0x50')]('nolimit')){_0x59af65[_0xf312('0x1f')]=qs[_0xf312('0x1f')](_0x23a33f['query']['limit']);_0x59af65[_0xf312('0x1d')]=qs[_0xf312('0x1d')](_0x23a33f['query'][_0xf312('0x1d')]);}return _0x96b6e5['getFields'](_0x59af65);}})[_0xf312('0x25')](function(_0x44d5fe){if(_0x44d5fe){return _0x44d5fe?{'count':_0x26d6b9,'rows':_0x44d5fe}:null;}})[_0xf312('0x25')](respondWithResult(_0xfaacd2,null))[_0xf312('0x44')](handleError(_0xfaacd2,null));};exports[_0xf312('0x51')]=function(_0x1c34ee,_0x57ff83,_0x297955){var _0xd32a3a={};var _0x42524c={};var _0x3b12ed;var _0x3168c2;return db['Dynamics365Configuration'][_0xf312('0x4d')]({'where':{'id':_0x1c34ee['params']['id']}})[_0xf312('0x25')](handleEntityNotFound(_0x57ff83,null))[_0xf312('0x25')](function(_0x27d89e){if(_0x27d89e){_0x3b12ed=_0x27d89e;_0x42524c[_0xf312('0x31')]=_[_0xf312('0x33')](db['Dynamics365Field'][_0xf312('0x2e')]);_0x42524c[_0xf312('0x32')]=_['keys'](_0x1c34ee[_0xf312('0x32')]);_0x42524c[_0xf312('0x34')]=_[_0xf312('0x35')](_0x42524c[_0xf312('0x31')],_0x42524c[_0xf312('0x32')]);_0xd32a3a[_0xf312('0x36')]=_[_0xf312('0x35')](_0x42524c['model'],qs['fields'](_0x1c34ee[_0xf312('0x32')][_0xf312('0x37')]));_0xd32a3a[_0xf312('0x36')]=_0xd32a3a['attributes'][_0xf312('0x38')]?_0xd32a3a[_0xf312('0x36')]:_0x42524c[_0xf312('0x31')];_0xd32a3a[_0xf312('0x39')]=qs[_0xf312('0x3a')](_0x1c34ee[_0xf312('0x32')][_0xf312('0x3a')]);_0xd32a3a[_0xf312('0x3c')]=qs[_0xf312('0x34')](_[_0xf312('0x4f')](_0x1c34ee[_0xf312('0x32')],_0x42524c[_0xf312('0x34')]));if(_0x1c34ee[_0xf312('0x32')][_0xf312('0x3b')]){_0xd32a3a[_0xf312('0x3c')]=_[_0xf312('0x3d')](_0xd32a3a[_0xf312('0x3c')],{'$or':_[_0xf312('0x2c')](_0xd32a3a['attributes'],function(_0x698453){var _0x1da0c4={};_0x1da0c4[_0x698453]={'$like':'%'+_0x1c34ee[_0xf312('0x32')][_0xf312('0x3b')]+'%'};return _0x1da0c4;})});}_0xd32a3a=_[_0xf312('0x3d')]({},_0xd32a3a,_0x1c34ee['options']);return _0x3b12ed[_0xf312('0x51')](_0xd32a3a);}})[_0xf312('0x25')](function(_0x2be5fb){if(_0x2be5fb){_0x3168c2=_0x2be5fb[_0xf312('0x38')];if(!_0x1c34ee[_0xf312('0x32')][_0xf312('0x50')]('nolimit')){_0xd32a3a['limit']=qs['limit'](_0x1c34ee[_0xf312('0x32')][_0xf312('0x1f')]);_0xd32a3a[_0xf312('0x1d')]=qs[_0xf312('0x1d')](_0x1c34ee[_0xf312('0x32')][_0xf312('0x1d')]);}return _0x3b12ed['getSubjects'](_0xd32a3a);}})[_0xf312('0x25')](function(_0x43222f){if(_0x43222f){return _0x43222f?{'count':_0x3168c2,'rows':_0x43222f}:null;}})['then'](respondWithResult(_0x57ff83,null))[_0xf312('0x44')](handleError(_0x57ff83,null));};exports[_0xf312('0x52')]=function(_0x1450f0,_0xc5b1,_0x2d1b3d){var _0x56c94e={};var _0x596c72={};var _0x597b6a;var _0x3855db;return db[_0xf312('0x2d')][_0xf312('0x4d')]({'where':{'id':_0x1450f0[_0xf312('0x46')]['id']}})['then'](handleEntityNotFound(_0xc5b1,null))[_0xf312('0x25')](function(_0x3dc1a5){if(_0x3dc1a5){_0x597b6a=_0x3dc1a5;_0x596c72[_0xf312('0x31')]=_['keys'](db[_0xf312('0x4e')][_0xf312('0x2e')]);_0x596c72[_0xf312('0x32')]=_['keys'](_0x1450f0[_0xf312('0x32')]);_0x596c72[_0xf312('0x34')]=_['intersection'](_0x596c72[_0xf312('0x31')],_0x596c72[_0xf312('0x32')]);_0x56c94e[_0xf312('0x36')]=_[_0xf312('0x35')](_0x596c72[_0xf312('0x31')],qs[_0xf312('0x37')](_0x1450f0[_0xf312('0x32')][_0xf312('0x37')]));_0x56c94e[_0xf312('0x36')]=_0x56c94e[_0xf312('0x36')]['length']?_0x56c94e[_0xf312('0x36')]:_0x596c72['model'];_0x56c94e[_0xf312('0x39')]=qs[_0xf312('0x3a')](_0x1450f0[_0xf312('0x32')][_0xf312('0x3a')]);_0x56c94e[_0xf312('0x3c')]=qs[_0xf312('0x34')](_[_0xf312('0x4f')](_0x1450f0['query'],_0x596c72[_0xf312('0x34')]));if(_0x1450f0[_0xf312('0x32')][_0xf312('0x3b')]){_0x56c94e['where']=_[_0xf312('0x3d')](_0x56c94e[_0xf312('0x3c')],{'$or':_[_0xf312('0x2c')](_0x56c94e['attributes'],function(_0x25f510){var _0x4ba147={};_0x4ba147[_0x25f510]={'$like':'%'+_0x1450f0[_0xf312('0x32')][_0xf312('0x3b')]+'%'};return _0x4ba147;})});}_0x56c94e=_['merge']({},_0x56c94e,_0x1450f0[_0xf312('0x40')]);return _0x597b6a[_0xf312('0x52')](_0x56c94e);}})['then'](function(_0x5167b1){if(_0x5167b1){_0x3855db=_0x5167b1['length'];if(!_0x1450f0[_0xf312('0x32')]['hasOwnProperty'](_0xf312('0x53'))){_0x56c94e['limit']=qs[_0xf312('0x1f')](_0x1450f0[_0xf312('0x32')][_0xf312('0x1f')]);_0x56c94e[_0xf312('0x1d')]=qs[_0xf312('0x1d')](_0x1450f0[_0xf312('0x32')]['offset']);}return _0x597b6a['getDescriptions'](_0x56c94e);}})[_0xf312('0x25')](function(_0x434bbb){if(_0x434bbb){return _0x434bbb?{'count':_0x3855db,'rows':_0x434bbb}:null;}})[_0xf312('0x25')](respondWithResult(_0xc5b1,null))['catch'](handleError(_0xc5b1,null));};
\ No newline at end of file