2023-09-17 22:13:42 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
|
|
|
|
import Common.Current;
|
2023-11-13 21:07:44 +03:00
|
|
|
import Common.Global;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Common.UI.UI;
|
|
|
|
|
import Common.Utils.Utils;
|
|
|
|
|
import Repository.Server.ServerCode;
|
|
|
|
|
import Repository.Server.ServerExchangeUnit_2021;
|
|
|
|
|
import TestingSystem.TestingServer;
|
2023-11-13 21:07:44 +03:00
|
|
|
import Visual_DVM_2021.Passes.Pass_2021;
|
2023-11-16 16:20:20 +03:00
|
|
|
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
2023-09-17 22:13:42 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
2023-11-13 21:07:44 +03:00
|
|
|
public class SynchronizeTestsTasks extends Pass_2021 {
|
|
|
|
|
byte[] db_file_bytes;
|
2023-09-17 22:13:42 +03:00
|
|
|
File new_db_file;
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2023-11-13 21:07:44 +03:00
|
|
|
db_file_bytes = null;
|
|
|
|
|
new_db_file = null;
|
|
|
|
|
if (Current.getAccount().CheckRegistered(Log)) {
|
|
|
|
|
TestingSystemPass download = new TestingSystemPass() {
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return "Загрузка базы тестовых задач";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveTestsTasksDatabase, Current.getAccount().email));
|
|
|
|
|
db_file_bytes = (byte[]) response.object;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return download.Do();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
return "/icons/ComponentsActual.png";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performPreparation() throws Exception {
|
2023-11-13 21:07:44 +03:00
|
|
|
Global.testingServer.account_db.Disconnect();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showPreparation() throws Exception {
|
2023-11-13 21:54:52 +03:00
|
|
|
Global.testingServer.account_db.SaveLastSelections();
|
2023-11-13 21:07:44 +03:00
|
|
|
Global.testingServer.account_db.packages.ClearUI();
|
|
|
|
|
Global.testingServer.account_db.sapforTasksPackages.ClearUI();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
2023-11-13 21:07:44 +03:00
|
|
|
protected void body() throws Exception {
|
|
|
|
|
Utils.unpackFile(db_file_bytes, new_db_file = Utils.getTempFileName("tdb"));
|
2023-09-17 22:13:42 +03:00
|
|
|
if (new_db_file.exists()) {
|
2023-11-13 21:07:44 +03:00
|
|
|
Utils.forceDeleteWithCheck(Global.testingServer.account_db.getFile());
|
|
|
|
|
FileUtils.moveFile(new_db_file, Global.testingServer.account_db.getFile());
|
|
|
|
|
Global.testingServer.account_db.setFile(Current.getAccount().email);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
2023-11-13 21:07:44 +03:00
|
|
|
//--
|
|
|
|
|
Global.testingServer.account_db.Connect();
|
|
|
|
|
Global.testingServer.account_db.CreateAllTables();
|
|
|
|
|
Global.testingServer.account_db.prepareTablesStatements();
|
|
|
|
|
Global.testingServer.account_db.Synchronize();
|
2023-09-17 22:13:42 +03:00
|
|
|
UI.getMainWindow().getTestingWindow().RemountTestTable();
|
2023-11-13 21:07:44 +03:00
|
|
|
//--
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean validate() {
|
2023-11-13 21:07:44 +03:00
|
|
|
return (db_file_bytes != null);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
2023-11-13 21:07:44 +03:00
|
|
|
protected void showFinish() throws Exception {
|
|
|
|
|
Global.testingServer.account_db.packages.ShowUI();
|
|
|
|
|
Global.testingServer.account_db.sapforTasksPackages.ShowUI();
|
2023-11-13 21:54:52 +03:00
|
|
|
Global.testingServer.account_db.RestoreLastSelections();
|
2023-11-13 21:07:44 +03:00
|
|
|
if (!Global.testingServer.account_db.hasActivePackages()) {
|
|
|
|
|
Global.properties.updateField("AutoCheckTesting", false);
|
|
|
|
|
TestingServer.TimerOff();
|
|
|
|
|
UI.testingBar.ShowAutoCheckTesting();
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|