2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2025-02-03 15:19:53 +03:00
|
|
|
import Common.Database.Objects.DBObject;
|
|
|
|
|
import Common.Passes.Pass;
|
|
|
|
|
import Common.Properties;
|
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-03 15:19:53 +03:00
|
|
|
import _VisualDVM.Passes.Server.ClientPass;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.BugReport.BugReport;
|
|
|
|
|
import _VisualDVM.Repository.EmailMessage;
|
2025-02-03 15:19:53 +03:00
|
|
|
import _VisualDVM.Repository.RepositoryServer;
|
|
|
|
|
import _VisualDVM.Repository.Server.ComponentsServer;
|
2024-10-09 22:21:57 +03:00
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
2025-02-03 15:19:53 +03:00
|
|
|
import com.google.gson.JsonObject;
|
2023-09-17 22:13:42 +03:00
|
|
|
import javafx.util.Pair;
|
|
|
|
|
|
2025-02-03 15:19:53 +03:00
|
|
|
import java.io.File;
|
2023-09-17 22:13:42 +03:00
|
|
|
import java.util.Date;
|
2025-02-03 15:19:53 +03:00
|
|
|
public class AppendBugReportField extends ClientPass<ComponentsServer,BugReport> {
|
2023-09-17 22:13:42 +03:00
|
|
|
String fieldName;
|
|
|
|
|
String oldValue;
|
|
|
|
|
String addition;
|
|
|
|
|
String newValue;
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconPath() {
|
|
|
|
|
return "/icons/Append.png";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2025-02-03 15:19:53 +03:00
|
|
|
protected boolean needsAnimation() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2023-09-17 22:13:42 +03:00
|
|
|
public String getButtonText() {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
protected boolean canUpdate() {
|
2025-02-01 22:24:15 +03:00
|
|
|
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 ComponentsServer getServer() {
|
|
|
|
|
return Global.componentsServer;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2023-09-17 22:13:42 +03:00
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
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;
|
|
|
|
|
}
|
|
|
|
|
return canUpdate();
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2025-02-03 15:19:53 +03:00
|
|
|
protected void body() throws Exception {
|
|
|
|
|
//todo возможно оформить это единственной командой на сервере.
|
|
|
|
|
BugReport actual= getServer().getActual(target, BugReport.class);
|
|
|
|
|
target.SynchronizeFields(actual);
|
2023-09-17 22:13:42 +03:00
|
|
|
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();
|
2025-02-03 15:19:53 +03:00
|
|
|
Global.componentsServer.db.Update(target);
|
2023-09-17 22:13:42 +03:00
|
|
|
//3. отправляем на сервер
|
2025-02-03 15:19:53 +03:00
|
|
|
getServer().ClientRequest(ServerCode.UpdateBugReportField, fieldName, 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;
|
|
|
|
|
}
|
2024-11-27 02:42:26 +03:00
|
|
|
EmailMessage message= new EmailMessage(
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|