Built motion from commit 47436d59.|2.6.7
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 8e65179..ad0de12 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfc20=['options','find','create','body','update','Dynamics365Field','pick','getFields','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','jayson/promise','client','request','then','info','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json','offset','limit','set','reject','destroy','stack','name','send','index','map','Dynamics365Configuration','rawAttributes','fieldName','type','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','where','merge','VIRTUAL','count','includeAll','include','findAll','show','params'];(function(_0x16dc60,_0xa989fe){var _0x27fad9=function(_0x5ae88b){while(--_0x5ae88b){_0x16dc60['push'](_0x16dc60['shift']());}};_0x27fad9(++_0xa989fe);}(_0xfc20,0x1cc));var _0x0fc2=function(_0x5905bc,_0x4d289a){_0x5905bc=_0x5905bc-0x0;var _0x2f6c27=_0xfc20[_0x5905bc];return _0x2f6c27;};'use strict';var pdf=require(_0x0fc2('0x0'));var emlformat=require(_0x0fc2('0x1'));var rimraf=require(_0x0fc2('0x2'));var zipdir=require(_0x0fc2('0x3'));var jsonpatch=require(_0x0fc2('0x4'));var rp=require(_0x0fc2('0x5'));var moment=require(_0x0fc2('0x6'));var BPromise=require(_0x0fc2('0x7'));var Mustache=require(_0x0fc2('0x8'));var util=require(_0x0fc2('0x9'));var path=require(_0x0fc2('0xa'));var sox=require('sox');var csv=require(_0x0fc2('0xb'));var ejs=require(_0x0fc2('0xc'));var fs=require('fs');var _=require('lodash');var squel=require(_0x0fc2('0xd'));var crypto=require(_0x0fc2('0xe'));var jsforce=require(_0x0fc2('0xf'));var deskjs=require(_0x0fc2('0x10'));var toCsv=require(_0x0fc2('0xb'));var querystring=require('querystring');var Papa=require(_0x0fc2('0x11'));var Redis=require(_0x0fc2('0x12'));var authService=require(_0x0fc2('0x13'));var qs=require(_0x0fc2('0x14'));var as=require(_0x0fc2('0x15'));var hardwareService=require(_0x0fc2('0x16'));var logger=require('../../config/logger')('api');var utils=require(_0x0fc2('0x17'));var config=require(_0x0fc2('0x18'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var jayson=require(_0x0fc2('0x19'));var client=jayson[_0x0fc2('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x5ad268,_0x591377,_0x3cd0d9,_0x3dbf92){return new BPromise(function(_0x8c157e,_0x11c73d){var _0x1551b3=_0x3dbf92||client;return _0x1551b3[_0x0fc2('0x1b')](_0x5ad268,_0x3cd0d9)[_0x0fc2('0x1c')](function(_0x341158){logger[_0x0fc2('0x1d')](_0x0fc2('0x1e'),_0x591377,_0x0fc2('0x1f'));logger[_0x0fc2('0x20')](_0x0fc2('0x21'),_0x591377,'request\x20sent',JSON[_0x0fc2('0x22')](_0x341158));if(_0x341158[_0x0fc2('0x23')]){if(_0x341158[_0x0fc2('0x23')][_0x0fc2('0x24')]===0x1f4){logger[_0x0fc2('0x23')](_0x0fc2('0x1e'),_0x591377,_0x341158[_0x0fc2('0x23')]['message']);return _0x11c73d(_0x341158[_0x0fc2('0x23')]['message']);}logger[_0x0fc2('0x23')]('Dynamics365Configuration,\x20%s,\x20%s',_0x591377,_0x341158[_0x0fc2('0x23')]['message']);return _0x8c157e(_0x341158[_0x0fc2('0x23')][_0x0fc2('0x25')]);}else{logger[_0x0fc2('0x1d')](_0x0fc2('0x1e'),_0x591377,_0x0fc2('0x1f'));_0x8c157e(_0x341158[_0x0fc2('0x26')]['message']);}})[_0x0fc2('0x27')](function(_0x11e722){logger[_0x0fc2('0x23')]('Dynamics365Configuration,\x20%s,\x20%s',_0x591377,_0x11e722);_0x11c73d(_0x11e722);});});}function respondWithStatusCode(_0x2666c8,_0x6a06c5){_0x6a06c5=_0x6a06c5||0xcc;return function(_0x513ffd){if(_0x513ffd){return _0x2666c8[_0x0fc2('0x28')](_0x6a06c5);}return _0x2666c8[_0x0fc2('0x29')](_0x6a06c5)[_0x0fc2('0x2a')]();};}function respondWithResult(_0x2aea6d,_0x2ea194){_0x2ea194=_0x2ea194||0xc8;return function(_0x2f2f20){if(_0x2f2f20){return _0x2aea6d[_0x0fc2('0x29')](_0x2ea194)[_0x0fc2('0x2b')](_0x2f2f20);}};}function respondWithFilteredResult(_0x33546c,_0x1fcecb){return function(_0x40876c){if(_0x40876c){var _0x4dcb01=_0x40876c['count'],_0xa7e6c8=_0x1fcecb['offset'],_0x1d31d3=_0x1fcecb[_0x0fc2('0x2c')]+_0x1fcecb[_0x0fc2('0x2d')],_0x45da39;if(_0x1d31d3>=_0x4dcb01){_0x1d31d3=_0x4dcb01;_0x45da39=0xc8;}else{_0x45da39=0xce;}_0x33546c['status'](_0x45da39);return _0x33546c[_0x0fc2('0x2e')]('Content-Range',_0xa7e6c8+'-'+_0x1d31d3+'/'+_0x4dcb01)[_0x0fc2('0x2b')](_0x40876c);}return null;};}function patchUpdates(_0xec95a2){return function(_0x307ece){try{jsonpatch['apply'](_0x307ece,_0xec95a2,!![]);}catch(_0x36d3c2){return BPromise[_0x0fc2('0x2f')](_0x36d3c2);}return _0x307ece['save']();};}function saveUpdates(_0x1af6c8,_0x1145a2){return function(_0x2c8c38){if(_0x2c8c38){return _0x2c8c38['update'](_0x1af6c8)[_0x0fc2('0x1c')](function(_0x4c3e04){return _0x4c3e04;});}return null;};}function removeEntity(_0x3e96cb,_0x12e8f3){return function(_0x28a656){if(_0x28a656){return _0x28a656[_0x0fc2('0x30')]()[_0x0fc2('0x1c')](function(){_0x3e96cb['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0xdd6501,_0x3c3c82){return function(_0x274f8b){if(!_0x274f8b){_0xdd6501[_0x0fc2('0x28')](0x194);}return _0x274f8b;};}function handleError(_0x1f6aee,_0x522805){_0x522805=_0x522805||0x1f4;return function(_0x4f858b){logger['error'](_0x4f858b[_0x0fc2('0x31')]);if(_0x4f858b[_0x0fc2('0x32')]){delete _0x4f858b[_0x0fc2('0x32')];}_0x1f6aee[_0x0fc2('0x29')](_0x522805)[_0x0fc2('0x33')](_0x4f858b);};}exports[_0x0fc2('0x34')]=function(_0x37b04c,_0x40ce95){var _0x483d4c={},_0x317fdb={},_0x1f5f83={'count':0x0,'rows':[]};var _0x5c9e8b=_[_0x0fc2('0x35')](db[_0x0fc2('0x36')][_0x0fc2('0x37')],function(_0x570706){return{'name':_0x570706[_0x0fc2('0x38')],'type':_0x570706[_0x0fc2('0x39')]['key']};});_0x317fdb[_0x0fc2('0x3a')]=_[_0x0fc2('0x35')](_0x5c9e8b,_0x0fc2('0x32'));_0x317fdb['query']=_[_0x0fc2('0x3b')](_0x37b04c['query']);_0x317fdb[_0x0fc2('0x3c')]=_[_0x0fc2('0x3d')](_0x317fdb['model'],_0x317fdb[_0x0fc2('0x3e')]);_0x483d4c[_0x0fc2('0x3f')]=_[_0x0fc2('0x3d')](_0x317fdb[_0x0fc2('0x3a')],qs[_0x0fc2('0x40')](_0x37b04c[_0x0fc2('0x3e')][_0x0fc2('0x40')]));_0x483d4c[_0x0fc2('0x3f')]=_0x483d4c[_0x0fc2('0x3f')][_0x0fc2('0x41')]?_0x483d4c[_0x0fc2('0x3f')]:_0x317fdb[_0x0fc2('0x3a')];if(!_0x37b04c[_0x0fc2('0x3e')][_0x0fc2('0x42')](_0x0fc2('0x43'))){_0x483d4c[_0x0fc2('0x2d')]=qs[_0x0fc2('0x2d')](_0x37b04c['query']['limit']);_0x483d4c[_0x0fc2('0x2c')]=qs['offset'](_0x37b04c[_0x0fc2('0x3e')][_0x0fc2('0x2c')]);}_0x483d4c[_0x0fc2('0x44')]=qs[_0x0fc2('0x45')](_0x37b04c['query']['sort']);_0x483d4c['where']=qs['filters'](_['pick'](_0x37b04c[_0x0fc2('0x3e')],_0x317fdb[_0x0fc2('0x3c')]),_0x5c9e8b);if(_0x37b04c[_0x0fc2('0x3e')][_0x0fc2('0x46')]){_0x483d4c[_0x0fc2('0x47')]=_[_0x0fc2('0x48')](_0x483d4c[_0x0fc2('0x47')],{'$or':_[_0x0fc2('0x35')](_0x5c9e8b,function(_0x49a771){if(_0x49a771[_0x0fc2('0x39')]!==_0x0fc2('0x49')){var _0x57f391={};_0x57f391[_0x49a771['name']]={'$like':'%'+_0x37b04c[_0x0fc2('0x3e')][_0x0fc2('0x46')]+'%'};return _0x57f391;}})});}_0x483d4c=_[_0x0fc2('0x48')]({},_0x483d4c,_0x37b04c['options']);var _0x9f1139={'where':_0x483d4c[_0x0fc2('0x47')]};return db[_0x0fc2('0x36')][_0x0fc2('0x4a')](_0x9f1139)[_0x0fc2('0x1c')](function(_0x4a03c2){_0x1f5f83[_0x0fc2('0x4a')]=_0x4a03c2;if(_0x37b04c[_0x0fc2('0x3e')][_0x0fc2('0x4b')]){_0x483d4c[_0x0fc2('0x4c')]=[{'all':!![]}];}return db['Dynamics365Configuration'][_0x0fc2('0x4d')](_0x483d4c);})[_0x0fc2('0x1c')](function(_0x3a8d90){_0x1f5f83['rows']=_0x3a8d90;return _0x1f5f83;})[_0x0fc2('0x1c')](respondWithFilteredResult(_0x40ce95,_0x483d4c))[_0x0fc2('0x27')](handleError(_0x40ce95,null));};exports[_0x0fc2('0x4e')]=function(_0x4de123,_0x852a79){var _0x472822={'raw':![],'where':{'id':_0x4de123[_0x0fc2('0x4f')]['id']}},_0x1b3f24={};_0x1b3f24[_0x0fc2('0x3a')]=_[_0x0fc2('0x3b')](db[_0x0fc2('0x36')][_0x0fc2('0x37')]);_0x1b3f24[_0x0fc2('0x3e')]=_[_0x0fc2('0x3b')](_0x4de123[_0x0fc2('0x3e')]);_0x1b3f24[_0x0fc2('0x3c')]=_[_0x0fc2('0x3d')](_0x1b3f24[_0x0fc2('0x3a')],_0x1b3f24['query']);_0x472822[_0x0fc2('0x3f')]=_['intersection'](_0x1b3f24[_0x0fc2('0x3a')],qs[_0x0fc2('0x40')](_0x4de123['query'][_0x0fc2('0x40')]));_0x472822['attributes']=_0x472822[_0x0fc2('0x3f')][_0x0fc2('0x41')]?_0x472822[_0x0fc2('0x3f')]:_0x1b3f24['model'];if(_0x4de123[_0x0fc2('0x3e')]['includeAll']){_0x472822[_0x0fc2('0x4c')]=[{'all':!![]}];}_0x472822=_['merge']({},_0x472822,_0x4de123[_0x0fc2('0x50')]);return db['Dynamics365Configuration'][_0x0fc2('0x51')](_0x472822)[_0x0fc2('0x1c')](handleEntityNotFound(_0x852a79,null))[_0x0fc2('0x1c')](respondWithResult(_0x852a79,null))['catch'](handleError(_0x852a79,null));};exports[_0x0fc2('0x52')]=function(_0x3b8de7,_0x45de43){return db[_0x0fc2('0x36')]['create'](_0x3b8de7[_0x0fc2('0x53')],{})[_0x0fc2('0x1c')](respondWithResult(_0x45de43,0xc9))[_0x0fc2('0x27')](handleError(_0x45de43,null));};exports[_0x0fc2('0x54')]=function(_0xe0a9d9,_0x55e8eb){if(_0xe0a9d9['body']['id']){delete _0xe0a9d9[_0x0fc2('0x53')]['id'];}return db[_0x0fc2('0x36')]['find']({'where':{'id':_0xe0a9d9[_0x0fc2('0x4f')]['id']}})[_0x0fc2('0x1c')](handleEntityNotFound(_0x55e8eb,null))[_0x0fc2('0x1c')](saveUpdates(_0xe0a9d9[_0x0fc2('0x53')],null))[_0x0fc2('0x1c')](respondWithResult(_0x55e8eb,null))[_0x0fc2('0x27')](handleError(_0x55e8eb,null));};exports[_0x0fc2('0x30')]=function(_0xc775dd,_0xcb9489){return db['Dynamics365Configuration'][_0x0fc2('0x51')]({'where':{'id':_0xc775dd[_0x0fc2('0x4f')]['id']}})['then'](handleEntityNotFound(_0xcb9489,null))['then'](removeEntity(_0xcb9489,null))[_0x0fc2('0x27')](handleError(_0xcb9489,null));};exports['getFields']=function(_0x1cfddf,_0x2f0b2c,_0x1e3461){var _0x44abc={};var _0x4de61a={};var _0xdbb615;var _0x3c1400;return db[_0x0fc2('0x36')]['findOne']({'where':{'id':_0x1cfddf[_0x0fc2('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2f0b2c,null))[_0x0fc2('0x1c')](function(_0x3008ec){if(_0x3008ec){_0xdbb615=_0x3008ec;_0x4de61a['model']=_[_0x0fc2('0x3b')](db[_0x0fc2('0x55')][_0x0fc2('0x37')]);_0x4de61a[_0x0fc2('0x3e')]=_[_0x0fc2('0x3b')](_0x1cfddf[_0x0fc2('0x3e')]);_0x4de61a[_0x0fc2('0x3c')]=_[_0x0fc2('0x3d')](_0x4de61a[_0x0fc2('0x3a')],_0x4de61a[_0x0fc2('0x3e')]);_0x44abc[_0x0fc2('0x3f')]=_[_0x0fc2('0x3d')](_0x4de61a['model'],qs[_0x0fc2('0x40')](_0x1cfddf[_0x0fc2('0x3e')][_0x0fc2('0x40')]));_0x44abc[_0x0fc2('0x3f')]=_0x44abc['attributes']['length']?_0x44abc[_0x0fc2('0x3f')]:_0x4de61a['model'];_0x44abc['order']=qs[_0x0fc2('0x45')](_0x1cfddf[_0x0fc2('0x3e')][_0x0fc2('0x45')]);_0x44abc['where']=qs[_0x0fc2('0x3c')](_[_0x0fc2('0x56')](_0x1cfddf[_0x0fc2('0x3e')],_0x4de61a[_0x0fc2('0x3c')]));if(_0x1cfddf[_0x0fc2('0x3e')][_0x0fc2('0x46')]){_0x44abc['where']=_['merge'](_0x44abc[_0x0fc2('0x47')],{'$or':_[_0x0fc2('0x35')](_0x44abc[_0x0fc2('0x3f')],function(_0x27ca3b){var _0x1a66d3={};_0x1a66d3[_0x27ca3b]={'$like':'%'+_0x1cfddf['query'][_0x0fc2('0x46')]+'%'};return _0x1a66d3;})});}_0x44abc=_[_0x0fc2('0x48')]({},_0x44abc,_0x1cfddf[_0x0fc2('0x50')]);return _0xdbb615[_0x0fc2('0x57')](_0x44abc);}})[_0x0fc2('0x1c')](function(_0x9e437e){if(_0x9e437e){_0x3c1400=_0x9e437e[_0x0fc2('0x41')];if(!_0x1cfddf[_0x0fc2('0x3e')]['hasOwnProperty'](_0x0fc2('0x43'))){_0x44abc[_0x0fc2('0x2d')]=qs['limit'](_0x1cfddf[_0x0fc2('0x3e')][_0x0fc2('0x2d')]);_0x44abc[_0x0fc2('0x2c')]=qs[_0x0fc2('0x2c')](_0x1cfddf[_0x0fc2('0x3e')][_0x0fc2('0x2c')]);}return _0xdbb615[_0x0fc2('0x57')](_0x44abc);}})[_0x0fc2('0x1c')](function(_0x50a413){if(_0x50a413){return _0x50a413?{'count':_0x3c1400,'rows':_0x50a413}:null;}})['then'](respondWithResult(_0x2f0b2c,null))[_0x0fc2('0x27')](handleError(_0x2f0b2c,null));};exports[_0x0fc2('0x58')]=function(_0x5d157b,_0x41462f,_0xb22ba3){var _0x2cf14d={};var _0x10f4fb={};var _0x2f74dd;var _0x1c5cd6;return db[_0x0fc2('0x36')]['findOne']({'where':{'id':_0x5d157b[_0x0fc2('0x4f')]['id']}})[_0x0fc2('0x1c')](handleEntityNotFound(_0x41462f,null))[_0x0fc2('0x1c')](function(_0xffc85f){if(_0xffc85f){_0x2f74dd=_0xffc85f;_0x10f4fb[_0x0fc2('0x3a')]=_[_0x0fc2('0x3b')](db[_0x0fc2('0x55')][_0x0fc2('0x37')]);_0x10f4fb[_0x0fc2('0x3e')]=_[_0x0fc2('0x3b')](_0x5d157b['query']);_0x10f4fb['filters']=_['intersection'](_0x10f4fb[_0x0fc2('0x3a')],_0x10f4fb[_0x0fc2('0x3e')]);_0x2cf14d['attributes']=_[_0x0fc2('0x3d')](_0x10f4fb['model'],qs[_0x0fc2('0x40')](_0x5d157b[_0x0fc2('0x3e')][_0x0fc2('0x40')]));_0x2cf14d['attributes']=_0x2cf14d[_0x0fc2('0x3f')][_0x0fc2('0x41')]?_0x2cf14d['attributes']:_0x10f4fb[_0x0fc2('0x3a')];_0x2cf14d[_0x0fc2('0x44')]=qs[_0x0fc2('0x45')](_0x5d157b[_0x0fc2('0x3e')][_0x0fc2('0x45')]);_0x2cf14d['where']=qs[_0x0fc2('0x3c')](_[_0x0fc2('0x56')](_0x5d157b[_0x0fc2('0x3e')],_0x10f4fb[_0x0fc2('0x3c')]));if(_0x5d157b['query'][_0x0fc2('0x46')]){_0x2cf14d[_0x0fc2('0x47')]=_[_0x0fc2('0x48')](_0x2cf14d[_0x0fc2('0x47')],{'$or':_[_0x0fc2('0x35')](_0x2cf14d[_0x0fc2('0x3f')],function(_0x3c0d30){var _0x2aa82a={};_0x2aa82a[_0x3c0d30]={'$like':'%'+_0x5d157b[_0x0fc2('0x3e')][_0x0fc2('0x46')]+'%'};return _0x2aa82a;})});}_0x2cf14d=_[_0x0fc2('0x48')]({},_0x2cf14d,_0x5d157b[_0x0fc2('0x50')]);return _0x2f74dd[_0x0fc2('0x58')](_0x2cf14d);}})['then'](function(_0x51403e){if(_0x51403e){_0x1c5cd6=_0x51403e[_0x0fc2('0x41')];if(!_0x5d157b[_0x0fc2('0x3e')][_0x0fc2('0x42')]('nolimit')){_0x2cf14d[_0x0fc2('0x2d')]=qs[_0x0fc2('0x2d')](_0x5d157b[_0x0fc2('0x3e')]['limit']);_0x2cf14d[_0x0fc2('0x2c')]=qs[_0x0fc2('0x2c')](_0x5d157b[_0x0fc2('0x3e')][_0x0fc2('0x2c')]);}return _0x2f74dd[_0x0fc2('0x58')](_0x2cf14d);}})[_0x0fc2('0x1c')](function(_0x3b16f0){if(_0x3b16f0){return _0x3b16f0?{'count':_0x1c5cd6,'rows':_0x3b16f0}:null;}})[_0x0fc2('0x1c')](respondWithResult(_0x41462f,null))[_0x0fc2('0x27')](handleError(_0x41462f,null));};exports[_0x0fc2('0x59')]=function(_0x357160,_0x5d45db,_0x4d5f78){var _0x44695f={};var _0x3bc8fb={};var _0x40d7ef;var _0xe226e2;return db[_0x0fc2('0x36')]['findOne']({'where':{'id':_0x357160['params']['id']}})[_0x0fc2('0x1c')](handleEntityNotFound(_0x5d45db,null))[_0x0fc2('0x1c')](function(_0x1cb379){if(_0x1cb379){_0x40d7ef=_0x1cb379;_0x3bc8fb[_0x0fc2('0x3a')]=_['keys'](db[_0x0fc2('0x55')][_0x0fc2('0x37')]);_0x3bc8fb[_0x0fc2('0x3e')]=_[_0x0fc2('0x3b')](_0x357160['query']);_0x3bc8fb[_0x0fc2('0x3c')]=_[_0x0fc2('0x3d')](_0x3bc8fb['model'],_0x3bc8fb['query']);_0x44695f[_0x0fc2('0x3f')]=_[_0x0fc2('0x3d')](_0x3bc8fb[_0x0fc2('0x3a')],qs[_0x0fc2('0x40')](_0x357160[_0x0fc2('0x3e')][_0x0fc2('0x40')]));_0x44695f[_0x0fc2('0x3f')]=_0x44695f[_0x0fc2('0x3f')][_0x0fc2('0x41')]?_0x44695f['attributes']:_0x3bc8fb[_0x0fc2('0x3a')];_0x44695f[_0x0fc2('0x44')]=qs['sort'](_0x357160[_0x0fc2('0x3e')][_0x0fc2('0x45')]);_0x44695f[_0x0fc2('0x47')]=qs[_0x0fc2('0x3c')](_['pick'](_0x357160[_0x0fc2('0x3e')],_0x3bc8fb[_0x0fc2('0x3c')]));if(_0x357160['query'][_0x0fc2('0x46')]){_0x44695f[_0x0fc2('0x47')]=_[_0x0fc2('0x48')](_0x44695f[_0x0fc2('0x47')],{'$or':_[_0x0fc2('0x35')](_0x44695f[_0x0fc2('0x3f')],function(_0x22398f){var _0x4aea4b={};_0x4aea4b[_0x22398f]={'$like':'%'+_0x357160[_0x0fc2('0x3e')][_0x0fc2('0x46')]+'%'};return _0x4aea4b;})});}_0x44695f=_[_0x0fc2('0x48')]({},_0x44695f,_0x357160[_0x0fc2('0x50')]);return _0x40d7ef[_0x0fc2('0x59')](_0x44695f);}})[_0x0fc2('0x1c')](function(_0x485590){if(_0x485590){_0xe226e2=_0x485590['length'];if(!_0x357160[_0x0fc2('0x3e')][_0x0fc2('0x42')](_0x0fc2('0x43'))){_0x44695f[_0x0fc2('0x2d')]=qs[_0x0fc2('0x2d')](_0x357160[_0x0fc2('0x3e')][_0x0fc2('0x2d')]);_0x44695f[_0x0fc2('0x2c')]=qs[_0x0fc2('0x2c')](_0x357160['query'][_0x0fc2('0x2c')]);}return _0x40d7ef[_0x0fc2('0x59')](_0x44695f);}})[_0x0fc2('0x1c')](function(_0x166e2c){if(_0x166e2c){return _0x166e2c?{'count':_0xe226e2,'rows':_0x166e2c}:null;}})[_0x0fc2('0x1c')](respondWithResult(_0x5d45db,null))['catch'](handleError(_0x5d45db,null));};
\ No newline at end of file
+var _0xd5b4=['squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','count','offset','limit','set','Content-Range','apply','save','update','then','destroy','error','stack','name','send','index','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','fields','attributes','hasOwnProperty','order','sort','filters','pick','where','merge','VIRTUAL','options','Dynamics365Configuration','includeAll','rows','catch','show','length','find','create','body','params','getFields','findOne','Dynamics365Field','filter','nolimit','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','fs-extra'];(function(_0x50b651,_0x2ce0c5){var _0x1ec2b0=function(_0x468b6d){while(--_0x468b6d){_0x50b651['push'](_0x50b651['shift']());}};_0x1ec2b0(++_0x2ce0c5);}(_0xd5b4,0xe9));var _0x4d5b=function(_0x1ae765,_0x395cc8){_0x1ae765=_0x1ae765-0x0;var _0x5eea74=_0xd5b4[_0x1ae765];return _0x5eea74;};'use strict';var emlformat=require(_0x4d5b('0x0'));var rimraf=require(_0x4d5b('0x1'));var zipdir=require(_0x4d5b('0x2'));var jsonpatch=require(_0x4d5b('0x3'));var rp=require(_0x4d5b('0x4'));var moment=require('moment');var BPromise=require(_0x4d5b('0x5'));var Mustache=require(_0x4d5b('0x6'));var util=require(_0x4d5b('0x7'));var path=require('path');var sox=require(_0x4d5b('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x4d5b('0x9'));var _=require('lodash');var squel=require(_0x4d5b('0xa'));var crypto=require('crypto');var jsforce=require(_0x4d5b('0xb'));var deskjs=require(_0x4d5b('0xc'));var toCsv=require(_0x4d5b('0xd'));var querystring=require(_0x4d5b('0xe'));var Papa=require(_0x4d5b('0xf'));var Redis=require(_0x4d5b('0x10'));var authService=require(_0x4d5b('0x11'));var qs=require(_0x4d5b('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4d5b('0x13'));var logger=require('../../config/logger')(_0x4d5b('0x14'));var utils=require(_0x4d5b('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x4d5b('0x16'));var db=require(_0x4d5b('0x17'))['db'];function respondWithStatusCode(_0x1d64ab,_0x388a35){_0x388a35=_0x388a35||0xcc;return function(_0x48ea23){if(_0x48ea23){return _0x1d64ab[_0x4d5b('0x18')](_0x388a35);}return _0x1d64ab[_0x4d5b('0x19')](_0x388a35)[_0x4d5b('0x1a')]();};}function respondWithResult(_0x13fc4f,_0x2c4fdf){_0x2c4fdf=_0x2c4fdf||0xc8;return function(_0x2b4117){if(_0x2b4117){return _0x13fc4f[_0x4d5b('0x19')](_0x2c4fdf)[_0x4d5b('0x1b')](_0x2b4117);}};}function respondWithFilteredResult(_0x3449c8,_0x1129eb){return function(_0xbabdf3){if(_0xbabdf3){var _0x51c74c=typeof _0x1129eb['offset']==='undefined'&&typeof _0x1129eb['limit']===_0x4d5b('0x1c');var _0x19bded=_0xbabdf3[_0x4d5b('0x1d')];var _0x4ef058=_0x51c74c?0x0:_0x1129eb['offset'];var _0xc755e4=_0x51c74c?_0xbabdf3['count']:_0x1129eb[_0x4d5b('0x1e')]+_0x1129eb[_0x4d5b('0x1f')];var _0x1f3c0d;if(_0xc755e4>=_0x19bded){_0xc755e4=_0x19bded;_0x1f3c0d=0xc8;}else{_0x1f3c0d=0xce;}_0x3449c8[_0x4d5b('0x19')](_0x1f3c0d);return _0x3449c8[_0x4d5b('0x20')](_0x4d5b('0x21'),_0x4ef058+'-'+_0xc755e4+'/'+_0x19bded)['json'](_0xbabdf3);}return null;};}function patchUpdates(_0x37932a){return function(_0x2c9d0f){try{jsonpatch[_0x4d5b('0x22')](_0x2c9d0f,_0x37932a,!![]);}catch(_0x3ba0fe){return BPromise['reject'](_0x3ba0fe);}return _0x2c9d0f[_0x4d5b('0x23')]();};}function saveUpdates(_0x3cc62f,_0x4abf68){return function(_0x57fed4){if(_0x57fed4){return _0x57fed4[_0x4d5b('0x24')](_0x3cc62f)[_0x4d5b('0x25')](function(_0x468194){return _0x468194;});}return null;};}function removeEntity(_0x15114c,_0x1d1938){return function(_0x2ccb06){if(_0x2ccb06){return _0x2ccb06[_0x4d5b('0x26')]()[_0x4d5b('0x25')](function(){_0x15114c['status'](0xcc)[_0x4d5b('0x1a')]();});}};}function handleEntityNotFound(_0x4367ce,_0x31a87c){return function(_0xbff367){if(!_0xbff367){_0x4367ce[_0x4d5b('0x18')](0x194);}return _0xbff367;};}function handleError(_0x357bf0,_0x4e9de3){_0x4e9de3=_0x4e9de3||0x1f4;return function(_0x353dc1){logger[_0x4d5b('0x27')](_0x353dc1[_0x4d5b('0x28')]);if(_0x353dc1[_0x4d5b('0x29')]){delete _0x353dc1[_0x4d5b('0x29')];}_0x357bf0[_0x4d5b('0x19')](_0x4e9de3)[_0x4d5b('0x2a')](_0x353dc1);};}exports[_0x4d5b('0x2b')]=function(_0x18027b,_0x5d87d9){var _0x3e27e2={},_0x1021ea={},_0x1e3e7b={'count':0x0,'rows':[]};var _0x4175b1=_['map'](db['Dynamics365Configuration'][_0x4d5b('0x2c')],function(_0x1d5d72){return{'name':_0x1d5d72[_0x4d5b('0x2d')],'type':_0x1d5d72[_0x4d5b('0x2e')][_0x4d5b('0x2f')]};});_0x1021ea[_0x4d5b('0x30')]=_[_0x4d5b('0x31')](_0x4175b1,_0x4d5b('0x29'));_0x1021ea[_0x4d5b('0x32')]=_[_0x4d5b('0x33')](_0x18027b[_0x4d5b('0x32')]);_0x1021ea['filters']=_[_0x4d5b('0x34')](_0x1021ea['model'],_0x1021ea['query']);_0x3e27e2['attributes']=_[_0x4d5b('0x34')](_0x1021ea[_0x4d5b('0x30')],qs[_0x4d5b('0x35')](_0x18027b[_0x4d5b('0x32')][_0x4d5b('0x35')]));_0x3e27e2[_0x4d5b('0x36')]=_0x3e27e2['attributes']['length']?_0x3e27e2['attributes']:_0x1021ea[_0x4d5b('0x30')];if(!_0x18027b[_0x4d5b('0x32')][_0x4d5b('0x37')]('nolimit')){_0x3e27e2[_0x4d5b('0x1f')]=qs[_0x4d5b('0x1f')](_0x18027b[_0x4d5b('0x32')]['limit']);_0x3e27e2[_0x4d5b('0x1e')]=qs[_0x4d5b('0x1e')](_0x18027b[_0x4d5b('0x32')][_0x4d5b('0x1e')]);}_0x3e27e2[_0x4d5b('0x38')]=qs['sort'](_0x18027b[_0x4d5b('0x32')][_0x4d5b('0x39')]);_0x3e27e2['where']=qs[_0x4d5b('0x3a')](_[_0x4d5b('0x3b')](_0x18027b[_0x4d5b('0x32')],_0x1021ea[_0x4d5b('0x3a')]),_0x4175b1);if(_0x18027b[_0x4d5b('0x32')]['filter']){_0x3e27e2[_0x4d5b('0x3c')]=_[_0x4d5b('0x3d')](_0x3e27e2[_0x4d5b('0x3c')],{'$or':_[_0x4d5b('0x31')](_0x4175b1,function(_0x483eeb){if(_0x483eeb[_0x4d5b('0x2e')]!==_0x4d5b('0x3e')){var _0x292cf9={};_0x292cf9[_0x483eeb['name']]={'$like':'%'+_0x18027b[_0x4d5b('0x32')]['filter']+'%'};return _0x292cf9;}})});}_0x3e27e2=_['merge']({},_0x3e27e2,_0x18027b[_0x4d5b('0x3f')]);var _0x1cf017={'where':_0x3e27e2[_0x4d5b('0x3c')]};return db[_0x4d5b('0x40')][_0x4d5b('0x1d')](_0x1cf017)[_0x4d5b('0x25')](function(_0x36c9f1){_0x1e3e7b['count']=_0x36c9f1;if(_0x18027b[_0x4d5b('0x32')][_0x4d5b('0x41')]){_0x3e27e2['include']=[{'all':!![]}];}return db[_0x4d5b('0x40')]['findAll'](_0x3e27e2);})[_0x4d5b('0x25')](function(_0xa1ffaf){_0x1e3e7b[_0x4d5b('0x42')]=_0xa1ffaf;return _0x1e3e7b;})[_0x4d5b('0x25')](respondWithFilteredResult(_0x5d87d9,_0x3e27e2))[_0x4d5b('0x43')](handleError(_0x5d87d9,null));};exports[_0x4d5b('0x44')]=function(_0x591d3f,_0x4f9fc4){var _0x358d37={'raw':![],'where':{'id':_0x591d3f['params']['id']}},_0x4df71a={};_0x4df71a['model']=_[_0x4d5b('0x33')](db[_0x4d5b('0x40')][_0x4d5b('0x2c')]);_0x4df71a[_0x4d5b('0x32')]=_[_0x4d5b('0x33')](_0x591d3f[_0x4d5b('0x32')]);_0x4df71a[_0x4d5b('0x3a')]=_[_0x4d5b('0x34')](_0x4df71a[_0x4d5b('0x30')],_0x4df71a['query']);_0x358d37[_0x4d5b('0x36')]=_[_0x4d5b('0x34')](_0x4df71a[_0x4d5b('0x30')],qs[_0x4d5b('0x35')](_0x591d3f[_0x4d5b('0x32')]['fields']));_0x358d37['attributes']=_0x358d37[_0x4d5b('0x36')][_0x4d5b('0x45')]?_0x358d37[_0x4d5b('0x36')]:_0x4df71a[_0x4d5b('0x30')];if(_0x591d3f[_0x4d5b('0x32')][_0x4d5b('0x41')]){_0x358d37['include']=[{'all':!![]}];}_0x358d37=_[_0x4d5b('0x3d')]({},_0x358d37,_0x591d3f[_0x4d5b('0x3f')]);return db[_0x4d5b('0x40')][_0x4d5b('0x46')](_0x358d37)['then'](handleEntityNotFound(_0x4f9fc4,null))[_0x4d5b('0x25')](respondWithResult(_0x4f9fc4,null))[_0x4d5b('0x43')](handleError(_0x4f9fc4,null));};exports[_0x4d5b('0x47')]=function(_0x36c5a3,_0xbfdc44){return db[_0x4d5b('0x40')]['create'](_0x36c5a3['body'],{})['then'](respondWithResult(_0xbfdc44,0xc9))[_0x4d5b('0x43')](handleError(_0xbfdc44,null));};exports['update']=function(_0x32fb39,_0x570378){if(_0x32fb39[_0x4d5b('0x48')]['id']){delete _0x32fb39[_0x4d5b('0x48')]['id'];}return db[_0x4d5b('0x40')][_0x4d5b('0x46')]({'where':{'id':_0x32fb39[_0x4d5b('0x49')]['id']}})[_0x4d5b('0x25')](handleEntityNotFound(_0x570378,null))[_0x4d5b('0x25')](saveUpdates(_0x32fb39[_0x4d5b('0x48')],null))[_0x4d5b('0x25')](respondWithResult(_0x570378,null))['catch'](handleError(_0x570378,null));};exports[_0x4d5b('0x26')]=function(_0x2e8c93,_0x461971){return db[_0x4d5b('0x40')][_0x4d5b('0x46')]({'where':{'id':_0x2e8c93[_0x4d5b('0x49')]['id']}})[_0x4d5b('0x25')](handleEntityNotFound(_0x461971,null))[_0x4d5b('0x25')](removeEntity(_0x461971,null))[_0x4d5b('0x43')](handleError(_0x461971,null));};exports[_0x4d5b('0x4a')]=function(_0x3f97b3,_0x2b24c6,_0x7098a7){var _0x2a5428={};var _0x412336={};var _0x37cfb2;var _0xc76f8e;return db['Dynamics365Configuration'][_0x4d5b('0x4b')]({'where':{'id':_0x3f97b3[_0x4d5b('0x49')]['id']}})[_0x4d5b('0x25')](handleEntityNotFound(_0x2b24c6,null))[_0x4d5b('0x25')](function(_0x1da3ff){if(_0x1da3ff){_0x37cfb2=_0x1da3ff;_0x412336[_0x4d5b('0x30')]=_[_0x4d5b('0x33')](db[_0x4d5b('0x4c')][_0x4d5b('0x2c')]);_0x412336['query']=_[_0x4d5b('0x33')](_0x3f97b3[_0x4d5b('0x32')]);_0x412336[_0x4d5b('0x3a')]=_[_0x4d5b('0x34')](_0x412336['model'],_0x412336[_0x4d5b('0x32')]);_0x2a5428['attributes']=_[_0x4d5b('0x34')](_0x412336['model'],qs[_0x4d5b('0x35')](_0x3f97b3[_0x4d5b('0x32')][_0x4d5b('0x35')]));_0x2a5428['attributes']=_0x2a5428[_0x4d5b('0x36')][_0x4d5b('0x45')]?_0x2a5428[_0x4d5b('0x36')]:_0x412336['model'];_0x2a5428['order']=qs[_0x4d5b('0x39')](_0x3f97b3[_0x4d5b('0x32')][_0x4d5b('0x39')]);_0x2a5428[_0x4d5b('0x3c')]=qs[_0x4d5b('0x3a')](_[_0x4d5b('0x3b')](_0x3f97b3[_0x4d5b('0x32')],_0x412336[_0x4d5b('0x3a')]));if(_0x3f97b3['query'][_0x4d5b('0x4d')]){_0x2a5428[_0x4d5b('0x3c')]=_[_0x4d5b('0x3d')](_0x2a5428[_0x4d5b('0x3c')],{'$or':_[_0x4d5b('0x31')](_0x2a5428[_0x4d5b('0x36')],function(_0x17f973){var _0x4e16b5={};_0x4e16b5[_0x17f973]={'$like':'%'+_0x3f97b3[_0x4d5b('0x32')][_0x4d5b('0x4d')]+'%'};return _0x4e16b5;})});}_0x2a5428=_[_0x4d5b('0x3d')]({},_0x2a5428,_0x3f97b3['options']);return _0x37cfb2['getFields'](_0x2a5428);}})[_0x4d5b('0x25')](function(_0xb47b01){if(_0xb47b01){_0xc76f8e=_0xb47b01['length'];if(!_0x3f97b3[_0x4d5b('0x32')][_0x4d5b('0x37')](_0x4d5b('0x4e'))){_0x2a5428[_0x4d5b('0x1f')]=qs[_0x4d5b('0x1f')](_0x3f97b3[_0x4d5b('0x32')][_0x4d5b('0x1f')]);_0x2a5428['offset']=qs[_0x4d5b('0x1e')](_0x3f97b3['query'][_0x4d5b('0x1e')]);}return _0x37cfb2[_0x4d5b('0x4a')](_0x2a5428);}})[_0x4d5b('0x25')](function(_0x2807d5){if(_0x2807d5){return _0x2807d5?{'count':_0xc76f8e,'rows':_0x2807d5}:null;}})[_0x4d5b('0x25')](respondWithResult(_0x2b24c6,null))['catch'](handleError(_0x2b24c6,null));};exports[_0x4d5b('0x4f')]=function(_0x20ce60,_0x319974,_0x20fd2d){var _0x49f136={};var _0x1e8508={};var _0x4a5476;var _0x552353;return db[_0x4d5b('0x40')][_0x4d5b('0x4b')]({'where':{'id':_0x20ce60[_0x4d5b('0x49')]['id']}})[_0x4d5b('0x25')](handleEntityNotFound(_0x319974,null))[_0x4d5b('0x25')](function(_0x17e380){if(_0x17e380){_0x4a5476=_0x17e380;_0x1e8508[_0x4d5b('0x30')]=_[_0x4d5b('0x33')](db[_0x4d5b('0x4c')][_0x4d5b('0x2c')]);_0x1e8508[_0x4d5b('0x32')]=_[_0x4d5b('0x33')](_0x20ce60[_0x4d5b('0x32')]);_0x1e8508[_0x4d5b('0x3a')]=_[_0x4d5b('0x34')](_0x1e8508[_0x4d5b('0x30')],_0x1e8508[_0x4d5b('0x32')]);_0x49f136[_0x4d5b('0x36')]=_[_0x4d5b('0x34')](_0x1e8508['model'],qs[_0x4d5b('0x35')](_0x20ce60[_0x4d5b('0x32')]['fields']));_0x49f136['attributes']=_0x49f136[_0x4d5b('0x36')]['length']?_0x49f136[_0x4d5b('0x36')]:_0x1e8508[_0x4d5b('0x30')];_0x49f136[_0x4d5b('0x38')]=qs[_0x4d5b('0x39')](_0x20ce60[_0x4d5b('0x32')][_0x4d5b('0x39')]);_0x49f136[_0x4d5b('0x3c')]=qs[_0x4d5b('0x3a')](_[_0x4d5b('0x3b')](_0x20ce60[_0x4d5b('0x32')],_0x1e8508[_0x4d5b('0x3a')]));if(_0x20ce60[_0x4d5b('0x32')]['filter']){_0x49f136[_0x4d5b('0x3c')]=_['merge'](_0x49f136[_0x4d5b('0x3c')],{'$or':_['map'](_0x49f136['attributes'],function(_0x4c7bf4){var _0x5c1510={};_0x5c1510[_0x4c7bf4]={'$like':'%'+_0x20ce60[_0x4d5b('0x32')][_0x4d5b('0x4d')]+'%'};return _0x5c1510;})});}_0x49f136=_['merge']({},_0x49f136,_0x20ce60['options']);return _0x4a5476['getSubjects'](_0x49f136);}})['then'](function(_0x15c00b){if(_0x15c00b){_0x552353=_0x15c00b[_0x4d5b('0x45')];if(!_0x20ce60['query'][_0x4d5b('0x37')](_0x4d5b('0x4e'))){_0x49f136[_0x4d5b('0x1f')]=qs[_0x4d5b('0x1f')](_0x20ce60[_0x4d5b('0x32')]['limit']);_0x49f136['offset']=qs[_0x4d5b('0x1e')](_0x20ce60['query'][_0x4d5b('0x1e')]);}return _0x4a5476[_0x4d5b('0x4f')](_0x49f136);}})['then'](function(_0x1505ba){if(_0x1505ba){return _0x1505ba?{'count':_0x552353,'rows':_0x1505ba}:null;}})[_0x4d5b('0x25')](respondWithResult(_0x319974,null))[_0x4d5b('0x43')](handleError(_0x319974,null));};exports['getDescriptions']=function(_0x118f3f,_0x311693,_0x442b4a){var _0x5d929b={};var _0xd9cc71={};var _0x43d9e1;var _0x1877fa;return db['Dynamics365Configuration'][_0x4d5b('0x4b')]({'where':{'id':_0x118f3f[_0x4d5b('0x49')]['id']}})['then'](handleEntityNotFound(_0x311693,null))[_0x4d5b('0x25')](function(_0x4890d4){if(_0x4890d4){_0x43d9e1=_0x4890d4;_0xd9cc71[_0x4d5b('0x30')]=_[_0x4d5b('0x33')](db[_0x4d5b('0x4c')][_0x4d5b('0x2c')]);_0xd9cc71[_0x4d5b('0x32')]=_[_0x4d5b('0x33')](_0x118f3f[_0x4d5b('0x32')]);_0xd9cc71[_0x4d5b('0x3a')]=_[_0x4d5b('0x34')](_0xd9cc71[_0x4d5b('0x30')],_0xd9cc71['query']);_0x5d929b[_0x4d5b('0x36')]=_[_0x4d5b('0x34')](_0xd9cc71['model'],qs['fields'](_0x118f3f['query']['fields']));_0x5d929b[_0x4d5b('0x36')]=_0x5d929b['attributes'][_0x4d5b('0x45')]?_0x5d929b[_0x4d5b('0x36')]:_0xd9cc71[_0x4d5b('0x30')];_0x5d929b['order']=qs['sort'](_0x118f3f[_0x4d5b('0x32')]['sort']);_0x5d929b[_0x4d5b('0x3c')]=qs[_0x4d5b('0x3a')](_[_0x4d5b('0x3b')](_0x118f3f[_0x4d5b('0x32')],_0xd9cc71[_0x4d5b('0x3a')]));if(_0x118f3f[_0x4d5b('0x32')][_0x4d5b('0x4d')]){_0x5d929b['where']=_[_0x4d5b('0x3d')](_0x5d929b[_0x4d5b('0x3c')],{'$or':_[_0x4d5b('0x31')](_0x5d929b[_0x4d5b('0x36')],function(_0x215c31){var _0x58c132={};_0x58c132[_0x215c31]={'$like':'%'+_0x118f3f[_0x4d5b('0x32')][_0x4d5b('0x4d')]+'%'};return _0x58c132;})});}_0x5d929b=_['merge']({},_0x5d929b,_0x118f3f[_0x4d5b('0x3f')]);return _0x43d9e1[_0x4d5b('0x50')](_0x5d929b);}})[_0x4d5b('0x25')](function(_0xd44cd0){if(_0xd44cd0){_0x1877fa=_0xd44cd0[_0x4d5b('0x45')];if(!_0x118f3f[_0x4d5b('0x32')][_0x4d5b('0x37')](_0x4d5b('0x4e'))){_0x5d929b['limit']=qs[_0x4d5b('0x1f')](_0x118f3f['query'][_0x4d5b('0x1f')]);_0x5d929b[_0x4d5b('0x1e')]=qs[_0x4d5b('0x1e')](_0x118f3f['query'][_0x4d5b('0x1e')]);}return _0x43d9e1[_0x4d5b('0x50')](_0x5d929b);}})[_0x4d5b('0x25')](function(_0x948e4f){if(_0x948e4f){return _0x948e4f?{'count':_0x1877fa,'rows':_0x948e4f}:null;}})[_0x4d5b('0x25')](respondWithResult(_0x311693,null))[_0x4d5b('0x43')](handleError(_0x311693,null));};
\ No newline at end of file