Beispiel #1
0
        public void DeleteList(List list)
        {
            var listToDelete = this.GetList(list);
            this.AllLists.Remove(listToDelete);

            this.SaveStore();
        }
Beispiel #2
0
        public void SaveList(List list)
        {
            if (!this.AllLists.Contains(list))
            {
                this.AllLists.Add(list);
            }

            this.SaveStore();
        }
Beispiel #3
0
        public static IEnumerable<Task> GetWhere(string filter, List<Task> tasks)
        {
            // (status:incomplete and isRepeating:false and isTagged:false)
            // (task.IsComplete == false && task.IsReapeating == false && task.HasTags == false)
            IEnumerable<Task> whereClause;

            var value = string.Empty;
            whereClause = AddListFilter(value, tasks);
            //whereClause += AddLocationFilter(value, tasks);

            return whereClause;
        }
        public TaskGroupViewModel(
            string groupName, int order, List<Task> tasks, DelegateCommand taskGroupCommand,
            INavigationService navigationService, ISynchronizationService synchronizationService)
            : base(navigationService)
        {
            this.Name = groupName;
            this.Order = order;
            this.Tasks = tasks;

            this.TaskGroupCommand = taskGroupCommand;

            this._synchronizationService = synchronizationService;

            this.ViewTaskCommand = new DelegateCommand(
                () => { this.NavigationService.Navigate(new Uri("/Views/TaskDetailsView.xaml", UriKind.Relative)); });

            Load();
            this.IsBeingActivated();
        }
        public static string SignArguments(string sharedSecret, Dictionary<string, string> parameters)
        {
            string sum = String.Empty;

            var paramList = new List<KeyValuePair<string, string>>(parameters);
            paramList.Sort((KeyValuePair<string, string> x, KeyValuePair<string, string> y) => {
                return x.Key.CompareTo(y.Key);
            });

            sum += sharedSecret;
            foreach (KeyValuePair<string, string> pair in paramList) {
                sum += pair.Key;
                sum += pair.Value;
            }

            return JeffWilcox.Utilities.Silverlight.MD5CryptoServiceProvider.GetMd5String(sum);
        }
Beispiel #6
0
 private static IEnumerable<Task> AddLocationFilter(string value, List<Task> tasks)
 {
     return tasks.Where(task => task.LocationId == value);
 }
Beispiel #7
0
 public void SaveList(List task)
 {
 }
Beispiel #8
0
 public List GetList(List task)
 {
     return new List();
 }
Beispiel #9
0
 public void DeleteList(List task)
 {
 }
