Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / components / export / xlsx.js
index 2b9388a..74010d4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x20de=['util','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename','AnalyticExtractedReport','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','find','split','splitSizeXlsx','then','sequelize','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','SELECT','Empty','num','push','basename','.xlsx','length','existsSync','join','each','%s%d.%s','xlsx','%s.%s','writeFileSync','zip','info','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','XLSX','Completed','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format'];(function(_0x149a69,_0x4969b7){var _0x1e3de1=function(_0x99b61d){while(--_0x99b61d){_0x149a69['push'](_0x149a69['shift']());}};_0x1e3de1(++_0x4969b7);}(_0x20de,0x134));var _0xe20d=function(_0x20589d,_0x55d5bf){_0x20589d=_0x20589d-0x0;var _0x422de9=_0x20de[_0x20589d];return _0x422de9;};'use strict';var util=require(_0xe20d('0x0'));var path=require('path');var _=require(_0xe20d('0x1'));var fs=require('fs');var json2xls=require(_0xe20d('0x2'));var BPromise=require(_0xe20d('0x3'));var zipdir=require(_0xe20d('0x4'));var rimraf=require(_0xe20d('0x5'));var db=require(_0xe20d('0x6'))['db'];var dbH=require(_0xe20d('0x6'))[_0xe20d('0x7')];var logger=require(_0xe20d('0x8'))(_0xe20d('0x9'));var EXTRACTED_REPORT_ID=Number(process[_0xe20d('0xa')][0x2]);var QUERY=process['argv'][0x3];var PATH=process[_0xe20d('0xa')][0x4];function analyticExtractedReport(_0x5a5ac2,_0x4e1fb9){var _0x4909c9={'status':_0x5a5ac2};var _0x110ff5={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x4e1fb9){_0x4909c9[_0xe20d('0xb')]=_0x4e1fb9;}return db[_0xe20d('0xc')]['update'](_0x4909c9,_0x110ff5);}function main(){var _0x288d35=0x1388;var _0x2df52b;logger['info'](util[_0xe20d('0xd')](_0xe20d('0xe'),EXTRACTED_REPORT_ID,'XLSX'));return db[_0xe20d('0xf')][_0xe20d('0x10')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0xe20d('0x11'),_0xe20d('0x12')]})['then'](function(_0x59a581){if(_0x59a581){_0x2df52b=_0x59a581;_0x288d35=_0x2df52b[_0xe20d('0x12')]||0x1388;}})[_0xe20d('0x13')](function(){return dbH[_0xe20d('0x14')][_0xe20d('0x15')](util[_0xe20d('0xd')](_0xe20d('0x16'),QUERY),{'type':dbH[_0xe20d('0x14')][_0xe20d('0x17')][_0xe20d('0x18')]});})['then'](function(_0x2367f7){if(!_0x2367f7[0x0]['num']){return analyticExtractedReport(_0xe20d('0x19'));}var _0x3aa19d=[];var _0x29b500=0x0;var _0x53f8c3=!![];if(_0x2df52b[_0xe20d('0x11')]){if(_0x2367f7&&_0x2367f7['length']){var _0x1738d9=_0x2367f7[0x0][_0xe20d('0x1a')]%(_0x29b500+_0x288d35);for(;_0x53f8c3;_0x29b500+=_0x288d35,_0x1738d9=_0x2367f7[0x0][_0xe20d('0x1a')]%(_0x29b500+_0x288d35)){if(_0x1738d9==0x0||_0x1738d9==_0x2367f7[0x0]['num']){_0x53f8c3=![];}_0x3aa19d[_0xe20d('0x1b')](dbH[_0xe20d('0x14')][_0xe20d('0x15')](util[_0xe20d('0xd')]('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x288d35,_0x29b500),{'type':dbH[_0xe20d('0x14')][_0xe20d('0x17')][_0xe20d('0x18')]}));}}}else{_0x3aa19d[_0xe20d('0x1b')](dbH['sequelize'][_0xe20d('0x15')](QUERY,{'type':dbH['sequelize']['QueryTypes'][_0xe20d('0x18')]}));}var _0x4045b3=path['dirname'](PATH);var _0x5e7237=path[_0xe20d('0x1c')](PATH,_0xe20d('0x1d'));var _0x5ce547=_0x2df52b[_0xe20d('0x11')]&&_0x3aa19d[_0xe20d('0x1e')]>0x1;var _0x3f0227=[];if(!fs[_0xe20d('0x1f')](path[_0xe20d('0x20')](_0x4045b3,_0x5e7237))&&_0x5ce547){fs['mkdirSync'](path[_0xe20d('0x20')](_0x4045b3,_0x5e7237));}return BPromise[_0xe20d('0x21')](_0x3aa19d,function(_0x1a76bc){_0x3f0227[_0xe20d('0x1b')](_0x1a76bc);})[_0xe20d('0x13')](function(){for(var _0x51f395=0x0;_0x51f395<_0x3f0227['length'];_0x51f395+=0x1){var _0x27b759;var _0x497726=_0x3f0227[_0x51f395];if(_0x5ce547){_0x27b759=path[_0xe20d('0x20')](_0x4045b3,_0x5e7237,util[_0xe20d('0xd')](_0xe20d('0x22'),_0x5e7237,_0x51f395,_0xe20d('0x23')));}else{_0x27b759=path[_0xe20d('0x20')](_0x4045b3,util[_0xe20d('0xd')](_0xe20d('0x24'),_0x5e7237,'xlsx'));}fs[_0xe20d('0x25')](_0x27b759,json2xls(_0x497726),'binary');}})['then'](function(){if(_0x5ce547){zipdir(path['join'](_0x4045b3,_0x5e7237),{'saveTo':path['join'](_0x4045b3,util['format'](_0xe20d('0x24'),_0x5e7237,_0xe20d('0x26')))},function(_0x41e140,_0x4f2d27){});rimraf(path['join'](_0x4045b3,_0x5e7237),function(){});}})[_0xe20d('0x13')](function(){logger[_0xe20d('0x27')](util[_0xe20d('0xd')](_0xe20d('0x28'),EXTRACTED_REPORT_ID,_0xe20d('0x29')));return analyticExtractedReport(_0xe20d('0x2a'),_0x5ce547?util[_0xe20d('0xd')](_0xe20d('0x24'),_0x5e7237,_0x5ce547?'zip':_0xe20d('0x23')):null);});})['catch'](function(_0x54a361){logger[_0xe20d('0x27')](util['format'](_0xe20d('0x2b'),EXTRACTED_REPORT_ID,_0xe20d('0x29')),util['inspect'](_0x54a361,{'showHidden':![],'depth':null}));return analyticExtractedReport('Failed');});}main();
\ No newline at end of file
+var _0x78d5=['split','push','%s\x20limit\x20%d\x20OFFSET\x20%d','query','dirname','basename','.xlsx','length','existsSync','mkdirSync','join','each','%s%d.%s','xlsx','%s.%s','writeFileSync','binary','info','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','inspect','Failed','util','path','lodash','json2xls','bluebird','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename','AnalyticExtractedReport','update','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','XLSX','Setting','splitSizeXlsx','then','sequelize','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','SELECT','num','Empty'];(function(_0x14b228,_0x5678b8){var _0x4b53e1=function(_0x2442c4){while(--_0x2442c4){_0x14b228['push'](_0x14b228['shift']());}};_0x4b53e1(++_0x5678b8);}(_0x78d5,0x1a8));var _0x578d=function(_0x4bd074,_0xb4376){_0x4bd074=_0x4bd074-0x0;var _0x4d6453=_0x78d5[_0x4bd074];return _0x4d6453;};'use strict';var util=require(_0x578d('0x0'));var path=require(_0x578d('0x1'));var _=require(_0x578d('0x2'));var fs=require('fs');var json2xls=require(_0x578d('0x3'));var BPromise=require(_0x578d('0x4'));var zipdir=require('zip-dir');var rimraf=require(_0x578d('0x5'));var db=require(_0x578d('0x6'))['db'];var dbH=require('../../mysqldb')[_0x578d('0x7')];var logger=require(_0x578d('0x8'))(_0x578d('0x9'));var EXTRACTED_REPORT_ID=Number(process[_0x578d('0xa')][0x2]);var QUERY=process[_0x578d('0xa')][0x3];var PATH=process[_0x578d('0xa')][0x4];function analyticExtractedReport(_0x16d152,_0x52ebea){var _0x310256={'status':_0x16d152};var _0x474fd9={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x52ebea){_0x310256[_0x578d('0xb')]=_0x52ebea;}return db[_0x578d('0xc')][_0x578d('0xd')](_0x310256,_0x474fd9);}function main(){var _0x2d6bcf=0x1388;var _0x21a456;logger['info'](util[_0x578d('0xe')](_0x578d('0xf'),EXTRACTED_REPORT_ID,_0x578d('0x10')));return db[_0x578d('0x11')]['find']({'where':{'id':0x1},'raw':!![],'attributes':['id','split','splitSizeXlsx']})['then'](function(_0x5db9ac){if(_0x5db9ac){_0x21a456=_0x5db9ac;_0x2d6bcf=_0x21a456[_0x578d('0x12')]||0x1388;}})[_0x578d('0x13')](function(){return dbH[_0x578d('0x14')]['query'](util[_0x578d('0xe')](_0x578d('0x15'),QUERY),{'type':dbH['sequelize'][_0x578d('0x16')][_0x578d('0x17')]});})['then'](function(_0x5bb445){if(!_0x5bb445[0x0][_0x578d('0x18')]){return analyticExtractedReport(_0x578d('0x19'));}var _0x49d146=[];var _0x45f575=0x0;var _0x287d25=!![];if(_0x21a456[_0x578d('0x1a')]){if(_0x5bb445&&_0x5bb445['length']){var _0x454126=_0x5bb445[0x0][_0x578d('0x18')]%(_0x45f575+_0x2d6bcf);for(;_0x287d25;_0x45f575+=_0x2d6bcf,_0x454126=_0x5bb445[0x0][_0x578d('0x18')]%(_0x45f575+_0x2d6bcf)){if(_0x454126==0x0||_0x454126==_0x5bb445[0x0][_0x578d('0x18')]){_0x287d25=![];}_0x49d146[_0x578d('0x1b')](dbH[_0x578d('0x14')]['query'](util[_0x578d('0xe')](_0x578d('0x1c'),QUERY,_0x2d6bcf,_0x45f575),{'type':dbH[_0x578d('0x14')][_0x578d('0x16')][_0x578d('0x17')]}));}}}else{_0x49d146[_0x578d('0x1b')](dbH['sequelize'][_0x578d('0x1d')](QUERY,{'type':dbH[_0x578d('0x14')][_0x578d('0x16')][_0x578d('0x17')]}));}var _0x22edcc=path[_0x578d('0x1e')](PATH);var _0x3786ad=path[_0x578d('0x1f')](PATH,_0x578d('0x20'));var _0x2aa2b5=_0x21a456[_0x578d('0x1a')]&&_0x49d146[_0x578d('0x21')]>0x1;var _0xdfbd93=[];if(!fs[_0x578d('0x22')](path['join'](_0x22edcc,_0x3786ad))&&_0x2aa2b5){fs[_0x578d('0x23')](path[_0x578d('0x24')](_0x22edcc,_0x3786ad));}return BPromise[_0x578d('0x25')](_0x49d146,function(_0x396ec7){_0xdfbd93[_0x578d('0x1b')](_0x396ec7);})[_0x578d('0x13')](function(){for(var _0x355d3c=0x0;_0x355d3c<_0xdfbd93[_0x578d('0x21')];_0x355d3c+=0x1){var _0x179028;var _0x46b926=_0xdfbd93[_0x355d3c];if(_0x2aa2b5){_0x179028=path[_0x578d('0x24')](_0x22edcc,_0x3786ad,util[_0x578d('0xe')](_0x578d('0x26'),_0x3786ad,_0x355d3c,_0x578d('0x27')));}else{_0x179028=path[_0x578d('0x24')](_0x22edcc,util[_0x578d('0xe')](_0x578d('0x28'),_0x3786ad,'xlsx'));}fs[_0x578d('0x29')](_0x179028,json2xls(_0x46b926),_0x578d('0x2a'));}})['then'](function(){if(_0x2aa2b5){zipdir(path[_0x578d('0x24')](_0x22edcc,_0x3786ad),{'saveTo':path[_0x578d('0x24')](_0x22edcc,util[_0x578d('0xe')](_0x578d('0x28'),_0x3786ad,'zip'))},function(_0x124711,_0x1d2019){});rimraf(path[_0x578d('0x24')](_0x22edcc,_0x3786ad),function(){});}})[_0x578d('0x13')](function(){logger[_0x578d('0x2b')](util[_0x578d('0xe')](_0x578d('0x2c'),EXTRACTED_REPORT_ID,_0x578d('0x10')));return analyticExtractedReport(_0x578d('0x2d'),_0x2aa2b5?util['format']('%s.%s',_0x3786ad,_0x2aa2b5?_0x578d('0x2e'):_0x578d('0x27')):null);});})['catch'](function(_0x4ee5dd){logger[_0x578d('0x2b')](util[_0x578d('0xe')](_0x578d('0x2f'),EXTRACTED_REPORT_ID,_0x578d('0x10')),util[_0x578d('0x30')](_0x4ee5dd,{'showHidden':![],'depth':null}));return analyticExtractedReport(_0x578d('0x31'));});}main();
\ No newline at end of file