//sos notifications private void sos(LiveUser user) { string fullName = user.Firstname + " " + user.Lastname; try { sosSound = new SoundPlayer(Properties.Resources.sos); //sosSound = new SoundPlayer(@"res\sos.wav"); sosSound.PlayLooping(); } catch (Exception e) { Console.WriteLine(e.Message); } //make windows notification in the tool bar sosLittleNotif = new NotifyIcon(); sosLittleNotif.Visible = true; sosLittleNotif.Icon = icon;// SystemIcons.Application; sosLittleNotif.Text = "SOS Alert!"; sosLittleNotif.BalloonTipTitle = "SOS NEEDED"; sosLittleNotif.BalloonTipText = fullName + " needs your help"; sosLittleNotif.BalloonTipIcon = ToolTipIcon.Error; sosLittleNotif.ShowBalloonTip(15000); sosLittleNotif.BalloonTipClosed += (sender, e) => { var thisIcon = (NotifyIcon)sender; thisIcon.Visible = false; thisIcon.Dispose(); }; string msg = fullName + " needs your help\n\n" + "View more info about " + user.Firstname + "'s SOS alert?!"; if (MessageBox.Show(msg, "SOS ALERT!!", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification) == DialogResult.Yes) { sosInfo = new AlertSO(user); //construct Thread.Sleep(3000); //new untested Connection.noMoreSOS(url, user.Username); // if ok is pressed, set sos back to 0 sosSound.Stop(); Thread.Sleep(3000); //show sosInfo.Show(); } else { Connection.noMoreSOS(url, user.Username); sosSound.Stop(); Thread.Sleep(3000); Console.WriteLine("open window"); } }
public AlertSO(LiveUser user) { InitializeComponent(); this.user = user; setup(user); }
public AlertES(LiveUser user, string es) { InitializeComponent(); this.user = user; this.type = es; setup(user, es); }
//email notification private void notifyEmail(string adminName, string adminLname, string adminEmail, LiveUser user, string eventType) { Connection.email(url, eventType, adminName, adminLname, user.Firstname, user.Lastname, user.Username, user.EmTime, user.Risklevel.ToString(), user.StartTime, user.EndTime, user.Mobile, user.Email, user.Phone, user.Rego, user.Longitude, user.Latitude, adminEmail); }
//escalation notifications private void notification(LiveUser user, string checkin, int esc) { string es = "Escalation " + esc.ToString(); string fullName = user.Firstname + " " + user.Lastname; //play sound try { escalationSound = new SoundPlayer(Properties.Resources.escalation); // escalationSound = new SoundPlayer(@"res\escalation.wav"); escalationSound.PlayLooping(); } catch (Exception e) { Console.WriteLine(e.Message); } //make windows notification in the tool bar escLittleNotif = new NotifyIcon(); escLittleNotif.Visible = true; escLittleNotif.Icon = icon;// SystemIcons.Application; escLittleNotif.Text = es + " Alert!"; escLittleNotif.BalloonTipTitle = es; escLittleNotif.BalloonTipText = fullName + " might be in trouble"; escLittleNotif.BalloonTipIcon = ToolTipIcon.Warning; escLittleNotif.ShowBalloonTip(15000); escLittleNotif.BalloonTipClosed += (sender, e) => { var thisIcon = (NotifyIcon)sender; thisIcon.Visible = false; thisIcon.Dispose(); //escalationSound.Stop(); }; //make window notification string msg = fullName + " might be in trouble\n\n\n" + "View more info about " + user.Firstname + "'s escalation alert?!"; if (MessageBox.Show(msg, es, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification) == DialogResult.Yes) { // if ok is pressed, set sos back to 0 esInfo = new AlertES(user, es); Thread.Sleep(3000); //new untested Connection.notified(url, user.Username, checkin, es); escalationSound.Stop(); Thread.Sleep(3000); esInfo.Show(); } else { Connection.notified(url, user.Username, checkin, es); escalationSound.Stop(); Thread.Sleep(3000); } }
private void setup(LiveUser user) { this.Text = "SOS Info"; header.Text = user.Firstname + "'s SOS"; fname.Text = user.Firstname; lname.Text = user.Lastname; username.Text = user.Username; if (user.Mobile != "" || user.Mobile != null) { mobile.Text = user.Mobile; } else { mobile.Text = "N/A"; } if (user.Rego != "" || user.Rego != null) { rego.Text = user.Rego; } else { rego.Text = "N/A"; } if (user.Phone != "" || user.Phone != null) { phone.Text = user.Phone; } else { phone.Text = "N/A"; } if (user.Email != "" || user.Email != null) { email.Text = user.Email; } else { email.Text = "N/A"; } if (user.Longitude == null || user.Longitude == "" || user.Latitude == null || user.Latitude == "") { longitude.Text = "UNKNOWN"; latitude.Text = "UNKNOWN"; var page = @" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <body> <br/> <br/> <center> Location is not available. </center> </body> </html>" ; map.DocumentText = page; map.ScriptErrorsSuppressed = true; map.ScrollBarsEnabled = false; } else { longitude.Text = user.Longitude; latitude.Text = user.Latitude; var page = @" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> <head> <style> *{margin:0;padding:0} html, body {height:100%;width:100%;overflow:hidden} table {height:100%;width:100%;table-layout:static;border-collapse:collapse} iframe {height:100%;width:100%} .content {height:100%} </style> </head> <body> <table> <tr><td class='content'> <iframe src='https://www.google.com/maps/embed/v1/place?key=AIzaSyBD7AjCRto1zWiZ1D3cW5JZZpz_ZoMBgDY&q=loc:" + user.Latitude + "," + user.Longitude + @"' frameborder='0'> </iframe> </td></tr> </table> </body> </html>" ; map.DocumentText = page; map.ScriptErrorsSuppressed = true; map.ScrollBarsEnabled = false; } }