示例#1
0
        void TaskListTaskCollectionRepo.AddNew(ITaskListCore container,
                                               ITaskCore item)
        {
            var command =
                "INSERT INTO Tasks" +
                "(Name, DueDate, CompletionDate, Priority, State, " +
                "Category, ExternalID) " +
                "VALUES (@name, @dueDate, @completionDate, " +
                "@priority, @state, @catId, ''); " +
                "SELECT last_insert_rowid();";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddWithValue("@name", item.Text);
                cmd.Parameters.AddWithValue("@dueDate",
                                            Database.FromDateTime(item.DueDate));
                cmd.Parameters.AddWithValue("@completionDate",
                                            Database.FromDateTime(DateTime.MinValue));
                cmd.Parameters.AddWithValue("@priority", (int)item.Priority);
                cmd.Parameters.AddWithValue("@state", (int)item.State);
                cmd.Parameters.AddWithValue("@catId",
                                            int.Parse(container.Id));
                var id = cmd.ExecuteScalar().ToString();
                item.SetId(id);
            }
        }
示例#2
0
        public string UpdateName(ITaskListCore taskList, string name)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);

            dummyList.ListName = name;
            return(name);
        }
示例#3
0
        public void Add(ITaskListCore taskList, ITaskCore task)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);
            var dummyTask = backend.GetTaskBy(task.Id);

            dummyList.Tasks.Add(dummyTask);
        }
示例#4
0
        public void Remove(ITaskListCore taskList, ITaskCore task)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);
            var dummyTask = dummyList.Tasks.Single(
                t => t.Id.ToString() == task.Id);

            dummyList.Tasks.Remove(dummyTask);
        }
示例#5
0
        void ITaskListTaskCollectionRepo.Remove(ITaskListCore container,
                                                ITaskCore item)
        {
            string taskSeriesId, taskId;

            backend.DecodeTaskId(item, out taskSeriesId, out taskId);
            backend.Rtm.TasksDelete(backend.Timeline, container.Id,
                                    taskSeriesId, taskId);
        }
示例#6
0
        public IEnumerable <ITaskCore> GetAll(ITaskListCore container)
        {
            var dummyList = backend.GetTaskListBy(container.Id);

            foreach (var dummyTask in dummyList.Tasks)
            {
                yield return(CreateTask(dummyTask));
            }
        }
示例#7
0
        void TaskListTaskCollectionRepo.Remove(ITaskListCore container,
                                               ITaskCore item)
        {
            var command = "DELETE FROM Tasks WHERE ID=@id;";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddWithValue("@id", int.Parse(item.Id));
                cmd.ExecuteNonQuery();
            }
        }
示例#8
0
        void ITaskListTaskCollectionRepo.AddNew(ITaskListCore container,
                                                ITaskCore item)
        {
            var list = backend.Rtm.TasksAdd(
                backend.Timeline, item.Text, container.Id);
            var taskSeries = list.TaskSeriesCollection [0];
            var last       = taskSeries.TaskCollection.Length - 1;
            var id         = backend.EncodeTaskId(
                taskSeries.TaskID, taskSeries.TaskCollection [last].TaskID);

            item.SetId(id);
        }
示例#9
0
        public void AddNew(ITaskListCore taskList, ITaskCore task)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);

            var dummyTask = new DummyTask(task.Text)
            {
                DueDate = task.DueDate == DateTime.MaxValue
                                ? DateTime.MinValue : task.DueDate,
                Priority = (int)task.Priority
            };

            dummyList.Tasks.Add(dummyTask);
        }
示例#10
0
        IEnumerable <ITaskCore> TaskListTaskCollectionRepo.GetAll(
            ITaskListCore container)
        {
            var command =
                "SELECT ID, Name, DueDate, CompletionDate, Priority, State " +
                "FROM Tasks WHERE Category=@id;";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddIdParameter(container);
                using (var dataReader = cmd.ExecuteReader()) {
                    while (dataReader.Read())
                    {
                        var id             = dataReader.GetInt32(0).ToString();
                        var name           = dataReader.GetString(1);
                        var state          = (TaskState)dataReader.GetInt32(5);
                        var completionDate =
                            Database.ToDateTime(dataReader.GetInt64(3));

                        ITaskCore task;
                        if (state == TaskState.Active)
                        {
                            task = backend.Factory.CreateTask(id, name);
                        }
                        else if (state == TaskState.Completed)
                        {
                            task = backend.Factory.CreateCompletedTask(
                                id, name, completionDate);
                        }
                        else
                        {
                            task = backend.Factory.CreateDiscardedTask(
                                id, name);
                        }
                        task.Priority = (TaskPriority)dataReader.GetInt32(4);
                        task.DueDate  =
                            Database.ToDateTime(dataReader.GetInt64(2));

                        yield return(task);
                    }
                }
            }
        }
