Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 7de2919..bcd5066 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x2178=['request-promise','moment','bluebird','sox','to-csv','ejs','fs-extra','squel','crypto','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','catch','show','keys','find','create','body','update','params','getFields','Dynamics365Field','hasOwnProperty','getSubjects','order','getDescriptions','findOne','eml-format','rimraf','fast-json-patch'];(function(_0x4d0662,_0x145963){var _0x6eea6d=function(_0x2def06){while(--_0x2def06){_0x4d0662['push'](_0x4d0662['shift']());}};_0x6eea6d(++_0x145963);}(_0x2178,0x131));var _0x8217=function(_0x192136,_0x434d09){_0x192136=_0x192136-0x0;var _0x2524a5=_0x2178[_0x192136];return _0x2524a5;};'use strict';var emlformat=require(_0x8217('0x0'));var rimraf=require(_0x8217('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8217('0x2'));var rp=require(_0x8217('0x3'));var moment=require(_0x8217('0x4'));var BPromise=require(_0x8217('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x8217('0x6'));var csv=require(_0x8217('0x7'));var ejs=require(_0x8217('0x8'));var fs=require('fs');var fs_extra=require(_0x8217('0x9'));var _=require('lodash');var squel=require(_0x8217('0xa'));var crypto=require(_0x8217('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x8217('0x7'));var querystring=require('querystring');var Papa=require(_0x8217('0xc'));var Redis=require(_0x8217('0xd'));var authService=require('../../components/auth/service');var qs=require(_0x8217('0xe'));var as=require(_0x8217('0xf'));var hardwareService=require(_0x8217('0x10'));var logger=require('../../config/logger')('api');var utils=require(_0x8217('0x11'));var config=require(_0x8217('0x12'));var licenseUtil=require('../../config/license/util');var db=require(_0x8217('0x13'))['db'];function respondWithStatusCode(_0x5a787a,_0x41b092){_0x41b092=_0x41b092||0xcc;return function(_0x36fa50){if(_0x36fa50){return _0x5a787a[_0x8217('0x14')](_0x41b092);}return _0x5a787a[_0x8217('0x15')](_0x41b092)[_0x8217('0x16')]();};}function respondWithResult(_0x24cc93,_0x5ae8cb){_0x5ae8cb=_0x5ae8cb||0xc8;return function(_0x3d8eba){if(_0x3d8eba){return _0x24cc93['status'](_0x5ae8cb)[_0x8217('0x17')](_0x3d8eba);}};}function respondWithFilteredResult(_0x7ccfd4,_0x1a1bfa){return function(_0x29a264){if(_0x29a264){var _0x62e2c0=typeof _0x1a1bfa[_0x8217('0x18')]===_0x8217('0x19')&&typeof _0x1a1bfa[_0x8217('0x1a')]===_0x8217('0x19');var _0x122f7b=_0x29a264['count'];var _0x241a34=_0x62e2c0?0x0:_0x1a1bfa[_0x8217('0x18')];var _0x195250=_0x62e2c0?_0x29a264[_0x8217('0x1b')]:_0x1a1bfa[_0x8217('0x18')]+_0x1a1bfa[_0x8217('0x1a')];var _0x509d35;if(_0x195250>=_0x122f7b){_0x195250=_0x122f7b;_0x509d35=0xc8;}else{_0x509d35=0xce;}_0x7ccfd4['status'](_0x509d35);return _0x7ccfd4[_0x8217('0x1c')](_0x8217('0x1d'),_0x241a34+'-'+_0x195250+'/'+_0x122f7b)[_0x8217('0x17')](_0x29a264);}return null;};}function patchUpdates(_0x4225d0){return function(_0x36f999){try{jsonpatch[_0x8217('0x1e')](_0x36f999,_0x4225d0,!![]);}catch(_0x3d7766){return BPromise[_0x8217('0x1f')](_0x3d7766);}return _0x36f999[_0x8217('0x20')]();};}function saveUpdates(_0x1ca81a,_0x5b3c3b){return function(_0x55ee67){if(_0x55ee67){return _0x55ee67['update'](_0x1ca81a)[_0x8217('0x21')](function(_0x126dbc){return _0x126dbc;});}return null;};}function removeEntity(_0x46fd3c,_0x43a686){return function(_0x35987b){if(_0x35987b){return _0x35987b[_0x8217('0x22')]()[_0x8217('0x21')](function(){_0x46fd3c['status'](0xcc)[_0x8217('0x16')]();});}};}function handleEntityNotFound(_0x569421,_0x248582){return function(_0x1d1562){if(!_0x1d1562){_0x569421[_0x8217('0x14')](0x194);}return _0x1d1562;};}function handleError(_0x528e64,_0x5cec74){_0x5cec74=_0x5cec74||0x1f4;return function(_0x2f6fee){logger[_0x8217('0x23')](_0x2f6fee[_0x8217('0x24')]);if(_0x2f6fee[_0x8217('0x25')]){delete _0x2f6fee[_0x8217('0x25')];}_0x528e64['status'](_0x5cec74)[_0x8217('0x26')](_0x2f6fee);};}exports['index']=function(_0x1bf9c7,_0x2fe551){var _0x4babcb={},_0x401475={},_0x3a8990={'count':0x0,'rows':[]};var _0x70110=_[_0x8217('0x27')](db[_0x8217('0x28')][_0x8217('0x29')],function(_0x515935){return{'name':_0x515935[_0x8217('0x2a')],'type':_0x515935[_0x8217('0x2b')][_0x8217('0x2c')]};});_0x401475[_0x8217('0x2d')]=_[_0x8217('0x27')](_0x70110,_0x8217('0x25'));_0x401475[_0x8217('0x2e')]=_['keys'](_0x1bf9c7['query']);_0x401475[_0x8217('0x2f')]=_[_0x8217('0x30')](_0x401475[_0x8217('0x2d')],_0x401475['query']);_0x4babcb[_0x8217('0x31')]=_['intersection'](_0x401475['model'],qs[_0x8217('0x32')](_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x32')]));_0x4babcb[_0x8217('0x31')]=_0x4babcb['attributes'][_0x8217('0x33')]?_0x4babcb['attributes']:_0x401475[_0x8217('0x2d')];if(!_0x1bf9c7[_0x8217('0x2e')]['hasOwnProperty'](_0x8217('0x34'))){_0x4babcb['limit']=qs[_0x8217('0x1a')](_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x1a')]);_0x4babcb[_0x8217('0x18')]=qs[_0x8217('0x18')](_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x18')]);}_0x4babcb['order']=qs[_0x8217('0x35')](_0x1bf9c7[_0x8217('0x2e')]['sort']);_0x4babcb[_0x8217('0x36')]=qs['filters'](_[_0x8217('0x37')](_0x1bf9c7['query'],_0x401475['filters']),_0x70110);if(_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x38')]){_0x4babcb[_0x8217('0x36')]=_['merge'](_0x4babcb['where'],{'$or':_[_0x8217('0x27')](_0x70110,function(_0xab8687){if(_0xab8687[_0x8217('0x2b')]!==_0x8217('0x39')){var _0x1dfb7d={};_0x1dfb7d[_0xab8687['name']]={'$like':'%'+_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x38')]+'%'};return _0x1dfb7d;}})});}_0x4babcb=_[_0x8217('0x3a')]({},_0x4babcb,_0x1bf9c7[_0x8217('0x3b')]);var _0x29b589={'where':_0x4babcb['where']};return db[_0x8217('0x28')][_0x8217('0x1b')](_0x29b589)[_0x8217('0x21')](function(_0x10985b){_0x3a8990[_0x8217('0x1b')]=_0x10985b;if(_0x1bf9c7[_0x8217('0x2e')][_0x8217('0x3c')]){_0x4babcb[_0x8217('0x3d')]=[{'all':!![]}];}return db[_0x8217('0x28')]['findAll'](_0x4babcb);})[_0x8217('0x21')](function(_0x4a15d3){_0x3a8990['rows']=_0x4a15d3;return _0x3a8990;})[_0x8217('0x21')](respondWithFilteredResult(_0x2fe551,_0x4babcb))[_0x8217('0x3e')](handleError(_0x2fe551,null));};exports[_0x8217('0x3f')]=function(_0x2a3853,_0x1fa8af){var _0x3c5c9e={'raw':![],'where':{'id':_0x2a3853['params']['id']}},_0x4b4367={};_0x4b4367[_0x8217('0x2d')]=_[_0x8217('0x40')](db[_0x8217('0x28')][_0x8217('0x29')]);_0x4b4367['query']=_[_0x8217('0x40')](_0x2a3853[_0x8217('0x2e')]);_0x4b4367[_0x8217('0x2f')]=_['intersection'](_0x4b4367[_0x8217('0x2d')],_0x4b4367[_0x8217('0x2e')]);_0x3c5c9e[_0x8217('0x31')]=_[_0x8217('0x30')](_0x4b4367[_0x8217('0x2d')],qs['fields'](_0x2a3853['query'][_0x8217('0x32')]));_0x3c5c9e[_0x8217('0x31')]=_0x3c5c9e[_0x8217('0x31')]['length']?_0x3c5c9e[_0x8217('0x31')]:_0x4b4367['model'];if(_0x2a3853[_0x8217('0x2e')][_0x8217('0x3c')]){_0x3c5c9e['include']=[{'all':!![]}];}_0x3c5c9e=_['merge']({},_0x3c5c9e,_0x2a3853[_0x8217('0x3b')]);return db[_0x8217('0x28')][_0x8217('0x41')](_0x3c5c9e)['then'](handleEntityNotFound(_0x1fa8af,null))[_0x8217('0x21')](respondWithResult(_0x1fa8af,null))[_0x8217('0x3e')](handleError(_0x1fa8af,null));};exports[_0x8217('0x42')]=function(_0x288304,_0x49cfb4){return db[_0x8217('0x28')][_0x8217('0x42')](_0x288304[_0x8217('0x43')],{})[_0x8217('0x21')](respondWithResult(_0x49cfb4,0xc9))[_0x8217('0x3e')](handleError(_0x49cfb4,null));};exports[_0x8217('0x44')]=function(_0x127fb4,_0x2240cb){if(_0x127fb4[_0x8217('0x43')]['id']){delete _0x127fb4['body']['id'];}return db[_0x8217('0x28')]['find']({'where':{'id':_0x127fb4[_0x8217('0x45')]['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x2240cb,null))['then'](saveUpdates(_0x127fb4[_0x8217('0x43')],null))[_0x8217('0x21')](respondWithResult(_0x2240cb,null))[_0x8217('0x3e')](handleError(_0x2240cb,null));};exports['destroy']=function(_0x30508f,_0x16b6d7){return db[_0x8217('0x28')][_0x8217('0x41')]({'where':{'id':_0x30508f[_0x8217('0x45')]['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x16b6d7,null))['then'](removeEntity(_0x16b6d7,null))[_0x8217('0x3e')](handleError(_0x16b6d7,null));};exports[_0x8217('0x46')]=function(_0x2fd2d3,_0x8c67de,_0x368634){var _0xf0f388={};var _0x4e3325={};var _0x1f12a2;var _0x2767c0;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x2fd2d3[_0x8217('0x45')]['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x8c67de,null))[_0x8217('0x21')](function(_0x2a29af){if(_0x2a29af){_0x1f12a2=_0x2a29af;_0x4e3325[_0x8217('0x2d')]=_[_0x8217('0x40')](db[_0x8217('0x47')]['rawAttributes']);_0x4e3325[_0x8217('0x2e')]=_[_0x8217('0x40')](_0x2fd2d3[_0x8217('0x2e')]);_0x4e3325[_0x8217('0x2f')]=_[_0x8217('0x30')](_0x4e3325[_0x8217('0x2d')],_0x4e3325[_0x8217('0x2e')]);_0xf0f388[_0x8217('0x31')]=_['intersection'](_0x4e3325['model'],qs['fields'](_0x2fd2d3[_0x8217('0x2e')]['fields']));_0xf0f388[_0x8217('0x31')]=_0xf0f388[_0x8217('0x31')][_0x8217('0x33')]?_0xf0f388['attributes']:_0x4e3325[_0x8217('0x2d')];_0xf0f388['order']=qs['sort'](_0x2fd2d3[_0x8217('0x2e')][_0x8217('0x35')]);_0xf0f388[_0x8217('0x36')]=qs[_0x8217('0x2f')](_[_0x8217('0x37')](_0x2fd2d3[_0x8217('0x2e')],_0x4e3325[_0x8217('0x2f')]));if(_0x2fd2d3[_0x8217('0x2e')]['filter']){_0xf0f388['where']=_[_0x8217('0x3a')](_0xf0f388['where'],{'$or':_[_0x8217('0x27')](_0xf0f388['attributes'],function(_0x14295a){var _0x25799e={};_0x25799e[_0x14295a]={'$like':'%'+_0x2fd2d3['query'][_0x8217('0x38')]+'%'};return _0x25799e;})});}_0xf0f388=_[_0x8217('0x3a')]({},_0xf0f388,_0x2fd2d3[_0x8217('0x3b')]);return _0x1f12a2[_0x8217('0x46')](_0xf0f388);}})[_0x8217('0x21')](function(_0x392ff0){if(_0x392ff0){_0x2767c0=_0x392ff0[_0x8217('0x33')];if(!_0x2fd2d3[_0x8217('0x2e')][_0x8217('0x48')](_0x8217('0x34'))){_0xf0f388[_0x8217('0x1a')]=qs['limit'](_0x2fd2d3[_0x8217('0x2e')]['limit']);_0xf0f388['offset']=qs[_0x8217('0x18')](_0x2fd2d3[_0x8217('0x2e')][_0x8217('0x18')]);}return _0x1f12a2['getFields'](_0xf0f388);}})[_0x8217('0x21')](function(_0x1751cd){if(_0x1751cd){return _0x1751cd?{'count':_0x2767c0,'rows':_0x1751cd}:null;}})[_0x8217('0x21')](respondWithResult(_0x8c67de,null))[_0x8217('0x3e')](handleError(_0x8c67de,null));};exports[_0x8217('0x49')]=function(_0xa1fea8,_0x224ffc,_0x1a1c12){var _0x159eab={};var _0x138aa4={};var _0xc1b466;var _0x361a4b;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0xa1fea8['params']['id']}})[_0x8217('0x21')](handleEntityNotFound(_0x224ffc,null))[_0x8217('0x21')](function(_0x1f906b){if(_0x1f906b){_0xc1b466=_0x1f906b;_0x138aa4['model']=_[_0x8217('0x40')](db[_0x8217('0x47')]['rawAttributes']);_0x138aa4[_0x8217('0x2e')]=_['keys'](_0xa1fea8['query']);_0x138aa4[_0x8217('0x2f')]=_[_0x8217('0x30')](_0x138aa4[_0x8217('0x2d')],_0x138aa4[_0x8217('0x2e')]);_0x159eab['attributes']=_[_0x8217('0x30')](_0x138aa4[_0x8217('0x2d')],qs[_0x8217('0x32')](_0xa1fea8[_0x8217('0x2e')][_0x8217('0x32')]));_0x159eab['attributes']=_0x159eab[_0x8217('0x31')][_0x8217('0x33')]?_0x159eab[_0x8217('0x31')]:_0x138aa4[_0x8217('0x2d')];_0x159eab[_0x8217('0x4a')]=qs[_0x8217('0x35')](_0xa1fea8[_0x8217('0x2e')]['sort']);_0x159eab[_0x8217('0x36')]=qs[_0x8217('0x2f')](_['pick'](_0xa1fea8[_0x8217('0x2e')],_0x138aa4[_0x8217('0x2f')]));if(_0xa1fea8[_0x8217('0x2e')][_0x8217('0x38')]){_0x159eab['where']=_['merge'](_0x159eab['where'],{'$or':_[_0x8217('0x27')](_0x159eab[_0x8217('0x31')],function(_0x5587d9){var _0x9443c4={};_0x9443c4[_0x5587d9]={'$like':'%'+_0xa1fea8['query'][_0x8217('0x38')]+'%'};return _0x9443c4;})});}_0x159eab=_[_0x8217('0x3a')]({},_0x159eab,_0xa1fea8[_0x8217('0x3b')]);return _0xc1b466[_0x8217('0x49')](_0x159eab);}})['then'](function(_0x41c28c){if(_0x41c28c){_0x361a4b=_0x41c28c[_0x8217('0x33')];if(!_0xa1fea8[_0x8217('0x2e')][_0x8217('0x48')]('nolimit')){_0x159eab[_0x8217('0x1a')]=qs[_0x8217('0x1a')](_0xa1fea8[_0x8217('0x2e')][_0x8217('0x1a')]);_0x159eab[_0x8217('0x18')]=qs['offset'](_0xa1fea8[_0x8217('0x2e')][_0x8217('0x18')]);}return _0xc1b466[_0x8217('0x49')](_0x159eab);}})[_0x8217('0x21')](function(_0x136550){if(_0x136550){return _0x136550?{'count':_0x361a4b,'rows':_0x136550}:null;}})[_0x8217('0x21')](respondWithResult(_0x224ffc,null))[_0x8217('0x3e')](handleError(_0x224ffc,null));};exports[_0x8217('0x4b')]=function(_0x471f1b,_0x313a00,_0xaa8859){var _0x1bc89d={};var _0xf5f6d0={};var _0x586792;var _0x43e1f2;return db[_0x8217('0x28')][_0x8217('0x4c')]({'where':{'id':_0x471f1b[_0x8217('0x45')]['id']}})['then'](handleEntityNotFound(_0x313a00,null))['then'](function(_0x30731a){if(_0x30731a){_0x586792=_0x30731a;_0xf5f6d0[_0x8217('0x2d')]=_[_0x8217('0x40')](db[_0x8217('0x47')][_0x8217('0x29')]);_0xf5f6d0[_0x8217('0x2e')]=_[_0x8217('0x40')](_0x471f1b['query']);_0xf5f6d0[_0x8217('0x2f')]=_[_0x8217('0x30')](_0xf5f6d0[_0x8217('0x2d')],_0xf5f6d0[_0x8217('0x2e')]);_0x1bc89d[_0x8217('0x31')]=_[_0x8217('0x30')](_0xf5f6d0[_0x8217('0x2d')],qs['fields'](_0x471f1b['query'][_0x8217('0x32')]));_0x1bc89d[_0x8217('0x31')]=_0x1bc89d[_0x8217('0x31')][_0x8217('0x33')]?_0x1bc89d[_0x8217('0x31')]:_0xf5f6d0[_0x8217('0x2d')];_0x1bc89d[_0x8217('0x4a')]=qs[_0x8217('0x35')](_0x471f1b[_0x8217('0x2e')]['sort']);_0x1bc89d[_0x8217('0x36')]=qs['filters'](_['pick'](_0x471f1b[_0x8217('0x2e')],_0xf5f6d0[_0x8217('0x2f')]));if(_0x471f1b[_0x8217('0x2e')][_0x8217('0x38')]){_0x1bc89d[_0x8217('0x36')]=_[_0x8217('0x3a')](_0x1bc89d[_0x8217('0x36')],{'$or':_['map'](_0x1bc89d[_0x8217('0x31')],function(_0x5bc565){var _0x43c3e1={};_0x43c3e1[_0x5bc565]={'$like':'%'+_0x471f1b[_0x8217('0x2e')][_0x8217('0x38')]+'%'};return _0x43c3e1;})});}_0x1bc89d=_[_0x8217('0x3a')]({},_0x1bc89d,_0x471f1b[_0x8217('0x3b')]);return _0x586792[_0x8217('0x4b')](_0x1bc89d);}})[_0x8217('0x21')](function(_0x2430d7){if(_0x2430d7){_0x43e1f2=_0x2430d7[_0x8217('0x33')];if(!_0x471f1b['query']['hasOwnProperty'](_0x8217('0x34'))){_0x1bc89d[_0x8217('0x1a')]=qs['limit'](_0x471f1b[_0x8217('0x2e')]['limit']);_0x1bc89d[_0x8217('0x18')]=qs[_0x8217('0x18')](_0x471f1b[_0x8217('0x2e')][_0x8217('0x18')]);}return _0x586792['getDescriptions'](_0x1bc89d);}})[_0x8217('0x21')](function(_0xd683cd){if(_0xd683cd){return _0xd683cd?{'count':_0x43e1f2,'rows':_0xd683cd}:null;}})[_0x8217('0x21')](respondWithResult(_0x313a00,null))[_0x8217('0x3e')](handleError(_0x313a00,null));};
\ No newline at end of file