Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intDynamics365Configuration / intDynamics365Configuration.controller.js
index 50925c0..3635b95 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 _0x5800=['params','length','options','find','create','body','destroy','findOne','Dynamics365Field','pick','getFields','getSubjects','order','getDescriptions','eml-format','zip-dir','fast-json-patch','bluebird','mustache','util','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','save','update','then','sendStatus','error','stack','name','send','index','map','Dynamics365Configuration','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','filter','merge','includeAll','include','findAll','catch','show'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5800,0xb0));var _0x0580=function(_0x263bdd,_0x498f2e){_0x263bdd=_0x263bdd-0x0;var _0x399eed=_0x5800[_0x263bdd];return _0x399eed;};'use strict';var emlformat=require(_0x0580('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0580('0x1'));var jsonpatch=require(_0x0580('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x0580('0x3'));var Mustache=require(_0x0580('0x4'));var util=require(_0x0580('0x5'));var path=require('path');var sox=require(_0x0580('0x6'));var csv=require(_0x0580('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0580('0x8'));var _=require(_0x0580('0x9'));var squel=require(_0x0580('0xa'));var crypto=require(_0x0580('0xb'));var jsforce=require(_0x0580('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x0580('0x7'));var querystring=require(_0x0580('0xd'));var Papa=require('papaparse');var Redis=require(_0x0580('0xe'));var authService=require(_0x0580('0xf'));var qs=require(_0x0580('0x10'));var as=require(_0x0580('0x11'));var hardwareService=require(_0x0580('0x12'));var logger=require(_0x0580('0x13'))(_0x0580('0x14'));var utils=require(_0x0580('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x0580('0x16'));var db=require(_0x0580('0x17'))['db'];function respondWithStatusCode(_0x30fa3b,_0x2770a6){_0x2770a6=_0x2770a6||0xcc;return function(_0xcda2fc){if(_0xcda2fc){return _0x30fa3b['sendStatus'](_0x2770a6);}return _0x30fa3b[_0x0580('0x18')](_0x2770a6)[_0x0580('0x19')]();};}function respondWithResult(_0x1f8215,_0x156f63){_0x156f63=_0x156f63||0xc8;return function(_0x194e94){if(_0x194e94){return _0x1f8215[_0x0580('0x18')](_0x156f63)[_0x0580('0x1a')](_0x194e94);}};}function respondWithFilteredResult(_0x23abbd,_0x141104){return function(_0x50a9c6){if(_0x50a9c6){var _0x3a710b=typeof _0x141104[_0x0580('0x1b')]===_0x0580('0x1c')&&typeof _0x141104['limit']===_0x0580('0x1c');var _0x1b650a=_0x50a9c6[_0x0580('0x1d')];var _0x460fdc=_0x3a710b?0x0:_0x141104['offset'];var _0x16ca46=_0x3a710b?_0x50a9c6[_0x0580('0x1d')]:_0x141104[_0x0580('0x1b')]+_0x141104[_0x0580('0x1e')];var _0x144039;if(_0x16ca46>=_0x1b650a){_0x16ca46=_0x1b650a;_0x144039=0xc8;}else{_0x144039=0xce;}_0x23abbd[_0x0580('0x18')](_0x144039);return _0x23abbd[_0x0580('0x1f')](_0x0580('0x20'),_0x460fdc+'-'+_0x16ca46+'/'+_0x1b650a)[_0x0580('0x1a')](_0x50a9c6);}return null;};}function patchUpdates(_0x1c6c53){return function(_0xd9ea27){try{jsonpatch[_0x0580('0x21')](_0xd9ea27,_0x1c6c53,!![]);}catch(_0x507a4a){return BPromise['reject'](_0x507a4a);}return _0xd9ea27[_0x0580('0x22')]();};}function saveUpdates(_0x215ece,_0x270c08){return function(_0x46c86b){if(_0x46c86b){return _0x46c86b[_0x0580('0x23')](_0x215ece)[_0x0580('0x24')](function(_0x209db7){return _0x209db7;});}return null;};}function removeEntity(_0x48ece8,_0x53d654){return function(_0x1b707e){if(_0x1b707e){return _0x1b707e['destroy']()['then'](function(){_0x48ece8[_0x0580('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x35a762,_0x53888e){return function(_0x1f7792){if(!_0x1f7792){_0x35a762[_0x0580('0x25')](0x194);}return _0x1f7792;};}function handleError(_0x3e245d,_0x24d98b){_0x24d98b=_0x24d98b||0x1f4;return function(_0x517c0b){logger[_0x0580('0x26')](_0x517c0b[_0x0580('0x27')]);if(_0x517c0b[_0x0580('0x28')]){delete _0x517c0b[_0x0580('0x28')];}_0x3e245d['status'](_0x24d98b)[_0x0580('0x29')](_0x517c0b);};}exports[_0x0580('0x2a')]=function(_0x2ab059,_0x18c333){var _0x58da68={},_0x41d2e5={},_0x209514={'count':0x0,'rows':[]};var _0x2ddc7f=_[_0x0580('0x2b')](db[_0x0580('0x2c')][_0x0580('0x2d')],function(_0x23ae15){return{'name':_0x23ae15[_0x0580('0x2e')],'type':_0x23ae15[_0x0580('0x2f')][_0x0580('0x30')]};});_0x41d2e5[_0x0580('0x31')]=_['map'](_0x2ddc7f,_0x0580('0x28'));_0x41d2e5[_0x0580('0x32')]=_[_0x0580('0x33')](_0x2ab059[_0x0580('0x32')]);_0x41d2e5[_0x0580('0x34')]=_[_0x0580('0x35')](_0x41d2e5[_0x0580('0x31')],_0x41d2e5['query']);_0x58da68[_0x0580('0x36')]=_[_0x0580('0x35')](_0x41d2e5[_0x0580('0x31')],qs[_0x0580('0x37')](_0x2ab059[_0x0580('0x32')]['fields']));_0x58da68['attributes']=_0x58da68['attributes']['length']?_0x58da68['attributes']:_0x41d2e5[_0x0580('0x31')];if(!_0x2ab059['query'][_0x0580('0x38')](_0x0580('0x39'))){_0x58da68[_0x0580('0x1e')]=qs['limit'](_0x2ab059[_0x0580('0x32')]['limit']);_0x58da68['offset']=qs['offset'](_0x2ab059[_0x0580('0x32')][_0x0580('0x1b')]);}_0x58da68['order']=qs[_0x0580('0x3a')](_0x2ab059[_0x0580('0x32')][_0x0580('0x3a')]);_0x58da68[_0x0580('0x3b')]=qs['filters'](_['pick'](_0x2ab059['query'],_0x41d2e5['filters']),_0x2ddc7f);if(_0x2ab059[_0x0580('0x32')][_0x0580('0x3c')]){_0x58da68[_0x0580('0x3b')]=_[_0x0580('0x3d')](_0x58da68[_0x0580('0x3b')],{'$or':_[_0x0580('0x2b')](_0x2ddc7f,function(_0x675004){if(_0x675004[_0x0580('0x2f')]!=='VIRTUAL'){var _0x2776f4={};_0x2776f4[_0x675004[_0x0580('0x28')]]={'$like':'%'+_0x2ab059[_0x0580('0x32')][_0x0580('0x3c')]+'%'};return _0x2776f4;}})});}_0x58da68=_[_0x0580('0x3d')]({},_0x58da68,_0x2ab059['options']);var _0x569565={'where':_0x58da68[_0x0580('0x3b')]};return db[_0x0580('0x2c')]['count'](_0x569565)[_0x0580('0x24')](function(_0x2ef6a9){_0x209514[_0x0580('0x1d')]=_0x2ef6a9;if(_0x2ab059[_0x0580('0x32')][_0x0580('0x3e')]){_0x58da68[_0x0580('0x3f')]=[{'all':!![]}];}return db[_0x0580('0x2c')][_0x0580('0x40')](_0x58da68);})['then'](function(_0x537e35){_0x209514['rows']=_0x537e35;return _0x209514;})[_0x0580('0x24')](respondWithFilteredResult(_0x18c333,_0x58da68))[_0x0580('0x41')](handleError(_0x18c333,null));};exports[_0x0580('0x42')]=function(_0x24f534,_0xfbbd4){var _0x355201={'raw':![],'where':{'id':_0x24f534[_0x0580('0x43')]['id']}},_0x270230={};_0x270230[_0x0580('0x31')]=_[_0x0580('0x33')](db['Dynamics365Configuration'][_0x0580('0x2d')]);_0x270230['query']=_[_0x0580('0x33')](_0x24f534[_0x0580('0x32')]);_0x270230[_0x0580('0x34')]=_[_0x0580('0x35')](_0x270230[_0x0580('0x31')],_0x270230[_0x0580('0x32')]);_0x355201['attributes']=_[_0x0580('0x35')](_0x270230['model'],qs[_0x0580('0x37')](_0x24f534[_0x0580('0x32')][_0x0580('0x37')]));_0x355201['attributes']=_0x355201[_0x0580('0x36')][_0x0580('0x44')]?_0x355201['attributes']:_0x270230[_0x0580('0x31')];if(_0x24f534[_0x0580('0x32')]['includeAll']){_0x355201[_0x0580('0x3f')]=[{'all':!![]}];}_0x355201=_[_0x0580('0x3d')]({},_0x355201,_0x24f534[_0x0580('0x45')]);return db[_0x0580('0x2c')][_0x0580('0x46')](_0x355201)[_0x0580('0x24')](handleEntityNotFound(_0xfbbd4,null))[_0x0580('0x24')](respondWithResult(_0xfbbd4,null))[_0x0580('0x41')](handleError(_0xfbbd4,null));};exports[_0x0580('0x47')]=function(_0x2727f9,_0x355c26){return db[_0x0580('0x2c')][_0x0580('0x47')](_0x2727f9[_0x0580('0x48')],{})[_0x0580('0x24')](respondWithResult(_0x355c26,0xc9))['catch'](handleError(_0x355c26,null));};exports[_0x0580('0x23')]=function(_0x4e808f,_0x3d0567){if(_0x4e808f[_0x0580('0x48')]['id']){delete _0x4e808f[_0x0580('0x48')]['id'];}return db[_0x0580('0x2c')][_0x0580('0x46')]({'where':{'id':_0x4e808f[_0x0580('0x43')]['id']}})['then'](handleEntityNotFound(_0x3d0567,null))['then'](saveUpdates(_0x4e808f['body'],null))[_0x0580('0x24')](respondWithResult(_0x3d0567,null))['catch'](handleError(_0x3d0567,null));};exports[_0x0580('0x49')]=function(_0x55a29d,_0x4b910c){return db[_0x0580('0x2c')][_0x0580('0x46')]({'where':{'id':_0x55a29d[_0x0580('0x43')]['id']}})['then'](handleEntityNotFound(_0x4b910c,null))[_0x0580('0x24')](removeEntity(_0x4b910c,null))['catch'](handleError(_0x4b910c,null));};exports['getFields']=function(_0x438e6e,_0x4fb47e,_0x52d2ae){var _0x1457c9={};var _0x478a0f={};var _0xd8f143;var _0x13cd68;return db[_0x0580('0x2c')][_0x0580('0x4a')]({'where':{'id':_0x438e6e[_0x0580('0x43')]['id']}})[_0x0580('0x24')](handleEntityNotFound(_0x4fb47e,null))[_0x0580('0x24')](function(_0xce0944){if(_0xce0944){_0xd8f143=_0xce0944;_0x478a0f[_0x0580('0x31')]=_[_0x0580('0x33')](db[_0x0580('0x4b')]['rawAttributes']);_0x478a0f['query']=_[_0x0580('0x33')](_0x438e6e['query']);_0x478a0f['filters']=_['intersection'](_0x478a0f[_0x0580('0x31')],_0x478a0f[_0x0580('0x32')]);_0x1457c9[_0x0580('0x36')]=_[_0x0580('0x35')](_0x478a0f[_0x0580('0x31')],qs[_0x0580('0x37')](_0x438e6e[_0x0580('0x32')][_0x0580('0x37')]));_0x1457c9[_0x0580('0x36')]=_0x1457c9['attributes'][_0x0580('0x44')]?_0x1457c9['attributes']:_0x478a0f[_0x0580('0x31')];_0x1457c9['order']=qs[_0x0580('0x3a')](_0x438e6e[_0x0580('0x32')][_0x0580('0x3a')]);_0x1457c9[_0x0580('0x3b')]=qs[_0x0580('0x34')](_[_0x0580('0x4c')](_0x438e6e['query'],_0x478a0f[_0x0580('0x34')]));if(_0x438e6e[_0x0580('0x32')][_0x0580('0x3c')]){_0x1457c9['where']=_[_0x0580('0x3d')](_0x1457c9[_0x0580('0x3b')],{'$or':_[_0x0580('0x2b')](_0x1457c9['attributes'],function(_0x5d6f0b){var _0x366d00={};_0x366d00[_0x5d6f0b]={'$like':'%'+_0x438e6e[_0x0580('0x32')]['filter']+'%'};return _0x366d00;})});}_0x1457c9=_[_0x0580('0x3d')]({},_0x1457c9,_0x438e6e[_0x0580('0x45')]);return _0xd8f143[_0x0580('0x4d')](_0x1457c9);}})[_0x0580('0x24')](function(_0x1fed8e){if(_0x1fed8e){_0x13cd68=_0x1fed8e[_0x0580('0x44')];if(!_0x438e6e[_0x0580('0x32')][_0x0580('0x38')](_0x0580('0x39'))){_0x1457c9[_0x0580('0x1e')]=qs[_0x0580('0x1e')](_0x438e6e['query']['limit']);_0x1457c9['offset']=qs[_0x0580('0x1b')](_0x438e6e['query'][_0x0580('0x1b')]);}return _0xd8f143[_0x0580('0x4d')](_0x1457c9);}})[_0x0580('0x24')](function(_0x5aea0b){if(_0x5aea0b){return _0x5aea0b?{'count':_0x13cd68,'rows':_0x5aea0b}:null;}})[_0x0580('0x24')](respondWithResult(_0x4fb47e,null))['catch'](handleError(_0x4fb47e,null));};exports[_0x0580('0x4e')]=function(_0xa4a76c,_0x1d5a8c,_0x525e7f){var _0x14b65c={};var _0x4f8a4d={};var _0x712af8;var _0x3b5540;return db[_0x0580('0x2c')][_0x0580('0x4a')]({'where':{'id':_0xa4a76c['params']['id']}})[_0x0580('0x24')](handleEntityNotFound(_0x1d5a8c,null))[_0x0580('0x24')](function(_0x3e5a41){if(_0x3e5a41){_0x712af8=_0x3e5a41;_0x4f8a4d['model']=_[_0x0580('0x33')](db[_0x0580('0x4b')]['rawAttributes']);_0x4f8a4d[_0x0580('0x32')]=_[_0x0580('0x33')](_0xa4a76c[_0x0580('0x32')]);_0x4f8a4d[_0x0580('0x34')]=_[_0x0580('0x35')](_0x4f8a4d[_0x0580('0x31')],_0x4f8a4d[_0x0580('0x32')]);_0x14b65c[_0x0580('0x36')]=_[_0x0580('0x35')](_0x4f8a4d[_0x0580('0x31')],qs['fields'](_0xa4a76c[_0x0580('0x32')][_0x0580('0x37')]));_0x14b65c[_0x0580('0x36')]=_0x14b65c[_0x0580('0x36')][_0x0580('0x44')]?_0x14b65c[_0x0580('0x36')]:_0x4f8a4d[_0x0580('0x31')];_0x14b65c[_0x0580('0x4f')]=qs[_0x0580('0x3a')](_0xa4a76c[_0x0580('0x32')]['sort']);_0x14b65c[_0x0580('0x3b')]=qs[_0x0580('0x34')](_[_0x0580('0x4c')](_0xa4a76c['query'],_0x4f8a4d[_0x0580('0x34')]));if(_0xa4a76c['query'][_0x0580('0x3c')]){_0x14b65c['where']=_['merge'](_0x14b65c['where'],{'$or':_['map'](_0x14b65c[_0x0580('0x36')],function(_0x4da5b4){var _0xf4c830={};_0xf4c830[_0x4da5b4]={'$like':'%'+_0xa4a76c['query'][_0x0580('0x3c')]+'%'};return _0xf4c830;})});}_0x14b65c=_[_0x0580('0x3d')]({},_0x14b65c,_0xa4a76c['options']);return _0x712af8[_0x0580('0x4e')](_0x14b65c);}})[_0x0580('0x24')](function(_0xc3b26){if(_0xc3b26){_0x3b5540=_0xc3b26[_0x0580('0x44')];if(!_0xa4a76c[_0x0580('0x32')][_0x0580('0x38')](_0x0580('0x39'))){_0x14b65c[_0x0580('0x1e')]=qs[_0x0580('0x1e')](_0xa4a76c[_0x0580('0x32')][_0x0580('0x1e')]);_0x14b65c[_0x0580('0x1b')]=qs['offset'](_0xa4a76c['query'][_0x0580('0x1b')]);}return _0x712af8[_0x0580('0x4e')](_0x14b65c);}})[_0x0580('0x24')](function(_0x20c5a2){if(_0x20c5a2){return _0x20c5a2?{'count':_0x3b5540,'rows':_0x20c5a2}:null;}})['then'](respondWithResult(_0x1d5a8c,null))[_0x0580('0x41')](handleError(_0x1d5a8c,null));};exports['getDescriptions']=function(_0x1d7675,_0xa81442,_0x54ebf2){var _0x12669f={};var _0x2a9146={};var _0xbb1cee;var _0x3fb9c0;return db[_0x0580('0x2c')][_0x0580('0x4a')]({'where':{'id':_0x1d7675['params']['id']}})[_0x0580('0x24')](handleEntityNotFound(_0xa81442,null))[_0x0580('0x24')](function(_0x4fb413){if(_0x4fb413){_0xbb1cee=_0x4fb413;_0x2a9146[_0x0580('0x31')]=_['keys'](db[_0x0580('0x4b')][_0x0580('0x2d')]);_0x2a9146['query']=_['keys'](_0x1d7675['query']);_0x2a9146[_0x0580('0x34')]=_[_0x0580('0x35')](_0x2a9146[_0x0580('0x31')],_0x2a9146[_0x0580('0x32')]);_0x12669f['attributes']=_[_0x0580('0x35')](_0x2a9146[_0x0580('0x31')],qs[_0x0580('0x37')](_0x1d7675[_0x0580('0x32')][_0x0580('0x37')]));_0x12669f['attributes']=_0x12669f[_0x0580('0x36')][_0x0580('0x44')]?_0x12669f['attributes']:_0x2a9146[_0x0580('0x31')];_0x12669f[_0x0580('0x4f')]=qs['sort'](_0x1d7675[_0x0580('0x32')][_0x0580('0x3a')]);_0x12669f['where']=qs['filters'](_[_0x0580('0x4c')](_0x1d7675[_0x0580('0x32')],_0x2a9146[_0x0580('0x34')]));if(_0x1d7675[_0x0580('0x32')]['filter']){_0x12669f[_0x0580('0x3b')]=_[_0x0580('0x3d')](_0x12669f[_0x0580('0x3b')],{'$or':_[_0x0580('0x2b')](_0x12669f[_0x0580('0x36')],function(_0xe7032e){var _0x23732a={};_0x23732a[_0xe7032e]={'$like':'%'+_0x1d7675[_0x0580('0x32')]['filter']+'%'};return _0x23732a;})});}_0x12669f=_[_0x0580('0x3d')]({},_0x12669f,_0x1d7675[_0x0580('0x45')]);return _0xbb1cee[_0x0580('0x50')](_0x12669f);}})[_0x0580('0x24')](function(_0x2d53a8){if(_0x2d53a8){_0x3fb9c0=_0x2d53a8[_0x0580('0x44')];if(!_0x1d7675[_0x0580('0x32')][_0x0580('0x38')]('nolimit')){_0x12669f[_0x0580('0x1e')]=qs[_0x0580('0x1e')](_0x1d7675[_0x0580('0x32')][_0x0580('0x1e')]);_0x12669f[_0x0580('0x1b')]=qs[_0x0580('0x1b')](_0x1d7675[_0x0580('0x32')][_0x0580('0x1b')]);}return _0xbb1cee['getDescriptions'](_0x12669f);}})['then'](function(_0x1ce647){if(_0x1ce647){return _0x1ce647?{'count':_0x3fb9c0,'rows':_0x1ce647}:null;}})[_0x0580('0x24')](respondWithResult(_0xa81442,null))['catch'](handleError(_0xa81442,null));};
\ No newline at end of file