2024-10-14 12:14:01 +03:00
|
|
|
package _VisualDVM.Passes.All;
|
2025-02-14 03:16:43 +03:00
|
|
|
import Common.Passes.Pass;
|
2024-10-11 00:00:30 +03:00
|
|
|
import Common.Utils.Utils_;
|
2025-02-18 16:21:20 +03:00
|
|
|
import _VisualDVM.ComponentsServer.Component.Component;
|
|
|
|
|
import _VisualDVM.ComponentsServer.Component.ComponentType;
|
|
|
|
|
import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson;
|
|
|
|
|
import _VisualDVM.ComponentsServer.Component.UI.PublishForm;
|
2025-02-20 13:51:27 +03:00
|
|
|
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
2025-02-13 20:27:01 +03:00
|
|
|
import _VisualDVM.Constants;
|
2024-10-07 00:58:29 +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.EmailMessage;
|
|
|
|
|
import _VisualDVM.Repository.Server.ServerCode;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
|
|
|
|
import java.util.Date;
|
2025-02-20 13:51:27 +03:00
|
|
|
import java.util.Vector;
|
2025-02-04 16:36:33 +03:00
|
|
|
public class PublishComponent extends ComponentsServerPass<Component> {
|
2023-09-17 22:13:42 +03:00
|
|
|
String version_mail_header = "";
|
|
|
|
|
String version_text = "";
|
|
|
|
|
PublishForm f = new PublishForm();
|
|
|
|
|
@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
|
2025-02-14 03:16:43 +03:00
|
|
|
protected boolean isSafe() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2023-09-17 22:13:42 +03:00
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2024-10-11 00:00:30 +03:00
|
|
|
if (!Utils_.isWindows()) {
|
2023-09-17 22:13:42 +03:00
|
|
|
Log.Writeln_("Публикация компонент разрешена только для Windows");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-10-13 22:08:13 +03:00
|
|
|
if (!Global.mainModule.getAccount().role.equals(AccountRole.Admin)) {
|
2023-09-17 22:13:42 +03:00
|
|
|
Log.Writeln_("Вы не являетесь администратором");
|
|
|
|
|
}
|
|
|
|
|
;
|
2024-10-25 00:50:19 +03:00
|
|
|
if (Global.components.getUI().CheckCurrent(Log)) {
|
2024-10-24 23:40:24 +03:00
|
|
|
target = Global.components.getUI().getCurrent();
|
2023-09-17 22:13:42 +03:00
|
|
|
f.fields.cbUpdateMinimalVersion.setSelected(false);
|
|
|
|
|
f.fields.lMinimalVersion.setText(String.valueOf(target.minimal_version));
|
|
|
|
|
f.fields.lPublishingVersion.setText(String.valueOf(target.version));
|
|
|
|
|
if (!target.isValidVersion(Log, "публикуемого")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-11-14 00:56:05 +03:00
|
|
|
if (target.getComponentType().equals(ComponentType.Sapfor_F)) {
|
|
|
|
|
f.fields.cbAssemblyOnServer.setVisible(true);
|
2023-11-21 21:29:38 +03:00
|
|
|
f.fields.cbAssemblyOnServer.setSelected(false);
|
2023-11-14 00:56:05 +03:00
|
|
|
} else {
|
|
|
|
|
f.fields.cbAssemblyOnServer.setVisible(false);
|
|
|
|
|
f.fields.cbAssemblyOnServer.setSelected(false);
|
|
|
|
|
}
|
2024-10-14 01:50:33 +03:00
|
|
|
if (f.ShowDialog(getDescription())) {
|
2025-02-03 23:04:40 +03:00
|
|
|
String change_description = (f.Result == null) ? "не указаны" : f.Result;
|
|
|
|
|
String change_record_header = String.join(" ",
|
|
|
|
|
Utils_.Brackets(Utils_.print_date(new Date())) + ":",
|
|
|
|
|
Global.mainModule.getAccount().name + Utils_.RBrackets(Global.mainModule.getAccount().email),
|
|
|
|
|
"публикует версию", Utils_.DQuotes(target.version)
|
|
|
|
|
);
|
|
|
|
|
String change_record = String.join("\n", change_record_header, "Изменения:",
|
|
|
|
|
change_description,
|
2025-02-13 20:27:01 +03:00
|
|
|
Constants.separator, ""
|
2025-02-03 23:04:40 +03:00
|
|
|
);
|
|
|
|
|
//--
|
|
|
|
|
ComponentPublicationInfoJson info=new ComponentPublicationInfoJson(target);
|
|
|
|
|
info.changeRecord = change_record;
|
|
|
|
|
info.needsUpdateMinimalVersion = f.fields.cbUpdateMinimalVersion.isSelected();
|
|
|
|
|
//--
|
|
|
|
|
return SendRequest(ServerCode.UpdateComponent, "",info);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void performDone() throws Exception {
|
|
|
|
|
target.actual_version = target.version;
|
|
|
|
|
target.CheckIfNeedsUpdateOrPublish();
|
|
|
|
|
if ((f.Result != null)) {
|
|
|
|
|
version_mail_header = String.join(" ",
|
|
|
|
|
"Опубликована версия",
|
2024-10-11 00:00:30 +03:00
|
|
|
Utils_.DQuotes(target.version),
|
2023-09-17 22:13:42 +03:00
|
|
|
"компонента",
|
2024-10-11 00:00:30 +03:00
|
|
|
Utils_.DQuotes(target.getComponentType().getDescription()));
|
2023-09-17 22:13:42 +03:00
|
|
|
EmailMessage message =
|
|
|
|
|
new EmailMessage(version_mail_header,
|
2024-11-27 02:42:26 +03:00
|
|
|
f.Result
|
|
|
|
|
);
|
2023-09-17 22:13:42 +03:00
|
|
|
if (f.fields.cbForceMail.isSelected())
|
|
|
|
|
message.addAttachement(target.getFile());
|
2024-11-27 02:42:26 +03:00
|
|
|
//--
|
2025-02-14 03:16:43 +03:00
|
|
|
//todo потом сделать красивее. на сторону сервера это безобразие
|
|
|
|
|
Pass unsafeEmail = new Email(){
|
|
|
|
|
@Override
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
return "Рассылка по Email";
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean isSafe() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-02-20 13:51:27 +03:00
|
|
|
unsafeEmail.Do(message, new Vector<>(Global.componentsServer.db.recipients.Data.values()));
|
2023-11-14 00:56:05 +03:00
|
|
|
//---
|
|
|
|
|
if (target.getComponentType().equals(ComponentType.Sapfor_F) && f.fields.cbAssemblyOnServer.isSelected()) {
|
2024-10-15 02:32:52 +03:00
|
|
|
Global.mainModule.getUI().getMainWindow().FocusTesting();
|
|
|
|
|
Global.mainModule.getUI().getMainWindow().getTestingWindow().FocusSapforTesting();
|
2024-10-13 23:55:03 +03:00
|
|
|
Global.mainModule.getPass(PassCode.CompileServerSapfor).Do();
|
2023-11-14 00:56:05 +03:00
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
protected void showDone() throws Exception {
|
2024-10-22 20:18:50 +03:00
|
|
|
Global.components.refreshUpdatesStatus();
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|