Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 299c7a1..7de2919 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8b08=['model','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','filter','merge','options','includeAll','include','findAll','rows','show','params','rawAttributes','keys','find','create','body','Dynamics365Field','pick','getFields','nolimit','getSubjects','findOne','getDescriptions','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../mysqldb','jayson/promise','client','test','Sequelize','request','then','info','request\x20sent','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','code','Dynamics365Configuration,\x20%s,\x20%s','message','result','catch','sendStatus','end','json','count','offset','limit','set','Content-Range','reject','save','update','destroy','status','name','send','index','map','Dynamics365Configuration','fieldName','type','key'];(function(_0xdb78df,_0x5c31b4){var _0x29a363=function(_0x347f37){while(--_0x347f37){_0xdb78df['push'](_0xdb78df['shift']());}};_0x29a363(++_0x5c31b4);}(_0x8b08,0x80));var _0x88b0=function(_0x12b8a3,_0x1e7210){_0x12b8a3=_0x12b8a3-0x0;var _0x21f317=_0x8b08[_0x12b8a3];return _0x21f317;};'use strict';var pdf=require(_0x88b0('0x0'));var emlformat=require(_0x88b0('0x1'));var rimraf=require(_0x88b0('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x88b0('0x3'));var rp=require(_0x88b0('0x4'));var moment=require(_0x88b0('0x5'));var BPromise=require(_0x88b0('0x6'));var Mustache=require(_0x88b0('0x7'));var util=require(_0x88b0('0x8'));var path=require(_0x88b0('0x9'));var sox=require(_0x88b0('0xa'));var csv=require(_0x88b0('0xb'));var ejs=require(_0x88b0('0xc'));var fs=require('fs');var _=require(_0x88b0('0xd'));var squel=require(_0x88b0('0xe'));var crypto=require(_0x88b0('0xf'));var jsforce=require(_0x88b0('0x10'));var deskjs=require(_0x88b0('0x11'));var toCsv=require(_0x88b0('0xb'));var querystring=require(_0x88b0('0x12'));var Papa=require(_0x88b0('0x13'));var Redis=require(_0x88b0('0x14'));var authService=require(_0x88b0('0x15'));var qs=require(_0x88b0('0x16'));var as=require(_0x88b0('0x17'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x88b0('0x18'))('api');var utils=require(_0x88b0('0x19'));var config=require('../../config/environment');var db=require(_0x88b0('0x1a'))['db'];var jayson=require(_0x88b0('0x1b'));var client=jayson[_0x88b0('0x1c')]['http']({'port':0x232a});function checkPasswordPattern(_0x1132cd,_0x33a197,_0x5c0c05){if(_0x5c0c05){var _0x4ac7f0=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4ac7f0[_0x88b0('0x1d')](_0x33a197)){return _0x1132cd;}else{throw new db[(_0x88b0('0x1e'))]['ValidationError']('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x1132cd;}}function respondWithRpcPromise(_0x4eeb0f,_0x1fd4ea,_0x588b85,_0x224ebf){return new BPromise(function(_0x5af113,_0x1352e6){var _0x2e8ec1=_0x224ebf||client;return _0x2e8ec1[_0x88b0('0x1f')](_0x4eeb0f,_0x588b85)[_0x88b0('0x20')](function(_0x58d445){logger[_0x88b0('0x21')]('Dynamics365Configuration,\x20%s,\x20%s',_0x1fd4ea,_0x88b0('0x22'));logger['debug'](_0x88b0('0x23'),_0x1fd4ea,_0x88b0('0x22'),JSON[_0x88b0('0x24')](_0x58d445));if(_0x58d445[_0x88b0('0x25')]){if(_0x58d445['error'][_0x88b0('0x26')]===0x1f4){logger[_0x88b0('0x25')](_0x88b0('0x27'),_0x1fd4ea,_0x58d445[_0x88b0('0x25')][_0x88b0('0x28')]);return _0x1352e6(_0x58d445['error'][_0x88b0('0x28')]);}logger[_0x88b0('0x25')](_0x88b0('0x27'),_0x1fd4ea,_0x58d445[_0x88b0('0x25')][_0x88b0('0x28')]);return _0x5af113(_0x58d445[_0x88b0('0x25')]['message']);}else{logger[_0x88b0('0x21')](_0x88b0('0x27'),_0x1fd4ea,_0x88b0('0x22'));_0x5af113(_0x58d445[_0x88b0('0x29')][_0x88b0('0x28')]);}})[_0x88b0('0x2a')](function(_0x1ff99e){logger[_0x88b0('0x25')]('Dynamics365Configuration,\x20%s,\x20%s',_0x1fd4ea,_0x1ff99e);_0x1352e6(_0x1ff99e);});});}function respondWithStatusCode(_0x17d369,_0xc334da){_0xc334da=_0xc334da||0xcc;return function(_0x1803b2){if(_0x1803b2){return _0x17d369[_0x88b0('0x2b')](_0xc334da);}return _0x17d369['status'](_0xc334da)[_0x88b0('0x2c')]();};}function respondWithResult(_0x58c5ed,_0x5f23f4){_0x5f23f4=_0x5f23f4||0xc8;return function(_0x306e07){if(_0x306e07){return _0x58c5ed['status'](_0x5f23f4)[_0x88b0('0x2d')](_0x306e07);}};}function respondWithFilteredResult(_0x3c6946,_0x4ad9ef){return function(_0x4c5666){if(_0x4c5666){var _0x2db078=_0x4c5666[_0x88b0('0x2e')],_0x4f4de6=_0x4ad9ef[_0x88b0('0x2f')],_0x1e7325=_0x4ad9ef[_0x88b0('0x2f')]+_0x4ad9ef[_0x88b0('0x30')],_0x34a30b;if(_0x1e7325>=_0x2db078){_0x1e7325=_0x2db078;_0x34a30b=0xc8;}else{_0x34a30b=0xce;}_0x3c6946['status'](_0x34a30b);return _0x3c6946[_0x88b0('0x31')](_0x88b0('0x32'),_0x4f4de6+'-'+_0x1e7325+'/'+_0x2db078)[_0x88b0('0x2d')](_0x4c5666);}return null;};}function patchUpdates(_0x406136){return function(_0x9e3cc9){try{jsonpatch['apply'](_0x9e3cc9,_0x406136,!![]);}catch(_0x4954a5){return BPromise[_0x88b0('0x33')](_0x4954a5);}return _0x9e3cc9[_0x88b0('0x34')]();};}function saveUpdates(_0x2b4fca,_0xc9249f){return function(_0x4870df){if(_0x4870df){return _0x4870df[_0x88b0('0x35')](_0x2b4fca)[_0x88b0('0x20')](function(_0x301c4a){return _0x301c4a;});}return null;};}function removeEntity(_0x394416,_0xc45077){return function(_0x2b11c9){if(_0x2b11c9){return _0x2b11c9[_0x88b0('0x36')]()[_0x88b0('0x20')](function(){_0x394416[_0x88b0('0x37')](0xcc)[_0x88b0('0x2c')]();});}};}function handleEntityNotFound(_0x42d37f,_0x202ba9){return function(_0x5ed279){if(!_0x5ed279){_0x42d37f[_0x88b0('0x2b')](0x194);}return _0x5ed279;};}function handleError(_0x463c57,_0x136044){_0x136044=_0x136044||0x1f4;return function(_0x4566ba){logger[_0x88b0('0x25')](_0x4566ba['stack']);if(_0x4566ba[_0x88b0('0x38')]){delete _0x4566ba['name'];}_0x463c57[_0x88b0('0x37')](_0x136044)[_0x88b0('0x39')](_0x4566ba);};}exports[_0x88b0('0x3a')]=function(_0x10651c,_0x59b168){var _0x261127={},_0x40b09b={},_0x3760ba={'count':0x0,'rows':[]};var _0x52b90c=_[_0x88b0('0x3b')](db[_0x88b0('0x3c')]['rawAttributes'],function(_0x33fd0e){return{'name':_0x33fd0e[_0x88b0('0x3d')],'type':_0x33fd0e[_0x88b0('0x3e')][_0x88b0('0x3f')]};});_0x40b09b[_0x88b0('0x40')]=_[_0x88b0('0x3b')](_0x52b90c,_0x88b0('0x38'));_0x40b09b['query']=_['keys'](_0x10651c[_0x88b0('0x41')]);_0x40b09b[_0x88b0('0x42')]=_[_0x88b0('0x43')](_0x40b09b['model'],_0x40b09b[_0x88b0('0x41')]);_0x261127[_0x88b0('0x44')]=_[_0x88b0('0x43')](_0x40b09b[_0x88b0('0x40')],qs['fields'](_0x10651c['query'][_0x88b0('0x45')]));_0x261127[_0x88b0('0x44')]=_0x261127[_0x88b0('0x44')][_0x88b0('0x46')]?_0x261127[_0x88b0('0x44')]:_0x40b09b[_0x88b0('0x40')];if(!_0x10651c[_0x88b0('0x41')][_0x88b0('0x47')]('nolimit')){_0x261127[_0x88b0('0x30')]=qs['limit'](_0x10651c['query'][_0x88b0('0x30')]);_0x261127['offset']=qs[_0x88b0('0x2f')](_0x10651c[_0x88b0('0x41')][_0x88b0('0x2f')]);}_0x261127[_0x88b0('0x48')]=qs[_0x88b0('0x49')](_0x10651c[_0x88b0('0x41')]['sort']);_0x261127[_0x88b0('0x4a')]=qs['filters'](_['pick'](_0x10651c[_0x88b0('0x41')],_0x40b09b[_0x88b0('0x42')]));if(_0x10651c[_0x88b0('0x41')][_0x88b0('0x4b')]){_0x261127[_0x88b0('0x4a')]=_[_0x88b0('0x4c')](_0x261127['where'],{'$or':_[_0x88b0('0x3b')](_0x52b90c,function(_0x5f2ea8){if(_0x5f2ea8['type']!=='VIRTUAL'){var _0x27dde0={};_0x27dde0[_0x5f2ea8['name']]={'$like':'%'+_0x10651c['query'][_0x88b0('0x4b')]+'%'};return _0x27dde0;}})});}_0x261127=_[_0x88b0('0x4c')]({},_0x261127,_0x10651c[_0x88b0('0x4d')]);var _0x50ce26={'where':_0x261127[_0x88b0('0x4a')]};return db[_0x88b0('0x3c')]['count'](_0x50ce26)[_0x88b0('0x20')](function(_0x348e0a){_0x3760ba[_0x88b0('0x2e')]=_0x348e0a;if(_0x10651c[_0x88b0('0x41')][_0x88b0('0x4e')]){_0x261127[_0x88b0('0x4f')]=[{'all':!![]}];}return db[_0x88b0('0x3c')][_0x88b0('0x50')](_0x261127);})['then'](function(_0x2042d8){_0x3760ba[_0x88b0('0x51')]=_0x2042d8;return _0x3760ba;})[_0x88b0('0x20')](respondWithFilteredResult(_0x59b168,_0x261127))[_0x88b0('0x2a')](handleError(_0x59b168,null));};exports[_0x88b0('0x52')]=function(_0x51efe4,_0x2fe174){var _0xd5410b={'raw':![],'where':{'id':_0x51efe4[_0x88b0('0x53')]['id']}},_0x4ce685={};_0x4ce685[_0x88b0('0x40')]=_['keys'](db[_0x88b0('0x3c')][_0x88b0('0x54')]);_0x4ce685[_0x88b0('0x41')]=_[_0x88b0('0x55')](_0x51efe4['query']);_0x4ce685[_0x88b0('0x42')]=_[_0x88b0('0x43')](_0x4ce685[_0x88b0('0x40')],_0x4ce685[_0x88b0('0x41')]);_0xd5410b[_0x88b0('0x44')]=_['intersection'](_0x4ce685[_0x88b0('0x40')],qs['fields'](_0x51efe4[_0x88b0('0x41')]['fields']));_0xd5410b[_0x88b0('0x44')]=_0xd5410b[_0x88b0('0x44')][_0x88b0('0x46')]?_0xd5410b['attributes']:_0x4ce685[_0x88b0('0x40')];if(_0x51efe4['query'][_0x88b0('0x4e')]){_0xd5410b[_0x88b0('0x4f')]=[{'all':!![]}];}_0xd5410b=_[_0x88b0('0x4c')]({},_0xd5410b,_0x51efe4['options']);return db[_0x88b0('0x3c')][_0x88b0('0x56')](_0xd5410b)[_0x88b0('0x20')](handleEntityNotFound(_0x2fe174,null))[_0x88b0('0x20')](respondWithResult(_0x2fe174,null))[_0x88b0('0x2a')](handleError(_0x2fe174,null));};exports['create']=function(_0x2671b7,_0x1bcab9){return db['Dynamics365Configuration'][_0x88b0('0x57')](_0x2671b7[_0x88b0('0x58')],{})[_0x88b0('0x20')](respondWithResult(_0x1bcab9,0xc9))[_0x88b0('0x2a')](handleError(_0x1bcab9,null));};exports[_0x88b0('0x35')]=function(_0x206568,_0x4d7422){if(_0x206568[_0x88b0('0x58')]['id']){delete _0x206568[_0x88b0('0x58')]['id'];}return db[_0x88b0('0x3c')][_0x88b0('0x56')]({'where':{'id':_0x206568[_0x88b0('0x53')]['id']}})[_0x88b0('0x20')](handleEntityNotFound(_0x4d7422,null))[_0x88b0('0x20')](saveUpdates(_0x206568[_0x88b0('0x58')],null))[_0x88b0('0x20')](respondWithResult(_0x4d7422,null))[_0x88b0('0x2a')](handleError(_0x4d7422,null));};exports[_0x88b0('0x36')]=function(_0x1fb288,_0x4c3cd4){return db['Dynamics365Configuration'][_0x88b0('0x56')]({'where':{'id':_0x1fb288[_0x88b0('0x53')]['id']}})[_0x88b0('0x20')](handleEntityNotFound(_0x4c3cd4,null))[_0x88b0('0x20')](removeEntity(_0x4c3cd4,null))[_0x88b0('0x2a')](handleError(_0x4c3cd4,null));};exports['getFields']=function(_0x24c6f9,_0x2f4950,_0x18cf83){var _0xe8c70f={};var _0x8e3978={};var _0x51ad9d;var _0xd1f46d;return db[_0x88b0('0x3c')]['findOne']({'where':{'id':_0x24c6f9[_0x88b0('0x53')]['id']}})['then'](handleEntityNotFound(_0x2f4950,null))[_0x88b0('0x20')](function(_0x10d75c){if(_0x10d75c){_0x51ad9d=_0x10d75c;_0x8e3978['model']=_[_0x88b0('0x55')](db[_0x88b0('0x59')][_0x88b0('0x54')]);_0x8e3978['query']=_['keys'](_0x24c6f9[_0x88b0('0x41')]);_0x8e3978[_0x88b0('0x42')]=_[_0x88b0('0x43')](_0x8e3978[_0x88b0('0x40')],_0x8e3978[_0x88b0('0x41')]);_0xe8c70f[_0x88b0('0x44')]=_[_0x88b0('0x43')](_0x8e3978[_0x88b0('0x40')],qs[_0x88b0('0x45')](_0x24c6f9[_0x88b0('0x41')][_0x88b0('0x45')]));_0xe8c70f[_0x88b0('0x44')]=_0xe8c70f[_0x88b0('0x44')][_0x88b0('0x46')]?_0xe8c70f[_0x88b0('0x44')]:_0x8e3978['model'];_0xe8c70f[_0x88b0('0x48')]=qs['sort'](_0x24c6f9[_0x88b0('0x41')][_0x88b0('0x49')]);_0xe8c70f[_0x88b0('0x4a')]=qs['filters'](_[_0x88b0('0x5a')](_0x24c6f9[_0x88b0('0x41')],_0x8e3978['filters']));if(_0x24c6f9[_0x88b0('0x41')][_0x88b0('0x4b')]){_0xe8c70f[_0x88b0('0x4a')]=_[_0x88b0('0x4c')](_0xe8c70f[_0x88b0('0x4a')],{'$or':_['map'](_0xe8c70f[_0x88b0('0x44')],function(_0x47213a){var _0x588487={};_0x588487[_0x47213a]={'$like':'%'+_0x24c6f9[_0x88b0('0x41')][_0x88b0('0x4b')]+'%'};return _0x588487;})});}_0xe8c70f=_[_0x88b0('0x4c')]({},_0xe8c70f,_0x24c6f9[_0x88b0('0x4d')]);return _0x51ad9d[_0x88b0('0x5b')](_0xe8c70f);}})[_0x88b0('0x20')](function(_0x361499){if(_0x361499){_0xd1f46d=_0x361499[_0x88b0('0x46')];if(!_0x24c6f9[_0x88b0('0x41')][_0x88b0('0x47')](_0x88b0('0x5c'))){_0xe8c70f[_0x88b0('0x30')]=qs[_0x88b0('0x30')](_0x24c6f9[_0x88b0('0x41')]['limit']);_0xe8c70f[_0x88b0('0x2f')]=qs[_0x88b0('0x2f')](_0x24c6f9['query'][_0x88b0('0x2f')]);}return _0x51ad9d[_0x88b0('0x5b')](_0xe8c70f);}})[_0x88b0('0x20')](function(_0x591173){if(_0x591173){return _0x591173?{'count':_0xd1f46d,'rows':_0x591173}:null;}})[_0x88b0('0x20')](respondWithResult(_0x2f4950,null))[_0x88b0('0x2a')](handleError(_0x2f4950,null));};exports[_0x88b0('0x5d')]=function(_0x2ea294,_0x1e642a,_0x8c672){var _0x563bdf={};var _0xc7f83c={};var _0x5bfbc8;var _0x3d2d0e;return db[_0x88b0('0x3c')][_0x88b0('0x5e')]({'where':{'id':_0x2ea294[_0x88b0('0x53')]['id']}})['then'](handleEntityNotFound(_0x1e642a,null))[_0x88b0('0x20')](function(_0x5bd9b3){if(_0x5bd9b3){_0x5bfbc8=_0x5bd9b3;_0xc7f83c[_0x88b0('0x40')]=_['keys'](db[_0x88b0('0x59')][_0x88b0('0x54')]);_0xc7f83c[_0x88b0('0x41')]=_[_0x88b0('0x55')](_0x2ea294[_0x88b0('0x41')]);_0xc7f83c[_0x88b0('0x42')]=_[_0x88b0('0x43')](_0xc7f83c[_0x88b0('0x40')],_0xc7f83c[_0x88b0('0x41')]);_0x563bdf[_0x88b0('0x44')]=_[_0x88b0('0x43')](_0xc7f83c[_0x88b0('0x40')],qs[_0x88b0('0x45')](_0x2ea294[_0x88b0('0x41')]['fields']));_0x563bdf['attributes']=_0x563bdf[_0x88b0('0x44')][_0x88b0('0x46')]?_0x563bdf[_0x88b0('0x44')]:_0xc7f83c[_0x88b0('0x40')];_0x563bdf[_0x88b0('0x48')]=qs[_0x88b0('0x49')](_0x2ea294['query'][_0x88b0('0x49')]);_0x563bdf[_0x88b0('0x4a')]=qs[_0x88b0('0x42')](_[_0x88b0('0x5a')](_0x2ea294[_0x88b0('0x41')],_0xc7f83c[_0x88b0('0x42')]));if(_0x2ea294['query'][_0x88b0('0x4b')]){_0x563bdf[_0x88b0('0x4a')]=_[_0x88b0('0x4c')](_0x563bdf[_0x88b0('0x4a')],{'$or':_['map'](_0x563bdf[_0x88b0('0x44')],function(_0xa5eda9){var _0x113d43={};_0x113d43[_0xa5eda9]={'$like':'%'+_0x2ea294['query']['filter']+'%'};return _0x113d43;})});}_0x563bdf=_[_0x88b0('0x4c')]({},_0x563bdf,_0x2ea294['options']);return _0x5bfbc8[_0x88b0('0x5d')](_0x563bdf);}})[_0x88b0('0x20')](function(_0x3760ce){if(_0x3760ce){_0x3d2d0e=_0x3760ce[_0x88b0('0x46')];if(!_0x2ea294[_0x88b0('0x41')]['hasOwnProperty'](_0x88b0('0x5c'))){_0x563bdf[_0x88b0('0x30')]=qs[_0x88b0('0x30')](_0x2ea294['query'][_0x88b0('0x30')]);_0x563bdf[_0x88b0('0x2f')]=qs[_0x88b0('0x2f')](_0x2ea294[_0x88b0('0x41')][_0x88b0('0x2f')]);}return _0x5bfbc8[_0x88b0('0x5d')](_0x563bdf);}})[_0x88b0('0x20')](function(_0x5e3f8e){if(_0x5e3f8e){return _0x5e3f8e?{'count':_0x3d2d0e,'rows':_0x5e3f8e}:null;}})[_0x88b0('0x20')](respondWithResult(_0x1e642a,null))[_0x88b0('0x2a')](handleError(_0x1e642a,null));};exports[_0x88b0('0x5f')]=function(_0xa1a5d4,_0x1c086f,_0x54e2d8){var _0x3caaa2={};var _0x14a270={};var _0x17a4ab;var _0x5ea83a;return db[_0x88b0('0x3c')][_0x88b0('0x5e')]({'where':{'id':_0xa1a5d4[_0x88b0('0x53')]['id']}})['then'](handleEntityNotFound(_0x1c086f,null))[_0x88b0('0x20')](function(_0x42b1f0){if(_0x42b1f0){_0x17a4ab=_0x42b1f0;_0x14a270['model']=_[_0x88b0('0x55')](db['Dynamics365Field'][_0x88b0('0x54')]);_0x14a270['query']=_[_0x88b0('0x55')](_0xa1a5d4[_0x88b0('0x41')]);_0x14a270[_0x88b0('0x42')]=_['intersection'](_0x14a270[_0x88b0('0x40')],_0x14a270[_0x88b0('0x41')]);_0x3caaa2[_0x88b0('0x44')]=_[_0x88b0('0x43')](_0x14a270[_0x88b0('0x40')],qs['fields'](_0xa1a5d4[_0x88b0('0x41')][_0x88b0('0x45')]));_0x3caaa2[_0x88b0('0x44')]=_0x3caaa2[_0x88b0('0x44')][_0x88b0('0x46')]?_0x3caaa2[_0x88b0('0x44')]:_0x14a270[_0x88b0('0x40')];_0x3caaa2['order']=qs['sort'](_0xa1a5d4['query'][_0x88b0('0x49')]);_0x3caaa2[_0x88b0('0x4a')]=qs[_0x88b0('0x42')](_[_0x88b0('0x5a')](_0xa1a5d4[_0x88b0('0x41')],_0x14a270[_0x88b0('0x42')]));if(_0xa1a5d4[_0x88b0('0x41')][_0x88b0('0x4b')]){_0x3caaa2[_0x88b0('0x4a')]=_[_0x88b0('0x4c')](_0x3caaa2[_0x88b0('0x4a')],{'$or':_[_0x88b0('0x3b')](_0x3caaa2[_0x88b0('0x44')],function(_0x130f1b){var _0x39e82e={};_0x39e82e[_0x130f1b]={'$like':'%'+_0xa1a5d4[_0x88b0('0x41')][_0x88b0('0x4b')]+'%'};return _0x39e82e;})});}_0x3caaa2=_[_0x88b0('0x4c')]({},_0x3caaa2,_0xa1a5d4[_0x88b0('0x4d')]);return _0x17a4ab[_0x88b0('0x5f')](_0x3caaa2);}})[_0x88b0('0x20')](function(_0x658f9a){if(_0x658f9a){_0x5ea83a=_0x658f9a[_0x88b0('0x46')];if(!_0xa1a5d4[_0x88b0('0x41')][_0x88b0('0x47')](_0x88b0('0x5c'))){_0x3caaa2['limit']=qs[_0x88b0('0x30')](_0xa1a5d4['query']['limit']);_0x3caaa2[_0x88b0('0x2f')]=qs[_0x88b0('0x2f')](_0xa1a5d4[_0x88b0('0x41')]['offset']);}return _0x17a4ab['getDescriptions'](_0x3caaa2);}})[_0x88b0('0x20')](function(_0xabf785){if(_0xabf785){return _0xabf785?{'count':_0x5ea83a,'rows':_0xabf785}:null;}})[_0x88b0('0x20')](respondWithResult(_0x1c086f,null))[_0x88b0('0x2a')](handleError(_0x1c086f,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