рефакторинг. неудачные наименования классов, и остатки старых вариантов

This commit is contained in:
2023-10-08 01:06:55 +03:00
parent 49805f1293
commit eedddcd7d3
42 changed files with 295 additions and 1415 deletions

View File

@@ -1,6 +1,86 @@
package SapforTestingSystem.ServerSapforTestingPlanner;
import Common.Constants;
import Common.Utils.Utils;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import TestingSystem.TasksPackage.TasksPackageState;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.TestingSystemPass;
import java.io.File;
import java.io.Serializable;
import java.util.Date;
public class ServerSapforTestingPlanner {
public void Perform(){
SapforTasksPackage sapforTasksPackage = null;
//---
int getSleepMillis() {
return 2000;
}
Object ServerCommand(ServerCode code_in, String arg, Serializable object_in) throws Exception {
TestingSystemPass<Object> pass = new TestingSystemPass<Object>() {
@Override
public String getDescription() {
return "";
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(code_in, arg, object_in));
target = response.object;
}
};
if (!pass.Do()) throw new PassException("Ошибка взаимодействия с сервером " + code_in);
return pass.target;
}
//---
void UpdatePackage(SapforTasksPackage package_in) throws Exception {
package_in.ChangeDate = new Date().getTime();
ServerCommand(ServerCode.EditObject, "", package_in);
}
void PackageStart() throws Exception {
File workspace = new File(sapforTasksPackage.workspace);
File script = new File(sapforTasksPackage.workspace, "start");
ProcessBuilder procBuilder = new ProcessBuilder(script.getAbsolutePath());
procBuilder.directory(workspace);
procBuilder.start();
sapforTasksPackage.state = TasksPackageState.RunningExecution;
UpdatePackage(sapforTasksPackage);
}
void CheckPackageState() throws Exception {
File done = new File(sapforTasksPackage.workspace, Constants.DONE);
File aborted = new File(sapforTasksPackage.workspace, Constants.ABORTED);
if (done.exists()) {
sapforTasksPackage.state = TasksPackageState.Done;
UpdatePackage(sapforTasksPackage);
} else if (aborted.exists()) {
sapforTasksPackage.state = TasksPackageState.Aborted;
UpdatePackage(sapforTasksPackage);
}
}
public void Perform() {
while (true) {
try {
//-
sapforTasksPackage = (SapforTasksPackage) ServerCommand(ServerCode.GetFirstActiveSapforTasksPackage, "", null);
switch (sapforTasksPackage.state) {
case PackageStart:
PackageStart();
break;
case RunningExecution:
CheckPackageState();
break;
default:
break;
}
//-
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
Utils.sleep(getSleepMillis());
} catch (Exception ignored) {
}
}
}
}
}