Пример #1
0
        public void EndTask(UTask task)
        {
            /* Finalizamos la tarea */
            task.EndTask();

            /* Guardamos la tarea finalizada */
            this._dbmanager.SaveTask(task);

            /* Quitamos la tarea finalizada de memoria */
            this._tasks.Remove(task.ID);
        }
Пример #2
0
        public void SaveTask(UTask task)
        {
            if (task == null)
            {
                return;
            }

            using (SqlCeConnection conn = new SqlCeConnection(this._ConnectionString))
            {
                using (SqlCeCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = SQL_INSERT;
                    cmd.Parameters.AddWithValue("@TaskId", task.ID);
                    cmd.Parameters.AddWithValue("@description", task.Description);
                    cmd.Parameters.AddWithValue("@start", task.Start);
                    cmd.Parameters.AddWithValue("@end", task.End);
                    conn.Open();

                    if (conn.State == ConnectionState.Open)
                    {
                        if (cmd.ExecuteNonQuery() != 1)
                        {
                            throw new InvalidOperationException("Cannot save task.");
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException("Cannot save task, disconnected.");
                    }

                    if (conn.State == ConnectionState.Open)
                    {
                        conn.Close();
                    }
                }
            }
        }
Пример #3
0
 public void AddTask(UTask task)
 {
     /* Iniciamos la tarea y la agregamos a la lista de tareas pendientes */
     task.StartTask();
     this._tasks.Add(task.ID, task);
 }