예제 #1
0
        static void SendEmail(string subject, string body)
        {
            SmtpClient client = new SmtpClient {
                Host                  = SMTPHost,
                Port                  = SMTPPort,
                EnableSsl             = true,
                Timeout               = 10000,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(Address, Password)
            };

            using (MailMessage mail = new MailMessage(Address, Address, subject, body)
            {
                BodyEncoding = Encoding.UTF8,
                DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
            }) {
                try {
                    client.Send(mail);
                } catch {
                    LogViewer.Log("Failed to send e-mail alert.");
                    Program.window.LastAlert.Text = LogViewer.GetLog(1);
                }
            }
        }
예제 #2
0
 public static void SendAlert(Room room, string message)
 {
     if (room != null)
     {
         room.BackColor = Color.Red;
     }
     if (Program.window != null)
     {
         SendEmail("Remote Monitoring Alert", message);
         LogViewer.Log(message);
         Program.window.LastAlert.Text = LogViewer.GetLog(1);
     }
     else
     {
         MessageBox.Show(message);
     }
 }
예제 #3
0
 /// <summary>
 /// Auto-save and export logs on close.
 /// </summary>
 private void HomeEditor_FormClosed(object sender, FormClosedEventArgs e)
 {
     ruleEngineTicker.Stop();
     ruleEngineTicker.Dispose();
     MQTT.Disconnect();
     SerializeHome(defaultFileName);
     try {
         if (!Directory.Exists("Logs"))
         {
             Directory.CreateDirectory("Logs");
         }
         if (!LogViewer.IsEmpty)
         {
             File.WriteAllText("Logs/" + DateTime.Now.ToString().Replace(':', '-') + ".txt", LogViewer.GetLog());
         }
     } catch { }
 }