Пример #1
0
        public Task AskForTask()
        {
            var mostRecentTask = _taskService.GetLastTask();

            var currentProject = GetProject(mostRecentTask);

            var recentTaskNames = _taskService.GetTasksByTaskIds(_timeService.GetRecentlyRecordedTaskIds(5)).Select(x => x.Name);
            var taskName        = _inputService.AskForSelectionOrInput("Choose from a recent task. (If none of these match what you are doing then just leave blank.)", recentTaskNames.ToList());

            var currentTask = (string.IsNullOrWhiteSpace(taskName)) ? null: _taskService.GetTaskByName(taskName);

            if (currentTask == null)
            {
                var tasks = _taskService.GetGeneralTasks();
                currentTask = _inputService.AskForSelection("Ok. Above is a list of tasks. Which one were you working on?",
                                                            tasks.ToList());
            }

            currentTask.Project = currentProject;

            return(currentTask);
        }
Пример #2
0
        void AskAboutBreak(Task currentTask, DateTime askTime, int missedInterval, string comment, Task associatedTask)
        {
            if (
                !_inputService.AskForBoolean("Looks like we missed " + missedInterval +
                                             " check in(s). Were you on break?"))
            {
                _timeService.RecordTime(currentTask, askTime, comment, associatedTask);

                // record an entry for now in the case where they forgot about nagger and are just now answering the questions
                if (_timeService.IntervalsSinceTime(askTime) > 1)
                {
                    _timeService.RecordTime(currentTask, DateTime.Now, comment, associatedTask);
                }

                //TODO: Create a method to ask about abscences (what if they have worked on multiple things in the amount of time they were gone?)
            }
            else
            {
                var lastTime = _timeService.GetLastTimeEntry().TimeRecorded;
                var minutes  = _timeService.GetIntervalMinutes(1).First();
                lastTime = lastTime.AddMinutes(minutes);

                // insert an internal time marker for ask time
                _timeService.RecordMarker(lastTime);

                if (_inputService.AskForBoolean("Have you worked on anything since you've been back?"))
                {
                    var intervalsMissed = _timeService.GetIntervalMinutes(missedInterval).ToList();

                    var minutesWorked =
                        _inputService.AskForSelection(
                            "Which of these options represents about how long you have been working?", intervalsMissed);

                    // insert an entry for when they started working
                    _timeService.RecordTime(currentTask, missedInterval, minutesWorked, lastTime, comment, associatedTask);
                }

                // also insert an entry for the current time (since they are working and are no longer on break)
                _timeService.RecordTime(currentTask, DateTime.Now, comment, associatedTask);
            }
        }