Beispiel #10
0
        private List<Task> ToTaskList(RtmGetTasksResponse response)
        {
            //TODO: handle response failure
            if (!response.Status.ToLower().Equals("ok"))
                return null;

            var taskList = new List<Task>();
            foreach (var list in response.Tasks.List)
            {
                if (null == list.TaskSeries)
                    continue;

                foreach (var series in list.TaskSeries)
                {
                    var tags = new List<string>();
                    if (null != series.Tags) {
                        tags.AddRange(series.Tags);
                    }

                    var participants = new List<User>();
                    if (null != series.Participants) {
                        participants.AddRange(series.Participants.Select(participant => new User {
                            Id = participant.Id,
                            UserName = participant.UserName,
                            FullName = participant.FullName
                        }));
                    }

                    var notes = new List<Note>();
                    if (null != series.Notes) {
                        notes.AddRange(series.Notes.Select(note => new Note {
                            Id = note.Id,
                            Text = note.Text,
                            Title = note.Title,
                            Created = note.Created.AsNullableDateTime(null),
                            Modified = note.Modified.AsNullableDateTime(null)
                        }));
                    }

                    var rootList = list;
                    var rootSeries = series;
                    taskList.AddRange(series.Tasks.Select(task => new Task {
                        ListId = rootList.Id,
                        TaskSeriesId = rootSeries.Id,
                        Created = rootSeries.Created.AsNullableDateTime(null),
                        Modified = rootSeries.Modified.AsNullableDateTime(null),
                        Name = rootSeries.Name,
                        Source = rootSeries.Source,
                        Url = rootSeries.Url,
                        LocationId = rootSeries.LocationId,
                        Tags = tags,
                        Participants = participants,
                        Notes = notes,
                        Id = task.Id,
                        Due = task.Due.AsNullableDateTime(null),
                        HasDueTime = task.HasDueTime.AsBool(false),
                        Added = task.Added.AsNullableDateTime(null),
                        Completed = task.Completed.AsNullableDateTime(null),
                        Deleted = task.Deleted.AsNullableDateTime(null),
                        Priority = task.Priority.AsInt(0),
                        Postponed = task.Postponed.AsInt(0),
                        Estimate = task.Estimate.AsNullableDateTime(null),
                        IsRepeating = rootSeries.Tasks.Count > 0
                    }));
                }
            }

            return taskList;
        }
        private void BuildLocationDimensions(List<Task> tasks)
        {
            var locations = this._locationStoreLocator.GetStore().GetAllLocations();

            _locationCollection = locations.Select(location => new Group {
                Name = location.Name, Order = 0, Tasks = tasks.Where(task =>
                    ((task.LocationId == location.Id) && (task.Completed == null) && (task.Deleted == null))
                ).ToList()
            }).ToList();

            this._locationCollectionViewModels = new ObservableCollection<TaskGroupViewModel>();
            var viewModels = this._locationCollection.Select(o =>
                    new TaskGroupViewModel(o.Name, o.Order, o.Tasks, ViewTaskCollectionCommand,
                        this.NavigationService, this._synchronizationService)).ToList();
            viewModels.ForEach(this._locationCollectionViewModels.Add);

            // Create collection views
            this._locationCollectionViewSource = new CollectionViewSource { Source = this._locationCollectionViewModels };
            this._locationCollectionViewSource.View.CurrentChanged += (o, args) => {
                this.SelectedGroup = (TaskGroupViewModel)this._locationCollectionViewSource.View.CurrentItem;
                this.SelectedGroupIndex = this._locationCollectionViewSource.View.CurrentPosition;
            };
        }
        private void BuildListDimensions(List<Task> tasks)
        {
            var lists = this._listStoreLocator.GetStore().GetAllLists();

            //TODO: add smart lists back once filtering for tasks is working
            _listCollection = lists
                .Where(list => list.Smart == false)
                .Select(list => new Group {
                    Name = list.Name, Order = list.Smart ? 1 : 0, Tasks = tasks.Where( task =>
                        ((task.ListId == list.Id) && (task.Completed == null) && (task.Deleted == null))
                    ).ToList()
                }).ToList();

            this._listCollectionViewModels = new ObservableCollection<TaskGroupViewModel>();
            var viewModels = this._listCollection.Select(o =>
                    new TaskGroupViewModel(o.Name, o.Order, o.Tasks, ViewTaskCollectionCommand,
                        this.NavigationService, this._synchronizationService)).ToList();
            viewModels.ForEach(this._listCollectionViewModels.Add);

            // Create collection views
            this._listCollectionViewSource = new CollectionViewSource { Source = this._listCollectionViewModels };

            this._listCollectionViewSource.View.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));

            this._listCollectionViewSource.View.CurrentChanged += (o, args) => {
                this.SelectedGroup = (TaskGroupViewModel)this._listCollectionViewSource.View.CurrentItem;
                this.SelectedGroupIndex = this._listCollectionViewSource.View.CurrentPosition;
            };
        }
        private void BuildDueByDimensions(List<Task> tasks)
        {
            var startOfWeek = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
            var endOfWeek = DateTime.Now.EndOfWeek(DayOfWeek.Monday);

            var dueTodayTasks = tasks.
                Where(task => ((task.Due.AsDateTime(DateTime.MaxValue) <= DateTime.Today) &&
                                (task.Completed == null) && (task.Deleted == null)));

            var dueTomorrowTasks = tasks.
                Where(task => ((task.Due.AsDateTime(DateTime.MaxValue) == DateTime.Today.AddDays(1)) &&
                                (task.Completed == null) && (task.Deleted == null)));

            var dueThisWeekTasks = tasks.
                Where(task => (task.Due.AsDateTime(DateTime.MaxValue) >= startOfWeek &&
                                task.Due.AsDateTime(DateTime.MaxValue) <= endOfWeek) &&
                               (task.Completed == null) && (task.Deleted == null));

            var dueNextWeekTasks = tasks.
                Where(task => (task.Due.AsDateTime(DateTime.MaxValue) >= startOfWeek.AddDays(7) &&
                                task.Due.AsDateTime(DateTime.MaxValue) <= endOfWeek.AddDays(7)) &&
                               (task.Completed == null) && (task.Deleted == null));

            _dueByCollection = new List<Group> {
                new Group {Name = "Today", Order = 0, Tasks = dueTodayTasks.ToList()},
                new Group {Name = "Tomorrow", Order = 1, Tasks = dueTomorrowTasks.ToList()},
                new Group {Name = "This Week", Order = 2, Tasks = dueThisWeekTasks.ToList()},
                new Group {Name = "Next Week", Order = 3, Tasks = dueNextWeekTasks.ToList()}
            };

            this._dueByCollectionViewModels = new ObservableCollection<TaskGroupViewModel>();
            var viewModels = this._dueByCollection.Select(o =>
                    new TaskGroupViewModel(o.Name, o.Order, o.Tasks, ViewTaskCollectionCommand,
                        this.NavigationService, this._synchronizationService)).ToList();
            viewModels.ForEach(this._dueByCollectionViewModels.Add);

            // Create collection views
            this._dueByCollectionViewSource = new CollectionViewSource { Source = this._dueByCollectionViewModels };
            this._dueByCollectionViewSource.View.CurrentChanged += (o, args) => {
                this.SelectedGroup = (TaskGroupViewModel)this._dueByCollectionViewSource.View.CurrentItem;
                this.SelectedGroupIndex = this._dueByCollectionViewSource.View.CurrentPosition;
            };
        }
Beispiel #14
0
 public List GetList(List list)
 {
     return this.AllLists.Where(a => list.Id == a.Id).FirstOrDefault();
 }