/// <summary> /// Gets the taskcore object from the sqlite cursor /// </summary> /// <param name="cursor"> /// A <see cref="SqliteDataReader"/>. This won't be traversed, must be /// called each time the cursor moves ahead /// </param> /// <returns> /// A <see cref="TaskCore"/> - allocated and re-created /// Returns null if reading failed /// </returns> public static TaskCore GetTaskCoreFromCursor(SqliteDataReader cursor) { // this assumes a single task exists // the task to be extracted from the cursor TaskCore task = new TaskCore (); try { task.Id = cursor.GetInt32 (cursor.GetOrdinal ("TaskId")); task.Depends = cursor.GetInt32 (cursor.GetOrdinal ("Depends")); task.Title = cursor.GetString (cursor.GetOrdinal ("Name")); task.Description = cursor.GetString (cursor.GetOrdinal ("Description")); task.Priority = cursor.GetInt32 (cursor.GetOrdinal ("Priority")); task.DueDate = cursor.GetDateTime (cursor.GetOrdinal ("DueDate")); task.CreateDate = cursor.GetDateTime (cursor.GetOrdinal ("CreateDate")); } catch { log.ERROR ("Reading from cursor failed"); return null; } // now, extract the comments. SqliteCommand cmd = new SqliteCommand (conn); cmd.CommandText = String.Format ("SELECT * FROM Comments WHERE (TaskId = {0});", task.Id); log.WARN ("Trying to read comments with query - " + cmd.CommandText); SqliteDataReader commentCursor = cmd.ExecuteReader (); while (commentCursor.Read ()) { CommentData comment = new CommentData (); try { comment.Id = commentCursor.GetInt32 (commentCursor.GetOrdinal ("CommentID")); comment.TaskId = commentCursor.GetInt32 (commentCursor.GetOrdinal ("TaskId")); comment.Title = commentCursor.GetString (commentCursor.GetOrdinal ("Subject")); comment.Author = commentCursor.GetString (commentCursor.GetOrdinal ("Author")); comment.Content = commentCursor.GetString (commentCursor.GetOrdinal ("Message")); comment.PostDate = commentCursor.GetDateTime (commentCursor.GetOrdinal ("PostDate")); log.DEBUG ("Extracted comment - " + comment.ToString ()); } catch { log.ERROR ("Something went wrong while retrieving comment"); return null; } task.Comments.Add (comment); } log.DEBUG ("Extracted task as : " + task.ToString ()); return task; }
protected virtual void OnApplyButtonClicked(object sender, System.EventArgs e) { // Create a TaskCore object and populate with values from GUI TaskCore core = new TaskCore (); /* * TODO: Why isn't this working? all the objects are defined in stetic core.Title = this.taskNameEntry.Text; core.Description = this.taskDescText.Buffer.Text; core.CreateDate = DateTime.Now; core.DueDate = this.dueDateCal.Date; core.Priority = this.prioritySpin.Value;*/ core.Title = "Stub A"; core.Description = "Stub B"; core.CreateDate = DateTime.Now; core.DueDate = DateTime.Now; core.Priority = 10; log.INFO ("Added new TaskCore - " + core.ToString ()); // create a taskdata object TaskData task = new TaskData (); // attach the new core object to the task task.CoreDataObject = core; // write the task data to the database DBHelper.AddTask (core); // set the title of the task node task.Label = core.Title; // Add the task to the provider's children and thus trigger // an update of the treeview ProviderNode.AddChild (task); }