예제 #1
0
        private void LaunchApplication(PacketHeader packetHeader)
        {
            if (_Configuration.TriggeredApplicationPath.Length == 0)
            {
                EventLog.WriteEntry(
                    "tcpTrigger",
                    "An application has been triggered to launch, but no application path has been specified.",
                    EventLogEntryType.Warning,
                    401);
                return;
            }

            try
            {
                Process.Start(
                    _Configuration.TriggeredApplicationPath,
                    UserVariableExpansion.GetExpandedString(_Configuration.TriggeredApplicationArguments, packetHeader));
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry(
                    "tcpTrigger",
                    $"Error launching triggered application: {ex.Message}",
                    EventLogEntryType.Error,
                    401);
            }
        }
예제 #2
0
 private void DisplayPopupMessage(PacketHeader packetHeader)
 {
     try
     {
         Process.Start("msg", $"* /time:0 {UserVariableExpansion.GetExpandedString(GetMessageBody(packetHeader), packetHeader)}");
     }
     catch (Exception ex)
     {
         EventLog.WriteEntry(
             "tcpTrigger",
             $"Error displaying popup message: {ex.Message}",
             EventLogEntryType.Error,
             404);
     }
 }
예제 #3
0
        private void SendEmail(PacketHeader packetHeader)
        {
            if (_Configuration.EmailRecipientAddress.Length == 0)
            {
                EventLog.WriteEntry(
                    "tcpTrigger",
                    "Email event triggered, but no recipient address is configured.",
                    EventLogEntryType.Warning,
                    402);
                return;
            }
            if (_Configuration.EmailSenderAddress.Length == 0)
            {
                EventLog.WriteEntry(
                    "tcpTrigger",
                    "Email event triggered, but no sender address is configured.",
                    EventLogEntryType.Warning,
                    402);
                return;
            }
            if (_Configuration.EmailServer.Length == 0)
            {
                EventLog.WriteEntry(
                    "tcpTrigger",
                    "Email event triggered, but no mail server is configured.",
                    EventLogEntryType.Warning,
                    402);
                return;
            }
            if (_Configuration.EmailSubject.Length == 0)
            {
                EventLog.WriteEntry(
                    "tcpTrigger",
                    "Email event triggered, but no message subject is configured.",
                    EventLogEntryType.Warning,
                    402);
                return;
            }

            using (var message = new MailMessage())
            {
                try
                {
                    var smtpClient = new SmtpClient();
                    smtpClient.Host = _Configuration.EmailServer;
                    smtpClient.Port = _Configuration.EmailServerPort;
                    message.From    = _Configuration.EmailSenderDisplayName.Length > 0 ?
                                      new MailAddress(_Configuration.EmailSenderAddress, _Configuration.EmailSenderDisplayName)
                        : new MailAddress(_Configuration.EmailSenderAddress);
                    message.To.Add(_Configuration.EmailRecipientAddress);
                    message.Subject = UserVariableExpansion.GetExpandedString(_Configuration.EmailSubject, packetHeader);
                    message.Body    = UserVariableExpansion.GetExpandedString(GetMessageBody(packetHeader), packetHeader);

                    //Send the email.
                    smtpClient.Send(message);
                }
                catch (Exception ex)
                {
                    EventLog.WriteEntry(
                        "tcpTrigger",
                        $"Email event triggered, but the message failed to send. {ex.Message}",
                        EventLogEntryType.Warning,
                        403);
                    return;
                }
            }
        }