Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 8e65179..7de2919 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 _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