Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / components / export / xlsx.js
index c2c1abf..abcee53 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4381=['SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','SELECT','num','Empty','length','forEach','push','%s\x20limit\x20%d\x20OFFSET\x20%d','dirname','basename','.xlsx','mkdirSync','join','each','%s%d.%s','xlsx','%s.%s','writeFileSync','binary','zip','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','Failed','finally','exit','util','path','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','dbH','analytics','argv','savename','AnalyticExtractedReport','update','info','XLSX','Setting','split','then','splitSizeXlsx','sequelize','query','format'];(function(_0x1e0624,_0x911ad7){var _0x3f67ab=function(_0x1440bf){while(--_0x1440bf){_0x1e0624['push'](_0x1e0624['shift']());}};_0x3f67ab(++_0x911ad7);}(_0x4381,0x1f1));var _0x1438=function(_0x4eb77e,_0x1eab21){_0x4eb77e=_0x4eb77e-0x0;var _0x418bde=_0x4381[_0x4eb77e];return _0x418bde;};'use strict';var util=require(_0x1438('0x0'));var path=require(_0x1438('0x1'));var _=require(_0x1438('0x2'));var fs=require('fs');var json2xls=require(_0x1438('0x3'));var BPromise=require(_0x1438('0x4'));var zipdir=require(_0x1438('0x5'));var rimraf=require(_0x1438('0x6'));var db=require(_0x1438('0x7'))['db'];var dbH=require(_0x1438('0x7'))[_0x1438('0x8')];var logger=require('../../config/logger')(_0x1438('0x9'));var EXTRACTED_REPORT_ID=Number(process['argv'][0x2]);var QUERY=process[_0x1438('0xa')][0x3];var PATH=process['argv'][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x36b30b,_0x132c9a){var _0xc70899={'status':_0x36b30b};var _0x1c5ba8={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x132c9a){_0xc70899[_0x1438('0xb')]=_0x132c9a;}return db[_0x1438('0xc')][_0x1438('0xd')](_0xc70899,_0x1c5ba8);}function main(){var _0x458c72=0x1388;var _0x312850;logger[_0x1438('0xe')](util['format']('Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format',EXTRACTED_REPORT_ID,_0x1438('0xf')));return db[_0x1438('0x10')]['find']({'where':{'id':0x1},'raw':!![],'attributes':['id',_0x1438('0x11'),'splitSizeXlsx']})[_0x1438('0x12')](function(_0x268db4){if(_0x268db4){_0x312850=_0x268db4;_0x458c72=_0x312850[_0x1438('0x13')]||0x1388;}})[_0x1438('0x12')](function(){return dbH[_0x1438('0x14')][_0x1438('0x15')](util[_0x1438('0x16')](_0x1438('0x17'),QUERY),{'type':dbH[_0x1438('0x14')][_0x1438('0x18')][_0x1438('0x19')]});})[_0x1438('0x12')](function(_0x36c0fd){if(!_0x36c0fd[0x0][_0x1438('0x1a')]){return analyticExtractedReport(_0x1438('0x1b'));}var _0x2eb2bb=[];var _0xaf4596=0x0;if(_0x312850[_0x1438('0x11')]){if(_0x36c0fd&&_0x36c0fd[_0x1438('0x1c')]){var _0x598e08=_['range'](_0x36c0fd[0x0]['num']/_0x458c72);var _0x2b2bcd=Number['isInteger'](_0x36c0fd[0x0]['num']/_0x458c72)?_0x36c0fd[0x0][_0x1438('0x1a')]%_0x458c72:0x0;_0x598e08[_0x1438('0x1d')](function(_0x18defa){if(_0x18defa>0x0){_0xaf4596+=_0x458c72;}_0x2eb2bb[_0x1438('0x1e')](dbH[_0x1438('0x14')][_0x1438('0x15')](util[_0x1438('0x16')](_0x1438('0x1f'),QUERY,_0x458c72,_0xaf4596),{'type':dbH[_0x1438('0x14')]['QueryTypes'][_0x1438('0x19')]}));});if(_0x2b2bcd>0x0){_0xaf4596+=_0x458c72;_0x2eb2bb[_0x1438('0x1e')](dbH[_0x1438('0x14')][_0x1438('0x15')](util[_0x1438('0x16')](_0x1438('0x1f'),QUERY,_0x2b2bcd,_0xaf4596),{'type':dbH[_0x1438('0x14')][_0x1438('0x18')][_0x1438('0x19')]}));}}}else{_0x2eb2bb[_0x1438('0x1e')](dbH[_0x1438('0x14')][_0x1438('0x15')](QUERY,{'type':dbH[_0x1438('0x14')][_0x1438('0x18')][_0x1438('0x19')]}));}var _0x49fab3=path[_0x1438('0x20')](PATH);var _0xd9f837=path[_0x1438('0x21')](PATH,_0x1438('0x22'));var _0x637417=_0x312850[_0x1438('0x11')]&&_0x2eb2bb['length']>0x1;var _0x54c1b6=[];if(!fs['existsSync'](path['join'](_0x49fab3,_0xd9f837))&&_0x637417){fs[_0x1438('0x23')](path[_0x1438('0x24')](_0x49fab3,_0xd9f837));}return BPromise[_0x1438('0x25')](_0x2eb2bb,function(_0x89d3b){_0x54c1b6[_0x1438('0x1e')](_0x89d3b);})['then'](function(){for(var _0x3768cf=0x0;_0x3768cf<_0x54c1b6[_0x1438('0x1c')];_0x3768cf+=0x1){var _0x4d5911;var _0x1a0eb8=_0x54c1b6[_0x3768cf];if(_0x637417){_0x4d5911=path[_0x1438('0x24')](_0x49fab3,_0xd9f837,util[_0x1438('0x16')](_0x1438('0x26'),_0xd9f837,_0x3768cf,_0x1438('0x27')));}else{_0x4d5911=path[_0x1438('0x24')](_0x49fab3,util['format'](_0x1438('0x28'),_0xd9f837,_0x1438('0x27')));}fs[_0x1438('0x29')](_0x4d5911,json2xls(_0x1a0eb8),_0x1438('0x2a'));}})[_0x1438('0x12')](function(){if(_0x637417){return new Promise(function(_0x450332){zipdir(path[_0x1438('0x24')](_0x49fab3,_0xd9f837),{'saveTo':path[_0x1438('0x24')](_0x49fab3,util[_0x1438('0x16')](_0x1438('0x28'),_0xd9f837,_0x1438('0x2b')))},function(_0x226874,_0xa1f047){rimraf(path['join'](_0x49fab3,_0xd9f837),function(){});_0x450332('zip\x20finished');});});}})[_0x1438('0x12')](function(){logger[_0x1438('0xe')](util[_0x1438('0x16')](_0x1438('0x2c'),EXTRACTED_REPORT_ID,_0x1438('0xf')));return analyticExtractedReport(_0x1438('0x2d'),_0x637417?util[_0x1438('0x16')](_0x1438('0x28'),_0xd9f837,_0x637417?_0x1438('0x2b'):_0x1438('0x27')):null);});})[_0x1438('0x2e')](function(_0x4ae82d){logger[_0x1438('0xe')](util[_0x1438('0x16')](_0x1438('0x2f'),EXTRACTED_REPORT_ID,_0x1438('0xf')),util[_0x1438('0x30')](_0x4ae82d,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x1438('0x31'));})[_0x1438('0x32')](function(){process[_0x1438('0x33')](EXIT_CODE);});}main();
\ No newline at end of file
+var _0x0abf=['num','Empty','length','range','isInteger','forEach','push','%s\x20limit\x20%d\x20OFFSET\x20%d','dirname','basename','.xlsx','existsSync','join','%s%d.%s','xlsx','writeFileSync','zip','zip\x20finished','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','XLSX','Completed','%s.%s','catch','info','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','finally','exit','util','lodash','json2xls','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename','update','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','find','split','splitSizeXlsx','then','sequelize','query','format','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','SELECT'];(function(_0x35ec77,_0xe2fc88){var _0x51a679=function(_0x129da5){while(--_0x129da5){_0x35ec77['push'](_0x35ec77['shift']());}};_0x51a679(++_0xe2fc88);}(_0x0abf,0xe8));var _0xf0ab=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0x0abf[_0x3947c9];return _0x2e7871;};'use strict';var util=require(_0xf0ab('0x0'));var path=require('path');var _=require(_0xf0ab('0x1'));var fs=require('fs');var json2xls=require(_0xf0ab('0x2'));var BPromise=require('bluebird');var zipdir=require('zip-dir');var rimraf=require(_0xf0ab('0x3'));var db=require('../../mysqldb')['db'];var dbH=require(_0xf0ab('0x4'))[_0xf0ab('0x5')];var logger=require(_0xf0ab('0x6'))(_0xf0ab('0x7'));var EXTRACTED_REPORT_ID=Number(process[_0xf0ab('0x8')][0x2]);var QUERY=process[_0xf0ab('0x8')][0x3];var PATH=process[_0xf0ab('0x8')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x57ff3b,_0x2c4628){var _0x3f7e2b={'status':_0x57ff3b};var _0x3ca099={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x2c4628){_0x3f7e2b[_0xf0ab('0x9')]=_0x2c4628;}return db['AnalyticExtractedReport'][_0xf0ab('0xa')](_0x3f7e2b,_0x3ca099);}function main(){var _0x4688d8=0x1388;var _0x1e7887;logger['info'](util['format'](_0xf0ab('0xb'),EXTRACTED_REPORT_ID,'XLSX'));return db[_0xf0ab('0xc')][_0xf0ab('0xd')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0xf0ab('0xe'),_0xf0ab('0xf')]})[_0xf0ab('0x10')](function(_0x38ca67){if(_0x38ca67){_0x1e7887=_0x38ca67;_0x4688d8=_0x1e7887[_0xf0ab('0xf')]||0x1388;}})['then'](function(){return dbH[_0xf0ab('0x11')][_0xf0ab('0x12')](util[_0xf0ab('0x13')](_0xf0ab('0x14'),QUERY),{'type':dbH[_0xf0ab('0x11')][_0xf0ab('0x15')][_0xf0ab('0x16')]});})[_0xf0ab('0x10')](function(_0x180d0b){if(!_0x180d0b[0x0][_0xf0ab('0x17')]){return analyticExtractedReport(_0xf0ab('0x18'));}var _0x221bac=[];var _0x200cf5=0x0;if(_0x1e7887[_0xf0ab('0xe')]){if(_0x180d0b&&_0x180d0b[_0xf0ab('0x19')]){var _0x54b0ce=_[_0xf0ab('0x1a')](_0x180d0b[0x0][_0xf0ab('0x17')]/_0x4688d8);var _0x1803f0=Number[_0xf0ab('0x1b')](_0x180d0b[0x0][_0xf0ab('0x17')]/_0x4688d8)?_0x180d0b[0x0][_0xf0ab('0x17')]%_0x4688d8:0x0;_0x54b0ce[_0xf0ab('0x1c')](function(_0x263e2b){if(_0x263e2b>0x0){_0x200cf5+=_0x4688d8;}_0x221bac[_0xf0ab('0x1d')](dbH[_0xf0ab('0x11')][_0xf0ab('0x12')](util[_0xf0ab('0x13')](_0xf0ab('0x1e'),QUERY,_0x4688d8,_0x200cf5),{'type':dbH[_0xf0ab('0x11')][_0xf0ab('0x15')][_0xf0ab('0x16')]}));});if(_0x1803f0>0x0){_0x200cf5+=_0x4688d8;_0x221bac['push'](dbH[_0xf0ab('0x11')][_0xf0ab('0x12')](util[_0xf0ab('0x13')](_0xf0ab('0x1e'),QUERY,_0x1803f0,_0x200cf5),{'type':dbH[_0xf0ab('0x11')][_0xf0ab('0x15')][_0xf0ab('0x16')]}));}}}else{_0x221bac[_0xf0ab('0x1d')](dbH[_0xf0ab('0x11')][_0xf0ab('0x12')](QUERY,{'type':dbH[_0xf0ab('0x11')]['QueryTypes']['SELECT']}));}var _0x4eee21=path[_0xf0ab('0x1f')](PATH);var _0x4f0caf=path[_0xf0ab('0x20')](PATH,_0xf0ab('0x21'));var _0x51ac90=_0x1e7887[_0xf0ab('0xe')]&&_0x221bac[_0xf0ab('0x19')]>0x1;var _0x10bf5f=[];if(!fs[_0xf0ab('0x22')](path[_0xf0ab('0x23')](_0x4eee21,_0x4f0caf))&&_0x51ac90){fs['mkdirSync'](path[_0xf0ab('0x23')](_0x4eee21,_0x4f0caf));}return BPromise['each'](_0x221bac,function(_0x55d799){_0x10bf5f[_0xf0ab('0x1d')](_0x55d799);})[_0xf0ab('0x10')](function(){for(var _0x1b223d=0x0;_0x1b223d<_0x10bf5f[_0xf0ab('0x19')];_0x1b223d+=0x1){var _0x43476c;var _0x174052=_0x10bf5f[_0x1b223d];if(_0x51ac90){_0x43476c=path[_0xf0ab('0x23')](_0x4eee21,_0x4f0caf,util[_0xf0ab('0x13')](_0xf0ab('0x24'),_0x4f0caf,_0x1b223d,_0xf0ab('0x25')));}else{_0x43476c=path[_0xf0ab('0x23')](_0x4eee21,util[_0xf0ab('0x13')]('%s.%s',_0x4f0caf,_0xf0ab('0x25')));}fs[_0xf0ab('0x26')](_0x43476c,json2xls(_0x174052),'binary');}})['then'](function(){if(_0x51ac90){return new Promise(function(_0x1eff91){zipdir(path[_0xf0ab('0x23')](_0x4eee21,_0x4f0caf),{'saveTo':path[_0xf0ab('0x23')](_0x4eee21,util['format']('%s.%s',_0x4f0caf,_0xf0ab('0x27')))},function(_0x58fa03,_0x1cfd52){rimraf(path['join'](_0x4eee21,_0x4f0caf),function(){});_0x1eff91(_0xf0ab('0x28'));});});}})[_0xf0ab('0x10')](function(){logger['info'](util['format'](_0xf0ab('0x29'),EXTRACTED_REPORT_ID,_0xf0ab('0x2a')));return analyticExtractedReport(_0xf0ab('0x2b'),_0x51ac90?util[_0xf0ab('0x13')](_0xf0ab('0x2c'),_0x4f0caf,_0x51ac90?_0xf0ab('0x27'):_0xf0ab('0x25')):null);});})[_0xf0ab('0x2d')](function(_0x2a2f5d){logger[_0xf0ab('0x2e')](util[_0xf0ab('0x13')](_0xf0ab('0x2f'),EXTRACTED_REPORT_ID,_0xf0ab('0x2a')),util[_0xf0ab('0x30')](_0x2a2f5d,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport('Failed');})[_0xf0ab('0x31')](function(){process[_0xf0ab('0x32')](EXIT_CODE);});}main();
\ No newline at end of file