Esempio n. 1
0
        public TaskExpectation GetPendingExpectation(Task task)
        {
            var expectations = GetTaskExpectations(task);

            if(expectations.Count == 0)
            {
                return null;
            }

            foreach (var expectation in expectations)
            {
                if(HasExpectationBeenMet(expectation) || IsThereAMoreRecentExpectation(expectations, expectation))
                {
                    continue;
                }

                var hours = DateTime.Now.Subtract(expectation.ExpectedDateTime).TotalHours;

                if(hours >= -1)
                {
                    return expectation;
                }
            }

            return null;
        }
Esempio n. 2
0
        public TaskExpectation GetDailyExpectation(Task task, DateTime dateTime)
        {
            if(!task.ShouldOccurOn(dateTime))
            {
                return null;
            }

            return new TaskExpectation(task.Guid, dateTime.Date, task.TimeOfDay);
        }
Esempio n. 3
0
        public void AddTask(Task task)
        {
            if(null != FindTaskInRoutine(task))
            {
                return;
            }

            Tasks.Add(task);
        }
Esempio n. 4
0
        public void CompleteTask(Task task)
        {
            var expectation = GetPendingExpectation(task);

            if(null == expectation)
            {
                throw new Exception("Task isn't pending");
            }

            TaskAudits.Add(new TaskAudit(task.Guid, expectation, DateTime.Now));
        }
Esempio n. 5
0
        public EditTaskForm(ManageTasksForm manageTasks, Task task, Routine routine)
        {
            Task = task;
            ManageTasks = manageTasks;
            Routine = routine;
            AlreadySaved = false;
            InitializeComponent();

            taskNameTextbox.Text = task.Title;
            taskTimePicker.Value = DateTime.Now.Date.Add(task.TimeOfDay);
            repeatCheckbox.Checked = task.Repeat;
            sundayRepeat.Checked = task.RepeatSunday;
            mondayRepeat.Checked = task.RepeatMonday;
            tuesdayRepeat.Checked = task.RepeatTuesday;
            wednesdayRepeat.Checked = task.RepeatWednesday;
            thursdayRepeat.Checked = task.RepeatThursday;
            fridayRepeat.Checked = task.RepeatFriday;
            saturdayRepeat.Checked = task.RepeatSaturday;
        }
Esempio n. 6
0
        private void SaveTask()
        {
            var taskGuid = Task.Guid;

            var taskTitle = taskNameTextbox.Text.Trim() == "" ? "<untitled task>" : taskNameTextbox.Text;

            var taskTimeOfDay = taskTimePicker.Value.TimeOfDay;

            var task = new Task(taskTitle, DateTime.Now, taskTimeOfDay, repeatCheckbox.Checked, sundayRepeat.Checked,
                                mondayRepeat.Checked, tuesdayRepeat.Checked, wednesdayRepeat.Checked,
                                thursdayRepeat.Checked, fridayRepeat.Checked, saturdayRepeat.Checked);

            task.Guid = taskGuid;

            Routine.UpdateTask(taskGuid, task);
        }
Esempio n. 7
0
        public List<TaskExpectation> GetTaskExpectations(Task task, int days = 30)
        {
            var now = DateTime.Now;

            var expectations = new List<TaskExpectation>();

            for(int x = 0; x < days; x++)
            {
                var dateTime = now.AddDays(-x);

                var expectation = GetDailyExpectation(task, dateTime);

                if(expectation == null)
                {
                    continue;
                }

                expectations.Add(expectation);
            }

            return expectations;
        }
Esempio n. 8
0
 Task FindTaskInRoutine(Task task)
 {
     return FindTaskInRoutine(task.Guid);
 }
Esempio n. 9
0
        public void UpdateTask(Guid taskGuid, Task task)
        {
            for(int x = 0; x < Tasks.Count; x++)
            {
                if(Tasks[x].Guid != taskGuid)
                {
                    continue;
                }

                Tasks[x] = task;
                break;
            }
        }
Esempio n. 10
0
 public void RemoveTask(Task task)
 {
     RemoveTask(task.Guid);
 }