// Send an email address notifying the admin of a changes in the flat-lined status of measurements.
private void SendEmailNotification(IEnumerable<IMeasurement> measurements, bool flatlined)
{
Ticks now = DateTime.Now.Ticks;
Mail message = new Mail("*****@*****.**", m_adminEmailAddress, m_smtpServer);
StringBuilder body = new StringBuilder();
body.AppendLine("Measurement Key, Value, Timestamp");
foreach (IMeasurement measurement in measurements)
{
body.Append(measurement.Key);
body.Append(", ");
body.Append(measurement.AdjustedValue);
body.Append(", ");
body.Append(measurement.Timestamp);
body.AppendLine();
if (flatlined)
m_lastNotified[measurement.Key] = now;
else
m_lastNotified.Remove(measurement.Key);
}
if (flatlined)
message.Subject = "Flat-lined measurements";
else
message.Subject = "No longer flat-lined measurements";
message.Body = body.ToString();
message.Send();
message.Dispose();
}