Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / components / export / xlsx.js
index b0ead3b..896346b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc41b=['Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','find','split','splitSizeXlsx','then','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','SELECT','Empty','length','num','sequelize','QueryTypes','push','dirname','.xlsx','existsSync','join','mkdirSync','%s%d.%s','xlsx','writeFileSync','binary','%s.%s','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','XLSX','path','lodash','json2xls','zip-dir','rimraf','dbH','argv','savename','info','format'];(function(_0x13d2d8,_0x11f706){var _0x659366=function(_0x215458){while(--_0x215458){_0x13d2d8['push'](_0x13d2d8['shift']());}};_0x659366(++_0x11f706);}(_0xc41b,0x9a));var _0xbc41=function(_0x59ee6f,_0x450239){_0x59ee6f=_0x59ee6f-0x0;var _0x4c0979=_0xc41b[_0x59ee6f];return _0x4c0979;};'use strict';var util=require('util');var path=require(_0xbc41('0x0'));var _=require(_0xbc41('0x1'));var fs=require('fs');var json2xls=require(_0xbc41('0x2'));var BPromise=require('bluebird');var zipdir=require(_0xbc41('0x3'));var rimraf=require(_0xbc41('0x4'));var db=require('../../mysqldb')['db'];var dbH=require('../../mysqldb')[_0xbc41('0x5')];var logger=require('../../config/logger')('analytics');var EXTRACTED_REPORT_ID=Number(process[_0xbc41('0x6')][0x2]);var QUERY=process[_0xbc41('0x6')][0x3];var PATH=process[_0xbc41('0x6')][0x4];function analyticExtractedReport(_0x21ed3c,_0x35d283){var _0x22f796={'status':_0x21ed3c};var _0x1e3cf5={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x35d283){_0x22f796[_0xbc41('0x7')]=_0x35d283;}return db['AnalyticExtractedReport']['update'](_0x22f796,_0x1e3cf5);}function main(){var _0x1c91a0=0x1388;var _0x4d283e;logger[_0xbc41('0x8')](util[_0xbc41('0x9')](_0xbc41('0xa'),EXTRACTED_REPORT_ID,'XLSX'));return db[_0xbc41('0xb')][_0xbc41('0xc')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0xbc41('0xd'),_0xbc41('0xe')]})['then'](function(_0xa129da){if(_0xa129da){_0x4d283e=_0xa129da;_0x1c91a0=_0x4d283e[_0xbc41('0xe')]||0x1388;}})[_0xbc41('0xf')](function(){return dbH['sequelize'][_0xbc41('0x10')](util[_0xbc41('0x9')](_0xbc41('0x11'),QUERY),{'type':dbH['sequelize']['QueryTypes'][_0xbc41('0x12')]});})['then'](function(_0x25b71d){if(!_0x25b71d[0x0]['num']){return analyticExtractedReport(_0xbc41('0x13'));}var _0x2d59f7=[];var _0x463400=0x0;var _0xd8cbe6=!![];if(_0x4d283e[_0xbc41('0xd')]){if(_0x25b71d&&_0x25b71d[_0xbc41('0x14')]){var _0x16f22c=_0x25b71d[0x0][_0xbc41('0x15')]%(_0x463400+_0x1c91a0);for(;_0xd8cbe6;_0x463400+=_0x1c91a0,_0x16f22c=_0x25b71d[0x0]['num']%(_0x463400+_0x1c91a0)){if(_0x16f22c==0x0||_0x16f22c==_0x25b71d[0x0][_0xbc41('0x15')]){_0xd8cbe6=![];}_0x2d59f7['push'](dbH[_0xbc41('0x16')][_0xbc41('0x10')](util['format']('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x1c91a0,_0x463400),{'type':dbH[_0xbc41('0x16')][_0xbc41('0x17')][_0xbc41('0x12')]}));}}}else{_0x2d59f7[_0xbc41('0x18')](dbH[_0xbc41('0x16')]['query'](QUERY,{'type':dbH['sequelize'][_0xbc41('0x17')][_0xbc41('0x12')]}));}var _0x21fdb1=path[_0xbc41('0x19')](PATH);var _0x2541d8=path['basename'](PATH,_0xbc41('0x1a'));var _0x55cbcf=_0x4d283e[_0xbc41('0xd')]&&_0x2d59f7[_0xbc41('0x14')]>0x1;var _0x3d747f=[];if(!fs[_0xbc41('0x1b')](path[_0xbc41('0x1c')](_0x21fdb1,_0x2541d8))&&_0x55cbcf){fs[_0xbc41('0x1d')](path[_0xbc41('0x1c')](_0x21fdb1,_0x2541d8));}return BPromise['each'](_0x2d59f7,function(_0x189c74){_0x3d747f[_0xbc41('0x18')](_0x189c74);})[_0xbc41('0xf')](function(){for(var _0x1c7341=0x0;_0x1c7341<_0x3d747f[_0xbc41('0x14')];_0x1c7341+=0x1){var _0x2f0377;var _0x5b3766=_0x3d747f[_0x1c7341];if(_0x55cbcf){_0x2f0377=path[_0xbc41('0x1c')](_0x21fdb1,_0x2541d8,util[_0xbc41('0x9')](_0xbc41('0x1e'),_0x2541d8,_0x1c7341,'xlsx'));}else{_0x2f0377=path['join'](_0x21fdb1,util['format']('%s.%s',_0x2541d8,_0xbc41('0x1f')));}fs[_0xbc41('0x20')](_0x2f0377,json2xls(_0x5b3766),_0xbc41('0x21'));}})[_0xbc41('0xf')](function(){if(_0x55cbcf){zipdir(path[_0xbc41('0x1c')](_0x21fdb1,_0x2541d8),{'saveTo':path['join'](_0x21fdb1,util['format'](_0xbc41('0x22'),_0x2541d8,_0xbc41('0x23')))},function(_0x258f70,_0x562d1c){});rimraf(path[_0xbc41('0x1c')](_0x21fdb1,_0x2541d8),function(){});}})[_0xbc41('0xf')](function(){logger[_0xbc41('0x8')](util[_0xbc41('0x9')](_0xbc41('0x24'),EXTRACTED_REPORT_ID,'XLSX'));return analyticExtractedReport(_0xbc41('0x25'),_0x55cbcf?util['format'](_0xbc41('0x22'),_0x2541d8,_0x55cbcf?_0xbc41('0x23'):_0xbc41('0x1f')):null);});})[_0xbc41('0x26')](function(_0x3b76e8){logger['info'](util[_0xbc41('0x9')](_0xbc41('0x27'),EXTRACTED_REPORT_ID,_0xbc41('0x28')),util['inspect'](_0x3b76e8,{'showHidden':![],'depth':null}));return analyticExtractedReport('Failed');});}main();
\ No newline at end of file
+var _0xa149=['inspect','Failed','finally','exit','util','path','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','../../config/logger','analytics','argv','AnalyticExtractedReport','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','XLSX','then','query','sequelize','QueryTypes','SELECT','num','Empty','split','length','range','isInteger','push','%s\x20limit\x20%d\x20OFFSET\x20%d','dirname','basename','.xlsx','existsSync','join','each','%s%d.%s','%s.%s','xlsx','writeFileSync','binary','zip\x20finished','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','zip','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0xa149,0x18c));var _0x9a14=function(_0x34d54e,_0x55730e){_0x34d54e=_0x34d54e-0x0;var _0x4d4e53=_0xa149[_0x34d54e];return _0x4d4e53;};'use strict';var util=require(_0x9a14('0x0'));var path=require(_0x9a14('0x1'));var _=require(_0x9a14('0x2'));var fs=require('fs');var json2xls=require(_0x9a14('0x3'));var BPromise=require(_0x9a14('0x4'));var zipdir=require(_0x9a14('0x5'));var rimraf=require(_0x9a14('0x6'));var db=require(_0x9a14('0x7'))['db'];var dbH=require(_0x9a14('0x7'))['dbH'];var logger=require(_0x9a14('0x8'))(_0x9a14('0x9'));var EXTRACTED_REPORT_ID=Number(process['argv'][0x2]);var QUERY=process[_0x9a14('0xa')][0x3];var PATH=process[_0x9a14('0xa')][0x4];var EXIT_CODE=0x0;function analyticExtractedReport(_0x286760,_0x17d2e5){var _0x109f69={'status':_0x286760};var _0x26efc5={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x17d2e5){_0x109f69['savename']=_0x17d2e5;}return db[_0x9a14('0xb')]['update'](_0x109f69,_0x26efc5);}function main(){var _0x3d0481=0x1388;var _0x25afa7;logger[_0x9a14('0xc')](util[_0x9a14('0xd')](_0x9a14('0xe'),EXTRACTED_REPORT_ID,_0x9a14('0xf')));return db['Setting']['find']({'where':{'id':0x1},'raw':!![],'attributes':['id','split','splitSizeXlsx']})[_0x9a14('0x10')](function(_0x34c392){if(_0x34c392){_0x25afa7=_0x34c392;_0x3d0481=_0x25afa7['splitSizeXlsx']||0x1388;}})[_0x9a14('0x10')](function(){return dbH['sequelize'][_0x9a14('0x11')](util['format']('SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t',QUERY),{'type':dbH[_0x9a14('0x12')][_0x9a14('0x13')][_0x9a14('0x14')]});})[_0x9a14('0x10')](function(_0x4b414d){if(!_0x4b414d[0x0][_0x9a14('0x15')]){return analyticExtractedReport(_0x9a14('0x16'));}var _0x172d72=[];var _0x8a0666=0x0;if(_0x25afa7[_0x9a14('0x17')]){if(_0x4b414d&&_0x4b414d[_0x9a14('0x18')]){var _0x283e10=_[_0x9a14('0x19')](_0x4b414d[0x0][_0x9a14('0x15')]/_0x3d0481);var _0x3aa654=Number[_0x9a14('0x1a')](_0x4b414d[0x0]['num']/_0x3d0481)?_0x4b414d[0x0]['num']%_0x3d0481:0x0;_0x283e10['forEach'](function(_0x485d6d){if(_0x485d6d>0x0){_0x8a0666+=_0x3d0481;}_0x172d72['push'](dbH[_0x9a14('0x12')][_0x9a14('0x11')](util['format']('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x3d0481,_0x8a0666),{'type':dbH['sequelize']['QueryTypes'][_0x9a14('0x14')]}));});if(_0x3aa654>0x0){_0x8a0666+=_0x3d0481;_0x172d72[_0x9a14('0x1b')](dbH[_0x9a14('0x12')][_0x9a14('0x11')](util[_0x9a14('0xd')](_0x9a14('0x1c'),QUERY,_0x3aa654,_0x8a0666),{'type':dbH[_0x9a14('0x12')]['QueryTypes']['SELECT']}));}}}else{_0x172d72[_0x9a14('0x1b')](dbH[_0x9a14('0x12')][_0x9a14('0x11')](QUERY,{'type':dbH['sequelize'][_0x9a14('0x13')][_0x9a14('0x14')]}));}var _0x1e477f=path[_0x9a14('0x1d')](PATH);var _0x16ae46=path[_0x9a14('0x1e')](PATH,_0x9a14('0x1f'));var _0x1545c7=_0x25afa7['split']&&_0x172d72['length']>0x1;var _0x3089e6=[];if(!fs[_0x9a14('0x20')](path[_0x9a14('0x21')](_0x1e477f,_0x16ae46))&&_0x1545c7){fs['mkdirSync'](path['join'](_0x1e477f,_0x16ae46));}return BPromise[_0x9a14('0x22')](_0x172d72,function(_0x3ee854){_0x3089e6[_0x9a14('0x1b')](_0x3ee854);})[_0x9a14('0x10')](function(){for(var _0x47755e=0x0;_0x47755e<_0x3089e6['length'];_0x47755e+=0x1){var _0x7b53f3;var _0x4e171b=_0x3089e6[_0x47755e];if(_0x1545c7){_0x7b53f3=path['join'](_0x1e477f,_0x16ae46,util[_0x9a14('0xd')](_0x9a14('0x23'),_0x16ae46,_0x47755e,'xlsx'));}else{_0x7b53f3=path[_0x9a14('0x21')](_0x1e477f,util['format'](_0x9a14('0x24'),_0x16ae46,_0x9a14('0x25')));}fs[_0x9a14('0x26')](_0x7b53f3,json2xls(_0x4e171b),_0x9a14('0x27'));}})[_0x9a14('0x10')](function(){if(_0x1545c7){return new Promise(function(_0xc9726a){zipdir(path[_0x9a14('0x21')](_0x1e477f,_0x16ae46),{'saveTo':path[_0x9a14('0x21')](_0x1e477f,util[_0x9a14('0xd')]('%s.%s',_0x16ae46,'zip'))},function(_0x4b2707,_0x325ab6){rimraf(path[_0x9a14('0x21')](_0x1e477f,_0x16ae46),function(){});_0xc9726a(_0x9a14('0x28'));});});}})[_0x9a14('0x10')](function(){logger[_0x9a14('0xc')](util[_0x9a14('0xd')](_0x9a14('0x29'),EXTRACTED_REPORT_ID,'XLSX'));return analyticExtractedReport(_0x9a14('0x2a'),_0x1545c7?util[_0x9a14('0xd')](_0x9a14('0x24'),_0x16ae46,_0x1545c7?_0x9a14('0x2b'):_0x9a14('0x25')):null);});})['catch'](function(_0x261476){logger[_0x9a14('0xc')](util['format'](_0x9a14('0x2c'),EXTRACTED_REPORT_ID,'XLSX'),util[_0x9a14('0x2d')](_0x261476,{'showHidden':![],'depth':null}));EXIT_CODE=0x1;return analyticExtractedReport(_0x9a14('0x2e'));})[_0x9a14('0x2f')](function(){process[_0x9a14('0x30')](EXIT_CODE);});}main();
\ No newline at end of file