Advertisement
Guest User

Untitled

a guest
Sep 1st, 2017
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. if (theID == 11)
  2. {
  3. templabel.Text = thetemp.ToString();
  4. humilabel.Text = thehumi.ToString();
  5. now = DateTime.Now;
  6.  
  7. int id1 = 2234543;
  8. string alarm_description1 = "Warning: Humidity";
  9. int ct1 = 78;
  10. string hmm1 = "10/50";
  11.  
  12. if (later.Subtract(now) >= TimeSpan.FromMinutes(1) && thehumi > 50)
  13. {
  14. try
  15. {
  16. myCommand.Parameters.AddWithValue("@ID", id1);
  17. myCommand.Parameters.AddWithValue("@alarmtype", alarm_description1);
  18. myCommand.Parameters.AddWithValue("@timestamp", now);
  19. myCommand.Parameters.AddWithValue("@location", where);
  20. myCommand.Parameters.AddWithValue("@tempmm", tmm);
  21. myCommand.Parameters.AddWithValue("@temp", ct1);
  22. myCommand.Parameters.AddWithValue("@humimm", hmm1);
  23. myCommand.Parameters.AddWithValue("@humi", thehumi);
  24. myCommand.Parameters.AddWithValue("@status", stat);
  25. myCommand.ExecuteNonQuery();
  26. this.test_panelTableAdapter.Fill(this.mynewdataDataSet.test_panel);
  27. //e-mail
  28. later = DateTime.Now;
  29. MailMessage msg = new MailMessage();
  30. msg.From = new MailAddress("autobahnalertsystem@gmail.com");
  31. msg.To.Add("xxxxxxxxxx@gmail.com");
  32. msg.Subject = "Alert:Humidity";
  33. msg.Body = "Unit 1: Temperature/Humidity has detected excessive humidity.";
  34.  
  35. SmtpClient smt = new SmtpClient();
  36. smt.Host = "smtp.gmail.com";
  37. System.Net.NetworkCredential ntcd = new NetworkCredential();
  38. ntcd.UserName = "xxxxxxx@gmail.com";
  39. ntcd.Password = "xxxxxxxxxx";
  40. smt.Credentials = ntcd;
  41. smt.EnableSsl = true;
  42. smt.Port = 587;
  43. smt.Send(msg);
  44. warninglabel.Text = "4";
  45. MessageBox.Show("Alarm Sent!");
  46.  
  47.  
  48. }
  49. catch (Exception ex)
  50. {
  51.  
  52. MessageBox.Show(ex.Message);
  53. }
  54. finally
  55. {
  56. conn.Close();
  57.  
  58. }
  59.  
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement