김예미

add database part

......@@ -21,6 +21,7 @@
</div>
<div class="content">
<h1 id="cc">Contents</h1>
</div>
<div data-role="main" class="ui-content" id="btn_group">
<button id="connect_btn" onclick="location.href='menu.html'">Next</button>
</div>
......
......@@ -18,14 +18,14 @@ connect_btn.addEventListener("click", () => {
webPreferences: {
nodeIntegration: true
}
});
});
//win.webContents.openDevTools();
win.on("close", () => {
win = null;
});
win.loadFile("./src/connect.html");
win.show();
//win.webContents.openDevTools();
win.on("close", () => {
win = null;
});
win.loadFile("./src/connect.html");
win.show();
});
......@@ -41,8 +41,10 @@ function apkInstall(){
cmd_install = exec('adb -s '+device+' install -r app-release.apk',function(error, stdout, stderr){
cc.innerHTML="install apk";
cmd_exec = exec('adb -s '+device+' shell am start -n com.example.dataextraction/com.example.dataextraction.MainActivity',function(error, stdout, stderr){
cc.innerHTML="start app";
cc.innerHTML="extract data";
cc.innerHTML="start app";
setTimeout(function(){
cc.innerHTML="extract data";
},10000);
})
});
cmd_install();
......@@ -54,48 +56,58 @@ ipcRenderer.on("device", (e, arg) => {
connect_btn.innerHTML = "Connected : ".concat(device);
//device.innerHTML = arg.toString();
cc.innerHTML="DATA EXTRACTION START !";
apkInstall();
});
function extractDB () {
cmd_backup = exec('adb -s '+device+' backup com.example.dataextraction -f backup.dataextraction.ad', function(error, stdout, stderr){
cc.innerHTML="backup app";
setTimeout(function(){
cmd_unpack = exec('java -jar abe.jar unpack backup.dataextraction.ad dataextraction.tar',function(error, stdout, stderr){
cc.innerHTML="unpack backup";
cmd_unzip = exec('tar xvf dataextraction.tar', function(error, stdout, stderr){
cc.innerHTML="unzip tar";
cmd_moveIdb = fs.rename('apps/com.example.dataextraction/db/InnerDatabase.db', 'InnerDatabase.db', function(){
cc.innerHTML="move InnerDB File";
cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){
cc.innerHTML="move NetworkDB File";
cmd_sqlIdb = exec('sqlite3 InnerDatabase.db .dump | python SQLiteToMysql.py > InnerDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="make InnerDB SQL";
cmd_sqlNdb = exec('sqlite3 networkDatabase.db .dump | python SQLiteToMysql_network.py > networkDatabase.sql', function(error, stdout, stderr){
cc.innerHTML="make NetworkDB SQL";
connection.query('DROP DATABASE IF EXISTS DATAEXTRACTION; CREATE DATABASE DATAEXTRACTION CHARACTER SET utf8mb4 COLLATE utf8mb4_bin',function(error, result,fields){
connection.query('DROP DATABASE IF EXISTS DATAEXTRACTION_NETWORK; CREATE DATABASE DATAEXTRACTION_NETWORK',function(error, result, fields){
})
});
})
})
})
})
})
})
},7000);
});
//cmd_backup();
cmd_backup = exec('adb -s '+device+' backup com.example.dataextraction -f backup.dataextraction.ad', function(error, stdout, stderr){
cc.innerHTML="backup app";
setTimeout(function(){
cmd_unpack = exec('java -jar abe.jar unpack backup.dataextraction.ad dataextraction.tar',function(error, stdout, stderr){
cc.innerHTML="unpack backup";
cmd_unzip = exec('tar xvf dataextraction.tar', function(error, stdout, stderr){
cc.innerHTML="unzip tar";
cmd_moveIdb = fs.rename('apps/com.example.dataextraction/db/InnerDatabase.db', 'InnerDatabase.db', function(){
cc.innerHTML="move InnerDB File";
cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){
cc.innerHTML="move NetworkDB File";
cmd_sqlIdb = exec('sqlite3 InnerDatabase.db .dump | python SQLiteToMysql.py > InnerDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="make InnerDB SQL";
cmd_sqlNdb = exec('sqlite3 networkDatabase.db .dump | python SQLiteToMysql_network.py > networkDatabase.sql', function(error, stdout, stderr){
cc.innerHTML="make NetworkDB SQL";
cmd_makeIdb = exec('mysql -uroot -p1234 -e "DROP DATABASE IF EXISTS DATAEXTRACTION;CREATE DATABASE DATAEXTRACTION CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;USE DATAEXTRACTION;"',function(error, stdout, stderr){
cc.innerHTML="create InnerDB";
cmd_insertIdb = exec('mysql -uroot -p1234 DATAEXTRACTION < InnerDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="insert Data ; InnerDB";
cmd_makeNdb = exec('mysql -uroot -p1234 -e "DROP DATABASE IF EXISTS DATAEXTRACTION_network;CREATE DATABASE DATAEXTRACTION_network;USE DATAEXTRACTION_network;"',function(error, stdout, stderr){
cc.innerHTML="create NetworkDB";
cmd_insertNdb = exec('mysql -uroot -p1234 DATAEXTRACTION_network < networkDatabase.sql',function(error, stdout, stderr){
cc.innerHTML="insert Data ; NetworkDB";
cc.innerHTML="Data Extraction Complete !";
cc.innerHTML="Click 'NEXT' Button";
})
})
})
})
})
})
})
})
})
})
},7000);
});
//cmd_backup();
}
//db insert done
io.on('connection', function(socket){
cc.innerHTML="connect";
cc.innerHTML="database created !";
var instanceId = socket.id;
socket.on('alert', function(data){
extractDB();
})
})
})
......