Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 50925c0..0c218a9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x279f=['create','body','getFields','findOne','getSubjects','Dynamics365Field','getDescriptions','html-pdf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','http','then','info','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','debug','stringify','code','error','message','result','catch','end','status','json','count','offset','reject','save','update','destroy','sendStatus','stack','name','send','map','Dynamics365Configuration','rawAttributes','fieldName','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','findAll','params','filters','includeAll','options','find'];(function(_0x452e83,_0x52e169){var _0x65b907=function(_0x1e75b7){while(--_0x1e75b7){_0x452e83['push'](_0x452e83['shift']());}};_0x65b907(++_0x52e169);}(_0x279f,0x109));var _0xf279=function(_0x1203f,_0x554bbc){_0x1203f=_0x1203f-0x0;var _0x365f0a=_0x279f[_0x1203f];return _0x365f0a;};'use strict';var pdf=require(_0xf279('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf279('0x1'));var jsonpatch=require(_0xf279('0x2'));var rp=require(_0xf279('0x3'));var moment=require(_0xf279('0x4'));var BPromise=require(_0xf279('0x5'));var Mustache=require(_0xf279('0x6'));var util=require(_0xf279('0x7'));var path=require(_0xf279('0x8'));var sox=require('sox');var csv=require(_0xf279('0x9'));var ejs=require(_0xf279('0xa'));var fs=require('fs');var _=require(_0xf279('0xb'));var squel=require('squel');var crypto=require(_0xf279('0xc'));var jsforce=require(_0xf279('0xd'));var deskjs=require(_0xf279('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xf279('0xf'));var Redis=require(_0xf279('0x10'));var authService=require(_0xf279('0x11'));var qs=require(_0xf279('0x12'));var as=require(_0xf279('0x13'));var hardwareService=require(_0xf279('0x14'));var logger=require('../../config/logger')(_0xf279('0x15'));var utils=require(_0xf279('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xf279('0x17'));var db=require(_0xf279('0x18'))['db'];var jayson=require(_0xf279('0x19'));var client=jayson['client'][_0xf279('0x1a')]({'port':0x232a});function respondWithRpcPromise(_0x37f848,_0x19b754,_0xc17a16,_0x2865c2){return new BPromise(function(_0x31fec1,_0x3fef12){var _0x18ce20=_0x2865c2||client;return _0x18ce20['request'](_0x37f848,_0xc17a16)[_0xf279('0x1b')](function(_0x3e4bf0){logger[_0xf279('0x1c')](_0xf279('0x1d'),_0x19b754,_0xf279('0x1e'));logger[_0xf279('0x1f')]('Dynamics365Configuration,\x20%s,\x20%s,\x20%s',_0x19b754,_0xf279('0x1e'),JSON[_0xf279('0x20')](_0x3e4bf0));if(_0x3e4bf0['error']){if(_0x3e4bf0['error'][_0xf279('0x21')]===0x1f4){logger[_0xf279('0x22')]('Dynamics365Configuration,\x20%s,\x20%s',_0x19b754,_0x3e4bf0['error'][_0xf279('0x23')]);return _0x3fef12(_0x3e4bf0[_0xf279('0x22')]['message']);}logger['error']('Dynamics365Configuration,\x20%s,\x20%s',_0x19b754,_0x3e4bf0[_0xf279('0x22')][_0xf279('0x23')]);return _0x31fec1(_0x3e4bf0[_0xf279('0x22')][_0xf279('0x23')]);}else{logger['info'](_0xf279('0x1d'),_0x19b754,_0xf279('0x1e'));_0x31fec1(_0x3e4bf0[_0xf279('0x24')][_0xf279('0x23')]);}})[_0xf279('0x25')](function(_0x2167c1){logger[_0xf279('0x22')]('Dynamics365Configuration,\x20%s,\x20%s',_0x19b754,_0x2167c1);_0x3fef12(_0x2167c1);});});}function respondWithStatusCode(_0x35f03a,_0x17a3b8){_0x17a3b8=_0x17a3b8||0xcc;return function(_0x46780c){if(_0x46780c){return _0x35f03a['sendStatus'](_0x17a3b8);}return _0x35f03a['status'](_0x17a3b8)[_0xf279('0x26')]();};}function respondWithResult(_0x393c76,_0x41dffe){_0x41dffe=_0x41dffe||0xc8;return function(_0x5134f3){if(_0x5134f3){return _0x393c76[_0xf279('0x27')](_0x41dffe)[_0xf279('0x28')](_0x5134f3);}};}function respondWithFilteredResult(_0x4b5a2c,_0xa5b4){return function(_0x2f807c){if(_0x2f807c){var _0x5a0f19=_0x2f807c[_0xf279('0x29')],_0x29ba7c=_0xa5b4[_0xf279('0x2a')],_0x560df1=_0xa5b4[_0xf279('0x2a')]+_0xa5b4['limit'],_0x268cc0;if(_0x560df1>=_0x5a0f19){_0x560df1=_0x5a0f19;_0x268cc0=0xc8;}else{_0x268cc0=0xce;}_0x4b5a2c[_0xf279('0x27')](_0x268cc0);return _0x4b5a2c['set']('Content-Range',_0x29ba7c+'-'+_0x560df1+'/'+_0x5a0f19)[_0xf279('0x28')](_0x2f807c);}return null;};}function patchUpdates(_0x2e9936){return function(_0x286801){try{jsonpatch['apply'](_0x286801,_0x2e9936,!![]);}catch(_0x3270eb){return BPromise[_0xf279('0x2b')](_0x3270eb);}return _0x286801[_0xf279('0x2c')]();};}function saveUpdates(_0x365c5b,_0x1bd598){return function(_0x201015){if(_0x201015){return _0x201015[_0xf279('0x2d')](_0x365c5b)[_0xf279('0x1b')](function(_0x1b17c6){return _0x1b17c6;});}return null;};}function removeEntity(_0x3be042,_0x3f5998){return function(_0x539818){if(_0x539818){return _0x539818[_0xf279('0x2e')]()[_0xf279('0x1b')](function(){_0x3be042[_0xf279('0x27')](0xcc)[_0xf279('0x26')]();});}};}function handleEntityNotFound(_0x3b681f,_0x4d495c){return function(_0x3513fd){if(!_0x3513fd){_0x3b681f[_0xf279('0x2f')](0x194);}return _0x3513fd;};}function handleError(_0x2976ca,_0x473598){_0x473598=_0x473598||0x1f4;return function(_0x283621){logger[_0xf279('0x22')](_0x283621[_0xf279('0x30')]);if(_0x283621['name']){delete _0x283621[_0xf279('0x31')];}_0x2976ca[_0xf279('0x27')](_0x473598)[_0xf279('0x32')](_0x283621);};}exports['index']=function(_0x4cd6bc,_0x10c8f4){var _0x277029={},_0xb667d1={},_0x5ac062={'count':0x0,'rows':[]};var _0x13948a=_[_0xf279('0x33')](db[_0xf279('0x34')][_0xf279('0x35')],function(_0x32f401){return{'name':_0x32f401[_0xf279('0x36')],'type':_0x32f401['type'][_0xf279('0x37')]};});_0xb667d1[_0xf279('0x38')]=_[_0xf279('0x33')](_0x13948a,'name');_0xb667d1[_0xf279('0x39')]=_[_0xf279('0x3a')](_0x4cd6bc['query']);_0xb667d1['filters']=_[_0xf279('0x3b')](_0xb667d1[_0xf279('0x38')],_0xb667d1['query']);_0x277029[_0xf279('0x3c')]=_[_0xf279('0x3b')](_0xb667d1['model'],qs[_0xf279('0x3d')](_0x4cd6bc['query'][_0xf279('0x3d')]));_0x277029['attributes']=_0x277029[_0xf279('0x3c')][_0xf279('0x3e')]?_0x277029[_0xf279('0x3c')]:_0xb667d1[_0xf279('0x38')];if(!_0x4cd6bc['query'][_0xf279('0x3f')](_0xf279('0x40'))){_0x277029[_0xf279('0x41')]=qs[_0xf279('0x41')](_0x4cd6bc[_0xf279('0x39')][_0xf279('0x41')]);_0x277029[_0xf279('0x2a')]=qs[_0xf279('0x2a')](_0x4cd6bc[_0xf279('0x39')][_0xf279('0x2a')]);}_0x277029[_0xf279('0x42')]=qs['sort'](_0x4cd6bc[_0xf279('0x39')][_0xf279('0x43')]);_0x277029[_0xf279('0x44')]=qs['filters'](_[_0xf279('0x45')](_0x4cd6bc['query'],_0xb667d1['filters']),_0x13948a);if(_0x4cd6bc[_0xf279('0x39')][_0xf279('0x46')]){_0x277029['where']=_[_0xf279('0x47')](_0x277029[_0xf279('0x44')],{'$or':_[_0xf279('0x33')](_0x13948a,function(_0x28ba1b){if(_0x28ba1b['type']!==_0xf279('0x48')){var _0x1bc2cf={};_0x1bc2cf[_0x28ba1b[_0xf279('0x31')]]={'$like':'%'+_0x4cd6bc[_0xf279('0x39')]['filter']+'%'};return _0x1bc2cf;}})});}_0x277029=_[_0xf279('0x47')]({},_0x277029,_0x4cd6bc['options']);var _0x4bc293={'where':_0x277029[_0xf279('0x44')]};return db[_0xf279('0x34')][_0xf279('0x29')](_0x4bc293)[_0xf279('0x1b')](function(_0x827927){_0x5ac062['count']=_0x827927;if(_0x4cd6bc[_0xf279('0x39')]['includeAll']){_0x277029['include']=[{'all':!![]}];}return db['Dynamics365Configuration'][_0xf279('0x49')](_0x277029);})[_0xf279('0x1b')](function(_0x406880){_0x5ac062['rows']=_0x406880;return _0x5ac062;})[_0xf279('0x1b')](respondWithFilteredResult(_0x10c8f4,_0x277029))[_0xf279('0x25')](handleError(_0x10c8f4,null));};exports['show']=function(_0xcdafe9,_0x4ceeac){var _0x507766={'raw':![],'where':{'id':_0xcdafe9[_0xf279('0x4a')]['id']}},_0x33b9da={};_0x33b9da[_0xf279('0x38')]=_[_0xf279('0x3a')](db[_0xf279('0x34')][_0xf279('0x35')]);_0x33b9da['query']=_[_0xf279('0x3a')](_0xcdafe9[_0xf279('0x39')]);_0x33b9da[_0xf279('0x4b')]=_[_0xf279('0x3b')](_0x33b9da[_0xf279('0x38')],_0x33b9da[_0xf279('0x39')]);_0x507766['attributes']=_['intersection'](_0x33b9da[_0xf279('0x38')],qs[_0xf279('0x3d')](_0xcdafe9[_0xf279('0x39')][_0xf279('0x3d')]));_0x507766['attributes']=_0x507766['attributes'][_0xf279('0x3e')]?_0x507766[_0xf279('0x3c')]:_0x33b9da[_0xf279('0x38')];if(_0xcdafe9[_0xf279('0x39')][_0xf279('0x4c')]){_0x507766['include']=[{'all':!![]}];}_0x507766=_[_0xf279('0x47')]({},_0x507766,_0xcdafe9[_0xf279('0x4d')]);return db[_0xf279('0x34')][_0xf279('0x4e')](_0x507766)[_0xf279('0x1b')](handleEntityNotFound(_0x4ceeac,null))[_0xf279('0x1b')](respondWithResult(_0x4ceeac,null))[_0xf279('0x25')](handleError(_0x4ceeac,null));};exports[_0xf279('0x4f')]=function(_0x1636da,_0x15a713){return db[_0xf279('0x34')][_0xf279('0x4f')](_0x1636da[_0xf279('0x50')],{})['then'](respondWithResult(_0x15a713,0xc9))[_0xf279('0x25')](handleError(_0x15a713,null));};exports[_0xf279('0x2d')]=function(_0x14538f,_0x30829c){if(_0x14538f[_0xf279('0x50')]['id']){delete _0x14538f[_0xf279('0x50')]['id'];}return db[_0xf279('0x34')][_0xf279('0x4e')]({'where':{'id':_0x14538f[_0xf279('0x4a')]['id']}})[_0xf279('0x1b')](handleEntityNotFound(_0x30829c,null))[_0xf279('0x1b')](saveUpdates(_0x14538f['body'],null))['then'](respondWithResult(_0x30829c,null))[_0xf279('0x25')](handleError(_0x30829c,null));};exports['destroy']=function(_0x22d916,_0x5d9f47){return db[_0xf279('0x34')]['find']({'where':{'id':_0x22d916[_0xf279('0x4a')]['id']}})[_0xf279('0x1b')](handleEntityNotFound(_0x5d9f47,null))[_0xf279('0x1b')](removeEntity(_0x5d9f47,null))[_0xf279('0x25')](handleError(_0x5d9f47,null));};exports[_0xf279('0x51')]=function(_0x1608b3,_0x4b0c16,_0x2ab4f3){var _0x17209e={};var _0x5e1b19={};var _0x1819dc;var _0x5e8260;return db[_0xf279('0x34')][_0xf279('0x52')]({'where':{'id':_0x1608b3[_0xf279('0x4a')]['id']}})['then'](handleEntityNotFound(_0x4b0c16,null))[_0xf279('0x1b')](function(_0x1cac8f){if(_0x1cac8f){_0x1819dc=_0x1cac8f;_0x5e1b19[_0xf279('0x38')]=_[_0xf279('0x3a')](db['Dynamics365Field']['rawAttributes']);_0x5e1b19[_0xf279('0x39')]=_['keys'](_0x1608b3[_0xf279('0x39')]);_0x5e1b19['filters']=_['intersection'](_0x5e1b19[_0xf279('0x38')],_0x5e1b19['query']);_0x17209e[_0xf279('0x3c')]=_[_0xf279('0x3b')](_0x5e1b19['model'],qs[_0xf279('0x3d')](_0x1608b3['query']['fields']));_0x17209e[_0xf279('0x3c')]=_0x17209e[_0xf279('0x3c')][_0xf279('0x3e')]?_0x17209e[_0xf279('0x3c')]:_0x5e1b19[_0xf279('0x38')];_0x17209e[_0xf279('0x42')]=qs[_0xf279('0x43')](_0x1608b3['query'][_0xf279('0x43')]);_0x17209e['where']=qs[_0xf279('0x4b')](_[_0xf279('0x45')](_0x1608b3[_0xf279('0x39')],_0x5e1b19[_0xf279('0x4b')]));if(_0x1608b3[_0xf279('0x39')][_0xf279('0x46')]){_0x17209e['where']=_[_0xf279('0x47')](_0x17209e[_0xf279('0x44')],{'$or':_[_0xf279('0x33')](_0x17209e[_0xf279('0x3c')],function(_0x1b4d9e){var _0x4a6985={};_0x4a6985[_0x1b4d9e]={'$like':'%'+_0x1608b3['query'][_0xf279('0x46')]+'%'};return _0x4a6985;})});}_0x17209e=_[_0xf279('0x47')]({},_0x17209e,_0x1608b3['options']);return _0x1819dc[_0xf279('0x51')](_0x17209e);}})[_0xf279('0x1b')](function(_0x403c5f){if(_0x403c5f){_0x5e8260=_0x403c5f[_0xf279('0x3e')];if(!_0x1608b3[_0xf279('0x39')][_0xf279('0x3f')]('nolimit')){_0x17209e[_0xf279('0x41')]=qs[_0xf279('0x41')](_0x1608b3[_0xf279('0x39')][_0xf279('0x41')]);_0x17209e['offset']=qs[_0xf279('0x2a')](_0x1608b3[_0xf279('0x39')]['offset']);}return _0x1819dc[_0xf279('0x51')](_0x17209e);}})[_0xf279('0x1b')](function(_0x476da6){if(_0x476da6){return _0x476da6?{'count':_0x5e8260,'rows':_0x476da6}:null;}})[_0xf279('0x1b')](respondWithResult(_0x4b0c16,null))['catch'](handleError(_0x4b0c16,null));};exports[_0xf279('0x53')]=function(_0x3723fd,_0x32bd11,_0x33c919){var _0x389740={};var _0x3517a7={};var _0x9ede99;var _0x4a2515;return db[_0xf279('0x34')][_0xf279('0x52')]({'where':{'id':_0x3723fd[_0xf279('0x4a')]['id']}})[_0xf279('0x1b')](handleEntityNotFound(_0x32bd11,null))['then'](function(_0x34f581){if(_0x34f581){_0x9ede99=_0x34f581;_0x3517a7[_0xf279('0x38')]=_[_0xf279('0x3a')](db[_0xf279('0x54')][_0xf279('0x35')]);_0x3517a7[_0xf279('0x39')]=_[_0xf279('0x3a')](_0x3723fd[_0xf279('0x39')]);_0x3517a7[_0xf279('0x4b')]=_[_0xf279('0x3b')](_0x3517a7[_0xf279('0x38')],_0x3517a7[_0xf279('0x39')]);_0x389740[_0xf279('0x3c')]=_[_0xf279('0x3b')](_0x3517a7[_0xf279('0x38')],qs[_0xf279('0x3d')](_0x3723fd[_0xf279('0x39')][_0xf279('0x3d')]));_0x389740['attributes']=_0x389740[_0xf279('0x3c')][_0xf279('0x3e')]?_0x389740[_0xf279('0x3c')]:_0x3517a7['model'];_0x389740[_0xf279('0x42')]=qs[_0xf279('0x43')](_0x3723fd[_0xf279('0x39')]['sort']);_0x389740['where']=qs[_0xf279('0x4b')](_['pick'](_0x3723fd[_0xf279('0x39')],_0x3517a7[_0xf279('0x4b')]));if(_0x3723fd[_0xf279('0x39')]['filter']){_0x389740[_0xf279('0x44')]=_['merge'](_0x389740[_0xf279('0x44')],{'$or':_[_0xf279('0x33')](_0x389740[_0xf279('0x3c')],function(_0x4458a2){var _0x25aa04={};_0x25aa04[_0x4458a2]={'$like':'%'+_0x3723fd[_0xf279('0x39')]['filter']+'%'};return _0x25aa04;})});}_0x389740=_[_0xf279('0x47')]({},_0x389740,_0x3723fd[_0xf279('0x4d')]);return _0x9ede99[_0xf279('0x53')](_0x389740);}})[_0xf279('0x1b')](function(_0x252f14){if(_0x252f14){_0x4a2515=_0x252f14[_0xf279('0x3e')];if(!_0x3723fd[_0xf279('0x39')]['hasOwnProperty']('nolimit')){_0x389740['limit']=qs[_0xf279('0x41')](_0x3723fd[_0xf279('0x39')]['limit']);_0x389740['offset']=qs['offset'](_0x3723fd[_0xf279('0x39')][_0xf279('0x2a')]);}return _0x9ede99[_0xf279('0x53')](_0x389740);}})[_0xf279('0x1b')](function(_0x269718){if(_0x269718){return _0x269718?{'count':_0x4a2515,'rows':_0x269718}:null;}})['then'](respondWithResult(_0x32bd11,null))[_0xf279('0x25')](handleError(_0x32bd11,null));};exports['getDescriptions']=function(_0x206153,_0x5a471f,_0x4548b1){var _0x5efa78={};var _0x5ab247={};var _0x454502;var _0x5273ee;return db[_0xf279('0x34')]['findOne']({'where':{'id':_0x206153['params']['id']}})['then'](handleEntityNotFound(_0x5a471f,null))[_0xf279('0x1b')](function(_0x1de9b4){if(_0x1de9b4){_0x454502=_0x1de9b4;_0x5ab247[_0xf279('0x38')]=_[_0xf279('0x3a')](db[_0xf279('0x54')]['rawAttributes']);_0x5ab247['query']=_['keys'](_0x206153[_0xf279('0x39')]);_0x5ab247['filters']=_[_0xf279('0x3b')](_0x5ab247[_0xf279('0x38')],_0x5ab247[_0xf279('0x39')]);_0x5efa78[_0xf279('0x3c')]=_['intersection'](_0x5ab247['model'],qs[_0xf279('0x3d')](_0x206153[_0xf279('0x39')][_0xf279('0x3d')]));_0x5efa78[_0xf279('0x3c')]=_0x5efa78[_0xf279('0x3c')][_0xf279('0x3e')]?_0x5efa78[_0xf279('0x3c')]:_0x5ab247[_0xf279('0x38')];_0x5efa78['order']=qs[_0xf279('0x43')](_0x206153[_0xf279('0x39')][_0xf279('0x43')]);_0x5efa78[_0xf279('0x44')]=qs[_0xf279('0x4b')](_[_0xf279('0x45')](_0x206153[_0xf279('0x39')],_0x5ab247['filters']));if(_0x206153[_0xf279('0x39')][_0xf279('0x46')]){_0x5efa78[_0xf279('0x44')]=_[_0xf279('0x47')](_0x5efa78[_0xf279('0x44')],{'$or':_[_0xf279('0x33')](_0x5efa78['attributes'],function(_0x4d2327){var _0xdb3692={};_0xdb3692[_0x4d2327]={'$like':'%'+_0x206153[_0xf279('0x39')][_0xf279('0x46')]+'%'};return _0xdb3692;})});}_0x5efa78=_['merge']({},_0x5efa78,_0x206153[_0xf279('0x4d')]);return _0x454502['getDescriptions'](_0x5efa78);}})[_0xf279('0x1b')](function(_0xddeb9a){if(_0xddeb9a){_0x5273ee=_0xddeb9a[_0xf279('0x3e')];if(!_0x206153[_0xf279('0x39')][_0xf279('0x3f')]('nolimit')){_0x5efa78[_0xf279('0x41')]=qs[_0xf279('0x41')](_0x206153[_0xf279('0x39')][_0xf279('0x41')]);_0x5efa78[_0xf279('0x2a')]=qs[_0xf279('0x2a')](_0x206153[_0xf279('0x39')][_0xf279('0x2a')]);}return _0x454502[_0xf279('0x55')](_0x5efa78);}})[_0xf279('0x1b')](function(_0x209ca3){if(_0x209ca3){return _0x209ca3?{'count':_0x5273ee,'rows':_0x209ca3}:null;}})[_0xf279('0x1b')](respondWithResult(_0x5a471f,null))[_0xf279('0x25')](handleError(_0x5a471f,null));};
\ No newline at end of file
+var _0x94a6=['zip-dir','fast-json-patch','request-promise','moment','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','info','Dynamics365Configuration,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','apply','save','update','then','destroy','stack','name','send','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','pick','filters','filter','where','merge','VIRTUAL','options','includeAll','include','rows','params','keys','length','find','create','body','getFields','findOne','Dynamics365Field','getSubjects','getDescriptions','eml-format','rimraf'];(function(_0x5d6e30,_0xc21d51){var _0x3d3f3b=function(_0x33597b){while(--_0x33597b){_0x5d6e30['push'](_0x5d6e30['shift']());}};_0x3d3f3b(++_0xc21d51);}(_0x94a6,0xae));var _0x694a=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x94a6[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x694a('0x0'));var rimraf=require(_0x694a('0x1'));var zipdir=require(_0x694a('0x2'));var jsonpatch=require(_0x694a('0x3'));var rp=require(_0x694a('0x4'));var moment=require(_0x694a('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x694a('0x6'));var util=require('util');var path=require(_0x694a('0x7'));var sox=require(_0x694a('0x8'));var csv=require(_0x694a('0x9'));var ejs=require(_0x694a('0xa'));var fs=require('fs');var _=require(_0x694a('0xb'));var squel=require(_0x694a('0xc'));var crypto=require(_0x694a('0xd'));var jsforce=require(_0x694a('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x694a('0xf'));var Papa=require(_0x694a('0x10'));var Redis=require(_0x694a('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x694a('0x12'));var as=require(_0x694a('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x694a('0x14'))(_0x694a('0x15'));var utils=require(_0x694a('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0x694a('0x17'));var db=require(_0x694a('0x18'))['db'];var jayson=require(_0x694a('0x19'));var client=jayson[_0x694a('0x1a')]['http']({'port':0x232a});function respondWithRpcPromise(_0x669c36,_0x23d94d,_0x219f09,_0x5ac79e){return new BPromise(function(_0x409cc0,_0x1d197e){var _0x5a05f6=_0x5ac79e||client;return _0x5a05f6['request'](_0x669c36,_0x219f09)['then'](function(_0x5e7578){logger[_0x694a('0x1b')](_0x694a('0x1c'),_0x23d94d,_0x694a('0x1d'));logger[_0x694a('0x1e')]('Dynamics365Configuration,\x20%s,\x20%s,\x20%s',_0x23d94d,_0x694a('0x1d'),JSON[_0x694a('0x1f')](_0x5e7578));if(_0x5e7578[_0x694a('0x20')]){if(_0x5e7578[_0x694a('0x20')]['code']===0x1f4){logger[_0x694a('0x20')](_0x694a('0x1c'),_0x23d94d,_0x5e7578[_0x694a('0x20')][_0x694a('0x21')]);return _0x1d197e(_0x5e7578[_0x694a('0x20')][_0x694a('0x21')]);}logger[_0x694a('0x20')]('Dynamics365Configuration,\x20%s,\x20%s',_0x23d94d,_0x5e7578[_0x694a('0x20')][_0x694a('0x21')]);return _0x409cc0(_0x5e7578[_0x694a('0x20')][_0x694a('0x21')]);}else{logger[_0x694a('0x1b')](_0x694a('0x1c'),_0x23d94d,_0x694a('0x1d'));_0x409cc0(_0x5e7578[_0x694a('0x22')]['message']);}})[_0x694a('0x23')](function(_0x32c12a){logger['error']('Dynamics365Configuration,\x20%s,\x20%s',_0x23d94d,_0x32c12a);_0x1d197e(_0x32c12a);});});}function respondWithStatusCode(_0x3812f4,_0x17f91b){_0x17f91b=_0x17f91b||0xcc;return function(_0x8ac95){if(_0x8ac95){return _0x3812f4[_0x694a('0x24')](_0x17f91b);}return _0x3812f4[_0x694a('0x25')](_0x17f91b)[_0x694a('0x26')]();};}function respondWithResult(_0x20fa8f,_0x44d205){_0x44d205=_0x44d205||0xc8;return function(_0x48ae28){if(_0x48ae28){return _0x20fa8f[_0x694a('0x25')](_0x44d205)[_0x694a('0x27')](_0x48ae28);}};}function respondWithFilteredResult(_0x2bbae9,_0x144f27){return function(_0x28d169){if(_0x28d169){var _0x4050b1=_0x28d169[_0x694a('0x28')],_0x177804=_0x144f27[_0x694a('0x29')],_0x414947=_0x144f27[_0x694a('0x29')]+_0x144f27[_0x694a('0x2a')],_0x5ba6cf;if(_0x414947>=_0x4050b1){_0x414947=_0x4050b1;_0x5ba6cf=0xc8;}else{_0x5ba6cf=0xce;}_0x2bbae9[_0x694a('0x25')](_0x5ba6cf);return _0x2bbae9[_0x694a('0x2b')]('Content-Range',_0x177804+'-'+_0x414947+'/'+_0x4050b1)[_0x694a('0x27')](_0x28d169);}return null;};}function patchUpdates(_0x35422e){return function(_0x330251){try{jsonpatch[_0x694a('0x2c')](_0x330251,_0x35422e,!![]);}catch(_0x5e9e64){return BPromise['reject'](_0x5e9e64);}return _0x330251[_0x694a('0x2d')]();};}function saveUpdates(_0x3d9fff,_0x52170d){return function(_0x35e173){if(_0x35e173){return _0x35e173[_0x694a('0x2e')](_0x3d9fff)[_0x694a('0x2f')](function(_0x52e6b1){return _0x52e6b1;});}return null;};}function removeEntity(_0x36803c,_0x2232f8){return function(_0x450424){if(_0x450424){return _0x450424[_0x694a('0x30')]()['then'](function(){_0x36803c[_0x694a('0x25')](0xcc)['end']();});}};}function handleEntityNotFound(_0x54590d,_0x29f607){return function(_0x503302){if(!_0x503302){_0x54590d[_0x694a('0x24')](0x194);}return _0x503302;};}function handleError(_0x1c2a5a,_0x13e083){_0x13e083=_0x13e083||0x1f4;return function(_0x33f0a8){logger['error'](_0x33f0a8[_0x694a('0x31')]);if(_0x33f0a8[_0x694a('0x32')]){delete _0x33f0a8['name'];}_0x1c2a5a[_0x694a('0x25')](_0x13e083)[_0x694a('0x33')](_0x33f0a8);};}exports['index']=function(_0x455f50,_0x3852d8){var _0x229989={},_0x4db895={},_0x589b8b={'count':0x0,'rows':[]};var _0x463191=_[_0x694a('0x34')](db[_0x694a('0x35')][_0x694a('0x36')],function(_0xd91758){return{'name':_0xd91758[_0x694a('0x37')],'type':_0xd91758[_0x694a('0x38')][_0x694a('0x39')]};});_0x4db895[_0x694a('0x3a')]=_['map'](_0x463191,'name');_0x4db895[_0x694a('0x3b')]=_['keys'](_0x455f50[_0x694a('0x3b')]);_0x4db895['filters']=_[_0x694a('0x3c')](_0x4db895['model'],_0x4db895[_0x694a('0x3b')]);_0x229989['attributes']=_['intersection'](_0x4db895[_0x694a('0x3a')],qs['fields'](_0x455f50[_0x694a('0x3b')][_0x694a('0x3d')]));_0x229989[_0x694a('0x3e')]=_0x229989['attributes']['length']?_0x229989['attributes']:_0x4db895[_0x694a('0x3a')];if(!_0x455f50[_0x694a('0x3b')][_0x694a('0x3f')](_0x694a('0x40'))){_0x229989[_0x694a('0x2a')]=qs[_0x694a('0x2a')](_0x455f50['query'][_0x694a('0x2a')]);_0x229989[_0x694a('0x29')]=qs[_0x694a('0x29')](_0x455f50[_0x694a('0x3b')][_0x694a('0x29')]);}_0x229989[_0x694a('0x41')]=qs[_0x694a('0x42')](_0x455f50['query'][_0x694a('0x42')]);_0x229989['where']=qs['filters'](_[_0x694a('0x43')](_0x455f50[_0x694a('0x3b')],_0x4db895[_0x694a('0x44')]),_0x463191);if(_0x455f50['query'][_0x694a('0x45')]){_0x229989[_0x694a('0x46')]=_[_0x694a('0x47')](_0x229989[_0x694a('0x46')],{'$or':_['map'](_0x463191,function(_0x39436f){if(_0x39436f['type']!==_0x694a('0x48')){var _0x342061={};_0x342061[_0x39436f[_0x694a('0x32')]]={'$like':'%'+_0x455f50[_0x694a('0x3b')]['filter']+'%'};return _0x342061;}})});}_0x229989=_[_0x694a('0x47')]({},_0x229989,_0x455f50[_0x694a('0x49')]);var _0x4facea={'where':_0x229989['where']};return db['Dynamics365Configuration'][_0x694a('0x28')](_0x4facea)['then'](function(_0x205bd4){_0x589b8b[_0x694a('0x28')]=_0x205bd4;if(_0x455f50[_0x694a('0x3b')][_0x694a('0x4a')]){_0x229989[_0x694a('0x4b')]=[{'all':!![]}];}return db['Dynamics365Configuration']['findAll'](_0x229989);})[_0x694a('0x2f')](function(_0x56f5cc){_0x589b8b[_0x694a('0x4c')]=_0x56f5cc;return _0x589b8b;})[_0x694a('0x2f')](respondWithFilteredResult(_0x3852d8,_0x229989))[_0x694a('0x23')](handleError(_0x3852d8,null));};exports['show']=function(_0x1116a6,_0x67ddaf){var _0x98f514={'raw':![],'where':{'id':_0x1116a6[_0x694a('0x4d')]['id']}},_0x241924={};_0x241924[_0x694a('0x3a')]=_[_0x694a('0x4e')](db[_0x694a('0x35')][_0x694a('0x36')]);_0x241924[_0x694a('0x3b')]=_[_0x694a('0x4e')](_0x1116a6[_0x694a('0x3b')]);_0x241924[_0x694a('0x44')]=_[_0x694a('0x3c')](_0x241924[_0x694a('0x3a')],_0x241924[_0x694a('0x3b')]);_0x98f514['attributes']=_[_0x694a('0x3c')](_0x241924[_0x694a('0x3a')],qs['fields'](_0x1116a6[_0x694a('0x3b')]['fields']));_0x98f514[_0x694a('0x3e')]=_0x98f514[_0x694a('0x3e')][_0x694a('0x4f')]?_0x98f514[_0x694a('0x3e')]:_0x241924[_0x694a('0x3a')];if(_0x1116a6['query']['includeAll']){_0x98f514[_0x694a('0x4b')]=[{'all':!![]}];}_0x98f514=_['merge']({},_0x98f514,_0x1116a6[_0x694a('0x49')]);return db[_0x694a('0x35')][_0x694a('0x50')](_0x98f514)[_0x694a('0x2f')](handleEntityNotFound(_0x67ddaf,null))[_0x694a('0x2f')](respondWithResult(_0x67ddaf,null))[_0x694a('0x23')](handleError(_0x67ddaf,null));};exports[_0x694a('0x51')]=function(_0x1b7269,_0x187d5d){return db['Dynamics365Configuration'][_0x694a('0x51')](_0x1b7269['body'],{})[_0x694a('0x2f')](respondWithResult(_0x187d5d,0xc9))[_0x694a('0x23')](handleError(_0x187d5d,null));};exports[_0x694a('0x2e')]=function(_0x14c919,_0x4b10f3){if(_0x14c919[_0x694a('0x52')]['id']){delete _0x14c919[_0x694a('0x52')]['id'];}return db['Dynamics365Configuration']['find']({'where':{'id':_0x14c919[_0x694a('0x4d')]['id']}})['then'](handleEntityNotFound(_0x4b10f3,null))[_0x694a('0x2f')](saveUpdates(_0x14c919['body'],null))['then'](respondWithResult(_0x4b10f3,null))['catch'](handleError(_0x4b10f3,null));};exports[_0x694a('0x30')]=function(_0x2726ac,_0x571729){return db['Dynamics365Configuration'][_0x694a('0x50')]({'where':{'id':_0x2726ac['params']['id']}})[_0x694a('0x2f')](handleEntityNotFound(_0x571729,null))[_0x694a('0x2f')](removeEntity(_0x571729,null))[_0x694a('0x23')](handleError(_0x571729,null));};exports[_0x694a('0x53')]=function(_0x4353ad,_0x5d418b,_0x142a2b){var _0x578401={};var _0x30865a={};var _0x530a4e;var _0x39bb15;return db[_0x694a('0x35')][_0x694a('0x54')]({'where':{'id':_0x4353ad[_0x694a('0x4d')]['id']}})['then'](handleEntityNotFound(_0x5d418b,null))[_0x694a('0x2f')](function(_0x117e18){if(_0x117e18){_0x530a4e=_0x117e18;_0x30865a[_0x694a('0x3a')]=_['keys'](db[_0x694a('0x55')][_0x694a('0x36')]);_0x30865a['query']=_[_0x694a('0x4e')](_0x4353ad[_0x694a('0x3b')]);_0x30865a[_0x694a('0x44')]=_[_0x694a('0x3c')](_0x30865a[_0x694a('0x3a')],_0x30865a['query']);_0x578401[_0x694a('0x3e')]=_[_0x694a('0x3c')](_0x30865a[_0x694a('0x3a')],qs[_0x694a('0x3d')](_0x4353ad[_0x694a('0x3b')][_0x694a('0x3d')]));_0x578401[_0x694a('0x3e')]=_0x578401[_0x694a('0x3e')][_0x694a('0x4f')]?_0x578401[_0x694a('0x3e')]:_0x30865a['model'];_0x578401[_0x694a('0x41')]=qs['sort'](_0x4353ad['query'][_0x694a('0x42')]);_0x578401['where']=qs['filters'](_[_0x694a('0x43')](_0x4353ad['query'],_0x30865a[_0x694a('0x44')]));if(_0x4353ad['query'][_0x694a('0x45')]){_0x578401[_0x694a('0x46')]=_['merge'](_0x578401[_0x694a('0x46')],{'$or':_['map'](_0x578401[_0x694a('0x3e')],function(_0x43ef6c){var _0x233f1c={};_0x233f1c[_0x43ef6c]={'$like':'%'+_0x4353ad[_0x694a('0x3b')][_0x694a('0x45')]+'%'};return _0x233f1c;})});}_0x578401=_[_0x694a('0x47')]({},_0x578401,_0x4353ad[_0x694a('0x49')]);return _0x530a4e[_0x694a('0x53')](_0x578401);}})[_0x694a('0x2f')](function(_0x34b104){if(_0x34b104){_0x39bb15=_0x34b104[_0x694a('0x4f')];if(!_0x4353ad[_0x694a('0x3b')][_0x694a('0x3f')]('nolimit')){_0x578401['limit']=qs['limit'](_0x4353ad[_0x694a('0x3b')][_0x694a('0x2a')]);_0x578401['offset']=qs[_0x694a('0x29')](_0x4353ad[_0x694a('0x3b')][_0x694a('0x29')]);}return _0x530a4e['getFields'](_0x578401);}})[_0x694a('0x2f')](function(_0x1ab38c){if(_0x1ab38c){return _0x1ab38c?{'count':_0x39bb15,'rows':_0x1ab38c}:null;}})[_0x694a('0x2f')](respondWithResult(_0x5d418b,null))[_0x694a('0x23')](handleError(_0x5d418b,null));};exports[_0x694a('0x56')]=function(_0x2b3acc,_0x2c8606,_0x3d7661){var _0x4a3658={};var _0x4054ed={};var _0x51dd07;var _0x14ec6c;return db[_0x694a('0x35')][_0x694a('0x54')]({'where':{'id':_0x2b3acc['params']['id']}})[_0x694a('0x2f')](handleEntityNotFound(_0x2c8606,null))[_0x694a('0x2f')](function(_0x3a422c){if(_0x3a422c){_0x51dd07=_0x3a422c;_0x4054ed[_0x694a('0x3a')]=_[_0x694a('0x4e')](db[_0x694a('0x55')][_0x694a('0x36')]);_0x4054ed[_0x694a('0x3b')]=_[_0x694a('0x4e')](_0x2b3acc[_0x694a('0x3b')]);_0x4054ed[_0x694a('0x44')]=_[_0x694a('0x3c')](_0x4054ed[_0x694a('0x3a')],_0x4054ed[_0x694a('0x3b')]);_0x4a3658[_0x694a('0x3e')]=_[_0x694a('0x3c')](_0x4054ed[_0x694a('0x3a')],qs[_0x694a('0x3d')](_0x2b3acc[_0x694a('0x3b')][_0x694a('0x3d')]));_0x4a3658[_0x694a('0x3e')]=_0x4a3658[_0x694a('0x3e')][_0x694a('0x4f')]?_0x4a3658[_0x694a('0x3e')]:_0x4054ed[_0x694a('0x3a')];_0x4a3658[_0x694a('0x41')]=qs['sort'](_0x2b3acc[_0x694a('0x3b')][_0x694a('0x42')]);_0x4a3658[_0x694a('0x46')]=qs[_0x694a('0x44')](_['pick'](_0x2b3acc['query'],_0x4054ed['filters']));if(_0x2b3acc[_0x694a('0x3b')][_0x694a('0x45')]){_0x4a3658[_0x694a('0x46')]=_[_0x694a('0x47')](_0x4a3658[_0x694a('0x46')],{'$or':_[_0x694a('0x34')](_0x4a3658[_0x694a('0x3e')],function(_0x4bb72c){var _0x32fea1={};_0x32fea1[_0x4bb72c]={'$like':'%'+_0x2b3acc['query']['filter']+'%'};return _0x32fea1;})});}_0x4a3658=_[_0x694a('0x47')]({},_0x4a3658,_0x2b3acc[_0x694a('0x49')]);return _0x51dd07[_0x694a('0x56')](_0x4a3658);}})[_0x694a('0x2f')](function(_0x1b3dd3){if(_0x1b3dd3){_0x14ec6c=_0x1b3dd3[_0x694a('0x4f')];if(!_0x2b3acc['query'][_0x694a('0x3f')](_0x694a('0x40'))){_0x4a3658[_0x694a('0x2a')]=qs[_0x694a('0x2a')](_0x2b3acc[_0x694a('0x3b')][_0x694a('0x2a')]);_0x4a3658[_0x694a('0x29')]=qs[_0x694a('0x29')](_0x2b3acc[_0x694a('0x3b')][_0x694a('0x29')]);}return _0x51dd07[_0x694a('0x56')](_0x4a3658);}})['then'](function(_0x51509f){if(_0x51509f){return _0x51509f?{'count':_0x14ec6c,'rows':_0x51509f}:null;}})['then'](respondWithResult(_0x2c8606,null))['catch'](handleError(_0x2c8606,null));};exports[_0x694a('0x57')]=function(_0x33cfcf,_0x1d5f7e,_0x50c96a){var _0x2066e4={};var _0x243161={};var _0x76ad4f;var _0x332dd7;return db[_0x694a('0x35')][_0x694a('0x54')]({'where':{'id':_0x33cfcf[_0x694a('0x4d')]['id']}})[_0x694a('0x2f')](handleEntityNotFound(_0x1d5f7e,null))[_0x694a('0x2f')](function(_0x295dfe){if(_0x295dfe){_0x76ad4f=_0x295dfe;_0x243161[_0x694a('0x3a')]=_[_0x694a('0x4e')](db[_0x694a('0x55')][_0x694a('0x36')]);_0x243161[_0x694a('0x3b')]=_['keys'](_0x33cfcf[_0x694a('0x3b')]);_0x243161[_0x694a('0x44')]=_[_0x694a('0x3c')](_0x243161['model'],_0x243161[_0x694a('0x3b')]);_0x2066e4[_0x694a('0x3e')]=_['intersection'](_0x243161[_0x694a('0x3a')],qs['fields'](_0x33cfcf['query']['fields']));_0x2066e4[_0x694a('0x3e')]=_0x2066e4['attributes'][_0x694a('0x4f')]?_0x2066e4['attributes']:_0x243161[_0x694a('0x3a')];_0x2066e4[_0x694a('0x41')]=qs['sort'](_0x33cfcf[_0x694a('0x3b')]['sort']);_0x2066e4[_0x694a('0x46')]=qs[_0x694a('0x44')](_[_0x694a('0x43')](_0x33cfcf[_0x694a('0x3b')],_0x243161['filters']));if(_0x33cfcf[_0x694a('0x3b')][_0x694a('0x45')]){_0x2066e4['where']=_['merge'](_0x2066e4['where'],{'$or':_[_0x694a('0x34')](_0x2066e4[_0x694a('0x3e')],function(_0x25d25c){var _0x154b52={};_0x154b52[_0x25d25c]={'$like':'%'+_0x33cfcf['query'][_0x694a('0x45')]+'%'};return _0x154b52;})});}_0x2066e4=_[_0x694a('0x47')]({},_0x2066e4,_0x33cfcf[_0x694a('0x49')]);return _0x76ad4f[_0x694a('0x57')](_0x2066e4);}})['then'](function(_0x1d812f){if(_0x1d812f){_0x332dd7=_0x1d812f['length'];if(!_0x33cfcf['query']['hasOwnProperty'](_0x694a('0x40'))){_0x2066e4[_0x694a('0x2a')]=qs['limit'](_0x33cfcf[_0x694a('0x3b')][_0x694a('0x2a')]);_0x2066e4[_0x694a('0x29')]=qs[_0x694a('0x29')](_0x33cfcf['query']['offset']);}return _0x76ad4f['getDescriptions'](_0x2066e4);}})[_0x694a('0x2f')](function(_0x5cd9db){if(_0x5cd9db){return _0x5cd9db?{'count':_0x332dd7,'rows':_0x5cd9db}:null;}})[_0x694a('0x2f')](respondWithResult(_0x1d5f7e,null))[_0x694a('0x23')](handleError(_0x1d5f7e,null));};
\ No newline at end of file