Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 9fa3bb6..570cdfe 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x414f=['fast-json-patch','request-promise','moment','util','to-csv','ejs','crypto','jsforce','desk.js','querystring','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','debug','Dynamics365Configuration,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','sendStatus','status','end','json','count','offset','limit','set','Content-Range','save','update','name','send','map','Dynamics365Configuration','rawAttributes','fieldName','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','sort','merge','type','VIRTUAL','filter','options','findAll','rows','catch','show','params','includeAll','include','create','body','find','destroy','getFields','Dynamics365Field','order','where','getSubjects','findOne','pick','nolimit','getDescriptions','eml-format','rimraf'];(function(_0x13b8f3,_0x442821){var _0x1a6d06=function(_0x5126f2){while(--_0x5126f2){_0x13b8f3['push'](_0x13b8f3['shift']());}};_0x1a6d06(++_0x442821);}(_0x414f,0xa8));var _0xf414=function(_0x4266b4,_0x4859ad){_0x4266b4=_0x4266b4-0x0;var _0x1442aa=_0x414f[_0x4266b4];return _0x1442aa;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xf414('0x0'));var rimraf=require(_0xf414('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf414('0x2'));var rp=require(_0xf414('0x3'));var moment=require(_0xf414('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xf414('0x5'));var path=require('path');var sox=require('sox');var csv=require(_0xf414('0x6'));var ejs=require(_0xf414('0x7'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xf414('0x8'));var jsforce=require(_0xf414('0x9'));var deskjs=require(_0xf414('0xa'));var toCsv=require(_0xf414('0x6'));var querystring=require(_0xf414('0xb'));var Papa=require('papaparse');var Redis=require(_0xf414('0xc'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xf414('0xd'));var hardwareService=require(_0xf414('0xe'));var logger=require(_0xf414('0xf'))('api');var utils=require('../../config/utils');var config=require(_0xf414('0x10'));var licenseUtil=require(_0xf414('0x11'));var db=require(_0xf414('0x12'))['db'];var jayson=require(_0xf414('0x13'));var client=jayson[_0xf414('0x14')][_0xf414('0x15')]({'port':0x232a});function respondWithRpcPromise(_0x22216b,_0x125e0b,_0xc84db5,_0x2be316){return new BPromise(function(_0x215198,_0x21e8bd){var _0x51b54d=_0x2be316||client;return _0x51b54d[_0xf414('0x16')](_0x22216b,_0xc84db5)[_0xf414('0x17')](function(_0x2122a7){logger['info'](_0xf414('0x18'),_0x125e0b,_0xf414('0x19'));logger[_0xf414('0x1a')](_0xf414('0x1b'),_0x125e0b,_0xf414('0x19'),JSON[_0xf414('0x1c')](_0x2122a7));if(_0x2122a7[_0xf414('0x1d')]){if(_0x2122a7[_0xf414('0x1d')]['code']===0x1f4){logger[_0xf414('0x1d')](_0xf414('0x18'),_0x125e0b,_0x2122a7[_0xf414('0x1d')]['message']);return _0x21e8bd(_0x2122a7[_0xf414('0x1d')]['message']);}logger[_0xf414('0x1d')](_0xf414('0x18'),_0x125e0b,_0x2122a7[_0xf414('0x1d')][_0xf414('0x1e')]);return _0x215198(_0x2122a7[_0xf414('0x1d')][_0xf414('0x1e')]);}else{logger[_0xf414('0x1f')](_0xf414('0x18'),_0x125e0b,_0xf414('0x19'));_0x215198(_0x2122a7[_0xf414('0x20')][_0xf414('0x1e')]);}})['catch'](function(_0x3822e4){logger[_0xf414('0x1d')](_0xf414('0x18'),_0x125e0b,_0x3822e4);_0x21e8bd(_0x3822e4);});});}function respondWithStatusCode(_0x22ce82,_0x35f719){_0x35f719=_0x35f719||0xcc;return function(_0x45971c){if(_0x45971c){return _0x22ce82[_0xf414('0x21')](_0x35f719);}return _0x22ce82[_0xf414('0x22')](_0x35f719)[_0xf414('0x23')]();};}function respondWithResult(_0x50c738,_0xcb45fa){_0xcb45fa=_0xcb45fa||0xc8;return function(_0x16597a){if(_0x16597a){return _0x50c738[_0xf414('0x22')](_0xcb45fa)[_0xf414('0x24')](_0x16597a);}};}function respondWithFilteredResult(_0x1f6682,_0x3f9170){return function(_0x713ab8){if(_0x713ab8){var _0x5d9419=_0x713ab8[_0xf414('0x25')],_0x2a9243=_0x3f9170[_0xf414('0x26')],_0x39918e=_0x3f9170['offset']+_0x3f9170[_0xf414('0x27')],_0x5363a7;if(_0x39918e>=_0x5d9419){_0x39918e=_0x5d9419;_0x5363a7=0xc8;}else{_0x5363a7=0xce;}_0x1f6682[_0xf414('0x22')](_0x5363a7);return _0x1f6682[_0xf414('0x28')](_0xf414('0x29'),_0x2a9243+'-'+_0x39918e+'/'+_0x5d9419)[_0xf414('0x24')](_0x713ab8);}return null;};}function patchUpdates(_0x30d78b){return function(_0x48cd1c){try{jsonpatch['apply'](_0x48cd1c,_0x30d78b,!![]);}catch(_0x249833){return BPromise['reject'](_0x249833);}return _0x48cd1c[_0xf414('0x2a')]();};}function saveUpdates(_0x8c0e4f,_0x344e4){return function(_0x5c116e){if(_0x5c116e){return _0x5c116e[_0xf414('0x2b')](_0x8c0e4f)[_0xf414('0x17')](function(_0x21ab64){return _0x21ab64;});}return null;};}function removeEntity(_0x58aeaa,_0x5a2e17){return function(_0x54f44c){if(_0x54f44c){return _0x54f44c['destroy']()['then'](function(){_0x58aeaa[_0xf414('0x22')](0xcc)[_0xf414('0x23')]();});}};}function handleEntityNotFound(_0x452745,_0x18468b){return function(_0xe3c85e){if(!_0xe3c85e){_0x452745[_0xf414('0x21')](0x194);}return _0xe3c85e;};}function handleError(_0x52dc05,_0x30c0c6){_0x30c0c6=_0x30c0c6||0x1f4;return function(_0x16d1c6){logger[_0xf414('0x1d')](_0x16d1c6['stack']);if(_0x16d1c6[_0xf414('0x2c')]){delete _0x16d1c6[_0xf414('0x2c')];}_0x52dc05[_0xf414('0x22')](_0x30c0c6)[_0xf414('0x2d')](_0x16d1c6);};}exports['index']=function(_0x37a10d,_0x3df1fe){var _0x55fa6b={},_0x4f3150={},_0x2dea2c={'count':0x0,'rows':[]};var _0xdeb9e8=_[_0xf414('0x2e')](db[_0xf414('0x2f')][_0xf414('0x30')],function(_0x1e0c6e){return{'name':_0x1e0c6e[_0xf414('0x31')],'type':_0x1e0c6e['type']['key']};});_0x4f3150['model']=_[_0xf414('0x2e')](_0xdeb9e8,_0xf414('0x2c'));_0x4f3150['query']=_[_0xf414('0x32')](_0x37a10d[_0xf414('0x33')]);_0x4f3150[_0xf414('0x34')]=_[_0xf414('0x35')](_0x4f3150[_0xf414('0x36')],_0x4f3150[_0xf414('0x33')]);_0x55fa6b[_0xf414('0x37')]=_[_0xf414('0x35')](_0x4f3150[_0xf414('0x36')],qs[_0xf414('0x38')](_0x37a10d['query']['fields']));_0x55fa6b[_0xf414('0x37')]=_0x55fa6b[_0xf414('0x37')][_0xf414('0x39')]?_0x55fa6b[_0xf414('0x37')]:_0x4f3150[_0xf414('0x36')];if(!_0x37a10d['query'][_0xf414('0x3a')]('nolimit')){_0x55fa6b[_0xf414('0x27')]=qs[_0xf414('0x27')](_0x37a10d['query'][_0xf414('0x27')]);_0x55fa6b['offset']=qs[_0xf414('0x26')](_0x37a10d[_0xf414('0x33')]['offset']);}_0x55fa6b['order']=qs[_0xf414('0x3b')](_0x37a10d[_0xf414('0x33')][_0xf414('0x3b')]);_0x55fa6b['where']=qs[_0xf414('0x34')](_['pick'](_0x37a10d['query'],_0x4f3150[_0xf414('0x34')]),_0xdeb9e8);if(_0x37a10d[_0xf414('0x33')]['filter']){_0x55fa6b['where']=_[_0xf414('0x3c')](_0x55fa6b['where'],{'$or':_[_0xf414('0x2e')](_0xdeb9e8,function(_0x3ab2be){if(_0x3ab2be[_0xf414('0x3d')]!==_0xf414('0x3e')){var _0x18b340={};_0x18b340[_0x3ab2be[_0xf414('0x2c')]]={'$like':'%'+_0x37a10d[_0xf414('0x33')][_0xf414('0x3f')]+'%'};return _0x18b340;}})});}_0x55fa6b=_[_0xf414('0x3c')]({},_0x55fa6b,_0x37a10d[_0xf414('0x40')]);var _0x120345={'where':_0x55fa6b['where']};return db[_0xf414('0x2f')][_0xf414('0x25')](_0x120345)['then'](function(_0x4a6985){_0x2dea2c[_0xf414('0x25')]=_0x4a6985;if(_0x37a10d[_0xf414('0x33')]['includeAll']){_0x55fa6b['include']=[{'all':!![]}];}return db['Dynamics365Configuration'][_0xf414('0x41')](_0x55fa6b);})['then'](function(_0xf075bb){_0x2dea2c[_0xf414('0x42')]=_0xf075bb;return _0x2dea2c;})[_0xf414('0x17')](respondWithFilteredResult(_0x3df1fe,_0x55fa6b))[_0xf414('0x43')](handleError(_0x3df1fe,null));};exports[_0xf414('0x44')]=function(_0x325411,_0x313ee3){var _0x2f2c0d={'raw':![],'where':{'id':_0x325411[_0xf414('0x45')]['id']}},_0x453b3a={};_0x453b3a['model']=_[_0xf414('0x32')](db[_0xf414('0x2f')][_0xf414('0x30')]);_0x453b3a[_0xf414('0x33')]=_[_0xf414('0x32')](_0x325411[_0xf414('0x33')]);_0x453b3a[_0xf414('0x34')]=_[_0xf414('0x35')](_0x453b3a['model'],_0x453b3a[_0xf414('0x33')]);_0x2f2c0d[_0xf414('0x37')]=_[_0xf414('0x35')](_0x453b3a[_0xf414('0x36')],qs['fields'](_0x325411[_0xf414('0x33')][_0xf414('0x38')]));_0x2f2c0d[_0xf414('0x37')]=_0x2f2c0d[_0xf414('0x37')][_0xf414('0x39')]?_0x2f2c0d[_0xf414('0x37')]:_0x453b3a[_0xf414('0x36')];if(_0x325411[_0xf414('0x33')][_0xf414('0x46')]){_0x2f2c0d[_0xf414('0x47')]=[{'all':!![]}];}_0x2f2c0d=_[_0xf414('0x3c')]({},_0x2f2c0d,_0x325411[_0xf414('0x40')]);return db[_0xf414('0x2f')]['find'](_0x2f2c0d)[_0xf414('0x17')](handleEntityNotFound(_0x313ee3,null))[_0xf414('0x17')](respondWithResult(_0x313ee3,null))[_0xf414('0x43')](handleError(_0x313ee3,null));};exports[_0xf414('0x48')]=function(_0x251560,_0x5c478c){return db[_0xf414('0x2f')][_0xf414('0x48')](_0x251560['body'],{})[_0xf414('0x17')](respondWithResult(_0x5c478c,0xc9))[_0xf414('0x43')](handleError(_0x5c478c,null));};exports[_0xf414('0x2b')]=function(_0x1060b2,_0x5840e7){if(_0x1060b2[_0xf414('0x49')]['id']){delete _0x1060b2[_0xf414('0x49')]['id'];}return db[_0xf414('0x2f')][_0xf414('0x4a')]({'where':{'id':_0x1060b2['params']['id']}})['then'](handleEntityNotFound(_0x5840e7,null))['then'](saveUpdates(_0x1060b2[_0xf414('0x49')],null))['then'](respondWithResult(_0x5840e7,null))['catch'](handleError(_0x5840e7,null));};exports[_0xf414('0x4b')]=function(_0x47e7b6,_0x3971ac){return db['Dynamics365Configuration'][_0xf414('0x4a')]({'where':{'id':_0x47e7b6[_0xf414('0x45')]['id']}})['then'](handleEntityNotFound(_0x3971ac,null))[_0xf414('0x17')](removeEntity(_0x3971ac,null))[_0xf414('0x43')](handleError(_0x3971ac,null));};exports[_0xf414('0x4c')]=function(_0x1c39c7,_0x57a837,_0x5c8496){var _0x1e40a7={};var _0x2287bd={};var _0x1eeb04;var _0x21199e;return db[_0xf414('0x2f')]['findOne']({'where':{'id':_0x1c39c7[_0xf414('0x45')]['id']}})[_0xf414('0x17')](handleEntityNotFound(_0x57a837,null))[_0xf414('0x17')](function(_0xd76f9b){if(_0xd76f9b){_0x1eeb04=_0xd76f9b;_0x2287bd[_0xf414('0x36')]=_[_0xf414('0x32')](db[_0xf414('0x4d')][_0xf414('0x30')]);_0x2287bd[_0xf414('0x33')]=_[_0xf414('0x32')](_0x1c39c7['query']);_0x2287bd['filters']=_['intersection'](_0x2287bd[_0xf414('0x36')],_0x2287bd[_0xf414('0x33')]);_0x1e40a7[_0xf414('0x37')]=_[_0xf414('0x35')](_0x2287bd['model'],qs[_0xf414('0x38')](_0x1c39c7['query'][_0xf414('0x38')]));_0x1e40a7[_0xf414('0x37')]=_0x1e40a7['attributes'][_0xf414('0x39')]?_0x1e40a7[_0xf414('0x37')]:_0x2287bd[_0xf414('0x36')];_0x1e40a7[_0xf414('0x4e')]=qs['sort'](_0x1c39c7[_0xf414('0x33')]['sort']);_0x1e40a7[_0xf414('0x4f')]=qs[_0xf414('0x34')](_['pick'](_0x1c39c7['query'],_0x2287bd[_0xf414('0x34')]));if(_0x1c39c7[_0xf414('0x33')][_0xf414('0x3f')]){_0x1e40a7['where']=_[_0xf414('0x3c')](_0x1e40a7[_0xf414('0x4f')],{'$or':_[_0xf414('0x2e')](_0x1e40a7[_0xf414('0x37')],function(_0x584673){var _0xa0b5f7={};_0xa0b5f7[_0x584673]={'$like':'%'+_0x1c39c7[_0xf414('0x33')][_0xf414('0x3f')]+'%'};return _0xa0b5f7;})});}_0x1e40a7=_['merge']({},_0x1e40a7,_0x1c39c7[_0xf414('0x40')]);return _0x1eeb04[_0xf414('0x4c')](_0x1e40a7);}})[_0xf414('0x17')](function(_0x8c56cc){if(_0x8c56cc){_0x21199e=_0x8c56cc[_0xf414('0x39')];if(!_0x1c39c7[_0xf414('0x33')][_0xf414('0x3a')]('nolimit')){_0x1e40a7[_0xf414('0x27')]=qs[_0xf414('0x27')](_0x1c39c7[_0xf414('0x33')][_0xf414('0x27')]);_0x1e40a7[_0xf414('0x26')]=qs['offset'](_0x1c39c7['query'][_0xf414('0x26')]);}return _0x1eeb04[_0xf414('0x4c')](_0x1e40a7);}})[_0xf414('0x17')](function(_0x4ac6fd){if(_0x4ac6fd){return _0x4ac6fd?{'count':_0x21199e,'rows':_0x4ac6fd}:null;}})[_0xf414('0x17')](respondWithResult(_0x57a837,null))['catch'](handleError(_0x57a837,null));};exports[_0xf414('0x50')]=function(_0x3e779a,_0x56e661,_0x4169e9){var _0x12d547={};var _0x1f73fb={};var _0x3dc99d;var _0x5a3035;return db[_0xf414('0x2f')][_0xf414('0x51')]({'where':{'id':_0x3e779a[_0xf414('0x45')]['id']}})['then'](handleEntityNotFound(_0x56e661,null))[_0xf414('0x17')](function(_0x2d066f){if(_0x2d066f){_0x3dc99d=_0x2d066f;_0x1f73fb[_0xf414('0x36')]=_[_0xf414('0x32')](db[_0xf414('0x4d')][_0xf414('0x30')]);_0x1f73fb[_0xf414('0x33')]=_[_0xf414('0x32')](_0x3e779a[_0xf414('0x33')]);_0x1f73fb['filters']=_[_0xf414('0x35')](_0x1f73fb['model'],_0x1f73fb[_0xf414('0x33')]);_0x12d547['attributes']=_[_0xf414('0x35')](_0x1f73fb[_0xf414('0x36')],qs[_0xf414('0x38')](_0x3e779a[_0xf414('0x33')][_0xf414('0x38')]));_0x12d547[_0xf414('0x37')]=_0x12d547[_0xf414('0x37')][_0xf414('0x39')]?_0x12d547[_0xf414('0x37')]:_0x1f73fb[_0xf414('0x36')];_0x12d547[_0xf414('0x4e')]=qs[_0xf414('0x3b')](_0x3e779a['query'][_0xf414('0x3b')]);_0x12d547[_0xf414('0x4f')]=qs[_0xf414('0x34')](_[_0xf414('0x52')](_0x3e779a[_0xf414('0x33')],_0x1f73fb[_0xf414('0x34')]));if(_0x3e779a['query'][_0xf414('0x3f')]){_0x12d547[_0xf414('0x4f')]=_['merge'](_0x12d547[_0xf414('0x4f')],{'$or':_[_0xf414('0x2e')](_0x12d547['attributes'],function(_0x1b8daf){var _0x20b3fd={};_0x20b3fd[_0x1b8daf]={'$like':'%'+_0x3e779a[_0xf414('0x33')][_0xf414('0x3f')]+'%'};return _0x20b3fd;})});}_0x12d547=_['merge']({},_0x12d547,_0x3e779a[_0xf414('0x40')]);return _0x3dc99d[_0xf414('0x50')](_0x12d547);}})['then'](function(_0x3dd8a){if(_0x3dd8a){_0x5a3035=_0x3dd8a['length'];if(!_0x3e779a[_0xf414('0x33')][_0xf414('0x3a')](_0xf414('0x53'))){_0x12d547['limit']=qs['limit'](_0x3e779a[_0xf414('0x33')][_0xf414('0x27')]);_0x12d547[_0xf414('0x26')]=qs[_0xf414('0x26')](_0x3e779a[_0xf414('0x33')][_0xf414('0x26')]);}return _0x3dc99d[_0xf414('0x50')](_0x12d547);}})[_0xf414('0x17')](function(_0x175293){if(_0x175293){return _0x175293?{'count':_0x5a3035,'rows':_0x175293}:null;}})['then'](respondWithResult(_0x56e661,null))[_0xf414('0x43')](handleError(_0x56e661,null));};exports[_0xf414('0x54')]=function(_0x215650,_0x500241,_0x3968a6){var _0x2699c9={};var _0x5749fc={};var _0x1f38d3;var _0xb6ff8f;return db[_0xf414('0x2f')][_0xf414('0x51')]({'where':{'id':_0x215650[_0xf414('0x45')]['id']}})['then'](handleEntityNotFound(_0x500241,null))[_0xf414('0x17')](function(_0x540ac9){if(_0x540ac9){_0x1f38d3=_0x540ac9;_0x5749fc[_0xf414('0x36')]=_[_0xf414('0x32')](db[_0xf414('0x4d')][_0xf414('0x30')]);_0x5749fc['query']=_['keys'](_0x215650[_0xf414('0x33')]);_0x5749fc[_0xf414('0x34')]=_[_0xf414('0x35')](_0x5749fc[_0xf414('0x36')],_0x5749fc[_0xf414('0x33')]);_0x2699c9[_0xf414('0x37')]=_['intersection'](_0x5749fc['model'],qs[_0xf414('0x38')](_0x215650['query'][_0xf414('0x38')]));_0x2699c9[_0xf414('0x37')]=_0x2699c9[_0xf414('0x37')]['length']?_0x2699c9[_0xf414('0x37')]:_0x5749fc['model'];_0x2699c9[_0xf414('0x4e')]=qs['sort'](_0x215650[_0xf414('0x33')][_0xf414('0x3b')]);_0x2699c9[_0xf414('0x4f')]=qs[_0xf414('0x34')](_[_0xf414('0x52')](_0x215650[_0xf414('0x33')],_0x5749fc[_0xf414('0x34')]));if(_0x215650['query']['filter']){_0x2699c9[_0xf414('0x4f')]=_['merge'](_0x2699c9[_0xf414('0x4f')],{'$or':_[_0xf414('0x2e')](_0x2699c9[_0xf414('0x37')],function(_0x16b5c7){var _0x5acac3={};_0x5acac3[_0x16b5c7]={'$like':'%'+_0x215650[_0xf414('0x33')][_0xf414('0x3f')]+'%'};return _0x5acac3;})});}_0x2699c9=_[_0xf414('0x3c')]({},_0x2699c9,_0x215650[_0xf414('0x40')]);return _0x1f38d3[_0xf414('0x54')](_0x2699c9);}})[_0xf414('0x17')](function(_0x1088bd){if(_0x1088bd){_0xb6ff8f=_0x1088bd[_0xf414('0x39')];if(!_0x215650[_0xf414('0x33')][_0xf414('0x3a')](_0xf414('0x53'))){_0x2699c9[_0xf414('0x27')]=qs[_0xf414('0x27')](_0x215650[_0xf414('0x33')][_0xf414('0x27')]);_0x2699c9[_0xf414('0x26')]=qs[_0xf414('0x26')](_0x215650[_0xf414('0x33')][_0xf414('0x26')]);}return _0x1f38d3[_0xf414('0x54')](_0x2699c9);}})['then'](function(_0x3c16d2){if(_0x3c16d2){return _0x3c16d2?{'count':_0xb6ff8f,'rows':_0x3c16d2}:null;}})[_0xf414('0x17')](respondWithResult(_0x500241,null))[_0xf414('0x43')](handleError(_0x500241,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