Exemplo 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;
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public void AddTask(Task task)
        {
            if(null != FindTaskInRoutine(task))
            {
                return;
            }

            Tasks.Add(task);
        }
Exemplo 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));
        }
Exemplo 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;
        }
Exemplo 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);
        }
Exemplo 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;
        }
Exemplo n.º 8
0
 Task FindTaskInRoutine(Task task)
 {
     return FindTaskInRoutine(task.Guid);
 }
Exemplo 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;
            }
        }
Exemplo n.º 10
0
 public void RemoveTask(Task task)
 {
     RemoveTask(task.Guid);
 }