Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 4b77aca..0f3a189 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0xcbeb=['ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','send','Dynamics365Configuration','rawAttributes','fieldName','map','name','query','filters','model','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','type','include','rows','show','keys','includeAll','merge','options','catch','create','body','find','params','getFields','findOne','Dynamics365Field','getSubjects','getDescriptions','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv'];(function(_0x2b749b,_0x3d31e6){var _0x4e0527=function(_0x30d0a1){while(--_0x30d0a1){_0x2b749b['push'](_0x2b749b['shift']());}};_0x4e0527(++_0x3d31e6);}(_0xcbeb,0xec));var _0xbcbe=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xcbeb[_0x3dd15e];return _0x231fd0;};'use strict';var emlformat=require(_0xbcbe('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbcbe('0x1'));var jsonpatch=require(_0xbcbe('0x2'));var rp=require(_0xbcbe('0x3'));var moment=require(_0xbcbe('0x4'));var BPromise=require(_0xbcbe('0x5'));var Mustache=require(_0xbcbe('0x6'));var util=require(_0xbcbe('0x7'));var path=require('path');var sox=require(_0xbcbe('0x8'));var csv=require(_0xbcbe('0x9'));var ejs=require(_0xbcbe('0xa'));var fs=require('fs');var fs_extra=require(_0xbcbe('0xb'));var _=require(_0xbcbe('0xc'));var squel=require(_0xbcbe('0xd'));var crypto=require(_0xbcbe('0xe'));var jsforce=require(_0xbcbe('0xf'));var deskjs=require('desk.js');var toCsv=require(_0xbcbe('0x9'));var querystring=require(_0xbcbe('0x10'));var Papa=require('papaparse');var Redis=require(_0xbcbe('0x11'));var authService=require(_0xbcbe('0x12'));var qs=require(_0xbcbe('0x13'));var as=require(_0xbcbe('0x14'));var hardwareService=require(_0xbcbe('0x15'));var logger=require('../../config/logger')(_0xbcbe('0x16'));var utils=require(_0xbcbe('0x17'));var config=require('../../config/environment');var licenseUtil=require(_0xbcbe('0x18'));var db=require(_0xbcbe('0x19'))['db'];function respondWithStatusCode(_0x2ebe4f,_0x11e846){_0x11e846=_0x11e846||0xcc;return function(_0x5d4b0c){if(_0x5d4b0c){return _0x2ebe4f[_0xbcbe('0x1a')](_0x11e846);}return _0x2ebe4f['status'](_0x11e846)[_0xbcbe('0x1b')]();};}function respondWithResult(_0x48d6a8,_0x86765b){_0x86765b=_0x86765b||0xc8;return function(_0x5b69d6){if(_0x5b69d6){return _0x48d6a8[_0xbcbe('0x1c')](_0x86765b)[_0xbcbe('0x1d')](_0x5b69d6);}};}function respondWithFilteredResult(_0x2508d0,_0x479e9b){return function(_0x36f83d){if(_0x36f83d){var _0x15daeb=typeof _0x479e9b[_0xbcbe('0x1e')]===_0xbcbe('0x1f')&&typeof _0x479e9b[_0xbcbe('0x20')]===_0xbcbe('0x1f');var _0x307009=_0x36f83d['count'];var _0xf29ab5=_0x15daeb?0x0:_0x479e9b[_0xbcbe('0x1e')];var _0x984528=_0x15daeb?_0x36f83d[_0xbcbe('0x21')]:_0x479e9b['offset']+_0x479e9b[_0xbcbe('0x20')];var _0x316cbf;if(_0x984528>=_0x307009){_0x984528=_0x307009;_0x316cbf=0xc8;}else{_0x316cbf=0xce;}_0x2508d0['status'](_0x316cbf);return _0x2508d0[_0xbcbe('0x22')](_0xbcbe('0x23'),_0xf29ab5+'-'+_0x984528+'/'+_0x307009)[_0xbcbe('0x1d')](_0x36f83d);}return null;};}function patchUpdates(_0x35553c){return function(_0x27ea57){try{jsonpatch[_0xbcbe('0x24')](_0x27ea57,_0x35553c,!![]);}catch(_0x1a31c2){return BPromise[_0xbcbe('0x25')](_0x1a31c2);}return _0x27ea57[_0xbcbe('0x26')]();};}function saveUpdates(_0x437ba3,_0x57d8fa){return function(_0x1b58dc){if(_0x1b58dc){return _0x1b58dc[_0xbcbe('0x27')](_0x437ba3)[_0xbcbe('0x28')](function(_0xb6694b){return _0xb6694b;});}return null;};}function removeEntity(_0x215683,_0x595d73){return function(_0x54d525){if(_0x54d525){return _0x54d525[_0xbcbe('0x29')]()[_0xbcbe('0x28')](function(){_0x215683[_0xbcbe('0x1c')](0xcc)[_0xbcbe('0x1b')]();});}};}function handleEntityNotFound(_0x1d3c61,_0x2523a3){return function(_0x40e459){if(!_0x40e459){_0x1d3c61[_0xbcbe('0x1a')](0x194);}return _0x40e459;};}function handleError(_0x30cc80,_0x34b5d0){_0x34b5d0=_0x34b5d0||0x1f4;return function(_0x23ba4d){logger[_0xbcbe('0x2a')](_0x23ba4d[_0xbcbe('0x2b')]);if(_0x23ba4d['name']){delete _0x23ba4d['name'];}_0x30cc80['status'](_0x34b5d0)[_0xbcbe('0x2c')](_0x23ba4d);};}exports['index']=function(_0x20ab01,_0x9d0363){var _0x1ab6b2={},_0x214a28={},_0x8cad58={'count':0x0,'rows':[]};var _0x2d89d9=_['map'](db[_0xbcbe('0x2d')][_0xbcbe('0x2e')],function(_0x23d830){return{'name':_0x23d830[_0xbcbe('0x2f')],'type':_0x23d830['type']['key']};});_0x214a28['model']=_[_0xbcbe('0x30')](_0x2d89d9,_0xbcbe('0x31'));_0x214a28[_0xbcbe('0x32')]=_['keys'](_0x20ab01['query']);_0x214a28[_0xbcbe('0x33')]=_['intersection'](_0x214a28[_0xbcbe('0x34')],_0x214a28[_0xbcbe('0x32')]);_0x1ab6b2['attributes']=_[_0xbcbe('0x35')](_0x214a28['model'],qs[_0xbcbe('0x36')](_0x20ab01[_0xbcbe('0x32')][_0xbcbe('0x36')]));_0x1ab6b2[_0xbcbe('0x37')]=_0x1ab6b2[_0xbcbe('0x37')][_0xbcbe('0x38')]?_0x1ab6b2[_0xbcbe('0x37')]:_0x214a28[_0xbcbe('0x34')];if(!_0x20ab01['query'][_0xbcbe('0x39')](_0xbcbe('0x3a'))){_0x1ab6b2['limit']=qs[_0xbcbe('0x20')](_0x20ab01['query'][_0xbcbe('0x20')]);_0x1ab6b2[_0xbcbe('0x1e')]=qs[_0xbcbe('0x1e')](_0x20ab01[_0xbcbe('0x32')][_0xbcbe('0x1e')]);}_0x1ab6b2[_0xbcbe('0x3b')]=qs[_0xbcbe('0x3c')](_0x20ab01[_0xbcbe('0x32')]['sort']);_0x1ab6b2[_0xbcbe('0x3d')]=qs[_0xbcbe('0x33')](_[_0xbcbe('0x3e')](_0x20ab01['query'],_0x214a28[_0xbcbe('0x33')]),_0x2d89d9);if(_0x20ab01[_0xbcbe('0x32')][_0xbcbe('0x3f')]){_0x1ab6b2[_0xbcbe('0x3d')]=_['merge'](_0x1ab6b2['where'],{'$or':_[_0xbcbe('0x30')](_0x2d89d9,function(_0x157a74){if(_0x157a74[_0xbcbe('0x40')]!=='VIRTUAL'){var _0x208a76={};_0x208a76[_0x157a74['name']]={'$like':'%'+_0x20ab01[_0xbcbe('0x32')]['filter']+'%'};return _0x208a76;}})});}_0x1ab6b2=_['merge']({},_0x1ab6b2,_0x20ab01['options']);var _0x21c4a3={'where':_0x1ab6b2[_0xbcbe('0x3d')]};return db[_0xbcbe('0x2d')][_0xbcbe('0x21')](_0x21c4a3)[_0xbcbe('0x28')](function(_0x28c1cd){_0x8cad58['count']=_0x28c1cd;if(_0x20ab01[_0xbcbe('0x32')]['includeAll']){_0x1ab6b2[_0xbcbe('0x41')]=[{'all':!![]}];}return db[_0xbcbe('0x2d')]['findAll'](_0x1ab6b2);})[_0xbcbe('0x28')](function(_0x540cf4){_0x8cad58[_0xbcbe('0x42')]=_0x540cf4;return _0x8cad58;})[_0xbcbe('0x28')](respondWithFilteredResult(_0x9d0363,_0x1ab6b2))['catch'](handleError(_0x9d0363,null));};exports[_0xbcbe('0x43')]=function(_0x2187d8,_0x57e9e4){var _0x3b1e95={'raw':![],'where':{'id':_0x2187d8['params']['id']}},_0x1f14cf={};_0x1f14cf[_0xbcbe('0x34')]=_[_0xbcbe('0x44')](db[_0xbcbe('0x2d')][_0xbcbe('0x2e')]);_0x1f14cf[_0xbcbe('0x32')]=_[_0xbcbe('0x44')](_0x2187d8['query']);_0x1f14cf[_0xbcbe('0x33')]=_[_0xbcbe('0x35')](_0x1f14cf['model'],_0x1f14cf['query']);_0x3b1e95[_0xbcbe('0x37')]=_[_0xbcbe('0x35')](_0x1f14cf[_0xbcbe('0x34')],qs[_0xbcbe('0x36')](_0x2187d8['query']['fields']));_0x3b1e95[_0xbcbe('0x37')]=_0x3b1e95[_0xbcbe('0x37')][_0xbcbe('0x38')]?_0x3b1e95[_0xbcbe('0x37')]:_0x1f14cf[_0xbcbe('0x34')];if(_0x2187d8[_0xbcbe('0x32')][_0xbcbe('0x45')]){_0x3b1e95[_0xbcbe('0x41')]=[{'all':!![]}];}_0x3b1e95=_[_0xbcbe('0x46')]({},_0x3b1e95,_0x2187d8[_0xbcbe('0x47')]);return db[_0xbcbe('0x2d')]['find'](_0x3b1e95)[_0xbcbe('0x28')](handleEntityNotFound(_0x57e9e4,null))[_0xbcbe('0x28')](respondWithResult(_0x57e9e4,null))[_0xbcbe('0x48')](handleError(_0x57e9e4,null));};exports[_0xbcbe('0x49')]=function(_0x4b6e4e,_0xfca5fa){return db[_0xbcbe('0x2d')][_0xbcbe('0x49')](_0x4b6e4e[_0xbcbe('0x4a')],{})['then'](respondWithResult(_0xfca5fa,0xc9))[_0xbcbe('0x48')](handleError(_0xfca5fa,null));};exports[_0xbcbe('0x27')]=function(_0x77a791,_0x5b3a7){if(_0x77a791[_0xbcbe('0x4a')]['id']){delete _0x77a791[_0xbcbe('0x4a')]['id'];}return db[_0xbcbe('0x2d')][_0xbcbe('0x4b')]({'where':{'id':_0x77a791[_0xbcbe('0x4c')]['id']}})[_0xbcbe('0x28')](handleEntityNotFound(_0x5b3a7,null))[_0xbcbe('0x28')](saveUpdates(_0x77a791[_0xbcbe('0x4a')],null))[_0xbcbe('0x28')](respondWithResult(_0x5b3a7,null))[_0xbcbe('0x48')](handleError(_0x5b3a7,null));};exports['destroy']=function(_0x597be3,_0x3c1f45){return db[_0xbcbe('0x2d')][_0xbcbe('0x4b')]({'where':{'id':_0x597be3[_0xbcbe('0x4c')]['id']}})['then'](handleEntityNotFound(_0x3c1f45,null))[_0xbcbe('0x28')](removeEntity(_0x3c1f45,null))[_0xbcbe('0x48')](handleError(_0x3c1f45,null));};exports[_0xbcbe('0x4d')]=function(_0x27a8e3,_0x386be6,_0x35d32e){var _0x313b01={};var _0x48f5cf={};var _0x28965a;var _0x4b3f8b;return db['Dynamics365Configuration'][_0xbcbe('0x4e')]({'where':{'id':_0x27a8e3['params']['id']}})[_0xbcbe('0x28')](handleEntityNotFound(_0x386be6,null))[_0xbcbe('0x28')](function(_0x5ef4d5){if(_0x5ef4d5){_0x28965a=_0x5ef4d5;_0x48f5cf[_0xbcbe('0x34')]=_[_0xbcbe('0x44')](db[_0xbcbe('0x4f')]['rawAttributes']);_0x48f5cf['query']=_['keys'](_0x27a8e3[_0xbcbe('0x32')]);_0x48f5cf[_0xbcbe('0x33')]=_[_0xbcbe('0x35')](_0x48f5cf[_0xbcbe('0x34')],_0x48f5cf['query']);_0x313b01[_0xbcbe('0x37')]=_[_0xbcbe('0x35')](_0x48f5cf[_0xbcbe('0x34')],qs[_0xbcbe('0x36')](_0x27a8e3[_0xbcbe('0x32')][_0xbcbe('0x36')]));_0x313b01['attributes']=_0x313b01[_0xbcbe('0x37')]['length']?_0x313b01[_0xbcbe('0x37')]:_0x48f5cf[_0xbcbe('0x34')];_0x313b01[_0xbcbe('0x3b')]=qs['sort'](_0x27a8e3['query'][_0xbcbe('0x3c')]);_0x313b01[_0xbcbe('0x3d')]=qs[_0xbcbe('0x33')](_[_0xbcbe('0x3e')](_0x27a8e3[_0xbcbe('0x32')],_0x48f5cf[_0xbcbe('0x33')]));if(_0x27a8e3[_0xbcbe('0x32')][_0xbcbe('0x3f')]){_0x313b01[_0xbcbe('0x3d')]=_[_0xbcbe('0x46')](_0x313b01['where'],{'$or':_['map'](_0x313b01[_0xbcbe('0x37')],function(_0x38ed0d){var _0x1abfd4={};_0x1abfd4[_0x38ed0d]={'$like':'%'+_0x27a8e3[_0xbcbe('0x32')][_0xbcbe('0x3f')]+'%'};return _0x1abfd4;})});}_0x313b01=_[_0xbcbe('0x46')]({},_0x313b01,_0x27a8e3['options']);return _0x28965a[_0xbcbe('0x4d')](_0x313b01);}})[_0xbcbe('0x28')](function(_0x8c1145){if(_0x8c1145){_0x4b3f8b=_0x8c1145['length'];if(!_0x27a8e3[_0xbcbe('0x32')][_0xbcbe('0x39')]('nolimit')){_0x313b01[_0xbcbe('0x20')]=qs[_0xbcbe('0x20')](_0x27a8e3[_0xbcbe('0x32')][_0xbcbe('0x20')]);_0x313b01[_0xbcbe('0x1e')]=qs['offset'](_0x27a8e3['query'][_0xbcbe('0x1e')]);}return _0x28965a[_0xbcbe('0x4d')](_0x313b01);}})['then'](function(_0x5cc2a1){if(_0x5cc2a1){return _0x5cc2a1?{'count':_0x4b3f8b,'rows':_0x5cc2a1}:null;}})[_0xbcbe('0x28')](respondWithResult(_0x386be6,null))[_0xbcbe('0x48')](handleError(_0x386be6,null));};exports[_0xbcbe('0x50')]=function(_0x335fb2,_0x5b919f,_0xb87df2){var _0x5efa29={};var _0x5a2fb1={};var _0x1413c8;var _0x5351c3;return db[_0xbcbe('0x2d')][_0xbcbe('0x4e')]({'where':{'id':_0x335fb2['params']['id']}})[_0xbcbe('0x28')](handleEntityNotFound(_0x5b919f,null))[_0xbcbe('0x28')](function(_0x3da386){if(_0x3da386){_0x1413c8=_0x3da386;_0x5a2fb1['model']=_[_0xbcbe('0x44')](db['Dynamics365Field'][_0xbcbe('0x2e')]);_0x5a2fb1[_0xbcbe('0x32')]=_['keys'](_0x335fb2[_0xbcbe('0x32')]);_0x5a2fb1[_0xbcbe('0x33')]=_[_0xbcbe('0x35')](_0x5a2fb1[_0xbcbe('0x34')],_0x5a2fb1['query']);_0x5efa29[_0xbcbe('0x37')]=_[_0xbcbe('0x35')](_0x5a2fb1[_0xbcbe('0x34')],qs[_0xbcbe('0x36')](_0x335fb2[_0xbcbe('0x32')]['fields']));_0x5efa29[_0xbcbe('0x37')]=_0x5efa29['attributes']['length']?_0x5efa29['attributes']:_0x5a2fb1[_0xbcbe('0x34')];_0x5efa29['order']=qs[_0xbcbe('0x3c')](_0x335fb2['query'][_0xbcbe('0x3c')]);_0x5efa29[_0xbcbe('0x3d')]=qs[_0xbcbe('0x33')](_[_0xbcbe('0x3e')](_0x335fb2[_0xbcbe('0x32')],_0x5a2fb1[_0xbcbe('0x33')]));if(_0x335fb2[_0xbcbe('0x32')][_0xbcbe('0x3f')]){_0x5efa29[_0xbcbe('0x3d')]=_[_0xbcbe('0x46')](_0x5efa29[_0xbcbe('0x3d')],{'$or':_[_0xbcbe('0x30')](_0x5efa29[_0xbcbe('0x37')],function(_0x28b9ee){var _0x26bac8={};_0x26bac8[_0x28b9ee]={'$like':'%'+_0x335fb2[_0xbcbe('0x32')][_0xbcbe('0x3f')]+'%'};return _0x26bac8;})});}_0x5efa29=_[_0xbcbe('0x46')]({},_0x5efa29,_0x335fb2[_0xbcbe('0x47')]);return _0x1413c8[_0xbcbe('0x50')](_0x5efa29);}})[_0xbcbe('0x28')](function(_0x3772de){if(_0x3772de){_0x5351c3=_0x3772de['length'];if(!_0x335fb2[_0xbcbe('0x32')][_0xbcbe('0x39')](_0xbcbe('0x3a'))){_0x5efa29[_0xbcbe('0x20')]=qs[_0xbcbe('0x20')](_0x335fb2[_0xbcbe('0x32')]['limit']);_0x5efa29[_0xbcbe('0x1e')]=qs[_0xbcbe('0x1e')](_0x335fb2[_0xbcbe('0x32')][_0xbcbe('0x1e')]);}return _0x1413c8[_0xbcbe('0x50')](_0x5efa29);}})[_0xbcbe('0x28')](function(_0x48c880){if(_0x48c880){return _0x48c880?{'count':_0x5351c3,'rows':_0x48c880}:null;}})[_0xbcbe('0x28')](respondWithResult(_0x5b919f,null))[_0xbcbe('0x48')](handleError(_0x5b919f,null));};exports[_0xbcbe('0x51')]=function(_0x55da6e,_0xa3ee5a,_0x1ce7df){var _0x24bd30={};var _0x43d5d4={};var _0x2a3b4e;var _0x4162a1;return db['Dynamics365Configuration'][_0xbcbe('0x4e')]({'where':{'id':_0x55da6e['params']['id']}})['then'](handleEntityNotFound(_0xa3ee5a,null))[_0xbcbe('0x28')](function(_0x2e556a){if(_0x2e556a){_0x2a3b4e=_0x2e556a;_0x43d5d4[_0xbcbe('0x34')]=_[_0xbcbe('0x44')](db[_0xbcbe('0x4f')][_0xbcbe('0x2e')]);_0x43d5d4[_0xbcbe('0x32')]=_['keys'](_0x55da6e['query']);_0x43d5d4[_0xbcbe('0x33')]=_[_0xbcbe('0x35')](_0x43d5d4[_0xbcbe('0x34')],_0x43d5d4[_0xbcbe('0x32')]);_0x24bd30[_0xbcbe('0x37')]=_['intersection'](_0x43d5d4[_0xbcbe('0x34')],qs[_0xbcbe('0x36')](_0x55da6e[_0xbcbe('0x32')][_0xbcbe('0x36')]));_0x24bd30['attributes']=_0x24bd30[_0xbcbe('0x37')][_0xbcbe('0x38')]?_0x24bd30[_0xbcbe('0x37')]:_0x43d5d4['model'];_0x24bd30['order']=qs[_0xbcbe('0x3c')](_0x55da6e['query'][_0xbcbe('0x3c')]);_0x24bd30[_0xbcbe('0x3d')]=qs[_0xbcbe('0x33')](_[_0xbcbe('0x3e')](_0x55da6e[_0xbcbe('0x32')],_0x43d5d4[_0xbcbe('0x33')]));if(_0x55da6e['query']['filter']){_0x24bd30[_0xbcbe('0x3d')]=_[_0xbcbe('0x46')](_0x24bd30[_0xbcbe('0x3d')],{'$or':_[_0xbcbe('0x30')](_0x24bd30['attributes'],function(_0x422104){var _0x2ad1db={};_0x2ad1db[_0x422104]={'$like':'%'+_0x55da6e[_0xbcbe('0x32')]['filter']+'%'};return _0x2ad1db;})});}_0x24bd30=_['merge']({},_0x24bd30,_0x55da6e[_0xbcbe('0x47')]);return _0x2a3b4e[_0xbcbe('0x51')](_0x24bd30);}})[_0xbcbe('0x28')](function(_0x10824c){if(_0x10824c){_0x4162a1=_0x10824c[_0xbcbe('0x38')];if(!_0x55da6e[_0xbcbe('0x32')][_0xbcbe('0x39')](_0xbcbe('0x3a'))){_0x24bd30['limit']=qs[_0xbcbe('0x20')](_0x55da6e[_0xbcbe('0x32')][_0xbcbe('0x20')]);_0x24bd30[_0xbcbe('0x1e')]=qs[_0xbcbe('0x1e')](_0x55da6e['query'][_0xbcbe('0x1e')]);}return _0x2a3b4e[_0xbcbe('0x51')](_0x24bd30);}})[_0xbcbe('0x28')](function(_0x2517ed){if(_0x2517ed){return _0x2517ed?{'count':_0x4162a1,'rows':_0x2517ed}:null;}})[_0xbcbe('0x28')](respondWithResult(_0xa3ee5a,null))['catch'](handleError(_0xa3ee5a,null));};
\ No newline at end of file