/// <summary> /// Retrieves list of recent birthdays /// </summary> /// <returns>List of friend</returns> private void GetRecentBirthdays() { try { var friendList = BirthdayUtility.GetFriendList(); var recentBirthdays = new List <FriendEntity>(); var todayBirthday = new List <FriendEntity>(); var weekBirthday = new List <FriendEntity>(); Settings = SettingsUtility.GetUserPreferences(); LoadLocalizedRes(); var notificationCount = 0; var isReminderExpired = false; foreach (var friend in friendList) { if (!friend.Birthday.HasValue || (friend.IsHidden.HasValue && friend.IsHidden.Value)) { continue; } var daysAhead = DateTimeUtility.GetTimeToEvent(friend.Birthday.Value); //if the birthday is today, add recent birthdays to list if (daysAhead == 0) { //if the birthday is today, raise a toast notification recentBirthdays.Add(friend); todayBirthday.Add(friend); notificationCount++; if (friend.LastToastRaisedYear < DateTime.Now.Year) { if (!Settings.ReminderNotification.LocalNotifications.HasValue || Settings.ReminderNotification.LocalNotifications.Value) { RaiseToast(friend.Name + " " + Resources.BdayTodayMsg, Resources.BdayTileLabel, new Uri("/FriendDetails.xaml?" + UriParameter.FriendId + "=" + friend.UniqueId, UriKind.Relative)); } //update the last notification raised year friend.LastToastRaisedYear = DateTime.Now.Year; BirthdayUtility.UpdateFriendDetails(friend); } } //if birthday is tomorrow if (daysAhead == 1) { recentBirthdays.Add(friend); notificationCount++; } //check if reminder for upcoming birthdays exist if (daysAhead > 0 && daysAhead < 7) { if (!friend.IsReminderCreated) { isReminderExpired = true; notificationCount++; } weekBirthday.Add(friend); } } //raise a toast notification if reminders have to be created if (isReminderExpired) { RaiseToast(Resources.UpdateBdayReminder, Resources.BdayTileLabel, new Uri("/StartChecks.xaml?" + UriParameter.Action + "=Toast", UriKind.Relative)); } //update shell tile UpdateTile(notificationCount, weekBirthday); BirthdayUtility.DownloadProfileImages("No"); //send an email - [[to be implemented later]] //if (settings.ReminderNotification.SendEmailReminders && !string.IsNullOrEmpty(settings.UserDetails.Email)) //{ // String emailText = getReminderEmailContent(todayBirthday); // sendEmail(settings.UserDetails.Email,emailText); //} ////wish via email //if (todayBirthday!=null && todayBirthday.Count>0) //{ // wishViaEmail(todayBirthday); //} } catch (Exception ex) { AppLog.WriteToLog(DateTime.Now, ex.Message + ". " + ex.StackTrace, LogLevel.Error); throw; } }