Esempio n. 1
0
        private void ScheduleReminder(UserReminder userReminder)
        {
            // TODO: implement reminders scheduling
            bool canBeAdded = false;
            string navigationUrl = string.Empty;
            switch (userReminder.Type)
            {
                case EnergyType.Water:
                    canBeAdded = isForWaterOn;
                    navigationUrl = WaterPage;
                    break;
                case EnergyType.Food:
                    canBeAdded = isForFoodOn;
                    navigationUrl = FoodPage;
                    break;
                case EnergyType.Activity:
                    canBeAdded = isForTrainingsOn;
                    navigationUrl = TrainingsPage;
                    break;
            }

            if (canBeAdded)
            {
                // if for all days of week
                if (userReminder.DaysOfWeek.Count == 7)
                {
                    string name = userReminder.GetReminderName(0);
                    var reminder = CreateSystemReminder(userReminder, name, navigationUrl);
                    reminder.RecurrenceType = RecurrenceInterval.Daily;
                    var existing = ScheduledActionService.Find(name);
                    if (existing != null)
                    {
                        ScheduledActionService.Remove(name);
                    }

                    try
                    {
                        ScheduledActionService.Add(reminder);
                    }
                    catch (Exception ex)
                    {
                        ErrorLogger.LogException(ex);
                    }
                }
            }
        }
Esempio n. 2
0
 private Reminder CreateSystemReminder(UserReminder userReminder, string name, string navigationUrl)
 {
     return new Reminder(name)
     {
         Title = userReminder.Title,
         Content = userReminder.Content,
         BeginTime = userReminder.Time,
         NavigationUri = new Uri(navigationUrl, UriKind.Relative)
     };
 }
Esempio n. 3
0
        public void AddReminder(UserReminder reminder)
        {
            userReminders.Add(reminder);
            ScheduleReminder(reminder);
            SaveReminders();

        }