示例#11
0
        IEnumerable <ITaskCore> ITaskListTaskCollectionRepo.GetAll(
            ITaskListCore container)
        {
            var tasks = backend.Rtm.TasksGetList(container.Id);

            foreach (var rtmList in tasks.ListCollection)
            {
                if (rtmList.TaskSeriesCollection == null)
                {
                    continue;
                }
                foreach (var rtmTaskSeries in rtmList.TaskSeriesCollection)
                {
                    var last    = rtmTaskSeries.TaskCollection.Length - 1;
                    var rtmTask = rtmTaskSeries.TaskCollection [last];
                    var taskId  = backend.EncodeTaskId(rtmTaskSeries.TaskID,
                                                       rtmTask.TaskID);
                    ITaskCore task;
                    if (rtmTask.Completed == DateTime.MinValue)
                    {
                        task = backend.Factory.CreateTask(
                            taskId, rtmTaskSeries.Name);
                    }
                    else
                    {
                        task = backend.Factory.CreateCompletedTask(
                            taskId, rtmTaskSeries.Name, rtmTask.Completed);
                    }
                    task.DueDate  = rtmTask.Due;
                    task.Priority = rtmTask.GetTaskPriority();

                    CacheNotes(rtmTaskSeries);
                    yield return(task);
                }
            }
        }
示例#12
0
		IEnumerable<ITaskCore> TaskListTaskCollectionRepo.GetAll (
			ITaskListCore container)
		{
			var command =
				"SELECT ID, Name, DueDate, CompletionDate, Priority, State " +
				"FROM Tasks WHERE Category=@id;";
			using (var cmd = new SqliteCommand (database.Connection)) {
				cmd.CommandText = command;
				cmd.Parameters.AddIdParameter (container);
				using (var dataReader = cmd.ExecuteReader ()) {
					while (dataReader.Read ()) {
						var id = dataReader.GetInt32 (0).ToString ();
						var name = dataReader.GetString (1);
						var state = (TaskState)dataReader.GetInt32 (5);
						var completionDate =
							Database.ToDateTime (dataReader.GetInt64 (3));

						ITaskCore task;
						if (state == TaskState.Active)
							task = backend.Factory.CreateTask (id, name);
						else if (state == TaskState.Completed) {
							task = backend.Factory.CreateCompletedTask (
								id, name, completionDate);
						} else {
							task = backend.Factory.CreateDiscardedTask (
								id, name);
						}
						task.Priority = (TaskPriority)dataReader.GetInt32 (4);
						task.DueDate =
							Database.ToDateTime (dataReader.GetInt64 (2));

						yield return task;
					}
				}
			}
		}
示例#13
0
        void ITaskListTaskCollectionRepo.Add(ITaskListCore container,
		                                      ITaskCore item)
        {
            throw new NotSupportedException (
                "A task can only belong to one task list.");
        }
示例#14
0
        string ITaskListRepository.UpdateName(ITaskListCore taskList,
		                                       string name)
        {
            throw new NotSupportedException (
                "Cannot change the name of a task list.");
        }
示例#15
0
 bool ITaskListRepository.CanChangeName(ITaskListCore taskList)
 {
     return false;
 }
示例#16
0
 string ITaskListRepository.UpdateName(ITaskListCore taskList,
                                       string name)
 {
     throw new NotSupportedException(
               "Cannot change the name of a task list.");
 }
示例#17
0
 void TaskListTaskCollectionRepo.ClearAll(ITaskListCore container)
 {
     throw new NotImplementedException();
 }
示例#18
0
        public void ClearAll(ITaskListCore taskList)
        {
            var dummyList = backend.GetTaskListBy(taskList.Id);

            dummyList.Tasks.Clear();
        }
示例#19
0
        void ITaskListTaskCollectionRepo.AddNew(ITaskListCore container,
		                                         ITaskCore item)
        {
            var list = backend.Rtm.TasksAdd (
                backend.Timeline, item.Text, container.Id);
            var taskSeries = list.TaskSeriesCollection [0];
            var last = taskSeries.TaskCollection.Length - 1;
            var id = backend.EncodeTaskId (
                taskSeries.TaskID, taskSeries.TaskCollection [last].TaskID);
            item.SetId (id);
        }
示例#20
0
 public bool CanChangeName(ITaskListCore taskList)
 {
     return(true);
 }
