Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (theID == 11)
- {
- templabel.Text = thetemp.ToString();
- humilabel.Text = thehumi.ToString();
- now = DateTime.Now;
- int id1 = 2234543;
- string alarm_description1 = "Warning: Humidity";
- int ct1 = 78;
- string hmm1 = "10/50";
- if (later.Subtract(now) >= TimeSpan.FromMinutes(1) && thehumi > 50)
- {
- try
- {
- myCommand.Parameters.AddWithValue("@ID", id1);
- myCommand.Parameters.AddWithValue("@alarmtype", alarm_description1);
- myCommand.Parameters.AddWithValue("@timestamp", now);
- myCommand.Parameters.AddWithValue("@location", where);
- myCommand.Parameters.AddWithValue("@tempmm", tmm);
- myCommand.Parameters.AddWithValue("@temp", ct1);
- myCommand.Parameters.AddWithValue("@humimm", hmm1);
- myCommand.Parameters.AddWithValue("@humi", thehumi);
- myCommand.Parameters.AddWithValue("@status", stat);
- myCommand.ExecuteNonQuery();
- this.test_panelTableAdapter.Fill(this.mynewdataDataSet.test_panel);
- //e-mail
- later = DateTime.Now;
- MailMessage msg = new MailMessage();
- msg.From = new MailAddress("autobahnalertsystem@gmail.com");
- msg.To.Add("xxxxxxxxxx@gmail.com");
- msg.Subject = "Alert:Humidity";
- msg.Body = "Unit 1: Temperature/Humidity has detected excessive humidity.";
- SmtpClient smt = new SmtpClient();
- smt.Host = "smtp.gmail.com";
- System.Net.NetworkCredential ntcd = new NetworkCredential();
- ntcd.UserName = "xxxxxxx@gmail.com";
- ntcd.Password = "xxxxxxxxxx";
- smt.Credentials = ntcd;
- smt.EnableSsl = true;
- smt.Port = 587;
- smt.Send(msg);
- warninglabel.Text = "4";
- MessageBox.Show("Alarm Sent!");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- finally
- {
- conn.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement