protected override void RunAction() { if (closedTasksGroup != null) { DateTime today = DateTime.Today; using (IRepository <Task, long> repository = PersistentFactory.GetContext().GetRepository <Task, long>()) { foreach (Task task in closedTasksGroup.AllTasks.ToList()) { if ((today - task.Closed).TotalDays > 60) { task.State = TaskState.Archived; closedTasksGroup.Dispatcher.Invoke(() => closedTasksGroup.RemoveTask(task)); repository.Update(task); StatsHelper.Update(StatsData.TaskArchived); NotificationHelper.Notify(NotificationType.TaskArchived, task.Name); Log.Debug($"Background action archived {task.Name} task", this); } } } } }
private void Command_PostponeTask(object sender, ExecutedRoutedEventArgs e) { if (groupOpen.SelectedTask != null) { Task selectedTask = groupOpen.SelectedTask; selectedTask.State = TaskState.Postponed; selectedTask.Updated = DateTime.Now; groupOpen.RemoveTask(selectedTask); groupPostponed.AddTask(selectedTask); using (IRepository <Task, long> repository = PersistentFactory.GetContext().GetRepository <Task, long>()) repository.Update(selectedTask); NotificationHelper.Notify(NotificationType.TaskDeferred, selectedTask.Name); } }
private void Command_RemoveTask(object sender, ExecutedRoutedEventArgs e) { TasksGroupControl selectedGroup = groups.FirstOrDefault(x => x.SelectedTask != null); if (selectedGroup != null) { Task selectedTask = selectedGroup.SelectedTask; selectedTask.State = TaskState.Removed; selectedGroup.RemoveTask(selectedTask); ActionsCollection.Instance.Remove(ActionsCollection.Instance.Actions.OfType <TaskDeadlineAction>().FirstOrDefault(x => x.Task == selectedTask)); using (IRepository <Task, long> repository = PersistentFactory.GetContext().GetRepository <Task, long>()) repository.Update(selectedTask); StatsHelper.Update(StatsData.TaskRemoved); NotificationHelper.Notify(NotificationType.TaskRemoved, selectedTask.Name); } }