промежуточный. частичный рефакторинг смены глобальный настроек. автоотключение проверки бд тестов если активных пакетов нет.

This commit is contained in:
2023-11-13 21:07:44 +03:00
parent 56f54581b6
commit a76e9d0310
21 changed files with 218 additions and 188 deletions

View File

@@ -1,20 +1,42 @@
package Visual_DVM_2021.Passes.All;
import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.TestingServer;
import Visual_DVM_2021.Passes.Pass_2021;
import Visual_DVM_2021.Passes.TestingSystemPass;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.util.Vector;
public class SynchronizeTestsTasks extends TestingSystemPass<Vector<Integer>> {
public class SynchronizeTestsTasks extends Pass_2021 {
byte[] db_file_bytes;
File new_db_file;
@Override
protected boolean canStart(Object... args) throws Exception {
return Current.getAccount().CheckRegistered(Log);
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;
}
@Override
protected boolean needsAnimation() {
@@ -30,37 +52,42 @@ public class SynchronizeTestsTasks extends TestingSystemPass<Vector<Integer>> {
}
@Override
protected void performPreparation() throws Exception {
server.account_db.Disconnect();
Global.testingServer.account_db.Disconnect();
}
@Override
protected void showPreparation() throws Exception {
server.account_db.packages.ClearUI();
server.account_db.sapforTasksPackages.ClearUI();
Global.testingServer.account_db.packages.ClearUI();
Global.testingServer.account_db.sapforTasksPackages.ClearUI();
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveTestsTasksDatabase, Current.getAccount().email));
response.Unpack(new_db_file = Utils.getTempFileName("tdb"));
protected void body() throws Exception {
Utils.unpackFile(db_file_bytes, new_db_file = Utils.getTempFileName("tdb"));
if (new_db_file.exists()) {
Utils.forceDeleteWithCheck(server.account_db.getFile());
FileUtils.moveFile(new_db_file, server.account_db.getFile());
server.account_db.setFile(Current.getAccount().email);
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);
}
server.account_db.Connect();
server.account_db.CreateAllTables();
server.account_db.prepareTablesStatements();
server.account_db.Synchronize();
//--
Global.testingServer.account_db.Connect();
Global.testingServer.account_db.CreateAllTables();
Global.testingServer.account_db.prepareTablesStatements();
Global.testingServer.account_db.Synchronize();
UI.getMainWindow().getTestingWindow().RemountTestTable();
//--
}
@Override
protected boolean validate() {
return (response.object != null);
return (db_file_bytes != null);
}
@Override
protected void showDone() throws Exception {
server.account_db.packages.ShowUI();
server.account_db.sapforTasksPackages.ShowUI();
if (!TestingServer.checkTasks) UI.getMainWindow().getTestingWindow().ShowAutoActualizeTestsState();
protected void showFinish() throws Exception {
Global.testingServer.account_db.packages.ShowUI();
Global.testingServer.account_db.sapforTasksPackages.ShowUI();
if (!Global.testingServer.account_db.hasActivePackages()) {
Global.properties.updateField("AutoCheckTesting", false);
TestingServer.TimerOff();
UI.testingBar.ShowAutoCheckTesting();
}
}
}