Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 50925c0..2452dd9 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 _0x217c=['include','findAll','show','find','catch','body','params','getFields','findOne','Dynamics365Field','filter','getSubjects','getDescriptions','order','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','sendStatus','error','stack','name','send','index','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','merge','VIRTUAL','options','includeAll'];(function(_0x1c15df,_0x241539){var _0x41c9ce=function(_0x49fb1){while(--_0x49fb1){_0x1c15df['push'](_0x1c15df['shift']());}};_0x41c9ce(++_0x241539);}(_0x217c,0x1f4));var _0xc217=function(_0x389b5b,_0x1adb11){_0x389b5b=_0x389b5b-0x0;var _0xf93e95=_0x217c[_0x389b5b];return _0xf93e95;};'use strict';var emlformat=require(_0xc217('0x0'));var rimraf=require(_0xc217('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xc217('0x2'));var rp=require(_0xc217('0x3'));var moment=require(_0xc217('0x4'));var BPromise=require(_0xc217('0x5'));var Mustache=require('mustache');var util=require(_0xc217('0x6'));var path=require(_0xc217('0x7'));var sox=require(_0xc217('0x8'));var csv=require(_0xc217('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xc217('0xa'));var _=require(_0xc217('0xb'));var squel=require(_0xc217('0xc'));var crypto=require(_0xc217('0xd'));var jsforce=require(_0xc217('0xe'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xc217('0xf'));var Papa=require(_0xc217('0x10'));var Redis=require(_0xc217('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xc217('0x12'));var as=require(_0xc217('0x13'));var hardwareService=require(_0xc217('0x14'));var logger=require(_0xc217('0x15'))('api');var utils=require('../../config/utils');var config=require(_0xc217('0x16'));var licenseUtil=require(_0xc217('0x17'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x17db0c,_0x29e65d){_0x29e65d=_0x29e65d||0xcc;return function(_0x4d1bf5){if(_0x4d1bf5){return _0x17db0c['sendStatus'](_0x29e65d);}return _0x17db0c['status'](_0x29e65d)['end']();};}function respondWithResult(_0x4f71ec,_0x1992ad){_0x1992ad=_0x1992ad||0xc8;return function(_0x5d68c0){if(_0x5d68c0){return _0x4f71ec[_0xc217('0x18')](_0x1992ad)[_0xc217('0x19')](_0x5d68c0);}};}function respondWithFilteredResult(_0x42ea56,_0x2a12b6){return function(_0x19a469){if(_0x19a469){var _0x123dc3=typeof _0x2a12b6[_0xc217('0x1a')]===_0xc217('0x1b')&&typeof _0x2a12b6[_0xc217('0x1c')]===_0xc217('0x1b');var _0x1193c3=_0x19a469[_0xc217('0x1d')];var _0x51341c=_0x123dc3?0x0:_0x2a12b6[_0xc217('0x1a')];var _0x5671c9=_0x123dc3?_0x19a469[_0xc217('0x1d')]:_0x2a12b6[_0xc217('0x1a')]+_0x2a12b6[_0xc217('0x1c')];var _0x337436;if(_0x5671c9>=_0x1193c3){_0x5671c9=_0x1193c3;_0x337436=0xc8;}else{_0x337436=0xce;}_0x42ea56['status'](_0x337436);return _0x42ea56[_0xc217('0x1e')](_0xc217('0x1f'),_0x51341c+'-'+_0x5671c9+'/'+_0x1193c3)['json'](_0x19a469);}return null;};}function patchUpdates(_0x2db9c2){return function(_0x11e911){try{jsonpatch[_0xc217('0x20')](_0x11e911,_0x2db9c2,!![]);}catch(_0x18d617){return BPromise[_0xc217('0x21')](_0x18d617);}return _0x11e911[_0xc217('0x22')]();};}function saveUpdates(_0x3b27f6,_0x3a37b2){return function(_0x957fb9){if(_0x957fb9){return _0x957fb9[_0xc217('0x23')](_0x3b27f6)['then'](function(_0x3b3b62){return _0x3b3b62;});}return null;};}function removeEntity(_0x5b3dc9,_0x40e840){return function(_0x2fbc35){if(_0x2fbc35){return _0x2fbc35[_0xc217('0x24')]()[_0xc217('0x25')](function(){_0x5b3dc9[_0xc217('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x462373,_0x2010d9){return function(_0x2e8cd9){if(!_0x2e8cd9){_0x462373[_0xc217('0x26')](0x194);}return _0x2e8cd9;};}function handleError(_0x4dba14,_0x5b05fb){_0x5b05fb=_0x5b05fb||0x1f4;return function(_0x55d02f){logger[_0xc217('0x27')](_0x55d02f[_0xc217('0x28')]);if(_0x55d02f[_0xc217('0x29')]){delete _0x55d02f[_0xc217('0x29')];}_0x4dba14[_0xc217('0x18')](_0x5b05fb)[_0xc217('0x2a')](_0x55d02f);};}exports[_0xc217('0x2b')]=function(_0x123207,_0x5c6834){var _0x3e31c4={},_0x1fac38={},_0x534dc4={'count':0x0,'rows':[]};var _0x4a2120=_[_0xc217('0x2c')](db[_0xc217('0x2d')][_0xc217('0x2e')],function(_0x2b86e7){return{'name':_0x2b86e7[_0xc217('0x2f')],'type':_0x2b86e7[_0xc217('0x30')][_0xc217('0x31')]};});_0x1fac38['model']=_[_0xc217('0x2c')](_0x4a2120,_0xc217('0x29'));_0x1fac38[_0xc217('0x32')]=_[_0xc217('0x33')](_0x123207[_0xc217('0x32')]);_0x1fac38[_0xc217('0x34')]=_['intersection'](_0x1fac38[_0xc217('0x35')],_0x1fac38[_0xc217('0x32')]);_0x3e31c4[_0xc217('0x36')]=_[_0xc217('0x37')](_0x1fac38['model'],qs[_0xc217('0x38')](_0x123207[_0xc217('0x32')][_0xc217('0x38')]));_0x3e31c4['attributes']=_0x3e31c4[_0xc217('0x36')][_0xc217('0x39')]?_0x3e31c4[_0xc217('0x36')]:_0x1fac38[_0xc217('0x35')];if(!_0x123207[_0xc217('0x32')][_0xc217('0x3a')](_0xc217('0x3b'))){_0x3e31c4['limit']=qs['limit'](_0x123207[_0xc217('0x32')][_0xc217('0x1c')]);_0x3e31c4[_0xc217('0x1a')]=qs['offset'](_0x123207['query'][_0xc217('0x1a')]);}_0x3e31c4['order']=qs[_0xc217('0x3c')](_0x123207['query']['sort']);_0x3e31c4[_0xc217('0x3d')]=qs[_0xc217('0x34')](_[_0xc217('0x3e')](_0x123207[_0xc217('0x32')],_0x1fac38[_0xc217('0x34')]),_0x4a2120);if(_0x123207[_0xc217('0x32')]['filter']){_0x3e31c4[_0xc217('0x3d')]=_[_0xc217('0x3f')](_0x3e31c4[_0xc217('0x3d')],{'$or':_[_0xc217('0x2c')](_0x4a2120,function(_0x3b2c79){if(_0x3b2c79['type']!==_0xc217('0x40')){var _0x460b4f={};_0x460b4f[_0x3b2c79['name']]={'$like':'%'+_0x123207[_0xc217('0x32')]['filter']+'%'};return _0x460b4f;}})});}_0x3e31c4=_[_0xc217('0x3f')]({},_0x3e31c4,_0x123207[_0xc217('0x41')]);var _0x2788ea={'where':_0x3e31c4[_0xc217('0x3d')]};return db[_0xc217('0x2d')][_0xc217('0x1d')](_0x2788ea)['then'](function(_0xda378){_0x534dc4[_0xc217('0x1d')]=_0xda378;if(_0x123207[_0xc217('0x32')][_0xc217('0x42')]){_0x3e31c4[_0xc217('0x43')]=[{'all':!![]}];}return db[_0xc217('0x2d')][_0xc217('0x44')](_0x3e31c4);})['then'](function(_0x4b2168){_0x534dc4['rows']=_0x4b2168;return _0x534dc4;})['then'](respondWithFilteredResult(_0x5c6834,_0x3e31c4))['catch'](handleError(_0x5c6834,null));};exports[_0xc217('0x45')]=function(_0x5d372c,_0x29b3cd){var _0x5a983f={'raw':![],'where':{'id':_0x5d372c['params']['id']}},_0x5e4fbb={};_0x5e4fbb[_0xc217('0x35')]=_[_0xc217('0x33')](db[_0xc217('0x2d')][_0xc217('0x2e')]);_0x5e4fbb[_0xc217('0x32')]=_[_0xc217('0x33')](_0x5d372c[_0xc217('0x32')]);_0x5e4fbb[_0xc217('0x34')]=_[_0xc217('0x37')](_0x5e4fbb[_0xc217('0x35')],_0x5e4fbb[_0xc217('0x32')]);_0x5a983f[_0xc217('0x36')]=_[_0xc217('0x37')](_0x5e4fbb[_0xc217('0x35')],qs[_0xc217('0x38')](_0x5d372c[_0xc217('0x32')][_0xc217('0x38')]));_0x5a983f[_0xc217('0x36')]=_0x5a983f['attributes']['length']?_0x5a983f[_0xc217('0x36')]:_0x5e4fbb['model'];if(_0x5d372c[_0xc217('0x32')][_0xc217('0x42')]){_0x5a983f['include']=[{'all':!![]}];}_0x5a983f=_[_0xc217('0x3f')]({},_0x5a983f,_0x5d372c[_0xc217('0x41')]);return db[_0xc217('0x2d')][_0xc217('0x46')](_0x5a983f)[_0xc217('0x25')](handleEntityNotFound(_0x29b3cd,null))[_0xc217('0x25')](respondWithResult(_0x29b3cd,null))[_0xc217('0x47')](handleError(_0x29b3cd,null));};exports['create']=function(_0x9b0807,_0x172fc8){return db[_0xc217('0x2d')]['create'](_0x9b0807[_0xc217('0x48')],{})[_0xc217('0x25')](respondWithResult(_0x172fc8,0xc9))['catch'](handleError(_0x172fc8,null));};exports[_0xc217('0x23')]=function(_0x2329cd,_0x303f85){if(_0x2329cd['body']['id']){delete _0x2329cd[_0xc217('0x48')]['id'];}return db[_0xc217('0x2d')][_0xc217('0x46')]({'where':{'id':_0x2329cd[_0xc217('0x49')]['id']}})[_0xc217('0x25')](handleEntityNotFound(_0x303f85,null))['then'](saveUpdates(_0x2329cd['body'],null))['then'](respondWithResult(_0x303f85,null))[_0xc217('0x47')](handleError(_0x303f85,null));};exports[_0xc217('0x24')]=function(_0x9ca6d6,_0x1190f0){return db[_0xc217('0x2d')]['find']({'where':{'id':_0x9ca6d6[_0xc217('0x49')]['id']}})[_0xc217('0x25')](handleEntityNotFound(_0x1190f0,null))[_0xc217('0x25')](removeEntity(_0x1190f0,null))['catch'](handleError(_0x1190f0,null));};exports[_0xc217('0x4a')]=function(_0x440bd4,_0x4d914c,_0x4ea78a){var _0x4d09f1={};var _0x13131e={};var _0x19b98a;var _0x55cd71;return db['Dynamics365Configuration'][_0xc217('0x4b')]({'where':{'id':_0x440bd4['params']['id']}})['then'](handleEntityNotFound(_0x4d914c,null))[_0xc217('0x25')](function(_0x5bfff0){if(_0x5bfff0){_0x19b98a=_0x5bfff0;_0x13131e[_0xc217('0x35')]=_[_0xc217('0x33')](db[_0xc217('0x4c')]['rawAttributes']);_0x13131e['query']=_[_0xc217('0x33')](_0x440bd4[_0xc217('0x32')]);_0x13131e[_0xc217('0x34')]=_['intersection'](_0x13131e['model'],_0x13131e['query']);_0x4d09f1['attributes']=_[_0xc217('0x37')](_0x13131e[_0xc217('0x35')],qs[_0xc217('0x38')](_0x440bd4[_0xc217('0x32')]['fields']));_0x4d09f1[_0xc217('0x36')]=_0x4d09f1[_0xc217('0x36')][_0xc217('0x39')]?_0x4d09f1[_0xc217('0x36')]:_0x13131e[_0xc217('0x35')];_0x4d09f1['order']=qs['sort'](_0x440bd4[_0xc217('0x32')][_0xc217('0x3c')]);_0x4d09f1['where']=qs[_0xc217('0x34')](_[_0xc217('0x3e')](_0x440bd4[_0xc217('0x32')],_0x13131e['filters']));if(_0x440bd4[_0xc217('0x32')][_0xc217('0x4d')]){_0x4d09f1['where']=_[_0xc217('0x3f')](_0x4d09f1['where'],{'$or':_[_0xc217('0x2c')](_0x4d09f1['attributes'],function(_0x4e90e7){var _0x25d8ba={};_0x25d8ba[_0x4e90e7]={'$like':'%'+_0x440bd4[_0xc217('0x32')][_0xc217('0x4d')]+'%'};return _0x25d8ba;})});}_0x4d09f1=_[_0xc217('0x3f')]({},_0x4d09f1,_0x440bd4[_0xc217('0x41')]);return _0x19b98a['getFields'](_0x4d09f1);}})[_0xc217('0x25')](function(_0x447020){if(_0x447020){_0x55cd71=_0x447020[_0xc217('0x39')];if(!_0x440bd4['query'][_0xc217('0x3a')]('nolimit')){_0x4d09f1[_0xc217('0x1c')]=qs[_0xc217('0x1c')](_0x440bd4[_0xc217('0x32')]['limit']);_0x4d09f1['offset']=qs['offset'](_0x440bd4[_0xc217('0x32')][_0xc217('0x1a')]);}return _0x19b98a['getFields'](_0x4d09f1);}})[_0xc217('0x25')](function(_0x2ddeac){if(_0x2ddeac){return _0x2ddeac?{'count':_0x55cd71,'rows':_0x2ddeac}:null;}})['then'](respondWithResult(_0x4d914c,null))[_0xc217('0x47')](handleError(_0x4d914c,null));};exports[_0xc217('0x4e')]=function(_0x324976,_0x5e2676,_0x3a0813){var _0x27a926={};var _0x207f3a={};var _0x405699;var _0x6ead7c;return db[_0xc217('0x2d')][_0xc217('0x4b')]({'where':{'id':_0x324976['params']['id']}})[_0xc217('0x25')](handleEntityNotFound(_0x5e2676,null))[_0xc217('0x25')](function(_0x46e0cb){if(_0x46e0cb){_0x405699=_0x46e0cb;_0x207f3a[_0xc217('0x35')]=_['keys'](db[_0xc217('0x4c')]['rawAttributes']);_0x207f3a['query']=_[_0xc217('0x33')](_0x324976[_0xc217('0x32')]);_0x207f3a[_0xc217('0x34')]=_[_0xc217('0x37')](_0x207f3a['model'],_0x207f3a['query']);_0x27a926['attributes']=_[_0xc217('0x37')](_0x207f3a[_0xc217('0x35')],qs[_0xc217('0x38')](_0x324976[_0xc217('0x32')][_0xc217('0x38')]));_0x27a926['attributes']=_0x27a926[_0xc217('0x36')][_0xc217('0x39')]?_0x27a926[_0xc217('0x36')]:_0x207f3a[_0xc217('0x35')];_0x27a926['order']=qs[_0xc217('0x3c')](_0x324976['query']['sort']);_0x27a926[_0xc217('0x3d')]=qs[_0xc217('0x34')](_[_0xc217('0x3e')](_0x324976[_0xc217('0x32')],_0x207f3a[_0xc217('0x34')]));if(_0x324976[_0xc217('0x32')][_0xc217('0x4d')]){_0x27a926['where']=_[_0xc217('0x3f')](_0x27a926['where'],{'$or':_['map'](_0x27a926[_0xc217('0x36')],function(_0x33d4f3){var _0x117f70={};_0x117f70[_0x33d4f3]={'$like':'%'+_0x324976[_0xc217('0x32')][_0xc217('0x4d')]+'%'};return _0x117f70;})});}_0x27a926=_[_0xc217('0x3f')]({},_0x27a926,_0x324976['options']);return _0x405699[_0xc217('0x4e')](_0x27a926);}})['then'](function(_0x1a57b2){if(_0x1a57b2){_0x6ead7c=_0x1a57b2[_0xc217('0x39')];if(!_0x324976['query'][_0xc217('0x3a')](_0xc217('0x3b'))){_0x27a926[_0xc217('0x1c')]=qs[_0xc217('0x1c')](_0x324976[_0xc217('0x32')]['limit']);_0x27a926[_0xc217('0x1a')]=qs['offset'](_0x324976[_0xc217('0x32')][_0xc217('0x1a')]);}return _0x405699[_0xc217('0x4e')](_0x27a926);}})[_0xc217('0x25')](function(_0x1fe600){if(_0x1fe600){return _0x1fe600?{'count':_0x6ead7c,'rows':_0x1fe600}:null;}})[_0xc217('0x25')](respondWithResult(_0x5e2676,null))[_0xc217('0x47')](handleError(_0x5e2676,null));};exports[_0xc217('0x4f')]=function(_0x3cb4ae,_0x183e85,_0x2e06b0){var _0x4f27d1={};var _0x44cc30={};var _0x56eda5;var _0x55b638;return db['Dynamics365Configuration']['findOne']({'where':{'id':_0x3cb4ae[_0xc217('0x49')]['id']}})[_0xc217('0x25')](handleEntityNotFound(_0x183e85,null))['then'](function(_0x4bdc34){if(_0x4bdc34){_0x56eda5=_0x4bdc34;_0x44cc30[_0xc217('0x35')]=_[_0xc217('0x33')](db[_0xc217('0x4c')]['rawAttributes']);_0x44cc30[_0xc217('0x32')]=_[_0xc217('0x33')](_0x3cb4ae['query']);_0x44cc30['filters']=_['intersection'](_0x44cc30[_0xc217('0x35')],_0x44cc30[_0xc217('0x32')]);_0x4f27d1[_0xc217('0x36')]=_[_0xc217('0x37')](_0x44cc30[_0xc217('0x35')],qs[_0xc217('0x38')](_0x3cb4ae[_0xc217('0x32')][_0xc217('0x38')]));_0x4f27d1['attributes']=_0x4f27d1[_0xc217('0x36')][_0xc217('0x39')]?_0x4f27d1[_0xc217('0x36')]:_0x44cc30['model'];_0x4f27d1[_0xc217('0x50')]=qs[_0xc217('0x3c')](_0x3cb4ae['query'][_0xc217('0x3c')]);_0x4f27d1[_0xc217('0x3d')]=qs[_0xc217('0x34')](_[_0xc217('0x3e')](_0x3cb4ae['query'],_0x44cc30[_0xc217('0x34')]));if(_0x3cb4ae['query'][_0xc217('0x4d')]){_0x4f27d1[_0xc217('0x3d')]=_['merge'](_0x4f27d1[_0xc217('0x3d')],{'$or':_[_0xc217('0x2c')](_0x4f27d1[_0xc217('0x36')],function(_0x11f9db){var _0x2f2ff6={};_0x2f2ff6[_0x11f9db]={'$like':'%'+_0x3cb4ae[_0xc217('0x32')][_0xc217('0x4d')]+'%'};return _0x2f2ff6;})});}_0x4f27d1=_[_0xc217('0x3f')]({},_0x4f27d1,_0x3cb4ae['options']);return _0x56eda5[_0xc217('0x4f')](_0x4f27d1);}})[_0xc217('0x25')](function(_0x7da751){if(_0x7da751){_0x55b638=_0x7da751[_0xc217('0x39')];if(!_0x3cb4ae[_0xc217('0x32')][_0xc217('0x3a')]('nolimit')){_0x4f27d1[_0xc217('0x1c')]=qs['limit'](_0x3cb4ae[_0xc217('0x32')][_0xc217('0x1c')]);_0x4f27d1[_0xc217('0x1a')]=qs[_0xc217('0x1a')](_0x3cb4ae[_0xc217('0x32')][_0xc217('0x1a')]);}return _0x56eda5[_0xc217('0x4f')](_0x4f27d1);}})[_0xc217('0x25')](function(_0x4ccab8){if(_0x4ccab8){return _0x4ccab8?{'count':_0x55b638,'rows':_0x4ccab8}:null;}})[_0xc217('0x25')](respondWithResult(_0x183e85,null))[_0xc217('0x47')](handleError(_0x183e85,null));};
\ No newline at end of file