private void Worker_DoWork(object sender, DoWorkEventArgs e) { while (true) { var birhtdays = from pw in db.GetPeopleWrapped() where pw.DayUntilBirthday < 3 select pw; var namedays = from pw in db.GetPeopleWrapped() where pw.DayUntilNameday < 3 select pw; StringBuilder stringBuilder = new StringBuilder(); if (birhtdays.Count() > 0) { stringBuilder.AppendLine($"{Application.Current.Resources["upcoming_birthdays"]}"); foreach (var bd in birhtdays) { stringBuilder.AppendLine($"{bd.Name} {bd.DayUntilBirthday} {Application.Current.Resources["day_left_"]}!"); } stringBuilder.AppendLine(); } if (namedays.Count() > 0) { stringBuilder.AppendLine($"{Application.Current.Resources["upcoming_namedays"]}"); foreach (var nd in namedays) { stringBuilder.AppendLine($"{nd.Name} {nd.DayUntilNameday} {Application.Current.Resources["day_left_"]}!"); } } stringBuilder.AppendLine(); stringBuilder.AppendLine($"{Application.Current.Resources["remind_you_later"]}"); if (namedays.Count() > 0 || birhtdays.Count() > 0) { if (MessageBox.Show(stringBuilder.ToString(), $"{ Application.Current.Resources["reminder"]}", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { break; } } // Remind every 20th minutes Thread.Sleep(1000 * 60 * 20); } }
private void RefreshUpcomingBirthDays() { this.dataGridBirthdays.ItemsSource = from pw in db.GetPeopleWrapped() orderby pw.DayUntilBirthday select pw; }