Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 94831c3..570cdfe 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf79b=['../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','request\x20sent','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','Dynamics365Configuration,\x20%s,\x20%s','info','result','status','end','json','count','offset','limit','set','Content-Range','apply','update','destroy','sendStatus','stack','name','send','index','map','Dynamics365Configuration','type','key','query','keys','filters','model','intersection','fields','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','rawAttributes','attributes','find','create','body','getFields','nolimit','getSubjects','getDescriptions','findOne','Dynamics365Field','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x46c42d,_0x42074b){var _0x376aa8=function(_0x191c2d){while(--_0x191c2d){_0x46c42d['push'](_0x46c42d['shift']());}};_0x376aa8(++_0x42074b);}(_0xf79b,0xa0));var _0xbf79=function(_0xcfdfeb,_0x46203b){_0xcfdfeb=_0xcfdfeb-0x0;var _0x5027a8=_0xf79b[_0xcfdfeb];return _0x5027a8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xbf79('0x0'));var zipdir=require(_0xbf79('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xbf79('0x2'));var moment=require(_0xbf79('0x3'));var BPromise=require(_0xbf79('0x4'));var Mustache=require('mustache');var util=require(_0xbf79('0x5'));var path=require(_0xbf79('0x6'));var sox=require(_0xbf79('0x7'));var csv=require(_0xbf79('0x8'));var ejs=require(_0xbf79('0x9'));var fs=require('fs');var fs_extra=require(_0xbf79('0xa'));var _=require(_0xbf79('0xb'));var squel=require(_0xbf79('0xc'));var crypto=require('crypto');var jsforce=require(_0xbf79('0xd'));var deskjs=require(_0xbf79('0xe'));var toCsv=require('to-csv');var querystring=require(_0xbf79('0xf'));var Papa=require('papaparse');var Redis=require(_0xbf79('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xbf79('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xbf79('0x12'))(_0xbf79('0x13'));var utils=require(_0xbf79('0x14'));var config=require(_0xbf79('0x15'));var licenseUtil=require(_0xbf79('0x16'));var db=require(_0xbf79('0x17'))['db'];var jayson=require(_0xbf79('0x18'));var client=jayson[_0xbf79('0x19')][_0xbf79('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0xa36c06,_0x1eb9ef,_0x97f300,_0x23fe13){return new BPromise(function(_0x26ea5f,_0x47cc95){var _0x3ca33b=_0x23fe13||client;return _0x3ca33b[_0xbf79('0x1b')](_0xa36c06,_0x97f300)[_0xbf79('0x1c')](function(_0x3b88dc){logger['info']('Dynamics365Configuration,\x20%s,\x20%s',_0x1eb9ef,_0xbf79('0x1d'));logger['debug'](_0xbf79('0x1e'),_0x1eb9ef,_0xbf79('0x1d'),JSON[_0xbf79('0x1f')](_0x3b88dc));if(_0x3b88dc['error']){if(_0x3b88dc[_0xbf79('0x20')][_0xbf79('0x21')]===0x1f4){logger[_0xbf79('0x20')]('Dynamics365Configuration,\x20%s,\x20%s',_0x1eb9ef,_0x3b88dc[_0xbf79('0x20')][_0xbf79('0x22')]);return _0x47cc95(_0x3b88dc[_0xbf79('0x20')][_0xbf79('0x22')]);}logger[_0xbf79('0x20')](_0xbf79('0x23'),_0x1eb9ef,_0x3b88dc[_0xbf79('0x20')][_0xbf79('0x22')]);return _0x26ea5f(_0x3b88dc[_0xbf79('0x20')][_0xbf79('0x22')]);}else{logger[_0xbf79('0x24')]('Dynamics365Configuration,\x20%s,\x20%s',_0x1eb9ef,_0xbf79('0x1d'));_0x26ea5f(_0x3b88dc[_0xbf79('0x25')][_0xbf79('0x22')]);}})['catch'](function(_0x4e0907){logger[_0xbf79('0x20')](_0xbf79('0x23'),_0x1eb9ef,_0x4e0907);_0x47cc95(_0x4e0907);});});}function respondWithStatusCode(_0x5badd1,_0x4ed375){_0x4ed375=_0x4ed375||0xcc;return function(_0x187a86){if(_0x187a86){return _0x5badd1['sendStatus'](_0x4ed375);}return _0x5badd1[_0xbf79('0x26')](_0x4ed375)[_0xbf79('0x27')]();};}function respondWithResult(_0x1fb682,_0x143e96){_0x143e96=_0x143e96||0xc8;return function(_0x41146b){if(_0x41146b){return _0x1fb682['status'](_0x143e96)[_0xbf79('0x28')](_0x41146b);}};}function respondWithFilteredResult(_0x5ba540,_0x49f57d){return function(_0x36f889){if(_0x36f889){var _0x4db121=_0x36f889[_0xbf79('0x29')],_0x1317c0=_0x49f57d['offset'],_0x1c03b7=_0x49f57d[_0xbf79('0x2a')]+_0x49f57d[_0xbf79('0x2b')],_0x50bc5f;if(_0x1c03b7>=_0x4db121){_0x1c03b7=_0x4db121;_0x50bc5f=0xc8;}else{_0x50bc5f=0xce;}_0x5ba540[_0xbf79('0x26')](_0x50bc5f);return _0x5ba540[_0xbf79('0x2c')](_0xbf79('0x2d'),_0x1317c0+'-'+_0x1c03b7+'/'+_0x4db121)['json'](_0x36f889);}return null;};}function patchUpdates(_0x5e11ad){return function(_0x3c4c5f){try{jsonpatch[_0xbf79('0x2e')](_0x3c4c5f,_0x5e11ad,!![]);}catch(_0x2bbf5c){return BPromise['reject'](_0x2bbf5c);}return _0x3c4c5f['save']();};}function saveUpdates(_0xf7e3eb,_0x227a84){return function(_0x34b4a4){if(_0x34b4a4){return _0x34b4a4[_0xbf79('0x2f')](_0xf7e3eb)[_0xbf79('0x1c')](function(_0x2d0575){return _0x2d0575;});}return null;};}function removeEntity(_0x1461bf,_0x400e7e){return function(_0xa669de){if(_0xa669de){return _0xa669de[_0xbf79('0x30')]()[_0xbf79('0x1c')](function(){_0x1461bf[_0xbf79('0x26')](0xcc)[_0xbf79('0x27')]();});}};}function handleEntityNotFound(_0x446dc3,_0x1ac0fb){return function(_0x3f49e3){if(!_0x3f49e3){_0x446dc3[_0xbf79('0x31')](0x194);}return _0x3f49e3;};}function handleError(_0x3a8dee,_0x659912){_0x659912=_0x659912||0x1f4;return function(_0x3a2422){logger[_0xbf79('0x20')](_0x3a2422[_0xbf79('0x32')]);if(_0x3a2422[_0xbf79('0x33')]){delete _0x3a2422['name'];}_0x3a8dee[_0xbf79('0x26')](_0x659912)[_0xbf79('0x34')](_0x3a2422);};}exports[_0xbf79('0x35')]=function(_0x33c930,_0x2e1e5b){var _0x31a75b={},_0x361705={},_0x4121fc={'count':0x0,'rows':[]};var _0x484662=_[_0xbf79('0x36')](db[_0xbf79('0x37')]['rawAttributes'],function(_0x571db8){return{'name':_0x571db8['fieldName'],'type':_0x571db8[_0xbf79('0x38')][_0xbf79('0x39')]};});_0x361705['model']=_['map'](_0x484662,_0xbf79('0x33'));_0x361705[_0xbf79('0x3a')]=_[_0xbf79('0x3b')](_0x33c930[_0xbf79('0x3a')]);_0x361705[_0xbf79('0x3c')]=_['intersection'](_0x361705[_0xbf79('0x3d')],_0x361705[_0xbf79('0x3a')]);_0x31a75b['attributes']=_[_0xbf79('0x3e')](_0x361705[_0xbf79('0x3d')],qs['fields'](_0x33c930[_0xbf79('0x3a')][_0xbf79('0x3f')]));_0x31a75b['attributes']=_0x31a75b['attributes'][_0xbf79('0x40')]?_0x31a75b['attributes']:_0x361705['model'];if(!_0x33c930[_0xbf79('0x3a')][_0xbf79('0x41')]('nolimit')){_0x31a75b[_0xbf79('0x2b')]=qs[_0xbf79('0x2b')](_0x33c930[_0xbf79('0x3a')][_0xbf79('0x2b')]);_0x31a75b[_0xbf79('0x2a')]=qs[_0xbf79('0x2a')](_0x33c930[_0xbf79('0x3a')][_0xbf79('0x2a')]);}_0x31a75b[_0xbf79('0x42')]=qs[_0xbf79('0x43')](_0x33c930[_0xbf79('0x3a')][_0xbf79('0x43')]);_0x31a75b[_0xbf79('0x44')]=qs[_0xbf79('0x3c')](_[_0xbf79('0x45')](_0x33c930[_0xbf79('0x3a')],_0x361705['filters']),_0x484662);if(_0x33c930[_0xbf79('0x3a')][_0xbf79('0x46')]){_0x31a75b[_0xbf79('0x44')]=_[_0xbf79('0x47')](_0x31a75b[_0xbf79('0x44')],{'$or':_[_0xbf79('0x36')](_0x484662,function(_0x43641b){if(_0x43641b['type']!==_0xbf79('0x48')){var _0x4b2405={};_0x4b2405[_0x43641b['name']]={'$like':'%'+_0x33c930[_0xbf79('0x3a')][_0xbf79('0x46')]+'%'};return _0x4b2405;}})});}_0x31a75b=_[_0xbf79('0x47')]({},_0x31a75b,_0x33c930[_0xbf79('0x49')]);var _0x482fcb={'where':_0x31a75b[_0xbf79('0x44')]};return db[_0xbf79('0x37')]['count'](_0x482fcb)[_0xbf79('0x1c')](function(_0x1e55e0){_0x4121fc[_0xbf79('0x29')]=_0x1e55e0;if(_0x33c930[_0xbf79('0x3a')][_0xbf79('0x4a')]){_0x31a75b['include']=[{'all':!![]}];}return db[_0xbf79('0x37')][_0xbf79('0x4b')](_0x31a75b);})['then'](function(_0xb18da6){_0x4121fc[_0xbf79('0x4c')]=_0xb18da6;return _0x4121fc;})[_0xbf79('0x1c')](respondWithFilteredResult(_0x2e1e5b,_0x31a75b))[_0xbf79('0x4d')](handleError(_0x2e1e5b,null));};exports[_0xbf79('0x4e')]=function(_0x51ae9e,_0x5c999d){var _0x1258f6={'raw':![],'where':{'id':_0x51ae9e[_0xbf79('0x4f')]['id']}},_0x1ef09d={};_0x1ef09d['model']=_[_0xbf79('0x3b')](db[_0xbf79('0x37')][_0xbf79('0x50')]);_0x1ef09d[_0xbf79('0x3a')]=_[_0xbf79('0x3b')](_0x51ae9e[_0xbf79('0x3a')]);_0x1ef09d['filters']=_['intersection'](_0x1ef09d[_0xbf79('0x3d')],_0x1ef09d[_0xbf79('0x3a')]);_0x1258f6[_0xbf79('0x51')]=_['intersection'](_0x1ef09d[_0xbf79('0x3d')],qs[_0xbf79('0x3f')](_0x51ae9e[_0xbf79('0x3a')]['fields']));_0x1258f6[_0xbf79('0x51')]=_0x1258f6[_0xbf79('0x51')][_0xbf79('0x40')]?_0x1258f6['attributes']:_0x1ef09d[_0xbf79('0x3d')];if(_0x51ae9e['query'][_0xbf79('0x4a')]){_0x1258f6['include']=[{'all':!![]}];}_0x1258f6=_['merge']({},_0x1258f6,_0x51ae9e[_0xbf79('0x49')]);return db['Dynamics365Configuration'][_0xbf79('0x52')](_0x1258f6)[_0xbf79('0x1c')](handleEntityNotFound(_0x5c999d,null))[_0xbf79('0x1c')](respondWithResult(_0x5c999d,null))[_0xbf79('0x4d')](handleError(_0x5c999d,null));};exports['create']=function(_0x2c302b,_0x26fd8f){return db[_0xbf79('0x37')][_0xbf79('0x53')](_0x2c302b[_0xbf79('0x54')],{})[_0xbf79('0x1c')](respondWithResult(_0x26fd8f,0xc9))[_0xbf79('0x4d')](handleError(_0x26fd8f,null));};exports['update']=function(_0xd6dcac,_0x25fbdc){if(_0xd6dcac[_0xbf79('0x54')]['id']){delete _0xd6dcac[_0xbf79('0x54')]['id'];}return db[_0xbf79('0x37')]['find']({'where':{'id':_0xd6dcac[_0xbf79('0x4f')]['id']}})[_0xbf79('0x1c')](handleEntityNotFound(_0x25fbdc,null))[_0xbf79('0x1c')](saveUpdates(_0xd6dcac[_0xbf79('0x54')],null))[_0xbf79('0x1c')](respondWithResult(_0x25fbdc,null))[_0xbf79('0x4d')](handleError(_0x25fbdc,null));};exports['destroy']=function(_0x526d8c,_0x5872a6){return db['Dynamics365Configuration'][_0xbf79('0x52')]({'where':{'id':_0x526d8c[_0xbf79('0x4f')]['id']}})[_0xbf79('0x1c')](handleEntityNotFound(_0x5872a6,null))[_0xbf79('0x1c')](removeEntity(_0x5872a6,null))[_0xbf79('0x4d')](handleError(_0x5872a6,null));};exports[_0xbf79('0x55')]=function(_0x2ca011,_0x15d6db,_0x4625b8){var _0x277a2d={};var _0x4a5863={};var _0x1ef495;var _0x241b1b;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x2ca011[_0xbf79('0x4f')]['id']}})[_0xbf79('0x1c')](handleEntityNotFound(_0x15d6db,null))[_0xbf79('0x1c')](function(_0x59de2a){if(_0x59de2a){_0x1ef495=_0x59de2a;_0x4a5863[_0xbf79('0x3d')]=_[_0xbf79('0x3b')](db['Dynamics365Field'][_0xbf79('0x50')]);_0x4a5863[_0xbf79('0x3a')]=_['keys'](_0x2ca011['query']);_0x4a5863['filters']=_[_0xbf79('0x3e')](_0x4a5863[_0xbf79('0x3d')],_0x4a5863[_0xbf79('0x3a')]);_0x277a2d[_0xbf79('0x51')]=_[_0xbf79('0x3e')](_0x4a5863['model'],qs[_0xbf79('0x3f')](_0x2ca011[_0xbf79('0x3a')][_0xbf79('0x3f')]));_0x277a2d[_0xbf79('0x51')]=_0x277a2d[_0xbf79('0x51')][_0xbf79('0x40')]?_0x277a2d[_0xbf79('0x51')]:_0x4a5863[_0xbf79('0x3d')];_0x277a2d['order']=qs[_0xbf79('0x43')](_0x2ca011['query']['sort']);_0x277a2d[_0xbf79('0x44')]=qs[_0xbf79('0x3c')](_[_0xbf79('0x45')](_0x2ca011[_0xbf79('0x3a')],_0x4a5863['filters']));if(_0x2ca011[_0xbf79('0x3a')][_0xbf79('0x46')]){_0x277a2d[_0xbf79('0x44')]=_[_0xbf79('0x47')](_0x277a2d[_0xbf79('0x44')],{'$or':_[_0xbf79('0x36')](_0x277a2d[_0xbf79('0x51')],function(_0x235cee){var _0x49a56e={};_0x49a56e[_0x235cee]={'$like':'%'+_0x2ca011[_0xbf79('0x3a')]['filter']+'%'};return _0x49a56e;})});}_0x277a2d=_['merge']({},_0x277a2d,_0x2ca011['options']);return _0x1ef495[_0xbf79('0x55')](_0x277a2d);}})[_0xbf79('0x1c')](function(_0x17884c){if(_0x17884c){_0x241b1b=_0x17884c['length'];if(!_0x2ca011[_0xbf79('0x3a')][_0xbf79('0x41')](_0xbf79('0x56'))){_0x277a2d[_0xbf79('0x2b')]=qs[_0xbf79('0x2b')](_0x2ca011[_0xbf79('0x3a')]['limit']);_0x277a2d[_0xbf79('0x2a')]=qs['offset'](_0x2ca011['query']['offset']);}return _0x1ef495[_0xbf79('0x55')](_0x277a2d);}})[_0xbf79('0x1c')](function(_0x130bf5){if(_0x130bf5){return _0x130bf5?{'count':_0x241b1b,'rows':_0x130bf5}:null;}})[_0xbf79('0x1c')](respondWithResult(_0x15d6db,null))[_0xbf79('0x4d')](handleError(_0x15d6db,null));};exports['getSubjects']=function(_0x217ab6,_0x5b3a3a,_0x485cd6){var _0x5934f1={};var _0x4bd678={};var _0x248031;var _0x4e3417;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x217ab6[_0xbf79('0x4f')]['id']}})[_0xbf79('0x1c')](handleEntityNotFound(_0x5b3a3a,null))[_0xbf79('0x1c')](function(_0x3747f6){if(_0x3747f6){_0x248031=_0x3747f6;_0x4bd678[_0xbf79('0x3d')]=_[_0xbf79('0x3b')](db['Dynamics365Field'][_0xbf79('0x50')]);_0x4bd678['query']=_['keys'](_0x217ab6[_0xbf79('0x3a')]);_0x4bd678[_0xbf79('0x3c')]=_['intersection'](_0x4bd678[_0xbf79('0x3d')],_0x4bd678[_0xbf79('0x3a')]);_0x5934f1[_0xbf79('0x51')]=_[_0xbf79('0x3e')](_0x4bd678[_0xbf79('0x3d')],qs[_0xbf79('0x3f')](_0x217ab6['query'][_0xbf79('0x3f')]));_0x5934f1[_0xbf79('0x51')]=_0x5934f1[_0xbf79('0x51')][_0xbf79('0x40')]?_0x5934f1[_0xbf79('0x51')]:_0x4bd678[_0xbf79('0x3d')];_0x5934f1[_0xbf79('0x42')]=qs[_0xbf79('0x43')](_0x217ab6[_0xbf79('0x3a')][_0xbf79('0x43')]);_0x5934f1[_0xbf79('0x44')]=qs['filters'](_[_0xbf79('0x45')](_0x217ab6[_0xbf79('0x3a')],_0x4bd678[_0xbf79('0x3c')]));if(_0x217ab6['query'][_0xbf79('0x46')]){_0x5934f1[_0xbf79('0x44')]=_[_0xbf79('0x47')](_0x5934f1[_0xbf79('0x44')],{'$or':_[_0xbf79('0x36')](_0x5934f1[_0xbf79('0x51')],function(_0x15e161){var _0x4ba8a4={};_0x4ba8a4[_0x15e161]={'$like':'%'+_0x217ab6[_0xbf79('0x3a')][_0xbf79('0x46')]+'%'};return _0x4ba8a4;})});}_0x5934f1=_[_0xbf79('0x47')]({},_0x5934f1,_0x217ab6[_0xbf79('0x49')]);return _0x248031[_0xbf79('0x57')](_0x5934f1);}})[_0xbf79('0x1c')](function(_0x2a78b3){if(_0x2a78b3){_0x4e3417=_0x2a78b3[_0xbf79('0x40')];if(!_0x217ab6['query'][_0xbf79('0x41')](_0xbf79('0x56'))){_0x5934f1[_0xbf79('0x2b')]=qs[_0xbf79('0x2b')](_0x217ab6[_0xbf79('0x3a')][_0xbf79('0x2b')]);_0x5934f1[_0xbf79('0x2a')]=qs['offset'](_0x217ab6[_0xbf79('0x3a')][_0xbf79('0x2a')]);}return _0x248031[_0xbf79('0x57')](_0x5934f1);}})[_0xbf79('0x1c')](function(_0x1fbd75){if(_0x1fbd75){return _0x1fbd75?{'count':_0x4e3417,'rows':_0x1fbd75}:null;}})[_0xbf79('0x1c')](respondWithResult(_0x5b3a3a,null))[_0xbf79('0x4d')](handleError(_0x5b3a3a,null));};exports[_0xbf79('0x58')]=function(_0x44b647,_0x46b4c8,_0x16f122){var _0x229c73={};var _0x357b9b={};var _0x3a80fa;var _0x49c2c1;return db[_0xbf79('0x37')][_0xbf79('0x59')]({'where':{'id':_0x44b647[_0xbf79('0x4f')]['id']}})[_0xbf79('0x1c')](handleEntityNotFound(_0x46b4c8,null))[_0xbf79('0x1c')](function(_0x59d491){if(_0x59d491){_0x3a80fa=_0x59d491;_0x357b9b[_0xbf79('0x3d')]=_[_0xbf79('0x3b')](db[_0xbf79('0x5a')][_0xbf79('0x50')]);_0x357b9b[_0xbf79('0x3a')]=_[_0xbf79('0x3b')](_0x44b647[_0xbf79('0x3a')]);_0x357b9b['filters']=_[_0xbf79('0x3e')](_0x357b9b[_0xbf79('0x3d')],_0x357b9b['query']);_0x229c73['attributes']=_[_0xbf79('0x3e')](_0x357b9b[_0xbf79('0x3d')],qs[_0xbf79('0x3f')](_0x44b647[_0xbf79('0x3a')]['fields']));_0x229c73[_0xbf79('0x51')]=_0x229c73[_0xbf79('0x51')][_0xbf79('0x40')]?_0x229c73[_0xbf79('0x51')]:_0x357b9b[_0xbf79('0x3d')];_0x229c73[_0xbf79('0x42')]=qs[_0xbf79('0x43')](_0x44b647[_0xbf79('0x3a')][_0xbf79('0x43')]);_0x229c73[_0xbf79('0x44')]=qs[_0xbf79('0x3c')](_[_0xbf79('0x45')](_0x44b647[_0xbf79('0x3a')],_0x357b9b[_0xbf79('0x3c')]));if(_0x44b647['query'][_0xbf79('0x46')]){_0x229c73[_0xbf79('0x44')]=_[_0xbf79('0x47')](_0x229c73[_0xbf79('0x44')],{'$or':_['map'](_0x229c73[_0xbf79('0x51')],function(_0x32434c){var _0x5ba5df={};_0x5ba5df[_0x32434c]={'$like':'%'+_0x44b647[_0xbf79('0x3a')][_0xbf79('0x46')]+'%'};return _0x5ba5df;})});}_0x229c73=_[_0xbf79('0x47')]({},_0x229c73,_0x44b647['options']);return _0x3a80fa['getDescriptions'](_0x229c73);}})[_0xbf79('0x1c')](function(_0x58555e){if(_0x58555e){_0x49c2c1=_0x58555e['length'];if(!_0x44b647['query']['hasOwnProperty'](_0xbf79('0x56'))){_0x229c73[_0xbf79('0x2b')]=qs[_0xbf79('0x2b')](_0x44b647['query']['limit']);_0x229c73['offset']=qs[_0xbf79('0x2a')](_0x44b647[_0xbf79('0x3a')]['offset']);}return _0x3a80fa[_0xbf79('0x58')](_0x229c73);}})[_0xbf79('0x1c')](function(_0x20993d){if(_0x20993d){return _0x20993d?{'count':_0x49c2c1,'rows':_0x20993d}:null;}})['then'](respondWithResult(_0x46b4c8,null))[_0xbf79('0x4d')](handleError(_0x46b4c8,null));};
\ No newline at end of file
+var _0x7722=['VIRTUAL','includeAll','include','findAll','rows','show','params','length','options','find','catch','create','body','getFields','Dynamics365Field','nolimit','getSubjects','getDescriptions','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','apply','reject','save','update','then','destroy','error','name','send','index','map','Dynamics365Configuration','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','pick','filter','merge','type'];(function(_0x5a9c0c,_0x4ec485){var _0x53c77d=function(_0x1cf384){while(--_0x1cf384){_0x5a9c0c['push'](_0x5a9c0c['shift']());}};_0x53c77d(++_0x4ec485);}(_0x7722,0x10b));var _0x2772=function(_0x114fd0,_0x36d30f){_0x114fd0=_0x114fd0-0x0;var _0x533de2=_0x7722[_0x114fd0];return _0x533de2;};'use strict';var emlformat=require(_0x2772('0x0'));var rimraf=require(_0x2772('0x1'));var zipdir=require(_0x2772('0x2'));var jsonpatch=require(_0x2772('0x3'));var rp=require(_0x2772('0x4'));var moment=require('moment');var BPromise=require(_0x2772('0x5'));var Mustache=require('mustache');var util=require(_0x2772('0x6'));var path=require(_0x2772('0x7'));var sox=require(_0x2772('0x8'));var csv=require(_0x2772('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x2772('0xa'));var _=require(_0x2772('0xb'));var squel=require(_0x2772('0xc'));var crypto=require(_0x2772('0xd'));var jsforce=require(_0x2772('0xe'));var deskjs=require(_0x2772('0xf'));var toCsv=require(_0x2772('0x9'));var querystring=require('querystring');var Papa=require(_0x2772('0x10'));var Redis=require(_0x2772('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x2772('0x12'));var as=require(_0x2772('0x13'));var hardwareService=require(_0x2772('0x14'));var logger=require(_0x2772('0x15'))('api');var utils=require(_0x2772('0x16'));var config=require(_0x2772('0x17'));var licenseUtil=require(_0x2772('0x18'));var db=require(_0x2772('0x19'))['db'];function respondWithStatusCode(_0x2590cf,_0x5b50d7){_0x5b50d7=_0x5b50d7||0xcc;return function(_0x4ad8a7){if(_0x4ad8a7){return _0x2590cf[_0x2772('0x1a')](_0x5b50d7);}return _0x2590cf[_0x2772('0x1b')](_0x5b50d7)[_0x2772('0x1c')]();};}function respondWithResult(_0x5e8c03,_0x32d246){_0x32d246=_0x32d246||0xc8;return function(_0x2746d0){if(_0x2746d0){return _0x5e8c03[_0x2772('0x1b')](_0x32d246)['json'](_0x2746d0);}};}function respondWithFilteredResult(_0x50f702,_0x5e012e){return function(_0x185e4a){if(_0x185e4a){var _0x287fa3=typeof _0x5e012e['offset']===_0x2772('0x1d')&&typeof _0x5e012e[_0x2772('0x1e')]===_0x2772('0x1d');var _0x50f07c=_0x185e4a[_0x2772('0x1f')];var _0x54c8fc=_0x287fa3?0x0:_0x5e012e[_0x2772('0x20')];var _0x41fac5=_0x287fa3?_0x185e4a['count']:_0x5e012e[_0x2772('0x20')]+_0x5e012e[_0x2772('0x1e')];var _0x43d166;if(_0x41fac5>=_0x50f07c){_0x41fac5=_0x50f07c;_0x43d166=0xc8;}else{_0x43d166=0xce;}_0x50f702[_0x2772('0x1b')](_0x43d166);return _0x50f702[_0x2772('0x21')](_0x2772('0x22'),_0x54c8fc+'-'+_0x41fac5+'/'+_0x50f07c)[_0x2772('0x23')](_0x185e4a);}return null;};}function patchUpdates(_0x33b5f0){return function(_0x28db54){try{jsonpatch[_0x2772('0x24')](_0x28db54,_0x33b5f0,!![]);}catch(_0x41ed5f){return BPromise[_0x2772('0x25')](_0x41ed5f);}return _0x28db54[_0x2772('0x26')]();};}function saveUpdates(_0x206ac9,_0x1098b4){return function(_0x2c61b2){if(_0x2c61b2){return _0x2c61b2[_0x2772('0x27')](_0x206ac9)[_0x2772('0x28')](function(_0x9c8046){return _0x9c8046;});}return null;};}function removeEntity(_0x1506d9,_0x473660){return function(_0x4f1472){if(_0x4f1472){return _0x4f1472[_0x2772('0x29')]()[_0x2772('0x28')](function(){_0x1506d9[_0x2772('0x1b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f8011,_0x3017ae){return function(_0x3dd559){if(!_0x3dd559){_0x4f8011['sendStatus'](0x194);}return _0x3dd559;};}function handleError(_0x3037df,_0x221a41){_0x221a41=_0x221a41||0x1f4;return function(_0x4fd23e){logger[_0x2772('0x2a')](_0x4fd23e['stack']);if(_0x4fd23e[_0x2772('0x2b')]){delete _0x4fd23e[_0x2772('0x2b')];}_0x3037df[_0x2772('0x1b')](_0x221a41)[_0x2772('0x2c')](_0x4fd23e);};}exports[_0x2772('0x2d')]=function(_0x348b39,_0x10e1d9){var _0x48e932={},_0x11ca74={},_0xff8309={'count':0x0,'rows':[]};var _0x4f13b7=_[_0x2772('0x2e')](db[_0x2772('0x2f')][_0x2772('0x30')],function(_0x4fa63d){return{'name':_0x4fa63d['fieldName'],'type':_0x4fa63d['type'][_0x2772('0x31')]};});_0x11ca74[_0x2772('0x32')]=_[_0x2772('0x2e')](_0x4f13b7,_0x2772('0x2b'));_0x11ca74[_0x2772('0x33')]=_[_0x2772('0x34')](_0x348b39['query']);_0x11ca74[_0x2772('0x35')]=_[_0x2772('0x36')](_0x11ca74['model'],_0x11ca74[_0x2772('0x33')]);_0x48e932[_0x2772('0x37')]=_['intersection'](_0x11ca74[_0x2772('0x32')],qs[_0x2772('0x38')](_0x348b39[_0x2772('0x33')][_0x2772('0x38')]));_0x48e932[_0x2772('0x37')]=_0x48e932[_0x2772('0x37')]['length']?_0x48e932[_0x2772('0x37')]:_0x11ca74[_0x2772('0x32')];if(!_0x348b39[_0x2772('0x33')][_0x2772('0x39')]('nolimit')){_0x48e932[_0x2772('0x1e')]=qs[_0x2772('0x1e')](_0x348b39[_0x2772('0x33')][_0x2772('0x1e')]);_0x48e932[_0x2772('0x20')]=qs['offset'](_0x348b39[_0x2772('0x33')]['offset']);}_0x48e932[_0x2772('0x3a')]=qs[_0x2772('0x3b')](_0x348b39[_0x2772('0x33')][_0x2772('0x3b')]);_0x48e932[_0x2772('0x3c')]=qs[_0x2772('0x35')](_[_0x2772('0x3d')](_0x348b39['query'],_0x11ca74[_0x2772('0x35')]),_0x4f13b7);if(_0x348b39[_0x2772('0x33')][_0x2772('0x3e')]){_0x48e932['where']=_[_0x2772('0x3f')](_0x48e932[_0x2772('0x3c')],{'$or':_['map'](_0x4f13b7,function(_0x444c04){if(_0x444c04[_0x2772('0x40')]!==_0x2772('0x41')){var _0x4a5ae6={};_0x4a5ae6[_0x444c04['name']]={'$like':'%'+_0x348b39['query'][_0x2772('0x3e')]+'%'};return _0x4a5ae6;}})});}_0x48e932=_[_0x2772('0x3f')]({},_0x48e932,_0x348b39['options']);var _0xb3da7={'where':_0x48e932[_0x2772('0x3c')]};return db[_0x2772('0x2f')]['count'](_0xb3da7)[_0x2772('0x28')](function(_0x3feaf2){_0xff8309[_0x2772('0x1f')]=_0x3feaf2;if(_0x348b39[_0x2772('0x33')][_0x2772('0x42')]){_0x48e932[_0x2772('0x43')]=[{'all':!![]}];}return db[_0x2772('0x2f')][_0x2772('0x44')](_0x48e932);})[_0x2772('0x28')](function(_0x430088){_0xff8309[_0x2772('0x45')]=_0x430088;return _0xff8309;})[_0x2772('0x28')](respondWithFilteredResult(_0x10e1d9,_0x48e932))['catch'](handleError(_0x10e1d9,null));};exports[_0x2772('0x46')]=function(_0x200c41,_0x548ccd){var _0x13da35={'raw':![],'where':{'id':_0x200c41[_0x2772('0x47')]['id']}},_0x274f07={};_0x274f07['model']=_[_0x2772('0x34')](db[_0x2772('0x2f')][_0x2772('0x30')]);_0x274f07[_0x2772('0x33')]=_[_0x2772('0x34')](_0x200c41[_0x2772('0x33')]);_0x274f07[_0x2772('0x35')]=_['intersection'](_0x274f07[_0x2772('0x32')],_0x274f07[_0x2772('0x33')]);_0x13da35[_0x2772('0x37')]=_[_0x2772('0x36')](_0x274f07[_0x2772('0x32')],qs['fields'](_0x200c41['query'][_0x2772('0x38')]));_0x13da35['attributes']=_0x13da35[_0x2772('0x37')][_0x2772('0x48')]?_0x13da35[_0x2772('0x37')]:_0x274f07[_0x2772('0x32')];if(_0x200c41[_0x2772('0x33')][_0x2772('0x42')]){_0x13da35[_0x2772('0x43')]=[{'all':!![]}];}_0x13da35=_[_0x2772('0x3f')]({},_0x13da35,_0x200c41[_0x2772('0x49')]);return db[_0x2772('0x2f')][_0x2772('0x4a')](_0x13da35)[_0x2772('0x28')](handleEntityNotFound(_0x548ccd,null))['then'](respondWithResult(_0x548ccd,null))[_0x2772('0x4b')](handleError(_0x548ccd,null));};exports[_0x2772('0x4c')]=function(_0x477633,_0x18b3df){return db[_0x2772('0x2f')][_0x2772('0x4c')](_0x477633[_0x2772('0x4d')],{})[_0x2772('0x28')](respondWithResult(_0x18b3df,0xc9))[_0x2772('0x4b')](handleError(_0x18b3df,null));};exports[_0x2772('0x27')]=function(_0x4d04f1,_0x54d017){if(_0x4d04f1[_0x2772('0x4d')]['id']){delete _0x4d04f1[_0x2772('0x4d')]['id'];}return db[_0x2772('0x2f')][_0x2772('0x4a')]({'where':{'id':_0x4d04f1[_0x2772('0x47')]['id']}})[_0x2772('0x28')](handleEntityNotFound(_0x54d017,null))[_0x2772('0x28')](saveUpdates(_0x4d04f1['body'],null))[_0x2772('0x28')](respondWithResult(_0x54d017,null))[_0x2772('0x4b')](handleError(_0x54d017,null));};exports[_0x2772('0x29')]=function(_0x2ac1e4,_0x2f4da1){return db['Dynamics365Configuration']['find']({'where':{'id':_0x2ac1e4[_0x2772('0x47')]['id']}})['then'](handleEntityNotFound(_0x2f4da1,null))[_0x2772('0x28')](removeEntity(_0x2f4da1,null))[_0x2772('0x4b')](handleError(_0x2f4da1,null));};exports[_0x2772('0x4e')]=function(_0x3e9e61,_0x2c938c,_0x4c5485){var _0x44fbe6={};var _0x19e96d={};var _0x205667;var _0xc50032;return db[_0x2772('0x2f')]['findOne']({'where':{'id':_0x3e9e61[_0x2772('0x47')]['id']}})[_0x2772('0x28')](handleEntityNotFound(_0x2c938c,null))[_0x2772('0x28')](function(_0xba631a){if(_0xba631a){_0x205667=_0xba631a;_0x19e96d['model']=_[_0x2772('0x34')](db[_0x2772('0x4f')][_0x2772('0x30')]);_0x19e96d[_0x2772('0x33')]=_[_0x2772('0x34')](_0x3e9e61[_0x2772('0x33')]);_0x19e96d[_0x2772('0x35')]=_[_0x2772('0x36')](_0x19e96d[_0x2772('0x32')],_0x19e96d['query']);_0x44fbe6[_0x2772('0x37')]=_[_0x2772('0x36')](_0x19e96d[_0x2772('0x32')],qs[_0x2772('0x38')](_0x3e9e61['query'][_0x2772('0x38')]));_0x44fbe6['attributes']=_0x44fbe6[_0x2772('0x37')][_0x2772('0x48')]?_0x44fbe6[_0x2772('0x37')]:_0x19e96d[_0x2772('0x32')];_0x44fbe6[_0x2772('0x3a')]=qs['sort'](_0x3e9e61[_0x2772('0x33')][_0x2772('0x3b')]);_0x44fbe6[_0x2772('0x3c')]=qs[_0x2772('0x35')](_[_0x2772('0x3d')](_0x3e9e61[_0x2772('0x33')],_0x19e96d[_0x2772('0x35')]));if(_0x3e9e61[_0x2772('0x33')][_0x2772('0x3e')]){_0x44fbe6['where']=_[_0x2772('0x3f')](_0x44fbe6[_0x2772('0x3c')],{'$or':_[_0x2772('0x2e')](_0x44fbe6[_0x2772('0x37')],function(_0x5c01cd){var _0x324915={};_0x324915[_0x5c01cd]={'$like':'%'+_0x3e9e61[_0x2772('0x33')][_0x2772('0x3e')]+'%'};return _0x324915;})});}_0x44fbe6=_['merge']({},_0x44fbe6,_0x3e9e61[_0x2772('0x49')]);return _0x205667['getFields'](_0x44fbe6);}})[_0x2772('0x28')](function(_0x5d07ae){if(_0x5d07ae){_0xc50032=_0x5d07ae[_0x2772('0x48')];if(!_0x3e9e61['query'][_0x2772('0x39')](_0x2772('0x50'))){_0x44fbe6[_0x2772('0x1e')]=qs[_0x2772('0x1e')](_0x3e9e61['query'][_0x2772('0x1e')]);_0x44fbe6['offset']=qs[_0x2772('0x20')](_0x3e9e61[_0x2772('0x33')]['offset']);}return _0x205667[_0x2772('0x4e')](_0x44fbe6);}})[_0x2772('0x28')](function(_0x3f0af4){if(_0x3f0af4){return _0x3f0af4?{'count':_0xc50032,'rows':_0x3f0af4}:null;}})[_0x2772('0x28')](respondWithResult(_0x2c938c,null))['catch'](handleError(_0x2c938c,null));};exports['getSubjects']=function(_0x4d434c,_0x439177,_0x2621fb){var _0x5bc570={};var _0x5a41d6={};var _0x2c2eba;var _0x2ca302;return db[_0x2772('0x2f')]['findOne']({'where':{'id':_0x4d434c[_0x2772('0x47')]['id']}})['then'](handleEntityNotFound(_0x439177,null))[_0x2772('0x28')](function(_0xd5ec66){if(_0xd5ec66){_0x2c2eba=_0xd5ec66;_0x5a41d6[_0x2772('0x32')]=_['keys'](db[_0x2772('0x4f')][_0x2772('0x30')]);_0x5a41d6[_0x2772('0x33')]=_[_0x2772('0x34')](_0x4d434c[_0x2772('0x33')]);_0x5a41d6[_0x2772('0x35')]=_[_0x2772('0x36')](_0x5a41d6[_0x2772('0x32')],_0x5a41d6[_0x2772('0x33')]);_0x5bc570[_0x2772('0x37')]=_[_0x2772('0x36')](_0x5a41d6[_0x2772('0x32')],qs[_0x2772('0x38')](_0x4d434c[_0x2772('0x33')]['fields']));_0x5bc570['attributes']=_0x5bc570[_0x2772('0x37')][_0x2772('0x48')]?_0x5bc570[_0x2772('0x37')]:_0x5a41d6[_0x2772('0x32')];_0x5bc570[_0x2772('0x3a')]=qs[_0x2772('0x3b')](_0x4d434c[_0x2772('0x33')][_0x2772('0x3b')]);_0x5bc570[_0x2772('0x3c')]=qs[_0x2772('0x35')](_[_0x2772('0x3d')](_0x4d434c[_0x2772('0x33')],_0x5a41d6[_0x2772('0x35')]));if(_0x4d434c[_0x2772('0x33')][_0x2772('0x3e')]){_0x5bc570[_0x2772('0x3c')]=_[_0x2772('0x3f')](_0x5bc570[_0x2772('0x3c')],{'$or':_['map'](_0x5bc570[_0x2772('0x37')],function(_0x298e26){var _0x18101c={};_0x18101c[_0x298e26]={'$like':'%'+_0x4d434c[_0x2772('0x33')][_0x2772('0x3e')]+'%'};return _0x18101c;})});}_0x5bc570=_[_0x2772('0x3f')]({},_0x5bc570,_0x4d434c['options']);return _0x2c2eba[_0x2772('0x51')](_0x5bc570);}})[_0x2772('0x28')](function(_0x1ff1c4){if(_0x1ff1c4){_0x2ca302=_0x1ff1c4[_0x2772('0x48')];if(!_0x4d434c['query'][_0x2772('0x39')](_0x2772('0x50'))){_0x5bc570[_0x2772('0x1e')]=qs[_0x2772('0x1e')](_0x4d434c['query'][_0x2772('0x1e')]);_0x5bc570['offset']=qs[_0x2772('0x20')](_0x4d434c[_0x2772('0x33')]['offset']);}return _0x2c2eba[_0x2772('0x51')](_0x5bc570);}})[_0x2772('0x28')](function(_0x1638e4){if(_0x1638e4){return _0x1638e4?{'count':_0x2ca302,'rows':_0x1638e4}:null;}})['then'](respondWithResult(_0x439177,null))['catch'](handleError(_0x439177,null));};exports[_0x2772('0x52')]=function(_0x4b9768,_0x337e18,_0x451a07){var _0x59aa0e={};var _0x52f231={};var _0x387b66;var _0x3490a8;return db[_0x2772('0x2f')]['findOne']({'where':{'id':_0x4b9768[_0x2772('0x47')]['id']}})[_0x2772('0x28')](handleEntityNotFound(_0x337e18,null))[_0x2772('0x28')](function(_0x2a2cac){if(_0x2a2cac){_0x387b66=_0x2a2cac;_0x52f231[_0x2772('0x32')]=_[_0x2772('0x34')](db[_0x2772('0x4f')][_0x2772('0x30')]);_0x52f231[_0x2772('0x33')]=_[_0x2772('0x34')](_0x4b9768[_0x2772('0x33')]);_0x52f231[_0x2772('0x35')]=_[_0x2772('0x36')](_0x52f231['model'],_0x52f231[_0x2772('0x33')]);_0x59aa0e[_0x2772('0x37')]=_[_0x2772('0x36')](_0x52f231[_0x2772('0x32')],qs[_0x2772('0x38')](_0x4b9768[_0x2772('0x33')][_0x2772('0x38')]));_0x59aa0e[_0x2772('0x37')]=_0x59aa0e[_0x2772('0x37')][_0x2772('0x48')]?_0x59aa0e[_0x2772('0x37')]:_0x52f231[_0x2772('0x32')];_0x59aa0e[_0x2772('0x3a')]=qs['sort'](_0x4b9768[_0x2772('0x33')]['sort']);_0x59aa0e[_0x2772('0x3c')]=qs[_0x2772('0x35')](_[_0x2772('0x3d')](_0x4b9768['query'],_0x52f231[_0x2772('0x35')]));if(_0x4b9768[_0x2772('0x33')][_0x2772('0x3e')]){_0x59aa0e[_0x2772('0x3c')]=_['merge'](_0x59aa0e['where'],{'$or':_[_0x2772('0x2e')](_0x59aa0e['attributes'],function(_0x231af4){var _0x316994={};_0x316994[_0x231af4]={'$like':'%'+_0x4b9768['query']['filter']+'%'};return _0x316994;})});}_0x59aa0e=_[_0x2772('0x3f')]({},_0x59aa0e,_0x4b9768['options']);return _0x387b66[_0x2772('0x52')](_0x59aa0e);}})[_0x2772('0x28')](function(_0x5e8662){if(_0x5e8662){_0x3490a8=_0x5e8662[_0x2772('0x48')];if(!_0x4b9768[_0x2772('0x33')][_0x2772('0x39')]('nolimit')){_0x59aa0e[_0x2772('0x1e')]=qs[_0x2772('0x1e')](_0x4b9768['query'][_0x2772('0x1e')]);_0x59aa0e[_0x2772('0x20')]=qs[_0x2772('0x20')](_0x4b9768[_0x2772('0x33')][_0x2772('0x20')]);}return _0x387b66[_0x2772('0x52')](_0x59aa0e);}})[_0x2772('0x28')](function(_0x20b99b){if(_0x20b99b){return _0x20b99b?{'count':_0x3490a8,'rows':_0x20b99b}:null;}})[_0x2772('0x28')](respondWithResult(_0x337e18,null))[_0x2772('0x4b')](handleError(_0x337e18,null));};
\ No newline at end of file