2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2024-10-13 22:08:13 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
2025-02-04 16:36:33 +03:00
|
|
|
import _VisualDVM.Passes.Server.ComponentsServerPass;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.BugReport.BugReport;
|
2025-02-03 19:53:48 +03:00
|
|
|
import _VisualDVM.Repository.BugReport.Json.BugReportAdditionJson;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.EmailMessage;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import java.util.Date;
|
2025-02-04 16:36:33 +03:00
|
|
|
public class AppendBugReportField extends ComponentsServerPass<BugReport> {
|
2023-09-17 22:13:42 +03:00
|
|
|
String fieldName;
|
|
|
|
|
String oldValue;
|
|
|
|
|
String addition;
|
|
|
|
|
String newValue;
|
2025-02-03 23:04:40 +03:00
|
|
|
BugReport actual;
|
2023-09-17 22:13:42 +03:00
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
return "/icons/Append.png";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2025-02-03 23:04:40 +03:00
|
|
|
actual = null;
|
2025-02-03 15:19:53 +03:00
|
|
|
if (getServer().db.getTable(BugReport.class).getUI().CheckCurrent(Log)) {
|
|
|
|
|
target = getServer().db.getTable(BugReport.class).getUI().getCurrent();
|
2024-10-22 13:36:57 +03:00
|
|
|
if (!target.CheckNotDraft(Log))
|
2023-09-17 22:13:42 +03:00
|
|
|
return false;
|
|
|
|
|
fieldName = (String) args[0];
|
|
|
|
|
addition = (String) args[1];
|
|
|
|
|
if (addition.isEmpty()) {
|
|
|
|
|
Log.Writeln_("Дополнение не может быть пустым.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-02-03 19:53:48 +03:00
|
|
|
addition = Utils_.Brackets(Utils_.print_date(
|
|
|
|
|
new Date())) + " " + Global.mainModule.getAccount().name
|
|
|
|
|
+ " : " + addition;
|
2025-02-03 23:04:40 +03:00
|
|
|
if (canUpdate() && (SendRequest(ServerCode.AppendBugReportTextField, "", new BugReportAdditionJson(target, fieldName, addition)))) {
|
|
|
|
|
actual = (BugReport) request.target;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2025-02-03 23:04:40 +03:00
|
|
|
protected boolean canUpdate() {
|
|
|
|
|
return target.canModify(Global.mainModule.getAccount(), Log);
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
@Override
|
2025-02-03 15:19:53 +03:00
|
|
|
protected void body() throws Exception {
|
|
|
|
|
target.SynchronizeFields(actual);
|
|
|
|
|
Global.componentsServer.db.Update(target);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showFinish() throws Exception {
|
2025-02-03 15:19:53 +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
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performDone() throws Exception {
|
2024-10-22 13:36:57 +03:00
|
|
|
String message_header = target.getMailTitlePrefix();
|
2023-09-17 22:13:42 +03:00
|
|
|
String message_text = "";
|
|
|
|
|
switch (fieldName) {
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
case "description":
|
|
|
|
|
message_header += "описание дополнено";
|
|
|
|
|
message_text = target.description
|
|
|
|
|
;
|
|
|
|
|
break;
|
|
|
|
|
case "comment":
|
|
|
|
|
message_header += "комментарий дополнен";
|
|
|
|
|
message_text = target.comment;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2025-02-03 19:53:48 +03:00
|
|
|
EmailMessage message = new EmailMessage(
|
2024-11-27 02:42:26 +03:00
|
|
|
message_header + " " + Utils_.Brackets(Global.mainModule.getAccount().name),
|
|
|
|
|
message_text
|
2023-09-17 22:13:42 +03:00
|
|
|
);
|
2024-11-28 16:52:17 +03:00
|
|
|
Global.mainModule.getPass(PassCode.Email).Do(
|
|
|
|
|
message,
|
2025-02-03 15:19:53 +03:00
|
|
|
Global.componentsServer.db.subscribers.checkRecipients(target.getRecipients())
|
2024-11-28 16:52:17 +03:00
|
|
|
);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|