продолжение рефакторинга рассылки и исправление анимации
v++
This commit is contained in:
@@ -84,8 +84,9 @@ public class AppendBugReportField extends ComponentsRepositoryPass<BugReport> {
|
||||
message_header + " " + Utils_.Brackets(Global.mainModule.getAccount().name),
|
||||
message_text
|
||||
);
|
||||
for (String address: target.getRecipients()) {
|
||||
Global.mainModule.getPass(PassCode.CheckedEmail).Do(message, address);
|
||||
}
|
||||
Global.mainModule.getPass(PassCode.Email).Do(
|
||||
message,
|
||||
server.db.subscribers.checkRecipients(target.getRecipients())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import _VisualDVM.Repository.Subscribes.Subscriber;
|
||||
//http://java-online.ru/javax-mail.xhtml
|
||||
//https://javarush.ru/groups/posts/1226-kak-otpravitjh-pisjhmo-iz-java-prilozhenija-s-primerom
|
||||
public class CheckedEmail extends Email {
|
||||
//отправляет с учетом включения рассылки у подписчика.
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (super.canStart(args)) {
|
||||
if (server.db.subscribers.containsKey(address)) {
|
||||
Subscriber subscriber = server.db.subscribers.get(address);
|
||||
if (subscriber.mailOn != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,29 @@ import _VisualDVM.Passes.Server.ComponentsRepositoryPass;
|
||||
import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
||||
|
||||
import java.util.Vector;
|
||||
public class Email extends ComponentsRepositoryPass<EmailMessage> {
|
||||
protected String address;
|
||||
Vector<String> recipients;
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
recipients = null;
|
||||
if (args.length<=1) {
|
||||
return false;
|
||||
}
|
||||
target = (EmailMessage) args[0];
|
||||
address = (String) args[1];
|
||||
return true;
|
||||
if (args[1]instanceof Vector) {
|
||||
recipients = (Vector<String>) args[1];
|
||||
return true;
|
||||
}
|
||||
else if (args[1] instanceof String){
|
||||
recipients= new Vector<>();
|
||||
for (int i=1; i< args.length; ++i){
|
||||
recipients.add((String) args[i]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected int getTimeout() {
|
||||
@@ -17,6 +33,12 @@ public class Email extends ComponentsRepositoryPass<EmailMessage> {
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.Email, address, target));
|
||||
int i = 0;
|
||||
for (String address : recipients) {
|
||||
ShowProgress(recipients.size(), i, true);
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.Email, address, target));
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,9 +65,10 @@ public class PublishBugReport extends Pass<BugReport> {
|
||||
message.addAttachement(screen);
|
||||
}
|
||||
}
|
||||
for (String address: target.getRecipients()) {
|
||||
Global.mainModule.getPass(PassCode.CheckedEmail).Do(message, address);
|
||||
}
|
||||
Global.mainModule.getPass(PassCode.Email).Do(
|
||||
message,
|
||||
Global.componentsServer.db.subscribers.checkRecipients(target.getRecipients())
|
||||
);
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Account.AccountRole;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
@@ -12,10 +11,8 @@ import _VisualDVM.Repository.EmailMessage;
|
||||
import _VisualDVM.Repository.RepositoryServer;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.Repository.Server.ServerExchangeUnit_2021;
|
||||
import _VisualDVM.Repository.Subscribes.Subscriber;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
public class PublishComponent extends ComponentsRepositoryPass<Component> {
|
||||
String version_mail_header = "";
|
||||
String version_text = "";
|
||||
@@ -111,20 +108,7 @@ public class PublishComponent extends ComponentsRepositoryPass<Component> {
|
||||
if (f.fields.cbForceMail.isSelected())
|
||||
message.addAttachement(target.getFile());
|
||||
//--
|
||||
Vector<String> mails = new Vector<>();
|
||||
//--
|
||||
for (Subscriber subscriber : Global.componentsServer.db.subscribers.Data.values()) {
|
||||
if ((subscriber.mailOn != 0) && !mails.contains(subscriber.address))
|
||||
mails.add(subscriber.address);
|
||||
}
|
||||
for (String admin_mail : Constants.admins_mails) {
|
||||
if (!mails.contains(admin_mail))
|
||||
mails.add(admin_mail);
|
||||
}
|
||||
//--
|
||||
for (String mail : mails) {
|
||||
Global.mainModule.getPass(PassCode.Email).Do(message, mail);
|
||||
}
|
||||
Global.mainModule.getPass(PassCode.Email).Do(message, Global.componentsServer.db.subscribers.getActiveSubscribers());
|
||||
//---
|
||||
if (target.getComponentType().equals(ComponentType.Sapfor_F) && f.fields.cbAssemblyOnServer.isSelected()) {
|
||||
Global.mainModule.getUI().getMainWindow().FocusTesting();
|
||||
|
||||
@@ -125,9 +125,10 @@ public class UpdateBugReportField extends ComponentsRepositoryPass<BugReport> {
|
||||
message_header + " " + Utils_.Brackets(Global.mainModule.getAccount().name),
|
||||
message_text
|
||||
);
|
||||
for (String address : target.getRecipients()) {
|
||||
Global.mainModule.getPass(PassCode.CheckedEmail).Do(message, address);
|
||||
}
|
||||
Global.mainModule.getPass(PassCode.Email).Do(
|
||||
message,
|
||||
server.db.subscribers.checkRecipients(target.getRecipients())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,6 @@ public enum PassCode implements PassCode_ {
|
||||
SendBugReport,
|
||||
DeleteDownloadedBugReports,
|
||||
ExtractRecipients,
|
||||
CheckedEmail,
|
||||
Email,
|
||||
//-
|
||||
GetComponentsActualVersions,
|
||||
@@ -358,7 +357,7 @@ public enum PassCode implements PassCode_ {
|
||||
public String getDescription() {
|
||||
switch (this) {
|
||||
case Email:
|
||||
return "Отправка по email";
|
||||
return "Рассылка по email";
|
||||
case SPF_RemoveDistArraysFromIO:
|
||||
return "Устранение конфликтов ввода вывода";
|
||||
case StartSelectedSAPFORConfigurations:
|
||||
@@ -748,8 +747,6 @@ public enum PassCode implements PassCode_ {
|
||||
return "Отправка отчёта об ошибке на сервер";
|
||||
case ExtractRecipients:
|
||||
return "Извлечение адресатов";
|
||||
case CheckedEmail:
|
||||
return "Отправка по email";
|
||||
case GetComponentsActualVersions:
|
||||
return "Получение актуальных версий компонент";
|
||||
case PublishComponent:
|
||||
|
||||
@@ -90,14 +90,6 @@ public class BugReport extends rDBObject {
|
||||
for (String a : data)
|
||||
if (a.length() > 0)
|
||||
res.add(a);
|
||||
//всегда добавляем себя и админов--
|
||||
if (!res.contains(Global.mainModule.getAccount().email))
|
||||
res.add(Global.mainModule.getAccount().email);
|
||||
for (String address: Constants.admins_mails) {
|
||||
if (!res.contains(address))
|
||||
res.add(address);
|
||||
}
|
||||
//---------------------------------
|
||||
return res;
|
||||
}
|
||||
public File getArchiveFile() {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Visualiser extends Component {
|
||||
//http://www.seostella.com/ru/article/2012/02/05/formatirovanie-daty-v-java.html
|
||||
@Override
|
||||
public void GetVersionInfo() {
|
||||
version = 1123;
|
||||
version = 1124;
|
||||
String pattern = "MMM dd yyyy HH:mm:ss";
|
||||
DateFormat df = new SimpleDateFormat(pattern, Locale.ENGLISH);
|
||||
date_text = df.format(getClassBuildTime());
|
||||
|
||||
@@ -12,6 +12,7 @@ import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.Passes.All.ArchivesBackupPass;
|
||||
import _VisualDVM.Passes.All.UnzipFolderPass;
|
||||
import _VisualDVM.Passes.All.ZipFolderPass;
|
||||
import _VisualDVM.Passes.Server.TestingSystemPass;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.Repository.BugReport.BugReport;
|
||||
import _VisualDVM.Repository.BugReportsDatabase;
|
||||
@@ -83,6 +84,7 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
);
|
||||
}
|
||||
//bonus backup
|
||||
//todo оформить как у планировщика, так как это нить, напрямую сервер трогать нельзя.
|
||||
if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
|
||||
EmailMessage message = new EmailMessage(
|
||||
"db backup",
|
||||
|
||||
@@ -5,11 +5,14 @@ import Common.Database.Tables.FKBehaviour;
|
||||
import Common.Database.Tables.FKCurrentObjectBehaviuor;
|
||||
import Common.Database.Tables.FKDataBehaviour;
|
||||
import Common.Visual.DataSetControlForm;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Repository.SubscriberWorkspace.SubscriberWorkspace;
|
||||
import _VisualDVM.Repository.Subscribes.UI.SubsribersForm;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class SubsribersDBTable extends DBTable<String, Subscriber> {
|
||||
public SubsribersDBTable() {
|
||||
super(String.class, Subscriber.class);
|
||||
@@ -33,4 +36,33 @@ public class SubsribersDBTable extends DBTable<String, Subscriber> {
|
||||
res.put(SubscriberWorkspace.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
|
||||
return res;
|
||||
}
|
||||
public Vector<String> getActiveSubscribers(){
|
||||
Vector<String> res = new Vector<>();
|
||||
for (Subscriber subscriber : Data.values()) {
|
||||
if ((subscriber.mailOn != 0) && !res.contains(subscriber.address))
|
||||
res.add(subscriber.address);
|
||||
}
|
||||
for (String admin_mail : Constants.admins_mails) {
|
||||
if (!res.contains(admin_mail))
|
||||
res.add(admin_mail);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public Vector<String> checkRecipients(Vector<String> recipients){
|
||||
Vector<String> res = new Vector<>();
|
||||
for (String address: recipients){
|
||||
if (this.containsKey(address) && get(address).mailOn!=0){
|
||||
res.add(address);
|
||||
}
|
||||
}
|
||||
//--
|
||||
if (!res.contains(Global.mainModule.getAccount().email))
|
||||
res.add(Global.mainModule.getAccount().email);
|
||||
//--
|
||||
for (String admin_mail : Constants.admins_mails) {
|
||||
if (!res.contains(admin_mail))
|
||||
res.add(admin_mail);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package _VisualDVM.TestingSystem.Common;
|
||||
import Common.CommonConstants;
|
||||
import Common.Utils.Loggable;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
@@ -107,7 +108,12 @@ public abstract class TestingPlanner<P extends TestingPackage> extends Repositor
|
||||
message.subject = "Состояние пакета тестирования " + packageDescription() + " " +
|
||||
Utils_.Brackets(testingPackage.id) + " изменилось на " + Utils_.Brackets(testingPackage.state.getDescription());
|
||||
message.text = testingPackage.description;
|
||||
ServerCommand(ServerCode.Email, testingPackage.sender_address, message);
|
||||
Vector<String> recipients = new Vector<>(Constants.admins_mails);
|
||||
if (!recipients.contains(testingPackage.sender_address))
|
||||
recipients.add(testingPackage.sender_address);
|
||||
//--
|
||||
for (String address: recipients)
|
||||
ServerCommand(ServerCode.Email, address, message);
|
||||
}
|
||||
}
|
||||
//---
|
||||
|
||||
Reference in New Issue
Block a user