示例#21
0
		void TaskListTaskCollectionRepo.Remove (ITaskListCore container,
		                                        ITaskCore item)
		{
			var command = "DELETE FROM Tasks WHERE ID=@id;";
			using (var cmd = new SqliteCommand (database.Connection)) {
				cmd.CommandText = command;
				cmd.Parameters.AddWithValue ("@id", int.Parse (item.Id));
				cmd.ExecuteNonQuery ();
			}
		}
示例#22
0
		void TaskListTaskCollectionRepo.AddNew (ITaskListCore container,
		                                        ITaskCore item)
		{
			var command =
				"INSERT INTO Tasks" +
				"(Name, DueDate, CompletionDate, Priority, State, " +
				"Category, ExternalID) " +
				"VALUES (@name, @dueDate, @completionDate, " +
				"@priority, @state, @catId, ''); " +
				"SELECT last_insert_rowid();";
			using (var cmd = new SqliteCommand (database.Connection)) {
				cmd.CommandText = command;
				cmd.Parameters.AddWithValue ("@name", item.Text);
				cmd.Parameters.AddWithValue ("@dueDate",
					Database.FromDateTime (item.DueDate));
				cmd.Parameters.AddWithValue ("@completionDate",
					Database.FromDateTime (DateTime.MinValue));
				cmd.Parameters.AddWithValue ("@priority", (int)item.Priority);
				cmd.Parameters.AddWithValue ("@state", (int)item.State);
				cmd.Parameters.AddWithValue ("@catId",
				                             int.Parse (container.Id));
				var id = cmd.ExecuteScalar ().ToString ();
				item.SetId (id);
			}
		}
示例#23
0
 public void Delete(ITaskListCore taskList)
 {
     throw new NotImplementedException();
 }
示例#24
0
		public void Delete (ITaskListCore taskList)
		{
			throw new NotImplementedException ();
		}
示例#25
0
 ITaskCore TaskListTaskCollectionRepo.GetBy(ITaskListCore container,
                                            string id)
 {
     throw new NotImplementedException();
 }
示例#26
0
 void TaskListTaskCollectionRepo.Add(ITaskListCore container,
                                     ITaskCore item)
 {
     throw new NotSupportedException(
               "A task can only belong to one task list.");
 }
示例#27
0
 void ITaskListTaskCollectionRepo.ClearAll(ITaskListCore container)
 {
     throw new NotImplementedException ();
 }
示例#28
0
 public ITaskCore GetBy(ITaskListCore container, string id)
 {
     return(CreateTask(backend.GetTaskBy(id)));
 }
示例#29
0
        IEnumerable<ITaskCore> ITaskListTaskCollectionRepo.GetAll(
			ITaskListCore container)
        {
            var tasks = backend.Rtm.TasksGetList (container.Id);
            foreach (var rtmList in tasks.ListCollection) {
                if (rtmList.TaskSeriesCollection == null)
                    continue;
                foreach (var rtmTaskSeries in rtmList.TaskSeriesCollection) {
                    var last = rtmTaskSeries.TaskCollection.Length - 1;
                    var rtmTask = rtmTaskSeries.TaskCollection [last];
                    var taskId = backend.EncodeTaskId (rtmTaskSeries.TaskID,
                                                       rtmTask.TaskID);
                    ITaskCore task;
                    if (rtmTask.Completed == DateTime.MinValue) {
                        task = backend.Factory.CreateTask (
                            taskId, rtmTaskSeries.Name);
                    } else {
                        task = backend.Factory.CreateCompletedTask (
                            taskId, rtmTaskSeries.Name, rtmTask.Completed);
                    }
                    task.DueDate = rtmTask.Due;
                    task.Priority = rtmTask.GetTaskPriority ();

                    CacheNotes (rtmTaskSeries);
                    yield return task;
                }
            }
        }
示例#30
0
 bool ITaskListRepository.CanChangeName(ITaskListCore taskList)
 {
     return(false);
 }
示例#31
0
        ITaskCore ITaskListTaskCollectionRepo.GetBy(ITaskListCore container,
		                                             string id)
        {
            throw new NotImplementedException ();
        }
示例#32
0
        void ITaskListTaskCollectionRepo.Remove(ITaskListCore container,
		                                         ITaskCore item)
        {
            string taskSeriesId, taskId;
            backend.DecodeTaskId (item, out taskSeriesId, out taskId);
            backend.Rtm.TasksDelete (backend.Timeline, container.Id,
                                     taskSeriesId, taskId);
        }
示例#33
0
 void IBackend.Delete(ITaskListCore taskList)
 {
     throw new NotImplementedException();
 }