Пример #1
0
        public void Test_DeleteTask()
        {
            TaskAdministration.Todo.Clear();
            Task testTask = test;

            Assert.IsTrue(TaskAdministration.AddTask(testTask.Titel, testTask.Notes, testTask.HourDuration, testTask.MinDuration, testTask.Completed, testTask.AccountEmail));
            Assert.IsTrue(TaskAdministration.RemoveTask(testTask));

            try
            {
                TaskAdministration.RemoveTask(test);
            }
            catch (Exception exception)
            {
                Assert.IsTrue(exception is PlannerExceptions);
                Assert.AreEqual(exception.Message, "Task doesn't exist in the ToDo list");
            }

            //Database test
            Task TestDBTask = new Task(test.Titel + "db testing", test.Notes + "db Testing", 7, 7, false, "*****@*****.**");

            Assert.IsTrue(TaskAdministration.AddTask(TestDBTask.Titel, TestDBTask.Notes, 7, 7, false, "*****@*****.**"));

            Assert.IsTrue(TaskAdministration.RemoveTask(TestDBTask));
            TaskDatabase taskDatabase = new TaskDatabase();

            Assert.IsNotNull(taskDatabase.GetTask(TestDBTask));
        }
Пример #2
0
        /// <summary>
        /// Show an alert based on a reminder.
        /// </summary>
        /// <param name="reminder"></param>
        private static void DisplayAlert(Reminder reminder)
        {
            if (!IsOpen(reminder) && !IsQueued(reminder))
            {
                //Thread alertThread = new Thread(() =>
                //{
                Application.Current.Dispatcher.BeginInvoke(() =>
                {
                    Toast alert;
                    string sound = Settings.AlertSound;

                    if (reminder.ReminderType == ReminderType.Appointment)
                    {
                        Appointment appt = AppointmentDatabase.GetAppointment(reminder.ID);

                        string timeString = "";                        // reminder.StartTime.ToShortDateString();

                        //timeString += " » ";

                        if (appt.AllDay)
                        {
                            if ((reminder.EventStartDate.Value - reminder.EventEndDate.Value).TotalDays > 1)
                            {
                                timeString = reminder.EventStartDate.Value.Date.ToShortDateString() + " - "
                                             + reminder.EventEndDate.Value.Date.ToShortDateString();
                            }
                            else
                            {
                                timeString = reminder.EventStartDate.Value.Date.ToShortDateString();
                            }

                            timeString += " » All Day";
                        }
                        else
                        {
                            if ((reminder.EventStartDate.Value.Date != reminder.EventEndDate.Value.Date))
                            {
                                timeString = reminder.EventStartDate.Value.ToShortDateString() + " "
                                             + RandomFunctions.FormatTime(reminder.EventStartDate.Value.TimeOfDay)
                                             + " - " + reminder.EventEndDate.Value.ToShortDateString() + " "
                                             + RandomFunctions.FormatTime(reminder.EventEndDate.Value.TimeOfDay);
                            }
                            else
                            {
                                timeString  = reminder.EventStartDate.Value.Date.ToShortDateString();
                                timeString += " » " +
                                              RandomFunctions.FormatTime(appt.StartDate.TimeOfDay) + " - "
                                              + RandomFunctions.FormatTime(appt.EndDate.TimeOfDay);
                            }
                        }

                        alert = new Toast(
                            !string.IsNullOrEmpty(appt.Subject) ? appt.Subject : "(No subject)",
                            appt.Location,
                            timeString,
                            new BitmapImage(new Uri("pack://*****:*****@"Resources/Media/" + sound, UriKind.Relative),
                            ToastDuration.Long,
                            Settings.UnmuteSpeakers);
                    }
                    else
                    {
                        UserTask task = TaskDatabase.GetTask(reminder.ID);
                        alert         = new Toast(
                            !string.IsNullOrEmpty(task.Subject) ? task.Subject : "(No subject)",
                            task.Priority.ToString(),
                            task.DueDate.HasValue ? task.DueDate.Value.ToShortDateString() : "No due date",
                            new BitmapImage(new Uri("pack://*****:*****@"Resources/Media/" + sound, UriKind.Relative),
                            ToastDuration.Long,
                            Settings.UnmuteSpeakers);
                    }

                    alert.Tag     = reminder;
                    alert.Closed += alert_Closed;
                    alert.Open();
                });
                //});

                //alertThread.SetApartmentState(ApartmentState.STA);
                //alertThread.IsBackground = true;
                //alertThread.Start();
            }
        }