2024-10-14 12:14:01 +03:00
|
|
|
|
package _VisualDVM.Passes.All;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
import Common.Passes.Pass;
|
2024-10-11 00:00:30 +03:00
|
|
|
|
import Common.Utils.Utils_;
|
2024-10-15 15:13:57 +03:00
|
|
|
|
import Common.Visual.UI;
|
2024-10-07 00:58:29 +03:00
|
|
|
|
import _VisualDVM.Global;
|
2024-10-14 15:19:13 +03:00
|
|
|
|
import _VisualDVM.Passes.PassCode;
|
2024-10-09 22:21:57 +03:00
|
|
|
|
import _VisualDVM.Repository.BugReport.BugReport;
|
|
|
|
|
|
import _VisualDVM.Repository.BugReport.BugReportState;
|
|
|
|
|
|
import _VisualDVM.Repository.EmailMessage;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
import java.util.Date;
|
2024-10-09 23:37:58 +03:00
|
|
|
|
public class PublishBugReport extends Pass<BugReport> {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
@Override
|
|
|
|
|
|
public String getIconPath() {
|
2024-10-15 16:58:20 +03:00
|
|
|
|
return "/Common/icons/Publish.png";
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected boolean canStart(Object... args) {
|
2024-10-25 02:08:23 +03:00
|
|
|
|
if (Global.componentsServer.db.bugReports.getUI().CheckCurrent(Log)) {
|
|
|
|
|
|
target = Global.componentsServer.db.bugReports.getUI().getCurrent();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
if (!target.state.equals(BugReportState.draft)) {
|
|
|
|
|
|
Log.Writeln_("Отчёт об ошибке " + target.id + " уже опубликован!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (target.executor.isEmpty()) {
|
2024-10-15 02:32:52 +03:00
|
|
|
|
Global.mainModule.getUI().getMainWindow().getCallbackWindow().FocusRecipients();
|
2024-10-15 15:13:57 +03:00
|
|
|
|
if (!UI.Question("Для отчёта об ошибке не назначен исполнитель.\nВсе равно опубликовать его"))
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-02-01 22:24:15 +03:00
|
|
|
|
if (!Global.mainModule.getAccount().CheckAuthorship(target.sender_address, Log)
|
|
|
|
|
|
&& (target.CheckDraft(Log))) {
|
2023-09-17 22:13:42 +03:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void body() throws Exception {
|
2024-12-01 20:52:27 +03:00
|
|
|
|
// target.targets = BugReport.getPackedTargets();
|
|
|
|
|
|
target.saveRecipientsAsJson(Global.componentsServer.db.subscribers.getUI().getSelectedItems());
|
2023-09-17 22:13:42 +03:00
|
|
|
|
target.change_date = new Date().getTime();
|
|
|
|
|
|
Global.componentsServer.db.Update(target);
|
|
|
|
|
|
target.state = BugReportState.active;
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
|
//2 - Отправка на сервер, с активным состоянием?
|
2024-10-13 23:55:03 +03:00
|
|
|
|
Global.mainModule.getPass(PassCode.SendBugReport).Do();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
Global.componentsServer.db.Update(target);
|
|
|
|
|
|
//3- рассылка
|
2024-11-27 02:42:26 +03:00
|
|
|
|
EmailMessage message = new EmailMessage(
|
|
|
|
|
|
"Обнаружена ошибка " + Utils_.Brackets(target.id),
|
|
|
|
|
|
target.getNewMailText()
|
|
|
|
|
|
);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
if (!target.project_version.isEmpty()) {
|
2024-10-22 13:36:57 +03:00
|
|
|
|
message.addAttachement(target.getArchiveFile());
|
2023-09-17 22:13:42 +03:00
|
|
|
|
//со скринами будет небольшой трабл. потому что теретически возможна ситуация,
|
|
|
|
|
|
//что проект черновика бага уже закрыт.
|
2024-10-13 22:08:13 +03:00
|
|
|
|
if (Global.mainModule.HasProject()) {
|
|
|
|
|
|
for (File screen : Global.mainModule.getProject().getScreenShots())
|
2023-09-17 22:13:42 +03:00
|
|
|
|
message.addAttachement(screen);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-28 16:52:17 +03:00
|
|
|
|
Global.mainModule.getPass(PassCode.Email).Do(
|
|
|
|
|
|
message,
|
|
|
|
|
|
Global.componentsServer.db.subscribers.checkRecipients(target.getRecipients())
|
|
|
|
|
|
);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void showDone() throws Exception {
|
2024-10-25 00:43:03 +03:00
|
|
|
|
Global.componentsServer.db.bugReports.getUI().RedrawControl();
|
2024-10-15 02:32:52 +03:00
|
|
|
|
Global.mainModule.getUI().getMainWindow().getCallbackWindow().ShowCurrentBugReport();
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
}
|