public void SendEmailMessagePandT(String velicina, float hodnota, string timestamp, int upozornenie, int ID) { SettingsController.NameEmail = "Jakub Ginter"; SettingsController.Email = "*****@*****.**"; var message = new MimeMessage(); message.From.Add(new MailboxAddress("HEALTH SPECTATOR", "*****@*****.**")); message.To.Add(new MailboxAddress(SettingsController.NameEmail, SettingsController.Email)); string upozornenieNazov = new LimitCheck().getStringValuePulseAndTempLimit(upozornenie); message.Subject = "Upozornenie: " + velicina + " - " + upozornenieNazov; string cas = "NA"; try { DateTime convertedDate = DateTime.Parse(timestamp); cas = convertedDate.ToShortTimeString(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Parsovanie datumu " + e.ToString()); } string hodnotaUprav = ""; if (velicina == "Teplota") { hodnotaUprav = hodnota.ToString("n2") + " °C "; } else if (velicina == "Tep") { hodnotaUprav = (int)Math.Round(hodnota) + " BPM "; } message.Body = new TextPart("plain") { Text = @"Aplikácia Health Spectator práve zaznamenala prekročenie hodnôt! Veličina: " + velicina + " Upozornenie: " + upozornenieNazov + " Hodnota: " + hodnotaUprav + " Čas: " + cas }; using (var client = new SmtpClient()) { // For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS) client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect("smtp.gmail.com", 587, false); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); // Note: only needed if the SMTP server requires authentication client.Authenticate("*****@*****.**", "Jakub1994"); client.Send(message); client.Disconnect(true); } }
public void alarmNotification(String velicina, float hodnota, string timestamp, int upozornenie, int ID) { string cas = "NA"; try { DateTime convertedDate = DateTime.Parse(timestamp); cas = convertedDate.ToShortTimeString(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Parsovanie datumu " + e.ToString()); } string upozornenieNazov = new LimitCheck().getStringValuePulseAndTempLimit(upozornenie); string title = ""; if (velicina == "Teplota") { title = "ALARM " + velicina + ": " + upozornenieNazov + " upozornenie. " + hodnota.ToString("n2") + " °C"; } else if (velicina == "Tep") { title = "ALARM " + velicina + ": " + upozornenieNazov + " upozornenie. " + (int)Math.Round(hodnota) + " BPM"; } string body = "[" + ID + "]V čase " + cas + " bolo vytvorené " + upozornenieNazov + " upozornenie."; CrossLocalNotifications.Current.Show(title, body, ID); var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current; player.Volume = 1; player.Load("alarm.mp3"); player.Play(); }