Built motion from commit (unavailable).|2.5.11
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 9fa3bb6..6a51afa 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 _0xea0f=['hasOwnProperty','nolimit','sort','where','filters','filter','merge','VIRTUAL','includeAll','include','findAll','rows','show','params','options','find','create','body','destroy','findOne','Dynamics365Field','order','pick','getFields','getSubjects','getDescriptions','html-pdf','eml-format','rimraf','request-promise','moment','bluebird','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','request','then','info','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','update','name','send','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','keys','attributes','intersection','fields','length'];(function(_0x44ae0b,_0x3e9865){var _0x69232a=function(_0x5ae588){while(--_0x5ae588){_0x44ae0b['push'](_0x44ae0b['shift']());}};_0x69232a(++_0x3e9865);}(_0xea0f,0x73));var _0xfea0=function(_0x27a1c7,_0x2698a4){_0x27a1c7=_0x27a1c7-0x0;var _0x597db7=_0xea0f[_0x27a1c7];return _0x597db7;};'use strict';var pdf=require(_0xfea0('0x0'));var emlformat=require(_0xfea0('0x1'));var rimraf=require(_0xfea0('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xfea0('0x3'));var moment=require(_0xfea0('0x4'));var BPromise=require(_0xfea0('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xfea0('0x6'));var sox=require(_0xfea0('0x7'));var csv=require(_0xfea0('0x8'));var ejs=require(_0xfea0('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0xfea0('0xa'));var crypto=require('crypto');var jsforce=require(_0xfea0('0xb'));var deskjs=require(_0xfea0('0xc'));var toCsv=require(_0xfea0('0x8'));var querystring=require(_0xfea0('0xd'));var Papa=require(_0xfea0('0xe'));var Redis=require(_0xfea0('0xf'));var authService=require(_0xfea0('0x10'));var qs=require(_0xfea0('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xfea0('0x12'))(_0xfea0('0x13'));var utils=require(_0xfea0('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xfea0('0x15'));var db=require(_0xfea0('0x16'))['db'];var jayson=require(_0xfea0('0x17'));var client=jayson[_0xfea0('0x18')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1c5260,_0x46d04d,_0xf16c6d,_0x9399e9){return new BPromise(function(_0x2f27e4,_0x5878ae){var _0x534109=_0x9399e9||client;return _0x534109[_0xfea0('0x19')](_0x1c5260,_0xf16c6d)[_0xfea0('0x1a')](function(_0x44fe3b){logger[_0xfea0('0x1b')](_0xfea0('0x1c'),_0x46d04d,_0xfea0('0x1d'));logger[_0xfea0('0x1e')]('Dynamics365Configuration,\x20%s,\x20%s,\x20%s',_0x46d04d,'request\x20sent',JSON[_0xfea0('0x1f')](_0x44fe3b));if(_0x44fe3b[_0xfea0('0x20')]){if(_0x44fe3b[_0xfea0('0x20')][_0xfea0('0x21')]===0x1f4){logger['error'](_0xfea0('0x1c'),_0x46d04d,_0x44fe3b[_0xfea0('0x20')][_0xfea0('0x22')]);return _0x5878ae(_0x44fe3b[_0xfea0('0x20')]['message']);}logger[_0xfea0('0x20')]('Dynamics365Configuration,\x20%s,\x20%s',_0x46d04d,_0x44fe3b['error'][_0xfea0('0x22')]);return _0x2f27e4(_0x44fe3b['error'][_0xfea0('0x22')]);}else{logger[_0xfea0('0x1b')](_0xfea0('0x1c'),_0x46d04d,_0xfea0('0x1d'));_0x2f27e4(_0x44fe3b[_0xfea0('0x23')][_0xfea0('0x22')]);}})[_0xfea0('0x24')](function(_0x54b430){logger['error'](_0xfea0('0x1c'),_0x46d04d,_0x54b430);_0x5878ae(_0x54b430);});});}function respondWithStatusCode(_0x3e5d12,_0x3869fb){_0x3869fb=_0x3869fb||0xcc;return function(_0x3e5912){if(_0x3e5912){return _0x3e5d12[_0xfea0('0x25')](_0x3869fb);}return _0x3e5d12[_0xfea0('0x26')](_0x3869fb)[_0xfea0('0x27')]();};}function respondWithResult(_0x2123ef,_0x252e69){_0x252e69=_0x252e69||0xc8;return function(_0x4aa224){if(_0x4aa224){return _0x2123ef[_0xfea0('0x26')](_0x252e69)[_0xfea0('0x28')](_0x4aa224);}};}function respondWithFilteredResult(_0x3a31c8,_0x5c84c4){return function(_0x2a371b){if(_0x2a371b){var _0x19a0b0=_0x2a371b[_0xfea0('0x29')],_0x5b4864=_0x5c84c4[_0xfea0('0x2a')],_0x35bd83=_0x5c84c4[_0xfea0('0x2a')]+_0x5c84c4[_0xfea0('0x2b')],_0x1fa324;if(_0x35bd83>=_0x19a0b0){_0x35bd83=_0x19a0b0;_0x1fa324=0xc8;}else{_0x1fa324=0xce;}_0x3a31c8['status'](_0x1fa324);return _0x3a31c8[_0xfea0('0x2c')](_0xfea0('0x2d'),_0x5b4864+'-'+_0x35bd83+'/'+_0x19a0b0)['json'](_0x2a371b);}return null;};}function patchUpdates(_0x568e1f){return function(_0xdcb083){try{jsonpatch['apply'](_0xdcb083,_0x568e1f,!![]);}catch(_0x55abf7){return BPromise[_0xfea0('0x2e')](_0x55abf7);}return _0xdcb083['save']();};}function saveUpdates(_0x176e02,_0x124782){return function(_0x2b984a){if(_0x2b984a){return _0x2b984a[_0xfea0('0x2f')](_0x176e02)[_0xfea0('0x1a')](function(_0x5df347){return _0x5df347;});}return null;};}function removeEntity(_0x321a4c,_0x1fc6e8){return function(_0x5eb59e){if(_0x5eb59e){return _0x5eb59e['destroy']()[_0xfea0('0x1a')](function(){_0x321a4c[_0xfea0('0x26')](0xcc)[_0xfea0('0x27')]();});}};}function handleEntityNotFound(_0x5d6067,_0x1b8ca2){return function(_0x331ca7){if(!_0x331ca7){_0x5d6067[_0xfea0('0x25')](0x194);}return _0x331ca7;};}function handleError(_0x273626,_0x2f7e84){_0x2f7e84=_0x2f7e84||0x1f4;return function(_0x2778d4){logger['error'](_0x2778d4['stack']);if(_0x2778d4[_0xfea0('0x30')]){delete _0x2778d4['name'];}_0x273626[_0xfea0('0x26')](_0x2f7e84)[_0xfea0('0x31')](_0x2778d4);};}exports['index']=function(_0x487040,_0x24b826){var _0x4dc26f={},_0x2953c1={},_0x2af050={'count':0x0,'rows':[]};var _0x3a132f=_[_0xfea0('0x32')](db[_0xfea0('0x33')][_0xfea0('0x34')],function(_0x1d9f63){return{'name':_0x1d9f63[_0xfea0('0x35')],'type':_0x1d9f63[_0xfea0('0x36')][_0xfea0('0x37')]};});_0x2953c1[_0xfea0('0x38')]=_['map'](_0x3a132f,_0xfea0('0x30'));_0x2953c1[_0xfea0('0x39')]=_[_0xfea0('0x3a')](_0x487040[_0xfea0('0x39')]);_0x2953c1['filters']=_['intersection'](_0x2953c1[_0xfea0('0x38')],_0x2953c1['query']);_0x4dc26f[_0xfea0('0x3b')]=_[_0xfea0('0x3c')](_0x2953c1[_0xfea0('0x38')],qs[_0xfea0('0x3d')](_0x487040[_0xfea0('0x39')][_0xfea0('0x3d')]));_0x4dc26f['attributes']=_0x4dc26f[_0xfea0('0x3b')][_0xfea0('0x3e')]?_0x4dc26f['attributes']:_0x2953c1['model'];if(!_0x487040[_0xfea0('0x39')][_0xfea0('0x3f')](_0xfea0('0x40'))){_0x4dc26f[_0xfea0('0x2b')]=qs[_0xfea0('0x2b')](_0x487040[_0xfea0('0x39')][_0xfea0('0x2b')]);_0x4dc26f['offset']=qs[_0xfea0('0x2a')](_0x487040[_0xfea0('0x39')]['offset']);}_0x4dc26f['order']=qs[_0xfea0('0x41')](_0x487040[_0xfea0('0x39')][_0xfea0('0x41')]);_0x4dc26f[_0xfea0('0x42')]=qs[_0xfea0('0x43')](_['pick'](_0x487040[_0xfea0('0x39')],_0x2953c1[_0xfea0('0x43')]),_0x3a132f);if(_0x487040['query'][_0xfea0('0x44')]){_0x4dc26f[_0xfea0('0x42')]=_[_0xfea0('0x45')](_0x4dc26f['where'],{'$or':_[_0xfea0('0x32')](_0x3a132f,function(_0x389502){if(_0x389502[_0xfea0('0x36')]!==_0xfea0('0x46')){var _0x1801f8={};_0x1801f8[_0x389502[_0xfea0('0x30')]]={'$like':'%'+_0x487040[_0xfea0('0x39')]['filter']+'%'};return _0x1801f8;}})});}_0x4dc26f=_[_0xfea0('0x45')]({},_0x4dc26f,_0x487040['options']);var _0x50f780={'where':_0x4dc26f['where']};return db['Dynamics365Configuration'][_0xfea0('0x29')](_0x50f780)[_0xfea0('0x1a')](function(_0x56a6fb){_0x2af050[_0xfea0('0x29')]=_0x56a6fb;if(_0x487040[_0xfea0('0x39')][_0xfea0('0x47')]){_0x4dc26f[_0xfea0('0x48')]=[{'all':!![]}];}return db[_0xfea0('0x33')][_0xfea0('0x49')](_0x4dc26f);})['then'](function(_0x1a564e){_0x2af050[_0xfea0('0x4a')]=_0x1a564e;return _0x2af050;})['then'](respondWithFilteredResult(_0x24b826,_0x4dc26f))['catch'](handleError(_0x24b826,null));};exports[_0xfea0('0x4b')]=function(_0x39d154,_0x256083){var _0x2226b5={'raw':![],'where':{'id':_0x39d154[_0xfea0('0x4c')]['id']}},_0x547500={};_0x547500[_0xfea0('0x38')]=_['keys'](db['Dynamics365Configuration'][_0xfea0('0x34')]);_0x547500[_0xfea0('0x39')]=_['keys'](_0x39d154[_0xfea0('0x39')]);_0x547500[_0xfea0('0x43')]=_[_0xfea0('0x3c')](_0x547500[_0xfea0('0x38')],_0x547500['query']);_0x2226b5[_0xfea0('0x3b')]=_[_0xfea0('0x3c')](_0x547500[_0xfea0('0x38')],qs[_0xfea0('0x3d')](_0x39d154[_0xfea0('0x39')]['fields']));_0x2226b5['attributes']=_0x2226b5[_0xfea0('0x3b')][_0xfea0('0x3e')]?_0x2226b5[_0xfea0('0x3b')]:_0x547500[_0xfea0('0x38')];if(_0x39d154[_0xfea0('0x39')][_0xfea0('0x47')]){_0x2226b5[_0xfea0('0x48')]=[{'all':!![]}];}_0x2226b5=_[_0xfea0('0x45')]({},_0x2226b5,_0x39d154[_0xfea0('0x4d')]);return db[_0xfea0('0x33')][_0xfea0('0x4e')](_0x2226b5)[_0xfea0('0x1a')](handleEntityNotFound(_0x256083,null))[_0xfea0('0x1a')](respondWithResult(_0x256083,null))['catch'](handleError(_0x256083,null));};exports[_0xfea0('0x4f')]=function(_0x2dd581,_0x2ae5b5){return db['Dynamics365Configuration']['create'](_0x2dd581[_0xfea0('0x50')],{})[_0xfea0('0x1a')](respondWithResult(_0x2ae5b5,0xc9))[_0xfea0('0x24')](handleError(_0x2ae5b5,null));};exports[_0xfea0('0x2f')]=function(_0x250a8b,_0x1f9d8a){if(_0x250a8b[_0xfea0('0x50')]['id']){delete _0x250a8b['body']['id'];}return db[_0xfea0('0x33')][_0xfea0('0x4e')]({'where':{'id':_0x250a8b['params']['id']}})[_0xfea0('0x1a')](handleEntityNotFound(_0x1f9d8a,null))[_0xfea0('0x1a')](saveUpdates(_0x250a8b[_0xfea0('0x50')],null))[_0xfea0('0x1a')](respondWithResult(_0x1f9d8a,null))[_0xfea0('0x24')](handleError(_0x1f9d8a,null));};exports[_0xfea0('0x51')]=function(_0x3d5c74,_0xa830cc){return db['Dynamics365Configuration']['find']({'where':{'id':_0x3d5c74[_0xfea0('0x4c')]['id']}})[_0xfea0('0x1a')](handleEntityNotFound(_0xa830cc,null))['then'](removeEntity(_0xa830cc,null))[_0xfea0('0x24')](handleError(_0xa830cc,null));};exports['getFields']=function(_0x28647a,_0x5bd663,_0x1e91f3){var _0x5214e1={};var _0x21b7c7={};var _0x25ab2b;var _0x22800c;return db['Dynamics365Configuration'][_0xfea0('0x52')]({'where':{'id':_0x28647a[_0xfea0('0x4c')]['id']}})[_0xfea0('0x1a')](handleEntityNotFound(_0x5bd663,null))[_0xfea0('0x1a')](function(_0x31ed23){if(_0x31ed23){_0x25ab2b=_0x31ed23;_0x21b7c7[_0xfea0('0x38')]=_[_0xfea0('0x3a')](db[_0xfea0('0x53')]['rawAttributes']);_0x21b7c7['query']=_[_0xfea0('0x3a')](_0x28647a[_0xfea0('0x39')]);_0x21b7c7[_0xfea0('0x43')]=_[_0xfea0('0x3c')](_0x21b7c7['model'],_0x21b7c7[_0xfea0('0x39')]);_0x5214e1[_0xfea0('0x3b')]=_[_0xfea0('0x3c')](_0x21b7c7[_0xfea0('0x38')],qs['fields'](_0x28647a[_0xfea0('0x39')][_0xfea0('0x3d')]));_0x5214e1['attributes']=_0x5214e1['attributes'][_0xfea0('0x3e')]?_0x5214e1[_0xfea0('0x3b')]:_0x21b7c7[_0xfea0('0x38')];_0x5214e1[_0xfea0('0x54')]=qs['sort'](_0x28647a[_0xfea0('0x39')][_0xfea0('0x41')]);_0x5214e1['where']=qs[_0xfea0('0x43')](_[_0xfea0('0x55')](_0x28647a[_0xfea0('0x39')],_0x21b7c7['filters']));if(_0x28647a[_0xfea0('0x39')][_0xfea0('0x44')]){_0x5214e1[_0xfea0('0x42')]=_[_0xfea0('0x45')](_0x5214e1[_0xfea0('0x42')],{'$or':_[_0xfea0('0x32')](_0x5214e1[_0xfea0('0x3b')],function(_0x29d975){var _0x1d7c3a={};_0x1d7c3a[_0x29d975]={'$like':'%'+_0x28647a['query']['filter']+'%'};return _0x1d7c3a;})});}_0x5214e1=_['merge']({},_0x5214e1,_0x28647a['options']);return _0x25ab2b[_0xfea0('0x56')](_0x5214e1);}})[_0xfea0('0x1a')](function(_0x6d5078){if(_0x6d5078){_0x22800c=_0x6d5078['length'];if(!_0x28647a[_0xfea0('0x39')][_0xfea0('0x3f')](_0xfea0('0x40'))){_0x5214e1[_0xfea0('0x2b')]=qs['limit'](_0x28647a[_0xfea0('0x39')][_0xfea0('0x2b')]);_0x5214e1['offset']=qs[_0xfea0('0x2a')](_0x28647a['query']['offset']);}return _0x25ab2b[_0xfea0('0x56')](_0x5214e1);}})[_0xfea0('0x1a')](function(_0x2f503f){if(_0x2f503f){return _0x2f503f?{'count':_0x22800c,'rows':_0x2f503f}:null;}})[_0xfea0('0x1a')](respondWithResult(_0x5bd663,null))[_0xfea0('0x24')](handleError(_0x5bd663,null));};exports[_0xfea0('0x57')]=function(_0x8bc803,_0x3cdbc6,_0x346e4c){var _0x19fd05={};var _0x163386={};var _0x23e380;var _0x47e32a;return db[_0xfea0('0x33')][_0xfea0('0x52')]({'where':{'id':_0x8bc803[_0xfea0('0x4c')]['id']}})[_0xfea0('0x1a')](handleEntityNotFound(_0x3cdbc6,null))[_0xfea0('0x1a')](function(_0x32e906){if(_0x32e906){_0x23e380=_0x32e906;_0x163386[_0xfea0('0x38')]=_[_0xfea0('0x3a')](db[_0xfea0('0x53')][_0xfea0('0x34')]);_0x163386[_0xfea0('0x39')]=_[_0xfea0('0x3a')](_0x8bc803[_0xfea0('0x39')]);_0x163386[_0xfea0('0x43')]=_[_0xfea0('0x3c')](_0x163386[_0xfea0('0x38')],_0x163386[_0xfea0('0x39')]);_0x19fd05['attributes']=_[_0xfea0('0x3c')](_0x163386[_0xfea0('0x38')],qs['fields'](_0x8bc803[_0xfea0('0x39')][_0xfea0('0x3d')]));_0x19fd05[_0xfea0('0x3b')]=_0x19fd05[_0xfea0('0x3b')][_0xfea0('0x3e')]?_0x19fd05['attributes']:_0x163386[_0xfea0('0x38')];_0x19fd05[_0xfea0('0x54')]=qs[_0xfea0('0x41')](_0x8bc803[_0xfea0('0x39')][_0xfea0('0x41')]);_0x19fd05['where']=qs[_0xfea0('0x43')](_[_0xfea0('0x55')](_0x8bc803['query'],_0x163386[_0xfea0('0x43')]));if(_0x8bc803['query'][_0xfea0('0x44')]){_0x19fd05[_0xfea0('0x42')]=_[_0xfea0('0x45')](_0x19fd05[_0xfea0('0x42')],{'$or':_['map'](_0x19fd05[_0xfea0('0x3b')],function(_0x272445){var _0x461b20={};_0x461b20[_0x272445]={'$like':'%'+_0x8bc803[_0xfea0('0x39')][_0xfea0('0x44')]+'%'};return _0x461b20;})});}_0x19fd05=_[_0xfea0('0x45')]({},_0x19fd05,_0x8bc803['options']);return _0x23e380[_0xfea0('0x57')](_0x19fd05);}})[_0xfea0('0x1a')](function(_0x586d01){if(_0x586d01){_0x47e32a=_0x586d01[_0xfea0('0x3e')];if(!_0x8bc803['query']['hasOwnProperty'](_0xfea0('0x40'))){_0x19fd05[_0xfea0('0x2b')]=qs[_0xfea0('0x2b')](_0x8bc803[_0xfea0('0x39')][_0xfea0('0x2b')]);_0x19fd05['offset']=qs[_0xfea0('0x2a')](_0x8bc803[_0xfea0('0x39')][_0xfea0('0x2a')]);}return _0x23e380['getSubjects'](_0x19fd05);}})[_0xfea0('0x1a')](function(_0x5adfa3){if(_0x5adfa3){return _0x5adfa3?{'count':_0x47e32a,'rows':_0x5adfa3}:null;}})[_0xfea0('0x1a')](respondWithResult(_0x3cdbc6,null))[_0xfea0('0x24')](handleError(_0x3cdbc6,null));};exports['getDescriptions']=function(_0x38ff73,_0x166fb7,_0x1dc076){var _0xe32bfa={};var _0x3cd41b={};var _0x1a04cb;var _0x3c4809;return db[_0xfea0('0x33')][_0xfea0('0x52')]({'where':{'id':_0x38ff73['params']['id']}})[_0xfea0('0x1a')](handleEntityNotFound(_0x166fb7,null))[_0xfea0('0x1a')](function(_0xc46852){if(_0xc46852){_0x1a04cb=_0xc46852;_0x3cd41b['model']=_[_0xfea0('0x3a')](db[_0xfea0('0x53')][_0xfea0('0x34')]);_0x3cd41b[_0xfea0('0x39')]=_[_0xfea0('0x3a')](_0x38ff73[_0xfea0('0x39')]);_0x3cd41b[_0xfea0('0x43')]=_['intersection'](_0x3cd41b[_0xfea0('0x38')],_0x3cd41b[_0xfea0('0x39')]);_0xe32bfa[_0xfea0('0x3b')]=_['intersection'](_0x3cd41b['model'],qs[_0xfea0('0x3d')](_0x38ff73[_0xfea0('0x39')][_0xfea0('0x3d')]));_0xe32bfa[_0xfea0('0x3b')]=_0xe32bfa[_0xfea0('0x3b')][_0xfea0('0x3e')]?_0xe32bfa['attributes']:_0x3cd41b[_0xfea0('0x38')];_0xe32bfa[_0xfea0('0x54')]=qs[_0xfea0('0x41')](_0x38ff73[_0xfea0('0x39')][_0xfea0('0x41')]);_0xe32bfa[_0xfea0('0x42')]=qs[_0xfea0('0x43')](_[_0xfea0('0x55')](_0x38ff73[_0xfea0('0x39')],_0x3cd41b['filters']));if(_0x38ff73['query'][_0xfea0('0x44')]){_0xe32bfa[_0xfea0('0x42')]=_['merge'](_0xe32bfa[_0xfea0('0x42')],{'$or':_[_0xfea0('0x32')](_0xe32bfa[_0xfea0('0x3b')],function(_0x372c86){var _0x20f75c={};_0x20f75c[_0x372c86]={'$like':'%'+_0x38ff73[_0xfea0('0x39')]['filter']+'%'};return _0x20f75c;})});}_0xe32bfa=_[_0xfea0('0x45')]({},_0xe32bfa,_0x38ff73[_0xfea0('0x4d')]);return _0x1a04cb[_0xfea0('0x58')](_0xe32bfa);}})[_0xfea0('0x1a')](function(_0x554df0){if(_0x554df0){_0x3c4809=_0x554df0[_0xfea0('0x3e')];if(!_0x38ff73[_0xfea0('0x39')][_0xfea0('0x3f')]('nolimit')){_0xe32bfa[_0xfea0('0x2b')]=qs[_0xfea0('0x2b')](_0x38ff73[_0xfea0('0x39')][_0xfea0('0x2b')]);_0xe32bfa[_0xfea0('0x2a')]=qs[_0xfea0('0x2a')](_0x38ff73[_0xfea0('0x39')][_0xfea0('0x2a')]);}return _0x1a04cb[_0xfea0('0x58')](_0xe32bfa);}})[_0xfea0('0x1a')](function(_0x1accf8){if(_0x1accf8){return _0x1accf8?{'count':_0x3c4809,'rows':_0x1accf8}:null;}})[_0xfea0('0x1a')](respondWithResult(_0x166fb7,null))['catch'](handleError(_0x166fb7,null));};
\ No newline at end of file