From: Vásáry Dániel Date: Thu, 12 Oct 2017 15:04:44 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=914879ecbfb14dc8b00c44dbc0ca73bec54f64bf;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30610 --- diff --git a/client/Maestro/Configuration/ConfigurationInfo.cs b/client/Maestro/Configuration/ConfigurationInfo.cs index a3328520..a46fb7a6 100644 --- a/client/Maestro/Configuration/ConfigurationInfo.cs +++ b/client/Maestro/Configuration/ConfigurationInfo.cs @@ -48,7 +48,13 @@ namespace Maestro.Configuration { public bool SaveSegments { get; set; } public bool CreateSubFolder { get; set; } public string Tag { get; set; } - public bool UseMetadata {get; set;} + public bool CreateMetadata {get; set;} + public bool SendEmailOnError { get; set; } + public string ErrorEmailRecipient { get; set; } + public string ErrorEmailPattern { get; set; } + public bool SendEmailOnSuccess { get; set; } + public string SuccessEmailRecipient { get; set; } + public string SuccessEmailPattern { get; set; } } public class Connection { diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index b2c7e53c..6168d62d 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -288,7 +288,7 @@ PreserveNewest - + PreserveNewest diff --git a/client/Maestro/Resources/configuration-nexio.json b/client/Maestro/Resources/configuration-control.json similarity index 61% rename from client/Maestro/Resources/configuration-nexio.json rename to client/Maestro/Resources/configuration-control.json index d967aa64..0c74a654 100644 --- a/client/Maestro/Resources/configuration-nexio.json +++ b/client/Maestro/Resources/configuration-control.json @@ -1,13 +1,10 @@ { - "title": "Adáslebonyolítás", + "title": "Lebonyolítás", "active": true, "startInTray": false, - "enableNameOverride": false, + "enableCustomMetadataId": true, "filter": "avi", "player": { - "enabled": true, - "autoStart": false, - "segmentEditor": true }, "source": { "$type": "NEXIOSource", @@ -15,7 +12,7 @@ "address": "ws://10.10.1.28/services/nexio" }, "remote": { - "address": "ftp://10.10.1.55:2098", + "address": "ftp://10.10.1.56:2098/MXF", "userName": "administrator", "password": "system" } @@ -25,8 +22,6 @@ "$type": "OctopusMetadata", "server": { "address": "http://10.10.1.28/services/rest/octopus", - "userName": "dani", - "password": "dani", "timeout": 1000 } }, @@ -36,27 +31,37 @@ "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;", "userName": "MAM", "password": "Echotv.hu", - "timeout": 5 + "timeout": 1000 } }, { "$type": "MediaCubeMetadata", "server": { "address": "http://10.10.1.28/services/rest/jobengine", - "userName": "dani", - "password": "dani" + "timeout": 1000 } } ], "targets": [ { - "label": "Adásba", + "label": "Adásellenőrzés", "processor": "FXPTargetProcessor", "outputFormat": "%ID%", + "tag": "Adáskész", "remote": { - "address": "ftp://10.10.1.100:21/READY", + "address": "ftp://10.10.1.100:21/PLAYOUT_CHECK", "userName": "mediacube", - "password": "Broadca5T" + "password": "Broadca5T" + } + }, + { + "label": "Archiválás", + "processor": "UNCTargetProcessor", + "outputFormat": "%ID%", + "tag": "Archiválás", + "createMetadata": true, + "remote": { + "address": "file://10.10.1.100/BRAAVOS/ARCHIVE" } } ] diff --git a/client/Maestro/Resources/configuration-ingest.json b/client/Maestro/Resources/configuration-ingest.json index 07acce92..cb371883 100644 --- a/client/Maestro/Resources/configuration-ingest.json +++ b/client/Maestro/Resources/configuration-ingest.json @@ -2,7 +2,7 @@ "title": "Betöltés", "active": true, "startInTray": false, - "enableCustomMetadataId": false, + "enableCustomMetadataId": true, "player": { "enabled": true, "autoStart": false, @@ -20,8 +20,6 @@ "$type": "OctopusMetadata", "server": { "address": "http://10.10.1.28/services/rest/octopus/", - "userName": "user", - "password": "password", "timeout": 1000 } }, @@ -31,15 +29,13 @@ "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;", "userName": "MAM", "password": "Echotv.hu", - "timeout": 5 + "timeout": 1000 } }, { "$type": "MediaCubeMetadata", "server": { "address": "http://10.10.1.28/services/rest/jobengine/", - "userName": "user", - "password": "password", "timeout": 1000 } } @@ -55,8 +51,7 @@ "useMetadata": false, "remote": { "address": "file://10.10.1.100/BRAAVOS/OCTOPUS", - "userName": "mediacube", - "password": "Broadca5T" + "timeout": 1000 } }, { @@ -64,14 +59,21 @@ "processor": "UNCTargetProcessor", "outputFormat": "%ID%", "tag": "Betöltés", - "saveSegments": false, "killDateDays": 7, - "createSubFolder": false, - "useMetadata": false, "remote": { "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_CHECK", - "userName": "mediacube", - "password": "Broadca5T" + "timeout": 1000 + } + }, + { + "label": "Archiválás", + "processor": "UNCTargetProcessor", + "outputFormat": "%ID%", + "tag": "Archiválás", + "useMetadata": true, + "remote": { + "address": "file://10.10.1.100/BRAAVOS/ARCHIVE", + "timeout": 1000 } } ] diff --git a/client/Maestro/Resources/configuration-playout.json b/client/Maestro/Resources/configuration-playout.json index e59187a5..f6a3ca39 100644 --- a/client/Maestro/Resources/configuration-playout.json +++ b/client/Maestro/Resources/configuration-playout.json @@ -1,5 +1,5 @@ { - "title": "Adásanyagok", + "title": "Ellenőrzés", "active": true, "startInTray": false, "enableCustomMetadataId": true, @@ -28,7 +28,7 @@ "address": "Data Source=10.10.1.45\\sql16;Initial Catalog=PA_Echo;Persist Security Info=True;", "userName": "MAM", "password": "Echotv.hu", - "timeout": 0 + "timeout": 1000 } }, { @@ -46,21 +46,32 @@ "outputFormat": "%ID%", "saveSegments": true, "tag": "Adáskész", - "createSubFolder": false, - "useMetadata": false, "remote": { "address": "file://10.10.1.100/BRAAVOS/PLAYOUT" } }, { - "label": "Újravágásra", + "label": "Újravágás", "processor": "UNCTargetProcessor", "outputFormat": "%ID%", - "tag": "Újravágásra", + "tag": "Újravágás", "remote": { "address": "file://10.10.1.100/BRAAVOS/PLAYOUT_NLE" + }, + "sendSEmailOnSuccess" : true, + "successEmailRecipient": "vasary@elgekko.net", + "successEmailPattern": "A %TARGETNAME% újravágása szükséges." + }, + { + "label": "Archiválás", + "processor": "UNCTargetProcessor", + "outputFormat": "%ID%", + "tag": "Archiválás", + "createMetadata": true, + "remote": { + "address": "file://10.10.1.100/BRAAVOS/ARCHIVE", + "timeout": 1000 } } - ] } diff --git a/client/Maestro/Resources/configuration-unc.json b/client/Maestro/Resources/configuration-unc.json index 1a1505e2..0f9d590e 100644 --- a/client/Maestro/Resources/configuration-unc.json +++ b/client/Maestro/Resources/configuration-unc.json @@ -68,7 +68,7 @@ "killDateDays": 0, "tag": "Adáskész", "createSubFolder": false, - "useMetadata": false, + "createMetadata": false, "remote": { "address": "file://10.10.1.100/BRAAVOS/PLAYOUT/IceGateway", "userName": "mediacube", diff --git a/client/Maestro/Targets/UNCTargetProcessor.cs b/client/Maestro/Targets/UNCTargetProcessor.cs index 4bdbfd2b..dd24ca2c 100644 --- a/client/Maestro/Targets/UNCTargetProcessor.cs +++ b/client/Maestro/Targets/UNCTargetProcessor.cs @@ -63,6 +63,8 @@ namespace Maestro.Targets { Message = e.Message; workFlowAction.description = Message; logger.Error(e); + if (parameters.TargetConfig.SendEmailOnError && !String.IsNullOrEmpty(parameters.TargetConfig.ErrorEmailRecipient) && !String.IsNullOrEmpty(parameters.TargetConfig.ErrorEmailPattern)) + SendEmail(parameters.TargetConfig.ErrorEmailRecipient, parameters.TargetConfig.ErrorEmailPattern); } finally { AfterExecute(); @@ -79,12 +81,24 @@ namespace Maestro.Targets { workFlowAction.successful = true; if (parameters.TargetConfig.KillDateDays > 0) UploadKillDateFile(); - if (parameters.TargetConfig.UseMetadata && parameters.ArchiveMetadata != null) + if (parameters.TargetConfig.CreateMetadata && parameters.ArchiveMetadata != null) CreateMetadata(); if (parameters.TargetConfig.SaveSegments && parameters.Segments != null) { SaveSegments(); parameters.Client.BroadcastOKForAir(parameters.VariantID); - } + } + if (parameters.TargetConfig.SendEmailOnSuccess && !String.IsNullOrEmpty(parameters.TargetConfig.SuccessEmailRecipient) && !String.IsNullOrEmpty(parameters.TargetConfig.SuccessEmailPattern)) + SendEmail(parameters.TargetConfig.SuccessEmailRecipient, parameters.TargetConfig.SuccessEmailPattern); + } + + private void SendEmail(string to, string messagePattern) { + try { + string message = messagePattern.Replace("%TARGETNAME%", Output); + parameters.MediaCubeApi.Notify(to, messagePattern); + } + catch (Exception e) { + MessageBox.Show(parent, e.Message); + } } private void SaveSegments() { @@ -159,8 +173,8 @@ namespace Maestro.Targets { } private CopyProgressResult CopyProgressHandler(long total, long transferred, long streamSize, long StreamByteTrans, uint dwStreamNumber, CopyProgressCallbackReason reason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData) { - if (transferred > 0) - Progress = (int)((double) transferred * 100 / total ); + if (transferred > 0) + Progress = (int)((double)transferred * 100 / total); return CopyProgressResult.PROGRESS_CONTINUE; } diff --git a/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java b/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java index e40d4511..7df714d4 100644 --- a/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java +++ b/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java @@ -1,6 +1,8 @@ package user.commons.log4j2.appender; import java.io.Serializable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.Core; @@ -22,37 +24,22 @@ import org.apache.logging.log4j.core.layout.HtmlLayout; import org.apache.logging.log4j.core.util.Booleans; /** - * Send an e-mail when a specific logging event occurs, typically on errors or - * fatal errors. + * Send an e-mail when a specific logging event occurs, typically on errors or fatal errors. * *

- * The number of logging events delivered in this e-mail depend on the value of - * BufferSize option. The SmtpAppender keeps only the last - * BufferSize logging events in its cyclic buffer. This keeps - * memory requirements at a reasonable level while still delivering useful - * application context. + * The number of logging events delivered in this e-mail depend on the value of BufferSize option. The SmtpAppender keeps only the last + * BufferSize logging events in its cyclic buffer. This keeps memory requirements at a reasonable level while still delivering useful application + * context. * - * By default, an email message will formatted as HTML. This can be modified by - * setting a layout for the appender. + * By default, an email message will formatted as HTML. This can be modified by setting a layout for the appender. * - * By default, an email message will be sent when an ERROR or higher severity - * message is appended. This can be modified by setting a filter for the - * appender. + * By default, an email message will be sent when an ERROR or higher severity message is appended. This can be modified by setting a filter for the appender. */ @Plugin(name = "HTMLMailAppender", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE, printObject = true) public final class HTMLMailAppender extends AbstractAppender { private static final int DEFAULT_BUFFER_SIZE = 512; - /** The SMTP Manager */ - private final SmtpManager manager; - - private HTMLMailAppender(final String name, final Filter filter, final Layout layout, - final SmtpManager manager, final boolean ignoreExceptions) { - super(name, filter, layout, ignoreExceptions); - this.manager = manager; - } - /** * Create a SmtpAppender. * @@ -68,8 +55,10 @@ public final class HTMLMailAppender extends AbstractAppender { * The email address of the sender. * @param replyTo * The comma-separated list of reply-to email addresses. - * @param subject The subject of the email message. - * @param smtpProtocol The SMTP transport protocol (such as "smtps", defaults to "smtp"). + * @param subject + * The subject of the email message. + * @param smtpProtocol + * The SMTP transport protocol (such as "smtps", defaults to "smtp"). * @param smtpHost * The SMTP hostname to send to. * @param smtpPortStr @@ -81,30 +70,23 @@ public final class HTMLMailAppender extends AbstractAppender { * @param smtpDebug * Enable mail session debuging on STDOUT. * @param bufferSizeStr - * How many log events should be buffered for inclusion in the - * message? + * How many log events should be buffered for inclusion in the message? * @param layout * The layout to use (defaults to HtmlLayout). * @param filter - * The Filter or null (defaults to ThresholdFilter, level of - * ERROR). - * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise - * they are propagated to the caller. + * The Filter or null (defaults to ThresholdFilter, level of ERROR). + * @param ignore + * If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller. * @return The SmtpAppender. */ @PluginFactory - public static HTMLMailAppender createAppender(@PluginConfiguration final Configuration config, - @PluginAttribute("name") @Required final String name, @PluginAttribute("to") final String to, - @PluginAttribute("cc") final String cc, @PluginAttribute("bcc") final String bcc, - @PluginAttribute("from") final String from, @PluginAttribute("replyTo") final String replyTo, - @PluginAttribute("subject") final String subject, - @PluginAttribute("smtpProtocol") final String smtpProtocol, - @PluginAttribute("smtpHost") final String smtpHost, + public static HTMLMailAppender createAppender(@PluginConfiguration final Configuration config, @PluginAttribute("name") @Required final String name, + @PluginAttribute("to") final String to, @PluginAttribute("cc") final String cc, @PluginAttribute("bcc") final String bcc, + @PluginAttribute("from") final String from, @PluginAttribute("replyTo") final String replyTo, @PluginAttribute("subject") final String subject, + @PluginAttribute("smtpProtocol") final String smtpProtocol, @PluginAttribute("smtpHost") final String smtpHost, @PluginAttribute(value = "smtpPort", defaultString = "0") @ValidPort final String smtpPortStr, - @PluginAttribute("smtpUsername") final String smtpUsername, - @PluginAttribute(value = "smtpPassword", sensitive = true) final String smtpPassword, - @PluginAttribute("smtpDebug") final String smtpDebug, - @PluginAttribute("bufferSize") final String bufferSizeStr, + @PluginAttribute("smtpUsername") final String smtpUsername, @PluginAttribute(value = "smtpPassword", sensitive = true) final String smtpPassword, + @PluginAttribute("smtpDebug") final String smtpDebug, @PluginAttribute("bufferSize") final String bufferSizeStr, @PluginElement("Layout") Layout layout, @PluginElement("Filter") Filter filter, @PluginAttribute("ignoreExceptions") final String ignore) { if (name == null) { @@ -125,9 +107,8 @@ public final class HTMLMailAppender extends AbstractAppender { } final Configuration configuration = config != null ? config : new DefaultConfiguration(); - final SmtpManager manager = SmtpManager.getSmtpManager(configuration, to, cc, bcc, from, replyTo, subject, - smtpProtocol, smtpHost, smtpPort, smtpUsername, smtpPassword, isSmtpDebug, filter.toString(), - bufferSize); + final SmtpManager manager = SmtpManager.getSmtpManager(configuration, to, cc, bcc, from, replyTo, subject, smtpProtocol, smtpHost, smtpPort, + smtpUsername, smtpPassword, isSmtpDebug, filter.toString(), bufferSize); if (manager == null) { return null; } @@ -135,9 +116,37 @@ public final class HTMLMailAppender extends AbstractAppender { return new HTMLMailAppender(name, filter, layout, manager, ignoreExceptions); } + /** The SMTP Manager */ + private final SmtpManager manager; + + private final ExecutorService executor = Executors.newFixedThreadPool(1); + + private HTMLMailAppender(final String name, final Filter filter, final Layout layout, final SmtpManager manager, + final boolean ignoreExceptions) { + super(name, filter, layout, ignoreExceptions); + this.manager = manager; + } + + /** + * Perform SmtpAppender specific appending actions, mainly adding the event to a cyclic buffer and checking if the event triggers an e-mail to be sent. + * + * @param event + * The Log event. + */ + @Override + public void append(final LogEvent event) { + + executor.submit(() -> { + manager.sendEvents(getLayout(), event); + }); + + } + /** * Capture all events in CyclicBuffer. - * @param event The Log event. + * + * @param event + * The Log event. * @return true if the event should be filtered. */ @Override @@ -148,15 +157,4 @@ public final class HTMLMailAppender extends AbstractAppender { } return filtered; } - - /** - * Perform SmtpAppender specific appending actions, mainly adding the event - * to a cyclic buffer and checking if the event triggers an e-mail to be - * sent. - * @param event The Log event. - */ - @Override - public void append(final LogEvent event) { - manager.sendEvents(getLayout(), event); - } } diff --git a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java index 503e5e2c..f276ab33 100644 --- a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java +++ b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java @@ -21,8 +21,6 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Date; import java.util.Properties; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import javax.activation.DataSource; import javax.mail.Authenticator; @@ -31,9 +29,11 @@ import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; +import javax.mail.internet.InternetAddress; import javax.mail.internet.InternetHeaders; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMessage.RecipientType; import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeUtility; import javax.mail.util.ByteArrayDataSource; @@ -214,8 +214,6 @@ public class SmtpManager extends AbstractManager { private final FactoryData data; - private final ExecutorService executor = Executors.newFixedThreadPool(5); - protected SmtpManager(final String name, final Session session, final MimeMessage message, final FactoryData data) { super(null, name); this.session = session; @@ -297,7 +295,7 @@ public class SmtpManager extends AbstractManager { try { if (appendEvent.getMarker() instanceof MediaCubeMarker) { MediaCubeMarker mcm = (MediaCubeMarker) appendEvent.getMarker(); - //message.setRecipient(RecipientType.TO, new InternetAddress(mcm.getTo())); + message.setRecipient(RecipientType.TO, new InternetAddress(mcm.getTo())); } final LogEvent[] priorEvents = buffer.removeAll(); @@ -311,14 +309,7 @@ public class SmtpManager extends AbstractManager { final InternetHeaders headers = getHeaders(contentType, encoding); final MimeMultipart mp = getMimeMultipart(encodedBytes, headers); - - executor.submit(() -> { - try { - sendMultipartMessage(message, mp); - } catch (MessagingException e) { - System.out.println(e.getMessage()); - } - }); + sendMultipartMessage(message, mp); } catch (final MessagingException | IOException | RuntimeException e) { logError("Caught exception while sending e-mail notification.", e); throw new LoggingException("Error occurred while sending email", e);