Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / components / export / xlsx.js
index 19d7d23..abcee53 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa613=['lodash','bluebird','zip-dir','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','update','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','XLSX','find','splitSizeXlsx','then','sequelize','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','num','split','length','push','%s\x20limit\x20%d\x20OFFSET\x20%d','QueryTypes','SELECT','dirname','basename','.xlsx','existsSync','join','%s%d.%s','xlsx','%s.%s','binary','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','zip','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','Failed','path'];(function(_0x5305dc,_0x3a0acc){var _0x47b203=function(_0x53f023){while(--_0x53f023){_0x5305dc['push'](_0x5305dc['shift']());}};_0x47b203(++_0x3a0acc);}(_0xa613,0x18b));var _0x3a61=function(_0x36641f,_0x1de996){_0x36641f=_0x36641f-0x0;var _0x264197=_0xa613[_0x36641f];return _0x264197;};'use strict';var util=require('util');var path=require(_0x3a61('0x0'));var _=require(_0x3a61('0x1'));var fs=require('fs');var json2xls=require('json2xls');var BPromise=require(_0x3a61('0x2'));var zipdir=require(_0x3a61('0x3'));var rimraf=require(_0x3a61('0x4'));var db=require(_0x3a61('0x5'))['db'];var dbH=require(_0x3a61('0x5'))[_0x3a61('0x6')];var logger=require(_0x3a61('0x7'))(_0x3a61('0x8'));var EXTRACTED_REPORT_ID=Number(process['argv'][0x2]);var QUERY=process[_0x3a61('0x9')][0x3];var PATH=process[_0x3a61('0x9')][0x4];function analyticExtractedReport(_0x3ccaf8,_0x56c4a5){var _0x149a77={'status':_0x3ccaf8};var _0x459882={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x56c4a5){_0x149a77['savename']=_0x56c4a5;}return db['AnalyticExtractedReport'][_0x3a61('0xa')](_0x149a77,_0x459882);}function main(){var _0x37516e=0x1388;var _0x421e82;logger[_0x3a61('0xb')](util[_0x3a61('0xc')](_0x3a61('0xd'),EXTRACTED_REPORT_ID,_0x3a61('0xe')));return db['Setting'][_0x3a61('0xf')]({'where':{'id':0x1},'raw':!![],'attributes':['id','split',_0x3a61('0x10')]})[_0x3a61('0x11')](function(_0x42fdba){if(_0x42fdba){_0x421e82=_0x42fdba;_0x37516e=_0x421e82[_0x3a61('0x10')]||0x1388;}})['then'](function(){return dbH[_0x3a61('0x12')][_0x3a61('0x13')](util[_0x3a61('0xc')](_0x3a61('0x14'),QUERY),{'type':dbH['sequelize']['QueryTypes']['SELECT']});})[_0x3a61('0x11')](function(_0xac3fa5){if(!_0xac3fa5[0x0][_0x3a61('0x15')]){return analyticExtractedReport('Empty');}var _0x1f6fcb=[];var _0xb604e0=0x0;var _0x1f34f2=!![];if(_0x421e82[_0x3a61('0x16')]){if(_0xac3fa5&&_0xac3fa5[_0x3a61('0x17')]){var _0x34f511=_0xac3fa5[0x0][_0x3a61('0x15')]%(_0xb604e0+_0x37516e);for(;_0x1f34f2;_0xb604e0+=_0x37516e,_0x34f511=_0xac3fa5[0x0][_0x3a61('0x15')]%(_0xb604e0+_0x37516e)){if(_0x34f511==0x0||_0x34f511==_0xac3fa5[0x0][_0x3a61('0x15')]){_0x1f34f2=![];}_0x1f6fcb[_0x3a61('0x18')](dbH[_0x3a61('0x12')][_0x3a61('0x13')](util['format'](_0x3a61('0x19'),QUERY,_0x37516e,_0xb604e0),{'type':dbH['sequelize'][_0x3a61('0x1a')][_0x3a61('0x1b')]}));}}}else{_0x1f6fcb[_0x3a61('0x18')](dbH[_0x3a61('0x12')][_0x3a61('0x13')](QUERY,{'type':dbH[_0x3a61('0x12')]['QueryTypes']['SELECT']}));}var _0x2d9e1e=path[_0x3a61('0x1c')](PATH);var _0x33278b=path[_0x3a61('0x1d')](PATH,_0x3a61('0x1e'));var _0x3cd39d=_0x421e82['split']&&_0x1f6fcb[_0x3a61('0x17')]>0x1;var _0x4d50ae=[];if(!fs[_0x3a61('0x1f')](path['join'](_0x2d9e1e,_0x33278b))&&_0x3cd39d){fs['mkdirSync'](path[_0x3a61('0x20')](_0x2d9e1e,_0x33278b));}return BPromise['each'](_0x1f6fcb,function(_0x161551){_0x4d50ae[_0x3a61('0x18')](_0x161551);})[_0x3a61('0x11')](function(){for(var _0x4ad106=0x0;_0x4ad106<_0x4d50ae['length'];_0x4ad106+=0x1){var _0x4d3fff;var _0x5841bd=_0x4d50ae[_0x4ad106];if(_0x3cd39d){_0x4d3fff=path['join'](_0x2d9e1e,_0x33278b,util['format'](_0x3a61('0x21'),_0x33278b,_0x4ad106,_0x3a61('0x22')));}else{_0x4d3fff=path[_0x3a61('0x20')](_0x2d9e1e,util[_0x3a61('0xc')](_0x3a61('0x23'),_0x33278b,_0x3a61('0x22')));}fs['writeFileSync'](_0x4d3fff,json2xls(_0x5841bd),_0x3a61('0x24'));}})[_0x3a61('0x11')](function(){if(_0x3cd39d){zipdir(path[_0x3a61('0x20')](_0x2d9e1e,_0x33278b),{'saveTo':path[_0x3a61('0x20')](_0x2d9e1e,util[_0x3a61('0xc')](_0x3a61('0x23'),_0x33278b,'zip'))},function(_0x4af9cc,_0x26053d){});rimraf(path[_0x3a61('0x20')](_0x2d9e1e,_0x33278b),function(){});}})[_0x3a61('0x11')](function(){logger[_0x3a61('0xb')](util[_0x3a61('0xc')](_0x3a61('0x25'),EXTRACTED_REPORT_ID,_0x3a61('0xe')));return analyticExtractedReport(_0x3a61('0x26'),_0x3cd39d?util[_0x3a61('0xc')](_0x3a61('0x23'),_0x33278b,_0x3cd39d?_0x3a61('0x27'):_0x3a61('0x22')):null);});})[_0x3a61('0x28')](function(_0x290392){logger['info'](util['format'](_0x3a61('0x29'),EXTRACTED_REPORT_ID,_0x3a61('0xe')),util[_0x3a61('0x2a')](_0x290392,{'showHidden':![],'depth':null}));return analyticExtractedReport(_0x3a61('0x2b'));});}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