public Task AskForAssociatedTask(Task currentTask) { // only ask for an associated task if the project repository has an associated repository if (currentTask.Project?.AssociatedRemoteRepository == null) { return(null); } if (!_inputService.AskForBoolean("Associate this entry with an additional task?")) { return(null); } Task associatedTask; var recentlyAssociatedTasks = _taskService.GetTasksByTaskIds(_timeService.GetRecentlyAssociatedTaskIds(5, currentTask)).ToDictionary(key => key.Name); var associatedTaskName = _inputService.AskForSelectionOrInput("Choose from a recent task or insert a new task name", recentlyAssociatedTasks.Keys.ToList()); if (recentlyAssociatedTasks.TryGetValue(associatedTaskName, out associatedTask)) { return(associatedTask); } return(_taskService.GetAssociatedTaskByName(associatedTaskName, currentTask.Project)); }
bool AdjustJiraEstimate(Project project = null) { var settingKey = _baseJiraRepository.GetSettingKey(AdjustEstimateKey); if (!_settingsService.GetSetting <string>(settingKey).IsNullOrWhitespace()) { return(_settingsService.GetSetting <bool>(settingKey)); } var projectString = (project != null) ? " for {0} ".FormatWith(project.Name) : ""; var adjustJiraEstimate = _inputService.AskForBoolean("Would you like JIRA to automatically adjust estimates {0}when you log your time?".FormatWith(projectString)); _settingsService.SaveSetting(settingKey, adjustJiraEstimate.ToString()); return(adjustJiraEstimate); }
public void Run() { _timeService.DailyTimeOperations(); var askTime = DateTime.Now; _outputService.ShowInterface(); _outputService.OutputSound(); var runMiss = 0; var lastTimeEntry = _timeService.GetLastTimeEntry(); var currentTask = lastTimeEntry?.Task; var comment = ""; var associatedTask = (Task)null; if (currentTask != null) { var stillWorking = false; if (lastTimeEntry.HasComment) { stillWorking = _inputService.AskForBoolean($"Are you still working on {lastTimeEntry.Comment} ({currentTask.Name})?"); if (stillWorking) { comment = lastTimeEntry.Comment; associatedTask = lastTimeEntry.AssociatedTask; } } if (!stillWorking) { // attempt to log all time up to this point because tasks were switched if (_settingsService.GetSetting <bool>("SyncOnTaskSwitch")) { _timeService.DailyTimeOperations(true); } stillWorking = _inputService.AskForBoolean($"Are you still working on {currentTask}?"); } if (!stillWorking) { currentTask = null; } } if (currentTask == null) { if (!_inputService.AskForBoolean("Are you working?")) { runMiss = _timeService.IntervalsSinceLastRecord(); if (runMiss <= 1) { _timeService.RecordMarker(askTime); } 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); } } else { currentTask = _remoteRunner.AskForTask(); } } if (currentTask == null) { _outputService.HideInterface(); return; } if (string.IsNullOrWhiteSpace(comment)) { var recentComments = _timeService.GetRecentlyRecordedCommentsForTask(5, currentTask).ToList(); comment = _inputService.AskForSelectionOrInput("Choose from options or insert a new comment. (Leave Blank for no comment)", recentComments); } if (associatedTask == null) { associatedTask = _remoteRunner.AskForAssociatedTask(currentTask); } //todo: refactor the way runMiss is done runMiss = _timeService.IntervalsSinceLastRecord(); // there will usually be 1 interval between the last time this ran and this time (it only makes sense) if (runMiss <= 1) { _timeService.RecordTime(currentTask, askTime, comment, associatedTask); } else { AskAboutBreak(currentTask, askTime, runMiss, comment, associatedTask); } _outputService.HideInterface(); }