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-09 22:01:19 +03:00
|
|
|
import _VisualDVM.Current;
|
2024-10-13 22:08:13 +03:00
|
|
|
import _VisualDVM.Global;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Passes.PassCode;
|
|
|
|
|
import _VisualDVM.Passes.Server.ComponentsRepositoryPass;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.BugReport.BugReport;
|
|
|
|
|
import _VisualDVM.Repository.BugReport.BugReportInterface;
|
|
|
|
|
import _VisualDVM.Repository.EmailMessage;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
2024-10-14 15:19:13 +03:00
|
|
|
import _VisualDVM.Visual.UI;
|
2023-09-17 22:13:42 +03:00
|
|
|
import javafx.util.Pair;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
public class AppendBugReportField extends ComponentsRepositoryPass<BugReport> {
|
|
|
|
|
String fieldName;
|
|
|
|
|
String oldValue;
|
|
|
|
|
String addition;
|
|
|
|
|
String newValue;
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
return "/icons/Append.png";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public String getButtonText() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
protected boolean canUpdate() {
|
2024-10-13 22:08:13 +03:00
|
|
|
return Global.mainModule.getAccount().CheckAccessRights(target.sender_address, Log);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2024-10-13 22:08:13 +03:00
|
|
|
if (Global.mainModule.Check(Log, Current.BugReport)) {
|
|
|
|
|
target = Global.mainModule.getBugReport();
|
2024-10-14 15:19:13 +03:00
|
|
|
if (!BugReportInterface.CheckNotDraft(target, 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;
|
|
|
|
|
}
|
|
|
|
|
return canUpdate();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void ServerAction() throws Exception {
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.GetObjectCopyByPK, "", new Pair<>(BugReport.class, target.id)));
|
|
|
|
|
target.SynchronizeFields((BugReport) response.object);
|
|
|
|
|
oldValue = (String) BugReport.class.getField(fieldName).get(target);
|
2024-10-11 00:00:30 +03:00
|
|
|
newValue = oldValue + "\n" + Utils_.Brackets(Utils_.print_date(
|
2024-10-13 22:08:13 +03:00
|
|
|
new Date())) + " " + Global.mainModule.getAccount().name
|
2023-09-17 22:13:42 +03:00
|
|
|
+ " : " + addition;
|
|
|
|
|
//2. дописываем нужное поле.
|
|
|
|
|
BugReport.class.getField(fieldName).set(target, newValue);
|
|
|
|
|
//обновляем дату.
|
|
|
|
|
target.change_date = new Date().getTime();
|
|
|
|
|
server.db.Update(target);
|
|
|
|
|
//3. отправляем на сервер
|
|
|
|
|
Command(new ServerExchangeUnit_2021(ServerCode.UpdateBugReportField, fieldName, target));
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showFinish() throws Exception {
|
|
|
|
|
server.db.bugReports.RefreshUI();
|
|
|
|
|
UI.getMainWindow().getCallbackWindow().ShowCurrentBugReport();
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
String message_header = BugReportInterface.getMailTitlePrefix(target);
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-10-13 23:55:03 +03:00
|
|
|
Global.mainModule.getPass(PassCode.Email).Do(
|
2023-09-17 22:13:42 +03:00
|
|
|
new EmailMessage(
|
2024-10-13 22:08:13 +03:00
|
|
|
message_header + " " + Utils_.Brackets(Global.mainModule.getAccount().name),
|
2023-09-17 22:13:42 +03:00
|
|
|
message_text,
|
2024-09-24 23:34:41 +03:00
|
|
|
BugReportInterface.getRecipients(target)
|
2023-09-17 22:13:42 +03:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|