Built motion from commit (unavailable).|2.5.16
[motion2.git] / server / api / jscriptyProject / jscriptyProject.controller.js
index afa38ff..7f08768 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf749=['isEmpty','now','writeFileSync','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','attachment;\x20filename=','Jscripty_Project_%d_Summary_%s.csv','Content-type','text/csv','download','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','destroy','then','get','Projects','UserProfileResource','error','name','send','rawAttributes','fieldName','type','key','model','map','query','intersection','fields','attributes','hasOwnProperty','order','sort','filters','pick','filter','where','merge','options','includeAll','JscriptyProject','findAll','rows','show','params','keys','include','find','create','user','role','userProfileId','autoAssociation','catch','clone','length','omit','createdAt','updatedAt','body','UserProfileSection','getSessions','findOne','JscriptySessionReport','nolimit','JscriptyAnswerReport','number','fromCharCode','toString','indexOf','replace','getSummary','startTime','starttime','parse','JscriptyQuestionReport','-createdAt','questionId','question','format','SessionId','answer','push'];(function(_0x167cc1,_0x56ef5a){var _0x10bc4b=function(_0xd6a255){while(--_0xd6a255){_0x167cc1['push'](_0x167cc1['shift']());}};_0x10bc4b(++_0x56ef5a);}(_0xf749,0xf0));var _0x9f74=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0xf749[_0x57b54c];return _0x59cc19;};'use strict';var pdf=require(_0x9f74('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x9f74('0x1'));var zipdir=require(_0x9f74('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9f74('0x3'));var moment=require(_0x9f74('0x4'));var BPromise=require(_0x9f74('0x5'));var Mustache=require(_0x9f74('0x6'));var util=require(_0x9f74('0x7'));var path=require(_0x9f74('0x8'));var sox=require('sox');var csv=require(_0x9f74('0x9'));var ejs=require(_0x9f74('0xa'));var fs=require('fs');var _=require(_0x9f74('0xb'));var squel=require(_0x9f74('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x9f74('0x9'));var querystring=require(_0x9f74('0xd'));var Papa=require(_0x9f74('0xe'));var Redis=require(_0x9f74('0xf'));var authService=require(_0x9f74('0x10'));var qs=require(_0x9f74('0x11'));var as=require(_0x9f74('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9f74('0x13'))(_0x9f74('0x14'));var utils=require('../../config/utils');var config=require(_0x9f74('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x289d28,_0x2dcced){_0x2dcced=_0x2dcced||0xcc;return function(_0x1f820d){if(_0x1f820d){return _0x289d28[_0x9f74('0x16')](_0x2dcced);}return _0x289d28[_0x9f74('0x17')](_0x2dcced)[_0x9f74('0x18')]();};}function respondWithResult(_0x2ec61d,_0x39f352){_0x39f352=_0x39f352||0xc8;return function(_0x3df5bd){if(_0x3df5bd){return _0x2ec61d['status'](_0x39f352)[_0x9f74('0x19')](_0x3df5bd);}};}function respondWithFilteredResult(_0x238480,_0x1de9f4){return function(_0x599055){if(_0x599055){var _0x51a00f=_0x599055[_0x9f74('0x1a')],_0x2bbd47=_0x1de9f4['offset'],_0x1c00e6=_0x1de9f4[_0x9f74('0x1b')]+_0x1de9f4[_0x9f74('0x1c')],_0x230876;if(_0x1c00e6>=_0x51a00f){_0x1c00e6=_0x51a00f;_0x230876=0xc8;}else{_0x230876=0xce;}_0x238480[_0x9f74('0x17')](_0x230876);return _0x238480[_0x9f74('0x1d')](_0x9f74('0x1e'),_0x2bbd47+'-'+_0x1c00e6+'/'+_0x51a00f)['json'](_0x599055);}return null;};}function patchUpdates(_0x1278e4){return function(_0x46e5dd){try{jsonpatch[_0x9f74('0x1f')](_0x46e5dd,_0x1278e4,!![]);}catch(_0x295fab){return BPromise[_0x9f74('0x20')](_0x295fab);}return _0x46e5dd['save']();};}function saveUpdates(_0x1081eb,_0x5db1c9){return function(_0x4446ea){if(_0x4446ea){return _0x4446ea[_0x9f74('0x21')](_0x1081eb)['then'](function(_0x4b9371){return _0x4b9371;});}return null;};}function removeEntity(_0x4ca25d,_0x393f37){return function(_0x116da4){if(_0x116da4){return _0x116da4[_0x9f74('0x22')]()[_0x9f74('0x23')](function(){var _0x1385b6=_0x116da4[_0x9f74('0x24')]({'plain':!![]});var _0x365168=_0x9f74('0x25');return db[_0x9f74('0x26')][_0x9f74('0x22')]({'where':{'type':_0x365168,'resourceId':_0x1385b6['id']}})[_0x9f74('0x23')](function(){return _0x116da4;});})[_0x9f74('0x23')](function(){_0x4ca25d['status'](0xcc)[_0x9f74('0x18')]();});}};}function handleEntityNotFound(_0x578f38,_0x5036d0){return function(_0x443fcc){if(!_0x443fcc){_0x578f38[_0x9f74('0x16')](0x194);}return _0x443fcc;};}function handleError(_0x1e3d01,_0x1326a8){_0x1326a8=_0x1326a8||0x1f4;return function(_0x3c2133){logger[_0x9f74('0x27')](_0x3c2133['stack']);if(_0x3c2133[_0x9f74('0x28')]){delete _0x3c2133[_0x9f74('0x28')];}_0x1e3d01[_0x9f74('0x17')](_0x1326a8)[_0x9f74('0x29')](_0x3c2133);};}exports['index']=function(_0x3bc14a,_0x3b106d){var _0x1aa123={},_0x150626={},_0x42c780={'count':0x0,'rows':[]};var _0x63ca49=_['map'](db['JscriptyProject'][_0x9f74('0x2a')],function(_0x7456bf){return{'name':_0x7456bf[_0x9f74('0x2b')],'type':_0x7456bf[_0x9f74('0x2c')][_0x9f74('0x2d')]};});_0x150626[_0x9f74('0x2e')]=_[_0x9f74('0x2f')](_0x63ca49,_0x9f74('0x28'));_0x150626[_0x9f74('0x30')]=_['keys'](_0x3bc14a[_0x9f74('0x30')]);_0x150626['filters']=_['intersection'](_0x150626['model'],_0x150626[_0x9f74('0x30')]);_0x1aa123['attributes']=_[_0x9f74('0x31')](_0x150626[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x32')]));_0x1aa123[_0x9f74('0x33')]=_0x1aa123[_0x9f74('0x33')]['length']?_0x1aa123['attributes']:_0x150626[_0x9f74('0x2e')];if(!_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x34')]('nolimit')){_0x1aa123[_0x9f74('0x1c')]=qs[_0x9f74('0x1c')](_0x3bc14a['query']['limit']);_0x1aa123[_0x9f74('0x1b')]=qs['offset'](_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x1b')]);}_0x1aa123[_0x9f74('0x35')]=qs['sort'](_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x36')]);_0x1aa123['where']=qs[_0x9f74('0x37')](_[_0x9f74('0x38')](_0x3bc14a[_0x9f74('0x30')],_0x150626[_0x9f74('0x37')]));if(_0x3bc14a['query'][_0x9f74('0x39')]){_0x1aa123[_0x9f74('0x3a')]=_[_0x9f74('0x3b')](_0x1aa123[_0x9f74('0x3a')],{'$or':_[_0x9f74('0x2f')](_0x63ca49,function(_0x5e6433){if(_0x5e6433[_0x9f74('0x2c')]!=='VIRTUAL'){var _0x3553df={};_0x3553df[_0x5e6433[_0x9f74('0x28')]]={'$like':'%'+_0x3bc14a['query']['filter']+'%'};return _0x3553df;}})});}_0x1aa123=_[_0x9f74('0x3b')]({},_0x1aa123,_0x3bc14a[_0x9f74('0x3c')]);var _0x334c22={'where':_0x1aa123['where']};return db['JscriptyProject'][_0x9f74('0x1a')](_0x334c22)[_0x9f74('0x23')](function(_0x1f5851){_0x42c780['count']=_0x1f5851;if(_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x1aa123['include']=[{'all':!![]}];}return db[_0x9f74('0x3e')][_0x9f74('0x3f')](_0x1aa123);})[_0x9f74('0x23')](function(_0x25eac0){_0x42c780[_0x9f74('0x40')]=_0x25eac0;return _0x42c780;})['then'](respondWithFilteredResult(_0x3b106d,_0x1aa123))['catch'](handleError(_0x3b106d,null));};exports[_0x9f74('0x41')]=function(_0x53919f,_0x398910){var _0x514ff3={'raw':![],'where':{'id':_0x53919f[_0x9f74('0x42')]['id']}},_0x6846be={};_0x6846be[_0x9f74('0x2e')]=_[_0x9f74('0x43')](db[_0x9f74('0x3e')][_0x9f74('0x2a')]);_0x6846be[_0x9f74('0x30')]=_[_0x9f74('0x43')](_0x53919f[_0x9f74('0x30')]);_0x6846be[_0x9f74('0x37')]=_[_0x9f74('0x31')](_0x6846be[_0x9f74('0x2e')],_0x6846be[_0x9f74('0x30')]);_0x514ff3['attributes']=_[_0x9f74('0x31')](_0x6846be[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x53919f['query']['fields']));_0x514ff3[_0x9f74('0x33')]=_0x514ff3[_0x9f74('0x33')]['length']?_0x514ff3[_0x9f74('0x33')]:_0x6846be[_0x9f74('0x2e')];if(_0x53919f[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x514ff3[_0x9f74('0x44')]=[{'all':!![]}];}_0x514ff3=_[_0x9f74('0x3b')]({},_0x514ff3,_0x53919f['options']);return db[_0x9f74('0x3e')][_0x9f74('0x45')](_0x514ff3)[_0x9f74('0x23')](handleEntityNotFound(_0x398910,null))[_0x9f74('0x23')](respondWithResult(_0x398910,null))['catch'](handleError(_0x398910,null));};exports[_0x9f74('0x46')]=function(_0x355dab,_0x301515){return db[_0x9f74('0x3e')][_0x9f74('0x46')](_0x355dab['body'],{})[_0x9f74('0x23')](function(_0x464e1a){var _0x14a306=_0x355dab[_0x9f74('0x47')]['get']({'plain':!![]});if(!_0x14a306)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x14a306[_0x9f74('0x48')]===_0x9f74('0x47')){var _0x4f4c1a=_0x464e1a[_0x9f74('0x24')]({'plain':!![]});var _0x502f77='Projects';return db['UserProfileSection']['find']({'where':{'name':_0x502f77,'userProfileId':_0x14a306[_0x9f74('0x49')]},'raw':!![]})[_0x9f74('0x23')](function(_0x4bb2bf){if(_0x4bb2bf&&_0x4bb2bf[_0x9f74('0x4a')]===0x0){return db[_0x9f74('0x26')]['create']({'name':_0x4f4c1a[_0x9f74('0x28')],'resourceId':_0x4f4c1a['id'],'type':_0x4bb2bf[_0x9f74('0x28')],'sectionId':_0x4bb2bf['id']},{})[_0x9f74('0x23')](function(){return _0x464e1a;});}else{return _0x464e1a;}})[_0x9f74('0x4b')](function(_0x133757){logger[_0x9f74('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x133757);throw _0x133757;});}return _0x464e1a;})[_0x9f74('0x23')](respondWithResult(_0x301515,0xc9))[_0x9f74('0x4b')](handleError(_0x301515,null));};exports[_0x9f74('0x4c')]=function(_0x3478b2,_0x5b56a){var _0x2b18f9={'where':{'id':_0x3478b2[_0x9f74('0x42')]['id']}},_0x156ba7={};_0x156ba7[_0x9f74('0x2e')]=_['keys'](db[_0x9f74('0x3e')][_0x9f74('0x2a')]);_0x2b18f9[_0x9f74('0x33')]=_[_0x9f74('0x31')](_0x156ba7[_0x9f74('0x2e')],qs['fields'](_0x3478b2[_0x9f74('0x30')]['fields']));_0x2b18f9[_0x9f74('0x33')]=_0x2b18f9[_0x9f74('0x33')][_0x9f74('0x4d')]?_0x2b18f9[_0x9f74('0x33')]:_0x156ba7[_0x9f74('0x2e')];if(_0x3478b2[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x2b18f9['include']=[{'all':!![]}];}_0x2b18f9=_[_0x9f74('0x3b')]({},_0x2b18f9,_0x3478b2['options']);return db[_0x9f74('0x3e')][_0x9f74('0x45')](_0x2b18f9)[_0x9f74('0x23')](handleEntityNotFound(_0x5b56a,null))[_0x9f74('0x23')](function(_0x19ff30){if(_0x19ff30){var _0x379757=_0x19ff30[_0x9f74('0x24')]({'plain':!![]});_0x379757=qs[_0x9f74('0x4e')](_0x379757,['id',_0x9f74('0x4f'),_0x9f74('0x50')]);_0x3478b2[_0x9f74('0x51')]=_[_0x9f74('0x4e')](_0x3478b2[_0x9f74('0x51')],['id','createdAt',_0x9f74('0x50')]);return db[_0x9f74('0x3e')][_0x9f74('0x46')](_[_0x9f74('0x3b')](_0x379757,_0x3478b2[_0x9f74('0x51')]),{'include':_0x3478b2['query'][_0x9f74('0x3d')]?[{'all':!![]}]:undefined})[_0x9f74('0x23')](function(_0x33f0d1){var _0x1d3814=_0x3478b2[_0x9f74('0x47')]['get']({'plain':!![]});if(!_0x1d3814)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1d3814[_0x9f74('0x48')]===_0x9f74('0x47')){var _0x2e344b=_0x33f0d1[_0x9f74('0x24')]({'plain':!![]});var _0x2b46b5='Projects';return db[_0x9f74('0x52')][_0x9f74('0x45')]({'where':{'name':_0x2b46b5,'userProfileId':_0x1d3814[_0x9f74('0x49')]},'raw':!![]})['then'](function(_0x1fdb14){if(_0x1fdb14&&_0x1fdb14[_0x9f74('0x4a')]===0x0){return db[_0x9f74('0x26')][_0x9f74('0x46')]({'name':_0x2e344b[_0x9f74('0x28')],'resourceId':_0x2e344b['id'],'type':_0x1fdb14[_0x9f74('0x28')],'sectionId':_0x1fdb14['id']},{})[_0x9f74('0x23')](function(){return _0x33f0d1;});}else{return _0x33f0d1;}})[_0x9f74('0x4b')](function(_0x36c4c7){logger[_0x9f74('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x36c4c7);throw _0x36c4c7;});}return _0x33f0d1;});}})[_0x9f74('0x23')](respondWithResult(_0x5b56a,0xc9))[_0x9f74('0x4b')](handleError(_0x5b56a,null));};exports[_0x9f74('0x21')]=function(_0xcb71b0,_0x264214){if(_0xcb71b0['body']['id']){delete _0xcb71b0[_0x9f74('0x51')]['id'];}return db['JscriptyProject'][_0x9f74('0x45')]({'where':{'id':_0xcb71b0[_0x9f74('0x42')]['id']}})[_0x9f74('0x23')](handleEntityNotFound(_0x264214,null))[_0x9f74('0x23')](saveUpdates(_0xcb71b0[_0x9f74('0x51')],null))[_0x9f74('0x23')](respondWithResult(_0x264214,null))[_0x9f74('0x4b')](handleError(_0x264214,null));};exports[_0x9f74('0x22')]=function(_0x466793,_0x31f5b1){return db[_0x9f74('0x3e')]['find']({'where':{'id':_0x466793[_0x9f74('0x42')]['id']}})['then'](handleEntityNotFound(_0x31f5b1,null))[_0x9f74('0x23')](removeEntity(_0x31f5b1,null))[_0x9f74('0x4b')](handleError(_0x31f5b1,null));};exports[_0x9f74('0x53')]=function(_0x57e0c1,_0x3fe446,_0x29f67e){var _0x2b92f1={'raw':!![],'where':{}};var _0x1c90d3={};var _0x1f7400={'count':0x0,'rows':[]};return db[_0x9f74('0x3e')][_0x9f74('0x54')]({'where':{'id':_0x57e0c1['params']['id']}})[_0x9f74('0x23')](handleEntityNotFound(_0x3fe446,null))['then'](function(_0x3c8c33){if(_0x3c8c33){_0x1c90d3[_0x9f74('0x2e')]=_[_0x9f74('0x43')](db[_0x9f74('0x55')][_0x9f74('0x2a')]);_0x1c90d3[_0x9f74('0x30')]=_[_0x9f74('0x43')](_0x57e0c1['query']);_0x1c90d3[_0x9f74('0x37')]=_[_0x9f74('0x31')](_0x1c90d3[_0x9f74('0x2e')],_0x1c90d3[_0x9f74('0x30')]);_0x2b92f1[_0x9f74('0x33')]=_[_0x9f74('0x31')](_0x1c90d3[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x57e0c1['query']['fields']));_0x2b92f1[_0x9f74('0x33')]=_0x2b92f1['attributes']['length']?_0x2b92f1[_0x9f74('0x33')]:_0x1c90d3['model'];if(!_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x34')](_0x9f74('0x56'))){_0x2b92f1[_0x9f74('0x1c')]=qs[_0x9f74('0x1c')](_0x57e0c1['query'][_0x9f74('0x1c')]);_0x2b92f1[_0x9f74('0x1b')]=qs[_0x9f74('0x1b')](_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x1b')]);}_0x2b92f1[_0x9f74('0x35')]=qs[_0x9f74('0x36')](_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x36')]);_0x2b92f1['where']=qs['filters'](_[_0x9f74('0x38')](_0x57e0c1['query'],_0x1c90d3[_0x9f74('0x37')]));_0x2b92f1['where']['ProjectId']=_0x3c8c33['id'];if(_0x57e0c1['query'][_0x9f74('0x39')]){_0x2b92f1[_0x9f74('0x3a')]=_[_0x9f74('0x3b')](_0x2b92f1[_0x9f74('0x3a')],{'$or':_[_0x9f74('0x2f')](_0x2b92f1[_0x9f74('0x33')],function(_0x5d865a){var _0x419be5={};_0x419be5[_0x5d865a]={'$like':'%'+_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x39')]+'%'};return _0x419be5;})});}_0x2b92f1=_['merge']({},_0x2b92f1,_0x57e0c1[_0x9f74('0x3c')]);return db['JscriptySessionReport'][_0x9f74('0x1a')]({'where':_0x2b92f1[_0x9f74('0x3a')]})['then'](function(_0x4272ad){_0x1f7400['count']=_0x4272ad;if(_0x57e0c1['query'][_0x9f74('0x3d')]){_0x2b92f1[_0x9f74('0x44')]=[{'all':!![]}];}return db[_0x9f74('0x55')]['findAll'](_0x2b92f1);})['then'](function(_0x2551c5){_0x1f7400[_0x9f74('0x40')]=_0x2551c5;return _0x1f7400;});}})[_0x9f74('0x23')](respondWithFilteredResult(_0x3fe446,_0x2b92f1))['catch'](handleError(_0x3fe446,null));};exports['getAnswers']=function(_0x5008fb,_0x4f1222,_0x427296){var _0x1b9345={'raw':!![],'where':{}};var _0x38d78d={};var _0x58f833={'count':0x0,'rows':[]};return db[_0x9f74('0x3e')][_0x9f74('0x54')]({'where':{'id':_0x5008fb[_0x9f74('0x42')]['id']}})[_0x9f74('0x23')](handleEntityNotFound(_0x4f1222,null))['then'](function(_0x11d4f7){if(_0x11d4f7){_0x38d78d[_0x9f74('0x2e')]=_[_0x9f74('0x43')](db[_0x9f74('0x57')][_0x9f74('0x2a')]);_0x38d78d[_0x9f74('0x30')]=_['keys'](_0x5008fb[_0x9f74('0x30')]);_0x38d78d[_0x9f74('0x37')]=_[_0x9f74('0x31')](_0x38d78d[_0x9f74('0x2e')],_0x38d78d[_0x9f74('0x30')]);_0x1b9345[_0x9f74('0x33')]=_[_0x9f74('0x31')](_0x38d78d[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x5008fb[_0x9f74('0x30')]['fields']));_0x1b9345[_0x9f74('0x33')]=_0x1b9345[_0x9f74('0x33')][_0x9f74('0x4d')]?_0x1b9345[_0x9f74('0x33')]:_0x38d78d[_0x9f74('0x2e')];if(!_0x5008fb[_0x9f74('0x30')][_0x9f74('0x34')](_0x9f74('0x56'))){_0x1b9345['limit']=qs[_0x9f74('0x1c')](_0x5008fb['query'][_0x9f74('0x1c')]);_0x1b9345[_0x9f74('0x1b')]=qs[_0x9f74('0x1b')](_0x5008fb[_0x9f74('0x30')][_0x9f74('0x1b')]);}_0x1b9345['order']=qs[_0x9f74('0x36')](_0x5008fb[_0x9f74('0x30')]['sort']);_0x1b9345[_0x9f74('0x3a')]=qs['filters'](_[_0x9f74('0x38')](_0x5008fb['query'],_0x38d78d['filters']));_0x1b9345[_0x9f74('0x3a')]['ProjectId']=_0x11d4f7['id'];if(_0x5008fb[_0x9f74('0x30')][_0x9f74('0x39')]){_0x1b9345[_0x9f74('0x3a')]=_['merge'](_0x1b9345[_0x9f74('0x3a')],{'$or':_[_0x9f74('0x2f')](_0x1b9345[_0x9f74('0x33')],function(_0x3cfbed){var _0xba4dc={};_0xba4dc[_0x3cfbed]={'$like':'%'+_0x5008fb[_0x9f74('0x30')][_0x9f74('0x39')]+'%'};return _0xba4dc;})});}_0x1b9345=_['merge']({},_0x1b9345,_0x5008fb[_0x9f74('0x3c')]);return db[_0x9f74('0x57')]['count']({'where':_0x1b9345[_0x9f74('0x3a')]})[_0x9f74('0x23')](function(_0x1ac09e){_0x58f833[_0x9f74('0x1a')]=_0x1ac09e;if(_0x5008fb[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x1b9345[_0x9f74('0x44')]=[{'all':!![]}];}return db[_0x9f74('0x57')][_0x9f74('0x3f')](_0x1b9345);})[_0x9f74('0x23')](function(_0x2fde96){_0x58f833[_0x9f74('0x40')]=_0x2fde96;return _0x58f833;});}})[_0x9f74('0x23')](respondWithFilteredResult(_0x4f1222,_0x1b9345))[_0x9f74('0x4b')](handleError(_0x4f1222,null));};function char(_0xb93015){return _0x9f74('0x58')===typeof _0xb93015?String[_0x9f74('0x59')][_0x9f74('0x1f')](null,arguments):_0xb93015;}function needsEncapsulation(_0x11e96e){return!!_0x11e96e&&(_0x11e96e[_0x9f74('0x5a')]()[_0x9f74('0x5b')](char(0xd))>=0x0||_0x11e96e[_0x9f74('0x5a')]()['indexOf'](char(0xa))>=0x0||_0x11e96e[_0x9f74('0x5a')]()['indexOf'](char(0x2c))>=0x0||_0x11e96e['toString']()[_0x9f74('0x5b')](char(0x22))>=0x0);}function encapsulate(_0x59bb72){var _0x8334d6=char(0x22),_0x29e0dc='\x5c'+char(0x22),_0x275c34=_0x59bb72['toString']()[_0x9f74('0x5c')](new RegExp(_0x8334d6,'g'),_0x29e0dc);return _0x8334d6+_0x275c34+_0x8334d6;}exports[_0x9f74('0x5d')]=function(_0x45cac3,_0x4f8ec5,_0x239e41){var _0x57304b,_0x51409e;var _0x5afe95={'where':{'ProjectId':_0x45cac3[_0x9f74('0x42')]['id']}};if(_0x45cac3[_0x9f74('0x30')][_0x9f74('0x5e')]){_0x5afe95[_0x9f74('0x3a')][_0x9f74('0x5f')]=JSON[_0x9f74('0x60')](_0x45cac3['query'][_0x9f74('0x5e')]);}return db['JscriptySessionReport'][_0x9f74('0x3f')](_0x5afe95)[_0x9f74('0x23')](handleEntityNotFound(_0x4f8ec5,null))['then'](function(_0x13bc3b){if(_0x13bc3b){_0x57304b=_0x13bc3b;return db[_0x9f74('0x61')]['findAll']({'where':{'SessionId':{'$in':_[_0x9f74('0x2f')](_0x57304b,'id')},'ProjectId':_0x45cac3[_0x9f74('0x42')]['id']},'order':_0x9f74('0x62')});}})[_0x9f74('0x23')](handleEntityNotFound(_0x4f8ec5,null))[_0x9f74('0x23')](function(_0x39b913){if(_0x39b913){_0x51409e=_0x39b913;var _0x1cd70a={};for(var _0x5bd726=0x0,_0x49e276=_0x51409e[_0x9f74('0x4d')];_0x5bd726<_0x49e276;_0x5bd726++){if(!_0x1cd70a[_0x9f74('0x34')](_0x51409e[_0x5bd726]['questionId'])){_0x1cd70a[_0x51409e[_0x5bd726][_0x9f74('0x63')]]=needsEncapsulation(_0x51409e[_0x5bd726]['question'])?encapsulate(_0x51409e[_0x5bd726][_0x9f74('0x64')]):_0x51409e[_0x5bd726][_0x9f74('0x64')];}}var _0x12ea5a=[],_0x3ab1a2={};for(var _0x2a95fe=0x0,_0x34e070=_0x57304b[_0x9f74('0x4d')];_0x2a95fe<_0x34e070;_0x2a95fe++){_0x3ab1a2={'ProjectId':_0x45cac3['params']['id'],'SessionId':_0x57304b[_0x2a95fe]['id'],'StartTime':moment(_0x57304b[_0x2a95fe][_0x9f74('0x5f')])[_0x9f74('0x65')]('YYYY-MM-DD\x20HH:mm:ss')};for(var _0x54a605=0x0,_0x341a14=_0x51409e[_0x9f74('0x4d')];_0x54a605<_0x341a14;_0x54a605++){if(_0x51409e[_0x54a605][_0x9f74('0x66')]==_0x57304b[_0x2a95fe]['id']&&_0x1cd70a[_0x9f74('0x34')](_0x51409e[_0x54a605][_0x9f74('0x63')])){_0x3ab1a2[_0x1cd70a[_0x51409e[_0x54a605]['questionId']]]=_0x51409e[_0x54a605][_0x9f74('0x67')];}}for(var _0x4d1c49 in _0x1cd70a){if(!_0x3ab1a2[_0x9f74('0x34')](_0x1cd70a[_0x4d1c49])){_0x3ab1a2[_0x1cd70a[_0x4d1c49]]=null;}}_0x12ea5a[_0x9f74('0x68')](_0x3ab1a2);}return _0x12ea5a;}})['then'](function(_0x5b005d){if(!_[_0x9f74('0x69')](_0x5b005d)){var _0x2f8ee3=toCsv(_0x5b005d);var _0x48c293=Date[_0x9f74('0x6a')]();fs[_0x9f74('0x6b')](util['format'](_0x9f74('0x6c'),_0x45cac3[_0x9f74('0x42')]['id'],_0x48c293),_0x2f8ee3);_0x4f8ec5[_0x9f74('0x6d')]('Content-disposition',_0x9f74('0x6e')+util[_0x9f74('0x65')](_0x9f74('0x6f'),_0x45cac3[_0x9f74('0x42')]['id'],_0x48c293));_0x4f8ec5[_0x9f74('0x6d')](_0x9f74('0x70'),_0x9f74('0x71'));return _0x4f8ec5[_0x9f74('0x72')](util['format'](_0x9f74('0x6c'),_0x45cac3[_0x9f74('0x42')]['id'],_0x48c293));}else{return _0x4f8ec5['sendStatus'](0xcc);}})[_0x9f74('0x4b')](handleError(_0x4f8ec5,null));};
\ No newline at end of file
+var _0x415c=['Jscripty_Project_%d_Summary_%s.csv','Content-type','text/csv','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','status','end','json','count','offset','limit','set','apply','reject','save','update','then','destroy','get','Projects','UserProfileResource','sendStatus','error','stack','name','send','index','map','JscriptyProject','rawAttributes','fieldName','type','key','keys','query','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','merge','where','filter','options','includeAll','include','findAll','rows','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','createdAt','updatedAt','UserProfileSection','getSessions','findOne','JscriptySessionReport','order','pick','ProjectId','getAnswers','JscriptyAnswerReport','fromCharCode','toString','indexOf','getSummary','startTime','parse','JscriptyQuestionReport','-createdAt','questionId','question','starttime','format','SessionId','answer','push','isEmpty','writeFileSync','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','Content-disposition'];(function(_0x35dfb7,_0x3f55f9){var _0x427bab=function(_0x27e260){while(--_0x27e260){_0x35dfb7['push'](_0x35dfb7['shift']());}};_0x427bab(++_0x3f55f9);}(_0x415c,0x78));var _0xc415=function(_0x3f994d,_0x249d72){_0x3f994d=_0x3f994d-0x0;var _0x5309b4=_0x415c[_0x3f994d];return _0x5309b4;};'use strict';var pdf=require(_0xc415('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xc415('0x1'));var zipdir=require(_0xc415('0x2'));var jsonpatch=require(_0xc415('0x3'));var rp=require(_0xc415('0x4'));var moment=require('moment');var BPromise=require(_0xc415('0x5'));var Mustache=require(_0xc415('0x6'));var util=require(_0xc415('0x7'));var path=require(_0xc415('0x8'));var sox=require(_0xc415('0x9'));var csv=require(_0xc415('0xa'));var ejs=require(_0xc415('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0xc415('0xc'));var crypto=require(_0xc415('0xd'));var jsforce=require(_0xc415('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xc415('0xa'));var querystring=require(_0xc415('0xf'));var Papa=require('papaparse');var Redis=require(_0xc415('0x10'));var authService=require(_0xc415('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc415('0x12'));var logger=require(_0xc415('0x13'))(_0xc415('0x14'));var utils=require('../../config/utils');var config=require(_0xc415('0x15'));var licenseUtil=require(_0xc415('0x16'));var db=require(_0xc415('0x17'))['db'];function respondWithStatusCode(_0x6525e5,_0xfb5915){_0xfb5915=_0xfb5915||0xcc;return function(_0x540e99){if(_0x540e99){return _0x6525e5['sendStatus'](_0xfb5915);}return _0x6525e5[_0xc415('0x18')](_0xfb5915)[_0xc415('0x19')]();};}function respondWithResult(_0x5cd878,_0x279b88){_0x279b88=_0x279b88||0xc8;return function(_0xffd66e){if(_0xffd66e){return _0x5cd878['status'](_0x279b88)[_0xc415('0x1a')](_0xffd66e);}};}function respondWithFilteredResult(_0x297f8a,_0x34bcb3){return function(_0x3444ad){if(_0x3444ad){var _0x57d167=_0x3444ad[_0xc415('0x1b')],_0x30069a=_0x34bcb3[_0xc415('0x1c')],_0x15ef4d=_0x34bcb3[_0xc415('0x1c')]+_0x34bcb3[_0xc415('0x1d')],_0x6959c2;if(_0x15ef4d>=_0x57d167){_0x15ef4d=_0x57d167;_0x6959c2=0xc8;}else{_0x6959c2=0xce;}_0x297f8a[_0xc415('0x18')](_0x6959c2);return _0x297f8a[_0xc415('0x1e')]('Content-Range',_0x30069a+'-'+_0x15ef4d+'/'+_0x57d167)['json'](_0x3444ad);}return null;};}function patchUpdates(_0x951c4f){return function(_0x28cfa5){try{jsonpatch[_0xc415('0x1f')](_0x28cfa5,_0x951c4f,!![]);}catch(_0x237626){return BPromise[_0xc415('0x20')](_0x237626);}return _0x28cfa5[_0xc415('0x21')]();};}function saveUpdates(_0x270830,_0x37052d){return function(_0x1668f3){if(_0x1668f3){return _0x1668f3[_0xc415('0x22')](_0x270830)[_0xc415('0x23')](function(_0xe7c643){return _0xe7c643;});}return null;};}function removeEntity(_0x56f09c,_0x4a88be){return function(_0x11bfc8){if(_0x11bfc8){return _0x11bfc8[_0xc415('0x24')]()[_0xc415('0x23')](function(){var _0x435c94=_0x11bfc8[_0xc415('0x25')]({'plain':!![]});var _0x1d4ae6=_0xc415('0x26');return db[_0xc415('0x27')][_0xc415('0x24')]({'where':{'type':_0x1d4ae6,'resourceId':_0x435c94['id']}})[_0xc415('0x23')](function(){return _0x11bfc8;});})[_0xc415('0x23')](function(){_0x56f09c[_0xc415('0x18')](0xcc)[_0xc415('0x19')]();});}};}function handleEntityNotFound(_0x3b0c7b,_0x9fae8e){return function(_0x576279){if(!_0x576279){_0x3b0c7b[_0xc415('0x28')](0x194);}return _0x576279;};}function handleError(_0x2e56eb,_0x14f23c){_0x14f23c=_0x14f23c||0x1f4;return function(_0x6c7ad8){logger[_0xc415('0x29')](_0x6c7ad8[_0xc415('0x2a')]);if(_0x6c7ad8[_0xc415('0x2b')]){delete _0x6c7ad8[_0xc415('0x2b')];}_0x2e56eb['status'](_0x14f23c)[_0xc415('0x2c')](_0x6c7ad8);};}exports[_0xc415('0x2d')]=function(_0x1dc9d4,_0x23ced){var _0x580701={},_0x19683f={},_0xfaa92f={'count':0x0,'rows':[]};var _0x2c4ea4=_[_0xc415('0x2e')](db[_0xc415('0x2f')][_0xc415('0x30')],function(_0x7ebdad){return{'name':_0x7ebdad[_0xc415('0x31')],'type':_0x7ebdad[_0xc415('0x32')][_0xc415('0x33')]};});_0x19683f['model']=_[_0xc415('0x2e')](_0x2c4ea4,'name');_0x19683f['query']=_[_0xc415('0x34')](_0x1dc9d4[_0xc415('0x35')]);_0x19683f[_0xc415('0x36')]=_['intersection'](_0x19683f[_0xc415('0x37')],_0x19683f['query']);_0x580701[_0xc415('0x38')]=_[_0xc415('0x39')](_0x19683f[_0xc415('0x37')],qs[_0xc415('0x3a')](_0x1dc9d4[_0xc415('0x35')]['fields']));_0x580701[_0xc415('0x38')]=_0x580701[_0xc415('0x38')][_0xc415('0x3b')]?_0x580701['attributes']:_0x19683f[_0xc415('0x37')];if(!_0x1dc9d4[_0xc415('0x35')][_0xc415('0x3c')](_0xc415('0x3d'))){_0x580701[_0xc415('0x1d')]=qs[_0xc415('0x1d')](_0x1dc9d4[_0xc415('0x35')][_0xc415('0x1d')]);_0x580701[_0xc415('0x1c')]=qs[_0xc415('0x1c')](_0x1dc9d4[_0xc415('0x35')][_0xc415('0x1c')]);}_0x580701['order']=qs[_0xc415('0x3e')](_0x1dc9d4[_0xc415('0x35')]['sort']);_0x580701['where']=qs['filters'](_['pick'](_0x1dc9d4['query'],_0x19683f[_0xc415('0x36')]),_0x2c4ea4);if(_0x1dc9d4['query']['filter']){_0x580701['where']=_[_0xc415('0x3f')](_0x580701[_0xc415('0x40')],{'$or':_[_0xc415('0x2e')](_0x2c4ea4,function(_0x40c8f3){if(_0x40c8f3[_0xc415('0x32')]!=='VIRTUAL'){var _0x25c764={};_0x25c764[_0x40c8f3[_0xc415('0x2b')]]={'$like':'%'+_0x1dc9d4[_0xc415('0x35')][_0xc415('0x41')]+'%'};return _0x25c764;}})});}_0x580701=_[_0xc415('0x3f')]({},_0x580701,_0x1dc9d4[_0xc415('0x42')]);var _0x1fc16d={'where':_0x580701[_0xc415('0x40')]};return db[_0xc415('0x2f')]['count'](_0x1fc16d)[_0xc415('0x23')](function(_0x460ab6){_0xfaa92f['count']=_0x460ab6;if(_0x1dc9d4['query'][_0xc415('0x43')]){_0x580701[_0xc415('0x44')]=[{'all':!![]}];}return db[_0xc415('0x2f')][_0xc415('0x45')](_0x580701);})[_0xc415('0x23')](function(_0x48d267){_0xfaa92f[_0xc415('0x46')]=_0x48d267;return _0xfaa92f;})[_0xc415('0x23')](respondWithFilteredResult(_0x23ced,_0x580701))['catch'](handleError(_0x23ced,null));};exports['show']=function(_0x316f31,_0x3c2b79){var _0x4a66dd={'raw':![],'where':{'id':_0x316f31['params']['id']}},_0x5581f9={};_0x5581f9[_0xc415('0x37')]=_[_0xc415('0x34')](db['JscriptyProject'][_0xc415('0x30')]);_0x5581f9['query']=_['keys'](_0x316f31[_0xc415('0x35')]);_0x5581f9[_0xc415('0x36')]=_[_0xc415('0x39')](_0x5581f9[_0xc415('0x37')],_0x5581f9['query']);_0x4a66dd[_0xc415('0x38')]=_[_0xc415('0x39')](_0x5581f9[_0xc415('0x37')],qs[_0xc415('0x3a')](_0x316f31[_0xc415('0x35')][_0xc415('0x3a')]));_0x4a66dd[_0xc415('0x38')]=_0x4a66dd['attributes'][_0xc415('0x3b')]?_0x4a66dd[_0xc415('0x38')]:_0x5581f9[_0xc415('0x37')];if(_0x316f31[_0xc415('0x35')][_0xc415('0x43')]){_0x4a66dd['include']=[{'all':!![]}];}_0x4a66dd=_[_0xc415('0x3f')]({},_0x4a66dd,_0x316f31[_0xc415('0x42')]);return db[_0xc415('0x2f')][_0xc415('0x47')](_0x4a66dd)[_0xc415('0x23')](handleEntityNotFound(_0x3c2b79,null))[_0xc415('0x23')](respondWithResult(_0x3c2b79,null))[_0xc415('0x48')](handleError(_0x3c2b79,null));};exports[_0xc415('0x49')]=function(_0x292608,_0x22fae6){return db[_0xc415('0x2f')][_0xc415('0x49')](_0x292608[_0xc415('0x4a')],{})[_0xc415('0x23')](function(_0xc586c3){var _0x52d691=_0x292608[_0xc415('0x4b')]['get']({'plain':!![]});if(!_0x52d691)throw new Error(_0xc415('0x4c'));if(_0x52d691['role']===_0xc415('0x4b')){var _0x49f0c6=_0xc586c3[_0xc415('0x25')]({'plain':!![]});var _0x574e28='Projects';return db['UserProfileSection'][_0xc415('0x47')]({'where':{'name':_0x574e28,'userProfileId':_0x52d691[_0xc415('0x4d')]},'raw':!![]})[_0xc415('0x23')](function(_0x5e688f){if(_0x5e688f&&_0x5e688f[_0xc415('0x4e')]===0x0){return db[_0xc415('0x27')][_0xc415('0x49')]({'name':_0x49f0c6['name'],'resourceId':_0x49f0c6['id'],'type':_0x5e688f[_0xc415('0x2b')],'sectionId':_0x5e688f['id']},{})['then'](function(){return _0xc586c3;});}else{return _0xc586c3;}})[_0xc415('0x48')](function(_0x526772){logger[_0xc415('0x29')](_0xc415('0x4f'),_0x526772);throw _0x526772;});}return _0xc586c3;})['then'](respondWithResult(_0x22fae6,0xc9))[_0xc415('0x48')](handleError(_0x22fae6,null));};exports[_0xc415('0x50')]=function(_0x148892,_0x1cc472){var _0x441106={'where':{'id':_0x148892[_0xc415('0x51')]['id']}},_0x7e862b={};_0x7e862b['model']=_[_0xc415('0x34')](db['JscriptyProject'][_0xc415('0x30')]);_0x441106['attributes']=_[_0xc415('0x39')](_0x7e862b['model'],qs[_0xc415('0x3a')](_0x148892[_0xc415('0x35')][_0xc415('0x3a')]));_0x441106[_0xc415('0x38')]=_0x441106[_0xc415('0x38')][_0xc415('0x3b')]?_0x441106[_0xc415('0x38')]:_0x7e862b['model'];if(_0x148892['query'][_0xc415('0x43')]){_0x441106[_0xc415('0x44')]=[{'all':!![]}];}_0x441106=_[_0xc415('0x3f')]({},_0x441106,_0x148892[_0xc415('0x42')]);return db[_0xc415('0x2f')][_0xc415('0x47')](_0x441106)[_0xc415('0x23')](handleEntityNotFound(_0x1cc472,null))['then'](function(_0x5b414c){if(_0x5b414c){var _0xa15443=_0x5b414c[_0xc415('0x25')]({'plain':!![]});_0xa15443=qs[_0xc415('0x52')](_0xa15443,['id',_0xc415('0x53'),_0xc415('0x54')]);_0x148892[_0xc415('0x4a')]=_[_0xc415('0x52')](_0x148892[_0xc415('0x4a')],['id','createdAt',_0xc415('0x54')]);return db[_0xc415('0x2f')][_0xc415('0x49')](_[_0xc415('0x3f')](_0xa15443,_0x148892[_0xc415('0x4a')]),{'include':_0x148892[_0xc415('0x35')]['includeAll']?[{'all':!![]}]:undefined})[_0xc415('0x23')](function(_0x3d9ea3){var _0x233829=_0x148892[_0xc415('0x4b')][_0xc415('0x25')]({'plain':!![]});if(!_0x233829)throw new Error(_0xc415('0x4c'));if(_0x233829['role']===_0xc415('0x4b')){var _0x39f9b1=_0x3d9ea3[_0xc415('0x25')]({'plain':!![]});var _0x130613=_0xc415('0x26');return db[_0xc415('0x55')]['find']({'where':{'name':_0x130613,'userProfileId':_0x233829[_0xc415('0x4d')]},'raw':!![]})[_0xc415('0x23')](function(_0x47fb83){if(_0x47fb83&&_0x47fb83[_0xc415('0x4e')]===0x0){return db[_0xc415('0x27')]['create']({'name':_0x39f9b1['name'],'resourceId':_0x39f9b1['id'],'type':_0x47fb83[_0xc415('0x2b')],'sectionId':_0x47fb83['id']},{})[_0xc415('0x23')](function(){return _0x3d9ea3;});}else{return _0x3d9ea3;}})[_0xc415('0x48')](function(_0x1660f8){logger[_0xc415('0x29')](_0xc415('0x4f'),_0x1660f8);throw _0x1660f8;});}return _0x3d9ea3;});}})[_0xc415('0x23')](respondWithResult(_0x1cc472,0xc9))['catch'](handleError(_0x1cc472,null));};exports[_0xc415('0x22')]=function(_0x2bdecf,_0x27b0ef){if(_0x2bdecf[_0xc415('0x4a')]['id']){delete _0x2bdecf[_0xc415('0x4a')]['id'];}return db[_0xc415('0x2f')][_0xc415('0x47')]({'where':{'id':_0x2bdecf[_0xc415('0x51')]['id']}})[_0xc415('0x23')](handleEntityNotFound(_0x27b0ef,null))[_0xc415('0x23')](saveUpdates(_0x2bdecf[_0xc415('0x4a')],null))['then'](respondWithResult(_0x27b0ef,null))['catch'](handleError(_0x27b0ef,null));};exports[_0xc415('0x24')]=function(_0x56a7b4,_0x33d36b){return db[_0xc415('0x2f')][_0xc415('0x47')]({'where':{'id':_0x56a7b4[_0xc415('0x51')]['id']}})[_0xc415('0x23')](handleEntityNotFound(_0x33d36b,null))[_0xc415('0x23')](removeEntity(_0x33d36b,null))[_0xc415('0x48')](handleError(_0x33d36b,null));};exports[_0xc415('0x56')]=function(_0x5b1f65,_0x4bbed7,_0x9636e1){var _0x4dc49b={'raw':!![],'where':{}};var _0x48e93c={};var _0x4f2980={'count':0x0,'rows':[]};return db[_0xc415('0x2f')][_0xc415('0x57')]({'where':{'id':_0x5b1f65[_0xc415('0x51')]['id']}})[_0xc415('0x23')](handleEntityNotFound(_0x4bbed7,null))[_0xc415('0x23')](function(_0x4d2863){if(_0x4d2863){_0x48e93c['model']=_[_0xc415('0x34')](db[_0xc415('0x58')]['rawAttributes']);_0x48e93c[_0xc415('0x35')]=_[_0xc415('0x34')](_0x5b1f65[_0xc415('0x35')]);_0x48e93c[_0xc415('0x36')]=_[_0xc415('0x39')](_0x48e93c[_0xc415('0x37')],_0x48e93c[_0xc415('0x35')]);_0x4dc49b['attributes']=_['intersection'](_0x48e93c[_0xc415('0x37')],qs['fields'](_0x5b1f65['query'][_0xc415('0x3a')]));_0x4dc49b[_0xc415('0x38')]=_0x4dc49b[_0xc415('0x38')][_0xc415('0x3b')]?_0x4dc49b['attributes']:_0x48e93c['model'];if(!_0x5b1f65[_0xc415('0x35')][_0xc415('0x3c')]('nolimit')){_0x4dc49b[_0xc415('0x1d')]=qs[_0xc415('0x1d')](_0x5b1f65[_0xc415('0x35')]['limit']);_0x4dc49b['offset']=qs[_0xc415('0x1c')](_0x5b1f65[_0xc415('0x35')][_0xc415('0x1c')]);}_0x4dc49b[_0xc415('0x59')]=qs[_0xc415('0x3e')](_0x5b1f65[_0xc415('0x35')]['sort']);_0x4dc49b[_0xc415('0x40')]=qs[_0xc415('0x36')](_[_0xc415('0x5a')](_0x5b1f65[_0xc415('0x35')],_0x48e93c[_0xc415('0x36')]));_0x4dc49b[_0xc415('0x40')][_0xc415('0x5b')]=_0x4d2863['id'];if(_0x5b1f65['query']['filter']){_0x4dc49b[_0xc415('0x40')]=_[_0xc415('0x3f')](_0x4dc49b[_0xc415('0x40')],{'$or':_[_0xc415('0x2e')](_0x4dc49b['attributes'],function(_0x36af8f){var _0x275b18={};_0x275b18[_0x36af8f]={'$like':'%'+_0x5b1f65['query'][_0xc415('0x41')]+'%'};return _0x275b18;})});}_0x4dc49b=_[_0xc415('0x3f')]({},_0x4dc49b,_0x5b1f65[_0xc415('0x42')]);return db[_0xc415('0x58')][_0xc415('0x1b')]({'where':_0x4dc49b[_0xc415('0x40')]})[_0xc415('0x23')](function(_0x28e18d){_0x4f2980[_0xc415('0x1b')]=_0x28e18d;if(_0x5b1f65['query'][_0xc415('0x43')]){_0x4dc49b[_0xc415('0x44')]=[{'all':!![]}];}return db[_0xc415('0x58')][_0xc415('0x45')](_0x4dc49b);})[_0xc415('0x23')](function(_0x3da43e){_0x4f2980[_0xc415('0x46')]=_0x3da43e;return _0x4f2980;});}})[_0xc415('0x23')](respondWithFilteredResult(_0x4bbed7,_0x4dc49b))['catch'](handleError(_0x4bbed7,null));};exports[_0xc415('0x5c')]=function(_0x2c3a06,_0x125ff4,_0x3d5a40){var _0x3dc0a4={'raw':!![],'where':{}};var _0x187301={};var _0x2dedad={'count':0x0,'rows':[]};return db[_0xc415('0x2f')]['findOne']({'where':{'id':_0x2c3a06[_0xc415('0x51')]['id']}})['then'](handleEntityNotFound(_0x125ff4,null))[_0xc415('0x23')](function(_0x3e7067){if(_0x3e7067){_0x187301[_0xc415('0x37')]=_[_0xc415('0x34')](db[_0xc415('0x5d')]['rawAttributes']);_0x187301[_0xc415('0x35')]=_[_0xc415('0x34')](_0x2c3a06[_0xc415('0x35')]);_0x187301[_0xc415('0x36')]=_[_0xc415('0x39')](_0x187301[_0xc415('0x37')],_0x187301['query']);_0x3dc0a4['attributes']=_[_0xc415('0x39')](_0x187301[_0xc415('0x37')],qs['fields'](_0x2c3a06[_0xc415('0x35')][_0xc415('0x3a')]));_0x3dc0a4[_0xc415('0x38')]=_0x3dc0a4['attributes'][_0xc415('0x3b')]?_0x3dc0a4[_0xc415('0x38')]:_0x187301[_0xc415('0x37')];if(!_0x2c3a06['query'][_0xc415('0x3c')]('nolimit')){_0x3dc0a4['limit']=qs[_0xc415('0x1d')](_0x2c3a06[_0xc415('0x35')][_0xc415('0x1d')]);_0x3dc0a4[_0xc415('0x1c')]=qs[_0xc415('0x1c')](_0x2c3a06[_0xc415('0x35')]['offset']);}_0x3dc0a4[_0xc415('0x59')]=qs[_0xc415('0x3e')](_0x2c3a06[_0xc415('0x35')][_0xc415('0x3e')]);_0x3dc0a4[_0xc415('0x40')]=qs[_0xc415('0x36')](_[_0xc415('0x5a')](_0x2c3a06[_0xc415('0x35')],_0x187301[_0xc415('0x36')]));_0x3dc0a4['where'][_0xc415('0x5b')]=_0x3e7067['id'];if(_0x2c3a06[_0xc415('0x35')]['filter']){_0x3dc0a4[_0xc415('0x40')]=_['merge'](_0x3dc0a4[_0xc415('0x40')],{'$or':_[_0xc415('0x2e')](_0x3dc0a4[_0xc415('0x38')],function(_0x25b1b3){var _0x4eac83={};_0x4eac83[_0x25b1b3]={'$like':'%'+_0x2c3a06['query'][_0xc415('0x41')]+'%'};return _0x4eac83;})});}_0x3dc0a4=_[_0xc415('0x3f')]({},_0x3dc0a4,_0x2c3a06['options']);return db[_0xc415('0x5d')]['count']({'where':_0x3dc0a4['where']})[_0xc415('0x23')](function(_0x103a6c){_0x2dedad['count']=_0x103a6c;if(_0x2c3a06[_0xc415('0x35')][_0xc415('0x43')]){_0x3dc0a4[_0xc415('0x44')]=[{'all':!![]}];}return db[_0xc415('0x5d')][_0xc415('0x45')](_0x3dc0a4);})[_0xc415('0x23')](function(_0x2345fb){_0x2dedad[_0xc415('0x46')]=_0x2345fb;return _0x2dedad;});}})[_0xc415('0x23')](respondWithFilteredResult(_0x125ff4,_0x3dc0a4))[_0xc415('0x48')](handleError(_0x125ff4,null));};function char(_0x115871){return'number'===typeof _0x115871?String[_0xc415('0x5e')][_0xc415('0x1f')](null,arguments):_0x115871;}function needsEncapsulation(_0x51e6b6){return!!_0x51e6b6&&(_0x51e6b6[_0xc415('0x5f')]()[_0xc415('0x60')](char(0xd))>=0x0||_0x51e6b6[_0xc415('0x5f')]()[_0xc415('0x60')](char(0xa))>=0x0||_0x51e6b6[_0xc415('0x5f')]()[_0xc415('0x60')](char(0x2c))>=0x0||_0x51e6b6[_0xc415('0x5f')]()[_0xc415('0x60')](char(0x22))>=0x0);}function encapsulate(_0x20ecff){var _0x3186e7=char(0x22),_0x412985='\x5c'+char(0x22),_0x850097=_0x20ecff[_0xc415('0x5f')]()['replace'](new RegExp(_0x3186e7,'g'),_0x412985);return _0x3186e7+_0x850097+_0x3186e7;}exports[_0xc415('0x61')]=function(_0x6826e0,_0x27af1a,_0x466889){var _0x55d287,_0x40ec4c;var _0x1df69d={'where':{'ProjectId':_0x6826e0[_0xc415('0x51')]['id']}};if(_0x6826e0[_0xc415('0x35')][_0xc415('0x62')]){_0x1df69d['where']['starttime']=JSON[_0xc415('0x63')](_0x6826e0[_0xc415('0x35')]['startTime']);}return db[_0xc415('0x58')][_0xc415('0x45')](_0x1df69d)[_0xc415('0x23')](handleEntityNotFound(_0x27af1a,null))[_0xc415('0x23')](function(_0x563817){if(_0x563817){_0x55d287=_0x563817;return db[_0xc415('0x64')]['findAll']({'where':{'SessionId':{'$in':_['map'](_0x55d287,'id')},'ProjectId':_0x6826e0[_0xc415('0x51')]['id']},'order':_0xc415('0x65')});}})[_0xc415('0x23')](handleEntityNotFound(_0x27af1a,null))[_0xc415('0x23')](function(_0x41d827){if(_0x41d827){_0x40ec4c=_0x41d827;var _0x451475={};for(var _0xab4d79=0x0,_0x46a55e=_0x40ec4c[_0xc415('0x3b')];_0xab4d79<_0x46a55e;_0xab4d79++){if(!_0x451475[_0xc415('0x3c')](_0x40ec4c[_0xab4d79][_0xc415('0x66')])){_0x451475[_0x40ec4c[_0xab4d79][_0xc415('0x66')]]=needsEncapsulation(_0x40ec4c[_0xab4d79][_0xc415('0x67')])?encapsulate(_0x40ec4c[_0xab4d79]['question']):_0x40ec4c[_0xab4d79][_0xc415('0x67')];}}var _0x56ce0b=[],_0x166f0a={};for(var _0x5109cc=0x0,_0x4e5dc0=_0x55d287['length'];_0x5109cc<_0x4e5dc0;_0x5109cc++){_0x166f0a={'ProjectId':_0x6826e0['params']['id'],'SessionId':_0x55d287[_0x5109cc]['id'],'StartTime':moment(_0x55d287[_0x5109cc][_0xc415('0x68')])[_0xc415('0x69')]('YYYY-MM-DD\x20HH:mm:ss')};for(var _0x1a4104=0x0,_0x36548a=_0x40ec4c[_0xc415('0x3b')];_0x1a4104<_0x36548a;_0x1a4104++){if(_0x40ec4c[_0x1a4104][_0xc415('0x6a')]==_0x55d287[_0x5109cc]['id']&&_0x451475[_0xc415('0x3c')](_0x40ec4c[_0x1a4104][_0xc415('0x66')])){_0x166f0a[_0x451475[_0x40ec4c[_0x1a4104]['questionId']]]=_0x40ec4c[_0x1a4104][_0xc415('0x6b')];}}for(var _0x618fc5 in _0x451475){if(!_0x166f0a[_0xc415('0x3c')](_0x451475[_0x618fc5])){_0x166f0a[_0x451475[_0x618fc5]]=null;}}_0x56ce0b[_0xc415('0x6c')](_0x166f0a);}return _0x56ce0b;}})[_0xc415('0x23')](function(_0x2bd404){if(!_[_0xc415('0x6d')](_0x2bd404)){var _0x2ceb39=toCsv(_0x2bd404);var _0x319cad=Date['now']();fs[_0xc415('0x6e')](util['format'](_0xc415('0x6f'),_0x6826e0[_0xc415('0x51')]['id'],_0x319cad),_0x2ceb39);_0x27af1a[_0xc415('0x70')](_0xc415('0x71'),'attachment;\x20filename='+util[_0xc415('0x69')](_0xc415('0x72'),_0x6826e0['params']['id'],_0x319cad));_0x27af1a[_0xc415('0x70')](_0xc415('0x73'),_0xc415('0x74'));return _0x27af1a['download'](util[_0xc415('0x69')](_0xc415('0x6f'),_0x6826e0[_0xc415('0x51')]['id'],_0x319cad));}else{return _0x27af1a[_0xc415('0x28')](0xcc);}})[_0xc415('0x48')](handleError(_0x27af1a,null));};
\ No newline at end of file