no message

This commit is contained in:
2024-10-14 12:14:01 +03:00
parent 3a29898d5f
commit 452c4c7268
466 changed files with 1255 additions and 1100 deletions

View File

@@ -0,0 +1,94 @@
package _VisualDVM.Passes.All;
import Common.Utils.Utils_;
import Common.Visual.UI_;
import Common.Database.Database;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Account.AccountRole;
import _VisualDVM.Repository.BugReport.BugReport;
import _VisualDVM.Repository.BugReport.BugReportInterface;
import _VisualDVM.Repository.BugReport.BugReportState;
import _VisualDVM.Repository.Component.ComponentType;
import Common.Passes.AddObjectPass;
import _VisualDVM.Passes.PassCode;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Date;
import java.util.Vector;
public class AddBugReport extends AddObjectPass<BugReport> {
public AddBugReport() {
super(BugReport.class);
}
@Override
protected Database getDb() {
return Global.componentsServer.db;
}
@Override
public boolean canStart(Object... args) throws Exception {
if (Global.mainModule.getAccount().role.equals(AccountRole.Undefined)) {
Log.Writeln_("Для создания отчёта требуется регистрация");
return false;
}
if (Global.mainModule.HasProject()) {
String version = Global.mainModule.getProject().Home.getAbsolutePath().substring(Global.mainModule.getRoot().Home.getParent().length());
if (version.toCharArray()[0] == '\\') version = version.substring(1);
target = new BugReport(Global.mainModule.getAccount().name, Global.mainModule.getAccount().email,
"Черновик отчёта об ошибке.\nЗаполните описание ошибочной ситуации, и нажмите 'Опубликовать'", version);
return true;
} else {
if (UI_.Warning("Создать отчёт об ошибке без прикрепления проекта.")) {
target = new BugReport();
target.genName();
target.sender_name = Global.mainModule.getAccount().name;
target.sender_address = Global.mainModule.getAccount().email;
target.project_version = "";
target.visualiser_version = Global.visualiser.version;
target.sapfor_version = Global.Components.get(ComponentType.Sapfor_F).version;
target.sapfor_settings =(Global.mainModule.getDb()).settings.getSapforSettingsText();
target.percentage = 0;
target.description = "Черновик отчёта об ошибке.\nЗаполните описание ошибочной ситуации, и нажмите 'Опубликовать'";
target.date = new Date().getTime();
target.change_date = new Date().getTime();
target.state = BugReportState.draft;
target.owner = null;
return true;
}
}
return false;
}
@Override
protected void performPreparation() throws Exception {
Global.mainModule.getSapfor().ResetAllAnalyses();
}
@Override
protected void body() throws Exception {
super.body();
if (!target.project_version.isEmpty()) {
Global.mainModule.getRoot().cleanDepAndGCOVR(); //удаление депов и гкова
//логи во вложения.
File attachementsDir = Global.mainModule.getProject().getAttachmentsDirectory();
Vector<File> logs = new Vector<>();
logs.add(Utils_.MainLog.getLogFile());
logs.add(Paths.get(Global.ComponentsDirectory.getAbsolutePath(), "Sapfor_log.txt").toFile());
logs.add(Paths.get(Global.ComponentsDirectory.getAbsolutePath(), "Server_log.txt").toFile());
logs.add(Global.Components.get(ComponentType.Visualizer_2).getLogFile());
for (File file : logs) {
if (file.exists())
Files.copy(file.toPath(), Paths.get(attachementsDir.getAbsolutePath(), file.getName()), StandardCopyOption.REPLACE_EXISTING);
}
//запаковка рута
Global.mainModule.getPass(PassCode.ZipFolderPass).Do(Global.mainModule.getRoot().Home.getAbsolutePath(), BugReportInterface.getArchiveFile(target).getAbsolutePath());
}
}
@Override
protected boolean validate() {
double size = Utils_.getFileSizeMegaBytes(BugReportInterface.getArchiveFile(target));
if (size > 100) {
Log.Writeln_("Размер запакованного вложения " + size + " Мб превышает 100 Мб");
return false;
}
return super.validate();
}
}