Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / components / export / xlsx.js
index 89df077..4250560 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8ad3=['Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','XLSX','Completed','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','Failed','util','lodash','json2xls','bluebird','../../config/logger','argv','savename','AnalyticExtractedReport','update','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','find','split','splitSizeXlsx','sequelize','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','SELECT','then','num','Empty','length','push','%s\x20limit\x20%d\x20OFFSET\x20%d','dirname','basename','.xlsx','existsSync','join','each','xlsx','%s.%s','writeFileSync','binary','zip'];(function(_0x1bda6c,_0x5440b1){var _0x501a86=function(_0x1de54c){while(--_0x1de54c){_0x1bda6c['push'](_0x1bda6c['shift']());}};_0x501a86(++_0x5440b1);}(_0x8ad3,0xe8));var _0x38ad=function(_0x165ea1,_0x3ae398){_0x165ea1=_0x165ea1-0x0;var _0x5db1a3=_0x8ad3[_0x165ea1];return _0x5db1a3;};'use strict';var util=require(_0x38ad('0x0'));var path=require('path');var _=require(_0x38ad('0x1'));var fs=require('fs');var json2xls=require(_0x38ad('0x2'));var BPromise=require(_0x38ad('0x3'));var zipdir=require('zip-dir');var rimraf=require('rimraf');var db=require('../../mysqldb')['db'];var dbH=require('../../mysqldb')['dbH'];var logger=require(_0x38ad('0x4'))('analytics');var EXTRACTED_REPORT_ID=Number(process[_0x38ad('0x5')][0x2]);var QUERY=process['argv'][0x3];var PATH=process['argv'][0x4];function analyticExtractedReport(_0x25d1d1,_0x36243d){var _0x1fb994={'status':_0x25d1d1};var _0xd9edd9={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x36243d){_0x1fb994[_0x38ad('0x6')]=_0x36243d;}return db[_0x38ad('0x7')][_0x38ad('0x8')](_0x1fb994,_0xd9edd9);}function main(){var _0x201ee5=0x1388;var _0x307afc;logger[_0x38ad('0x9')](util[_0x38ad('0xa')](_0x38ad('0xb'),EXTRACTED_REPORT_ID,'XLSX'));return db[_0x38ad('0xc')][_0x38ad('0xd')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0x38ad('0xe'),_0x38ad('0xf')]})['then'](function(_0x18ec09){if(_0x18ec09){_0x307afc=_0x18ec09;_0x201ee5=_0x307afc[_0x38ad('0xf')]||0x1388;}})['then'](function(){return dbH[_0x38ad('0x10')][_0x38ad('0x11')](util[_0x38ad('0xa')](_0x38ad('0x12'),QUERY),{'type':dbH[_0x38ad('0x10')][_0x38ad('0x13')][_0x38ad('0x14')]});})[_0x38ad('0x15')](function(_0x138ba4){if(!_0x138ba4[0x0][_0x38ad('0x16')]){return analyticExtractedReport(_0x38ad('0x17'));}var _0x319109=[];var _0x1a7b2f=0x0;var _0x1436f2=!![];if(_0x307afc[_0x38ad('0xe')]){if(_0x138ba4&&_0x138ba4[_0x38ad('0x18')]){var _0x5f06e9=_0x138ba4[0x0][_0x38ad('0x16')]%(_0x1a7b2f+_0x201ee5);for(;_0x1436f2;_0x1a7b2f+=_0x201ee5,_0x5f06e9=_0x138ba4[0x0][_0x38ad('0x16')]%(_0x1a7b2f+_0x201ee5)){if(_0x5f06e9==0x0||_0x5f06e9==_0x138ba4[0x0][_0x38ad('0x16')]){_0x1436f2=![];}_0x319109[_0x38ad('0x19')](dbH[_0x38ad('0x10')][_0x38ad('0x11')](util[_0x38ad('0xa')](_0x38ad('0x1a'),QUERY,_0x201ee5,_0x1a7b2f),{'type':dbH[_0x38ad('0x10')][_0x38ad('0x13')][_0x38ad('0x14')]}));}}}else{_0x319109[_0x38ad('0x19')](dbH[_0x38ad('0x10')][_0x38ad('0x11')](QUERY,{'type':dbH[_0x38ad('0x10')][_0x38ad('0x13')]['SELECT']}));}var _0x22bedd=path[_0x38ad('0x1b')](PATH);var _0x57cd33=path[_0x38ad('0x1c')](PATH,_0x38ad('0x1d'));var _0x8bb8ec=_0x307afc[_0x38ad('0xe')]&&_0x319109[_0x38ad('0x18')]>0x1;var _0x1f92db=[];if(!fs[_0x38ad('0x1e')](path[_0x38ad('0x1f')](_0x22bedd,_0x57cd33))&&_0x8bb8ec){fs['mkdirSync'](path['join'](_0x22bedd,_0x57cd33));}return BPromise[_0x38ad('0x20')](_0x319109,function(_0x27bf09){_0x1f92db[_0x38ad('0x19')](_0x27bf09);})[_0x38ad('0x15')](function(){for(var _0x5725f8=0x0;_0x5725f8<_0x1f92db['length'];_0x5725f8+=0x1){var _0x24cd86;var _0x5f5b64=_0x1f92db[_0x5725f8];if(_0x8bb8ec){_0x24cd86=path[_0x38ad('0x1f')](_0x22bedd,_0x57cd33,util['format']('%s%d.%s',_0x57cd33,_0x5725f8,_0x38ad('0x21')));}else{_0x24cd86=path[_0x38ad('0x1f')](_0x22bedd,util[_0x38ad('0xa')](_0x38ad('0x22'),_0x57cd33,_0x38ad('0x21')));}fs[_0x38ad('0x23')](_0x24cd86,json2xls(_0x5f5b64),_0x38ad('0x24'));}})[_0x38ad('0x15')](function(){if(_0x8bb8ec){zipdir(path['join'](_0x22bedd,_0x57cd33),{'saveTo':path[_0x38ad('0x1f')](_0x22bedd,util['format'](_0x38ad('0x22'),_0x57cd33,_0x38ad('0x25')))},function(_0x29c990,_0x253ca2){});rimraf(path[_0x38ad('0x1f')](_0x22bedd,_0x57cd33),function(){});}})['then'](function(){logger[_0x38ad('0x9')](util[_0x38ad('0xa')](_0x38ad('0x26'),EXTRACTED_REPORT_ID,_0x38ad('0x27')));return analyticExtractedReport(_0x38ad('0x28'),_0x8bb8ec?util['format'](_0x38ad('0x22'),_0x57cd33,_0x8bb8ec?'zip':_0x38ad('0x21')):null);});})[_0x38ad('0x29')](function(_0x13a2d5){logger[_0x38ad('0x9')](util[_0x38ad('0xa')](_0x38ad('0x2a'),EXTRACTED_REPORT_ID,_0x38ad('0x27')),util[_0x38ad('0x2b')](_0x13a2d5,{'showHidden':![],'depth':null}));return analyticExtractedReport(_0x38ad('0x2c'));});}main();
\ No newline at end of file
+var _0xb1ab=['length','push','QueryTypes','dirname','basename','existsSync','join','mkdirSync','each','%s%d.%s','xlsx','%s.%s','writeFileSync','binary','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','zip','catch','inspect','Failed','path','lodash','json2xls','bluebird','zip-dir','rimraf','../../mysqldb','dbH','../../config/logger','analytics','argv','savename','AnalyticExtractedReport','update','info','format','XLSX','Setting','find','split','then','sequelize','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','SELECT','num','Empty'];(function(_0x25762c,_0x2709df){var _0x2f77a8=function(_0x9f133f){while(--_0x9f133f){_0x25762c['push'](_0x25762c['shift']());}};_0x2f77a8(++_0x2709df);}(_0xb1ab,0x6f));var _0xbb1a=function(_0x4d05a0,_0x53aa7e){_0x4d05a0=_0x4d05a0-0x0;var _0x4c999c=_0xb1ab[_0x4d05a0];return _0x4c999c;};'use strict';var util=require('util');var path=require(_0xbb1a('0x0'));var _=require(_0xbb1a('0x1'));var fs=require('fs');var json2xls=require(_0xbb1a('0x2'));var BPromise=require(_0xbb1a('0x3'));var zipdir=require(_0xbb1a('0x4'));var rimraf=require(_0xbb1a('0x5'));var db=require(_0xbb1a('0x6'))['db'];var dbH=require(_0xbb1a('0x6'))[_0xbb1a('0x7')];var logger=require(_0xbb1a('0x8'))(_0xbb1a('0x9'));var EXTRACTED_REPORT_ID=Number(process[_0xbb1a('0xa')][0x2]);var QUERY=process[_0xbb1a('0xa')][0x3];var PATH=process[_0xbb1a('0xa')][0x4];function analyticExtractedReport(_0x56b479,_0x11d6d5){var _0x26f61e={'status':_0x56b479};var _0x934d77={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x11d6d5){_0x26f61e[_0xbb1a('0xb')]=_0x11d6d5;}return db[_0xbb1a('0xc')][_0xbb1a('0xd')](_0x26f61e,_0x934d77);}function main(){var _0x2988bb=0x1388;var _0x436367;logger[_0xbb1a('0xe')](util[_0xbb1a('0xf')]('Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format',EXTRACTED_REPORT_ID,_0xbb1a('0x10')));return db[_0xbb1a('0x11')][_0xbb1a('0x12')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0xbb1a('0x13'),'splitSizeXlsx']})[_0xbb1a('0x14')](function(_0x25de55){if(_0x25de55){_0x436367=_0x25de55;_0x2988bb=_0x436367['splitSizeXlsx']||0x1388;}})[_0xbb1a('0x14')](function(){return dbH[_0xbb1a('0x15')][_0xbb1a('0x16')](util[_0xbb1a('0xf')](_0xbb1a('0x17'),QUERY),{'type':dbH[_0xbb1a('0x15')]['QueryTypes'][_0xbb1a('0x18')]});})['then'](function(_0x12811f){if(!_0x12811f[0x0][_0xbb1a('0x19')]){return analyticExtractedReport(_0xbb1a('0x1a'));}var _0x396c50=[];var _0x1d9dd6=0x0;var _0x581e33=!![];if(_0x436367['split']){if(_0x12811f&&_0x12811f[_0xbb1a('0x1b')]){var _0x2fbbe2=_0x12811f[0x0]['num']%(_0x1d9dd6+_0x2988bb);for(;_0x581e33;_0x1d9dd6+=_0x2988bb,_0x2fbbe2=_0x12811f[0x0][_0xbb1a('0x19')]%(_0x1d9dd6+_0x2988bb)){if(_0x2fbbe2==0x0||_0x2fbbe2==_0x12811f[0x0]['num']){_0x581e33=![];}_0x396c50[_0xbb1a('0x1c')](dbH['sequelize'][_0xbb1a('0x16')](util[_0xbb1a('0xf')]('%s\x20limit\x20%d\x20OFFSET\x20%d',QUERY,_0x2988bb,_0x1d9dd6),{'type':dbH['sequelize'][_0xbb1a('0x1d')]['SELECT']}));}}}else{_0x396c50[_0xbb1a('0x1c')](dbH[_0xbb1a('0x15')]['query'](QUERY,{'type':dbH[_0xbb1a('0x15')][_0xbb1a('0x1d')][_0xbb1a('0x18')]}));}var _0x5ef652=path[_0xbb1a('0x1e')](PATH);var _0x34bce4=path[_0xbb1a('0x1f')](PATH,'.xlsx');var _0x2ed14e=_0x436367[_0xbb1a('0x13')]&&_0x396c50[_0xbb1a('0x1b')]>0x1;var _0x4decf6=[];if(!fs[_0xbb1a('0x20')](path[_0xbb1a('0x21')](_0x5ef652,_0x34bce4))&&_0x2ed14e){fs[_0xbb1a('0x22')](path[_0xbb1a('0x21')](_0x5ef652,_0x34bce4));}return BPromise[_0xbb1a('0x23')](_0x396c50,function(_0x4e62a7){_0x4decf6[_0xbb1a('0x1c')](_0x4e62a7);})['then'](function(){for(var _0x3fc716=0x0;_0x3fc716<_0x4decf6[_0xbb1a('0x1b')];_0x3fc716+=0x1){var _0x440d16;var _0x342303=_0x4decf6[_0x3fc716];if(_0x2ed14e){_0x440d16=path[_0xbb1a('0x21')](_0x5ef652,_0x34bce4,util[_0xbb1a('0xf')](_0xbb1a('0x24'),_0x34bce4,_0x3fc716,_0xbb1a('0x25')));}else{_0x440d16=path[_0xbb1a('0x21')](_0x5ef652,util[_0xbb1a('0xf')](_0xbb1a('0x26'),_0x34bce4,_0xbb1a('0x25')));}fs[_0xbb1a('0x27')](_0x440d16,json2xls(_0x342303),_0xbb1a('0x28'));}})['then'](function(){if(_0x2ed14e){zipdir(path['join'](_0x5ef652,_0x34bce4),{'saveTo':path[_0xbb1a('0x21')](_0x5ef652,util[_0xbb1a('0xf')]('%s.%s',_0x34bce4,'zip'))},function(_0x5cecc9,_0xed4110){});rimraf(path['join'](_0x5ef652,_0x34bce4),function(){});}})['then'](function(){logger[_0xbb1a('0xe')](util['format'](_0xbb1a('0x29'),EXTRACTED_REPORT_ID,'XLSX'));return analyticExtractedReport('Completed',_0x2ed14e?util[_0xbb1a('0xf')](_0xbb1a('0x26'),_0x34bce4,_0x2ed14e?_0xbb1a('0x2a'):_0xbb1a('0x25')):null);});})[_0xbb1a('0x2b')](function(_0x4ec818){logger[_0xbb1a('0xe')](util[_0xbb1a('0xf')]('Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format',EXTRACTED_REPORT_ID,'XLSX'),util[_0xbb1a('0x2c')](_0x4ec818,{'showHidden':![],'depth':null}));return analyticExtractedReport(_0xbb1a('0x2d'));});}main();
\ No newline at end of file