no message
This commit is contained in:
77
src/_VisualDVM/Passes/All/PublishBugReport.java
Normal file
77
src/_VisualDVM/Passes/All/PublishBugReport.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.UI_;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Visual.UI;
|
||||
import _VisualDVM.Repository.BugReport.BugReport;
|
||||
import _VisualDVM.Repository.BugReport.BugReportInterface;
|
||||
import _VisualDVM.Repository.BugReport.BugReportState;
|
||||
import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import Common.Passes.Pass;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
public class PublishBugReport extends Pass<BugReport> {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Publish.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) {
|
||||
if (Global.mainModule.Check(Log, Current.BugReport)) {
|
||||
target = Global.mainModule.getBugReport();
|
||||
if (!target.state.equals(BugReportState.draft)) {
|
||||
Log.Writeln_("Отчёт об ошибке " + target.id + " уже опубликован!");
|
||||
return false;
|
||||
}
|
||||
if (target.executor.isEmpty()) {
|
||||
UI.getMainWindow().getCallbackWindow().FocusRecipients();
|
||||
if (!UI_.Question("Для отчёта об ошибке не назначен исполнитель.\nВсе равно опубликовать его"))
|
||||
return false;
|
||||
}
|
||||
if (!Global.mainModule.getAccount().CheckAccessRights(target.sender_address, Log) && (BugReportInterface.CheckDraft(target, Log))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
target.targets = BugReportInterface.getPackedTargets();
|
||||
target.change_date = new Date().getTime();
|
||||
Global.componentsServer.db.Update(target);
|
||||
target.state = BugReportState.active;
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
//2 - Отправка на сервер, с активным состоянием?
|
||||
Global.mainModule.getPass(PassCode.SendBugReport).Do();
|
||||
Global.componentsServer.db.Update(target);
|
||||
//3- рассылка
|
||||
EmailMessage message = new EmailMessage("Обнаружена ошибка " + Utils_.Brackets(target.id),
|
||||
BugReportInterface.getNewMailText(target),
|
||||
BugReportInterface.getRecipients(target));
|
||||
if (!target.project_version.isEmpty()) {
|
||||
message.addAttachement(BugReportInterface.getArchiveFile(target));
|
||||
//со скринами будет небольшой трабл. потому что теретически возможна ситуация,
|
||||
//что проект черновика бага уже закрыт.
|
||||
if (Global.mainModule.HasProject()) {
|
||||
for (File screen : Global.mainModule.getProject().getScreenShots())
|
||||
message.addAttachement(screen);
|
||||
}
|
||||
}
|
||||
Global.mainModule.getPass(PassCode.Email).Do(message);
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
Global.componentsServer.db.bugReports.RefreshUI();
|
||||
UI.getMainWindow().getCallbackWindow().ShowCurrentBugReport();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user