[tasque/transition: 147/213] SQlite: before doing real work, format everything



commit ab5cff78cf3ad2bcb4e0064cdb4153bb70968a57
Author: Antonius Riha <antoniusriha gmail com>
Date:   Sat Aug 18 18:29:46 2012 +0200

    SQlite: before doing real work, format everything
    
    reduces the format change noise in "real" commits (where actual code
    changes occur)

 src/Addins/SqliteBackend/Database.cs          |  246 +++++++++++++------------
 src/Addins/SqliteBackend/SqliteBackend.cs     |  142 +++++++--------
 src/Addins/SqliteBackend/SqliteBackend.csproj |   12 ++
 src/Addins/SqliteBackend/SqliteCategory.cs    |   55 ++++--
 src/Addins/SqliteBackend/SqliteNote.cs        |   14 +-
 src/Addins/SqliteBackend/SqliteTask.cs        |  195 +++++++++++---------
 6 files changed, 350 insertions(+), 314 deletions(-)
---
diff --git a/src/Addins/SqliteBackend/Database.cs b/src/Addins/SqliteBackend/Database.cs
index a1609ce..3de7903 100644
--- a/src/Addins/SqliteBackend/Database.cs
+++ b/src/Addins/SqliteBackend/Database.cs
@@ -1,63 +1,65 @@
 // Database.cs created with MonoDevelop
-// User: calvin at 11:27 AMÂ2/19/2008
+// User: calvin at 11:27 AM 2/19/2008
 //
 // To change standard headers go to Edit->Preferences->Coding->Standard Headers
 //
-
 using System;
-using Mono.Data.Sqlite;
+using System.Diagnostics;
 using System.IO;
-using Tasque;
+using Mono.Data.Sqlite;
 
 namespace Tasque.Backends.Sqlite
 {
 	public class Database
 	{
 		private SqliteConnection connection;
-        public static readonly DateTime LocalUnixEpoch = new DateTime(1970, 1, 1).ToLocalTime();
+		public static readonly DateTime LocalUnixEpoch = new DateTime (
+				1970,
+				1,
+				1
+			).ToLocalTime ();
 		
-		public SqliteConnection Connection
-		{
+		public SqliteConnection Connection {
 			get { return connection; }
 		}
 		
-		public Database()
+		public Database ()
 		{
 		}
 		
-		
-		public void Open()
+		public void Open ()
 		{
-			string dbLocation = "URI=file:" + Path.Combine(
-						Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 
+			string dbLocation = "URI=file:" + Path.Combine (
+						Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), 
 						"tasque/sqlitebackend.db");
 
-			connection = new SqliteConnection(dbLocation);
-			connection.Open();
+			connection = new SqliteConnection (dbLocation);
+			connection.Open ();
 			
-			CreateTables();
+			CreateTables ();
 		}
 		
-		public void Close()
+		public void Close ()
 		{
-			connection.Close();
+			connection.Close ();
 			connection = null;			
 		}
 		
-		public void CreateTables()
+		public void CreateTables ()
 		{
-			if(!TableExists("Categories")) {
-				Console.WriteLine("Creating Categories table");
-				ExecuteScalar(@"CREATE TABLE Categories (
+			if (!TableExists ("Categories")) {
+				Console.WriteLine ("Creating Categories table");
+				ExecuteScalar (@"CREATE TABLE Categories (
 					ID INTEGER PRIMARY KEY,
 					Name TEXT,
 					ExternalID TEXT
-				)");
+				)"
+				);
 			}
 
-			if(!TableExists("Tasks")) {
-				Console.WriteLine("Creating Tasks table");
-				ExecuteScalar(@"CREATE TABLE Tasks (
+			if (!TableExists ("Tasks")) {
+				Console.WriteLine ("Creating Tasks table");
+				ExecuteScalar (@"CREATE TABLE Tasks (
 					ID INTEGER PRIMARY KEY,
 					Category INTEGER,
 					Name TEXT,
@@ -66,144 +68,146 @@ namespace Tasque.Backends.Sqlite
 					Priority INTEGER,
 					State INTEGER,
 					ExternalID TEXT
-				)");
+				)"
+				);
 			}
 
-			if(!TableExists("Notes")) {
-				Console.WriteLine("Creating Notes table");
-				ExecuteScalar(@"CREATE TABLE Notes (
+			if (!TableExists ("Notes")) {
+				Console.WriteLine ("Creating Notes table");
+				ExecuteScalar (@"CREATE TABLE Notes (
 					ID INTEGER PRIMARY KEY,
 					Task INTEGER KEY,
 					Name TEXT,
 					Text TEXT,
 					ExternalID TEXT
-				)");
+				)"
+				);
 			}
 		}
-		
 
-		public object ExecuteScalar(string command)
-        {
-        	object resultset;
+		public object ExecuteScalar (string command)
+		{
+			object resultset;
         	
-        	SqliteCommand cmd = connection.CreateCommand();
-        	cmd.CommandText = command;
-        	resultset = cmd.ExecuteScalar();
-        	return resultset;
-        }
+			SqliteCommand cmd = connection.CreateCommand ();
+			cmd.CommandText = command;
+			resultset = cmd.ExecuteScalar ();
+			return resultset;
+		}
         
-        public int ExecuteNonQuery(string command)		
-        {
-        	int resultCode;
-        	SqliteCommand cmd = connection.CreateCommand();
-        	cmd.CommandText = command;
-        	resultCode = cmd.ExecuteNonQuery();
-        	cmd.Dispose();
-        	return resultCode;
-        }
+		public int ExecuteNonQuery (string command)
+		{
+			int resultCode;
+			SqliteCommand cmd = connection.CreateCommand ();
+			cmd.CommandText = command;
+			resultCode = cmd.ExecuteNonQuery ();
+			cmd.Dispose ();
+			return resultCode;
+		}
         
-        public string GetSingleString(string command)
-        {
-        	string readString = String.Empty;
-        	try {
-	        	SqliteCommand cmd = connection.CreateCommand();
-	        	cmd.CommandText = command;
-	        	SqliteDataReader dataReader = cmd.ExecuteReader();
-	        	if(dataReader.Read())
-	        		readString = dataReader.GetString(0);
-	        	else
-	        		readString = string.Empty;
-	        	dataReader.Close();
-	        	cmd.Dispose();
+		public string GetSingleString (string command)
+		{
+			string readString = String.Empty;
+			try {
+				SqliteCommand cmd = connection.CreateCommand ();
+				cmd.CommandText = command;
+				SqliteDataReader dataReader = cmd.ExecuteReader ();
+				if (dataReader.Read ())
+					readString = dataReader.GetString (0);
+				else
+					readString = string.Empty;
+				dataReader.Close ();
+				cmd.Dispose ();
 			} catch (Exception e) {
-				Debug.WriteLine("Exception Thrown {0}", e);
+				Debug.WriteLine ("Exception Thrown {0}", e);
 			}
-        	return readString;
-        }
+			return readString;
+		}
         
-        public DateTime GetDateTime(string command)
-        {
-        	long longValue;
-        	DateTime dtValue;
-	       	try{
-	        	longValue = GetSingleLong(command);
-	        	if(longValue == 0)
-	        		dtValue = DateTime.MinValue;
-	        	else
-	        		dtValue = Database.ToDateTime(longValue);
+		public DateTime GetDateTime (string command)
+		{
+			long longValue;
+			DateTime dtValue;
+			try {
+				longValue = GetSingleLong (command);
+				if (longValue == 0)
+					dtValue = DateTime.MinValue;
+				else
+					dtValue = Database.ToDateTime (longValue);
 			} catch (Exception e) {
-				Debug.WriteLine("Exception Thrown {0}", e);
+				Debug.WriteLine ("Exception Thrown {0}", e);
 				dtValue = DateTime.MinValue;
 			}
-        	return dtValue;
-        }        
+			return dtValue;
+		}
         
-        public int GetSingleInt(string command)
-        {
-        	int dtVal = 0;
-        	try {        	
-	        	SqliteCommand cmd = connection.CreateCommand();
-	        	cmd.CommandText = command;
-	        	SqliteDataReader dataReader = cmd.ExecuteReader();
-	        	if(dataReader.Read())
-	        		dtVal = dataReader.GetInt32(0);
-	        	else
-	        		dtVal = 0;
-	        	dataReader.Close();
-	        	cmd.Dispose();
+		public int GetSingleInt (string command)
+		{
+			int dtVal = 0;
+			try {        	
+				SqliteCommand cmd = connection.CreateCommand ();
+				cmd.CommandText = command;
+				SqliteDataReader dataReader = cmd.ExecuteReader ();
+				if (dataReader.Read ())
+					dtVal = dataReader.GetInt32 (0);
+				else
+					dtVal = 0;
+				dataReader.Close ();
+				cmd.Dispose ();
 			} catch (Exception e) {
-				Debug.WriteLine("Exception Thrown {0}", e);
+				Debug.WriteLine ("Exception Thrown {0}", e);
 			}        	
-        	return dtVal;
-        }  
+			return dtVal;
+		}
 
-        public long GetSingleLong(string command)
-        {
-        	long dtVal = 0;
-         	try {       	
-	        	SqliteCommand cmd = connection.CreateCommand();
-	        	cmd.CommandText = command;
-	        	SqliteDataReader dataReader = cmd.ExecuteReader();
-	        	if(dataReader.Read())
-	        		dtVal = dataReader.GetInt64(0);
-	        	else
-	        		dtVal = 0;
-	        	dataReader.Close();
-	        	cmd.Dispose();
+		public long GetSingleLong (string command)
+		{
+			long dtVal = 0;
+			try {       	
+				SqliteCommand cmd = connection.CreateCommand ();
+				cmd.CommandText = command;
+				SqliteDataReader dataReader = cmd.ExecuteReader ();
+				if (dataReader.Read ())
+					dtVal = dataReader.GetInt64 (0);
+				else
+					dtVal = 0;
+				dataReader.Close ();
+				cmd.Dispose ();
 			} catch (Exception e) {
-				Debug.WriteLine("Exception Thrown {0}", e);
+				Debug.WriteLine ("Exception Thrown {0}", e);
 			} 
-        	return dtVal;
-        }  
-
+			return dtVal;
+		}
         
-		public bool TableExists(string table)
+		public bool TableExists (string table)
 		{
-			return Convert.ToInt32(ExecuteScalar(String.Format(@"
+			return Convert.ToInt32 (ExecuteScalar (String.Format (@"
 				SELECT COUNT(*)
 				FROM sqlite_master
 				WHERE Type='table' AND Name='{0}'", 
-				table))) > 0;
+				table)
+			)
+			) > 0;
 		}
 
-		public static DateTime ToDateTime(long time)
+		public static DateTime ToDateTime (long time)
 		{
-			return FromTimeT(time);
+			return FromTimeT (time);
 		}
 
-		public static long FromDateTime(DateTime time)
+		public static long FromDateTime (DateTime time)
 		{
-			return ToTimeT(time);
+			return ToTimeT (time);
 		}
 
-		public static DateTime FromTimeT(long time)
+		public static DateTime FromTimeT (long time)
 		{
-			return LocalUnixEpoch.AddSeconds(time);
+			return LocalUnixEpoch.AddSeconds (time);
 		}
 
-		public static long ToTimeT(DateTime time)
+		public static long ToTimeT (DateTime time)
 		{
-			return (long)time.Subtract(LocalUnixEpoch).TotalSeconds;
+			return (long)time.Subtract (LocalUnixEpoch).TotalSeconds;
 		}
 	}
 }
diff --git a/src/Addins/SqliteBackend/SqliteBackend.cs b/src/Addins/SqliteBackend/SqliteBackend.cs
index 68dfcd0..517befa 100644
--- a/src/Addins/SqliteBackend/SqliteBackend.cs
+++ b/src/Addins/SqliteBackend/SqliteBackend.cs
@@ -1,11 +1,10 @@
 // SqliteBackend.cs created with MonoDevelop
-// User: boyd at 7:10 AMÂ2/11/2008
-
+// User: boyd at 7:10 AM 2/11/2008
 using System;
 using System.Collections.Generic;
-using Mono.Unix;
-using Tasque.Backends;
+using System.Diagnostics;
 using Mono.Data.Sqlite;
+using Mono.Unix;
 
 namespace Tasque.Backends.Sqlite
 {
@@ -16,64 +15,59 @@ namespace Tasque.Backends.Sqlite
 		private Gtk.TreeModelSort sortedTasksModel;
 		private bool initialized;
 		private bool configured = true;
-		
 		private Database db;
-		
 		private Gtk.ListStore categoryListStore;
 		private Gtk.TreeModelSort sortedCategoriesModel;
-
-		public event BackendInitializedHandler BackendInitialized;
-		public event BackendSyncStartedHandler BackendSyncStarted;
-		public event BackendSyncFinishedHandler BackendSyncFinished;
-		
 		SqliteCategory defaultCategory;
 		//SqliteCategory workCategory;
 		//SqliteCategory projectsCategory;
 		
-		public SqliteBackend ()
+		public SqliteBackend () : base (Catalog.GetString ("Local File"))
 		{
 			initialized = false;
 			taskIters = new Dictionary<int, Gtk.TreeIter> (); 
-			taskStore = new Gtk.TreeStore (typeof (Task));
+			taskStore = new Gtk.TreeStore (typeof(Task));
 			
 			sortedTasksModel = new Gtk.TreeModelSort (taskStore);
-			sortedTasksModel.SetSortFunc (0, new Gtk.TreeIterCompareFunc (CompareTasksSortFunc));
+			sortedTasksModel.SetSortFunc (
+				0,
+				new Gtk.TreeIterCompareFunc (CompareTasksSortFunc)
+			);
 			sortedTasksModel.SetSortColumnId (0, Gtk.SortType.Ascending);
 			
-			categoryListStore = new Gtk.ListStore (typeof (Category));
+			categoryListStore = new Gtk.ListStore (typeof(Category));
 			
 			sortedCategoriesModel = new Gtk.TreeModelSort (categoryListStore);
-			sortedCategoriesModel.SetSortFunc (0, new Gtk.TreeIterCompareFunc (CompareCategorySortFunc));
+			sortedCategoriesModel.SetSortFunc (
+				0,
+				new Gtk.TreeIterCompareFunc (CompareCategorySortFunc)
+			);
 			sortedCategoriesModel.SetSortColumnId (0, Gtk.SortType.Ascending);
 		}
 		
 		#region Public Properties
-		public string Name
-		{
-			get { return "Local File"; } // TODO: Return something more usable to the user like, "Built-in" or whatever
+		public string Name {
+			get { return; } // TODO: Return something more usable to the user like, "Built-in" or whatever
 		}
 		
 		/// <value>
 		/// All the tasks including ITaskDivider items.
 		/// </value>
-		public Gtk.TreeModel SortedTasks
-		{
+		public Gtk.TreeModel SortedTasks {
 			get { return sortedTasksModel; }
 		}
 		
 		/// <value>
 		/// This returns all the task lists (categories) that exist.
 		/// </value>
-		public Gtk.TreeModel Categories
-		{
+		public Gtk.TreeModel Categories {
 			get { return sortedCategoriesModel; }
 		}
 		
 		/// <value>
 		/// Indication that the Sqlite backend is configured
 		/// </value>
-		public bool Configured 
-		{
+		public bool Configured {
 			get { return configured; }
 		}
 		
@@ -81,19 +75,17 @@ namespace Tasque.Backends.Sqlite
 		/// <value>
 		/// Inidication that the backend is initialized
 		/// </value>
-		public bool Initialized
-		{
+		public bool Initialized {
 			get { return initialized; }
-		}		
+		}
 		
-		public Database Database
-		{
+		public Database Database {
 			get { return db; }
 		}
 		#endregion // Public Properties
 		
 		#region Public Methods
-		public Task CreateTask (string taskName, Category category)		
+		public Task CreateTask (string taskName, Category category)
 		{
 			// not sure what to do here with the category
 			SqliteTask task = new SqliteTask (this, taskName);
@@ -111,7 +103,7 @@ namespace Tasque.Backends.Sqlite
 			return task;
 		}
 		
-		public void DeleteTask(Task task)
+		public void DeleteTask (Task task)
 		{
 			//string id = task.Id;
 			task.Delete ();
@@ -119,15 +111,16 @@ namespace Tasque.Backends.Sqlite
 			//db.ExecuteNonQuery (command);
 		}
 		
-		public void Refresh()
-		{}
+		public void Refresh ()
+		{
+		}
 		
-		public void Initialize()
+		public void Initialize ()
 		{
-			if(db == null)
-				db = new Database();
+			if (db == null)
+				db = new Database ();
 				
-			db.Open();
+			db.Open ();
 			
 			//
 			// Add in the "All" Category
@@ -137,24 +130,24 @@ namespace Tasque.Backends.Sqlite
 			categoryListStore.SetValue (iter, 0, allCategory);
 			
 			
-			RefreshCategories();
-			RefreshTasks();		
+			RefreshCategories ();
+			RefreshTasks ();		
 
 		
 			initialized = true;
-			if(BackendInitialized != null) {
-				BackendInitialized();
+			if (BackendInitialized != null) {
+				BackendInitialized ();
 			}		
 		}
 
-		public void Cleanup()
+		public void Cleanup ()
 		{
-			this.categoryListStore.Clear();
-			this.taskStore.Clear();
-			this.taskIters.Clear();
+			this.categoryListStore.Clear ();
+			this.taskStore.Clear ();
+			this.taskIters.Clear ();
 
 			if (db != null)
-				db.Close();
+				db.Close ();
 			db = null;
 			initialized = false;		
 		}
@@ -234,34 +227,31 @@ namespace Tasque.Backends.Sqlite
 			}
 		}
 		
-		
-		
-		public void RefreshCategories()
+		public void RefreshCategories ()
 		{
 			Gtk.TreeIter iter;
 			SqliteCategory newCategory;
 			bool hasValues = false;
 			
 			string command = "SELECT id FROM Categories";
-			SqliteCommand cmd = db.Connection.CreateCommand();
+			SqliteCommand cmd = db.Connection.CreateCommand ();
 			cmd.CommandText = command;
-			SqliteDataReader dataReader = cmd.ExecuteReader();
-			while(dataReader.Read()) {
-			    int id = dataReader.GetInt32(0);
+			SqliteDataReader dataReader = cmd.ExecuteReader ();
+			while (dataReader.Read()) {
+				int id = dataReader.GetInt32 (0);
 				hasValues = true;
 				
 				newCategory = new SqliteCategory (this, id);
-				if( (defaultCategory == null) || (newCategory.Name.CompareTo("Work") == 0) )
+				if ((defaultCategory == null) || (newCategory.Name.CompareTo ("Work") == 0))
 					defaultCategory = newCategory;
 				iter = categoryListStore.Append ();
 				categoryListStore.SetValue (iter, 0, newCategory);				
 			}
 			
-			dataReader.Close();
-			cmd.Dispose();
+			dataReader.Close ();
+			cmd.Dispose ();
 
-			if(!hasValues)
-			{
+			if (!hasValues) {
 				defaultCategory = newCategory = new SqliteCategory (this, "Work");
 				iter = categoryListStore.Append ();
 				categoryListStore.SetValue (iter, 0, newCategory);
@@ -279,42 +269,40 @@ namespace Tasque.Backends.Sqlite
 				categoryListStore.SetValue (iter, 0, newCategory);		
 			}
 		}
-		
 
-		public void RefreshTasks()
+		public void RefreshTasks ()
 		{
 			Gtk.TreeIter iter;
 			SqliteTask newTask;
 			bool hasValues = false;
 
 			string command = "SELECT id,Category,Name,DueDate,CompletionDate,Priority, State FROM Tasks";
-			SqliteCommand cmd = db.Connection.CreateCommand();
+			SqliteCommand cmd = db.Connection.CreateCommand ();
 			cmd.CommandText = command;
-			SqliteDataReader dataReader = cmd.ExecuteReader();
-			while(dataReader.Read()) {
-				int id = dataReader.GetInt32(0);
-				int category = dataReader.GetInt32(1);
-				string name = dataReader.GetString(2);
-				long dueDate = dataReader.GetInt64(3);
-				long completionDate = dataReader.GetInt64(4);
-				int priority = dataReader.GetInt32(5);
-				int state = dataReader.GetInt32(6);
+			SqliteDataReader dataReader = cmd.ExecuteReader ();
+			while (dataReader.Read()) {
+				int id = dataReader.GetInt32 (0);
+				int category = dataReader.GetInt32 (1);
+				string name = dataReader.GetString (2);
+				long dueDate = dataReader.GetInt64 (3);
+				long completionDate = dataReader.GetInt64 (4);
+				int priority = dataReader.GetInt32 (5);
+				int state = dataReader.GetInt32 (6);
 
 				hasValues = true;
 
-				newTask = new SqliteTask(this, id, category,
+				newTask = new SqliteTask (this, id, category,
 				                         name, dueDate, completionDate,
 				                         priority, state);
-				iter = taskStore.AppendNode();
+				iter = taskStore.AppendNode ();
 				taskStore.SetValue (iter, 0, newTask);
 				taskIters [newTask.SqliteId] = iter;
 			}
 
-			dataReader.Close();
-			cmd.Dispose();
+			dataReader.Close ();
+			cmd.Dispose ();
 
-			if(!hasValues)
-			{
+			if (!hasValues) {
 				newTask = new SqliteTask (this, "Create some tasks");
 				newTask.Category = defaultCategory;
 				newTask.DueDate = DateTime.Now;
diff --git a/src/Addins/SqliteBackend/SqliteBackend.csproj b/src/Addins/SqliteBackend/SqliteBackend.csproj
index 8c24115..51ec3fc 100644
--- a/src/Addins/SqliteBackend/SqliteBackend.csproj
+++ b/src/Addins/SqliteBackend/SqliteBackend.csproj
@@ -58,6 +58,12 @@
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
     <Reference Include="System" />
+    <Reference Include="Mono.Data.Sqlite" />
+    <Reference Include="Mono.Posix" />
+    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Private>False</Private>
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -73,4 +79,10 @@
     <Compile Include="SqliteNote.cs" />
     <Compile Include="SqliteTask.cs" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\libtasque\libtasque.csproj">
+      <Project>{784C9AA8-2B28-400B-8CC4-DCDC48CA37F0}</Project>
+      <Name>libtasque</Name>
+    </ProjectReference>
+  </ItemGroup>
 </Project>
diff --git a/src/Addins/SqliteBackend/SqliteCategory.cs b/src/Addins/SqliteBackend/SqliteCategory.cs
index 0fdac61..43dfcf7 100644
--- a/src/Addins/SqliteBackend/SqliteCategory.cs
+++ b/src/Addins/SqliteBackend/SqliteCategory.cs
@@ -1,11 +1,9 @@
 // SqliteCategory.cs created with MonoDevelop
-// User: boyd at 9:06 AMÂ2/11/2008
+// User: boyd at 9:06 AM 2/11/2008
 //
 // To change standard headers go to Edit->Preferences->Coding->Standard Headers
 //
-
 using System;
-using Tasque;
 
 namespace Tasque.Backends.Sqlite
 {
@@ -14,40 +12,55 @@ namespace Tasque.Backends.Sqlite
 		private int id;
 		SqliteBackend backend;
 		
-		public int ID
-		{
+		public int ID {
 			get { return id; }
 		}
 		
-		public string Name
-		{
+		public string Name {
 			get {
-				string command = String.Format("SELECT Name FROM Categories where ID='{0}'", id);
-				return backend.Database.GetSingleString(command);
+				string command = String.Format (
+					"SELECT Name FROM Categories where ID='{0}'",
+					id
+				);
+				return backend.Database.GetSingleString (command);
 			}
 			set {
-				string command = String.Format("UPDATE Categories set Name='{0}' where ID='{0}'", value, id);
-				backend.Database.ExecuteScalar(command);
+				string command = String.Format (
+					"UPDATE Categories set Name='{0}' where ID='{0}'",
+					value,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
 			}
 		}
 		
-		public string ExternalID
-		{
+		public string ExternalID {
 			get {
-				string command = String.Format("SELECT ExternalID FROM Categories where ID='{0}'", id);
-				return backend.Database.GetSingleString(command);
+				string command = String.Format (
+					"SELECT ExternalID FROM Categories where ID='{0}'",
+					id
+				);
+				return backend.Database.GetSingleString (command);
 			}
 			set {
-				string command = String.Format("UPDATE Categories set ExternalID='{0}' where ID='{0}'", value, id);
-				backend.Database.ExecuteScalar(command);
+				string command = String.Format (
+					"UPDATE Categories set ExternalID='{0}' where ID='{0}'",
+					value,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
 			}
 		}
 		
 		public SqliteCategory (SqliteBackend backend, string name)
 		{
 			this.backend = backend;
-			string command = String.Format("INSERT INTO Categories (Name, ExternalID) values ('{0}', '{1}'); SELECT last_insert_rowid();", name, string.Empty);
-			this.id = Convert.ToInt32 (backend.Database.ExecuteScalar(command));
+			string command = String.Format (
+				"INSERT INTO Categories (Name, ExternalID) values ('{0}', '{1}'); SELECT last_insert_rowid();",
+				name,
+				string.Empty
+			);
+			this.id = Convert.ToInt32 (backend.Database.ExecuteScalar (command));
 			//Debug.WriteLine("Inserted category named: {0} with id {1}", name, id);
 		}
 		
@@ -57,9 +70,9 @@ namespace Tasque.Backends.Sqlite
 			this.id = id;
 		}
 
-		public bool ContainsTask(Task task)
+		public bool ContainsTask (Task task)
 		{
-			if(task.Category is SqliteCategory)
+			if (task.Category is SqliteCategory)
 				return ((task.Category as SqliteCategory).ID == id);
 
 			return false;
diff --git a/src/Addins/SqliteBackend/SqliteNote.cs b/src/Addins/SqliteBackend/SqliteNote.cs
index 3875a9d..a590e50 100644
--- a/src/Addins/SqliteBackend/SqliteNote.cs
+++ b/src/Addins/SqliteBackend/SqliteNote.cs
@@ -1,12 +1,9 @@
 // SqliteNote.cs created with MonoDevelop
-// User: calvin at 10:56 AMÂ2/12/2008
+// User: calvin at 10:56 AM 2/12/2008
 //
 // To change standard headers go to Edit->Preferences->Coding->Standard Headers
 //
 
-using System;
-using Tasque;
-
 namespace Tasque.Backends.Sqlite
 {
 	public class SqliteNote : TaskNote
@@ -14,22 +11,19 @@ namespace Tasque.Backends.Sqlite
 		private int id;
 		private string text;
 
-		public SqliteNote(int id, string text)
+		public SqliteNote (int id, string text)
 		{
 			this.id = id;
 			this.text = text;
 		}
 
-		public string Text
-		{
+		public string Text {
 			get { return this.text; }
 			set { this.text = value; }
 		}
 
-		public int ID
-		{
+		public int ID {
 			get { return this.id; }
 		}
-
 	}
 }
diff --git a/src/Addins/SqliteBackend/SqliteTask.cs b/src/Addins/SqliteBackend/SqliteTask.cs
index 70fbeef..e2f559f 100644
--- a/src/Addins/SqliteBackend/SqliteTask.cs
+++ b/src/Addins/SqliteBackend/SqliteTask.cs
@@ -1,14 +1,13 @@
 // SqliteTask.cs created with MonoDevelop
-// User: boyd at 8:50 PMÂ2/10/2008
-
+// User: boyd at 8:50 PM 2/10/2008
 using System;
-using Tasque;
 using System.Collections.Generic;
+using System.Diagnostics;
 using Mono.Data.Sqlite;
 
 namespace Tasque.Backends.Sqlite
 {
-	public class SqliteTask : AbstractTask
+	public class SqliteTask : Task
 	{
 		private SqliteBackend backend;
 		private int id;
@@ -19,18 +18,18 @@ namespace Tasque.Backends.Sqlite
 		private int priority;
 		private int state;
 
-		public SqliteTask(SqliteBackend backend, string name)
+		public SqliteTask (SqliteBackend backend, string name)
 		{
 			this.backend = backend;
-			Debug.WriteLine("Creating New Task Object : {0} (id={1})", name, id);
+			Debug.WriteLine ("Creating New Task Object : {0} (id={1})", name, id);
 			name = backend.SanitizeText (name);
 			this.name = name;
-			this.dueDate =  Database.FromDateTime(DateTime.MinValue);
-			this.completionDate = Database.FromDateTime(DateTime.MinValue);
+			this.dueDate = Database.FromDateTime (DateTime.MinValue);
+			this.completionDate = Database.FromDateTime (DateTime.MinValue);
 			this.category = 0;
 			this.priority = (int)(TaskPriority.None);
 			this.state = (int)TaskState.Active;
-			string command = String.Format("INSERT INTO Tasks (Name, DueDate, CompletionDate, Priority, State, Category, ExternalID) values ('{0}','{1}', '{2}','{3}', '{4}', '{5}', '{6}'); SELECT last_insert_rowid();", 
+			string command = String.Format ("INSERT INTO Tasks (Name, DueDate, CompletionDate, Priority, State, Category, ExternalID) values ('{0}','{1}', '{2}','{3}', '{4}', '{5}', '{6}'); SELECT last_insert_rowid();", 
 								name, dueDate, completionDate,
 								priority, state, category, string.Empty);
 			this.id = Convert.ToInt32 (backend.Database.ExecuteScalar (command));
@@ -51,54 +50,58 @@ namespace Tasque.Backends.Sqlite
 		
 		#region Public Properties
 		
-		public override string Id
-		{
-			get { return id.ToString(); }
+		public override string Id {
+			get { return id.ToString (); }
 		}
 
-		internal int SqliteId
-		{
+		internal int SqliteId {
 			get { return id; } 
 		}
 		
-		public override string Name
-		{
+		public override string Name {
 			get { return this.name; }
 			set {
 				string name = backend.SanitizeText (value);
 				this.name = name;
-				string command = String.Format("UPDATE Tasks set Name='{0}' where ID='{1}'", name, id);
-				backend.Database.ExecuteScalar(command);
-				backend.UpdateTask(this);
+				string command = String.Format (
+					"UPDATE Tasks set Name='{0}' where ID='{1}'",
+					name,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
+				backend.UpdateTask (this);
 			}
 		}
 		
-		public override DateTime DueDate
-		{
-			get { return Database.ToDateTime(this.dueDate); }
+		public override DateTime DueDate {
+			get { return Database.ToDateTime (this.dueDate); }
 			set {
-			        this.dueDate = Database.FromDateTime(value);
-				string command = String.Format("UPDATE Tasks set DueDate='{0}' where ID='{1}'", this.dueDate, id);
-				backend.Database.ExecuteScalar(command);
-				backend.UpdateTask(this);				
+				this.dueDate = Database.FromDateTime (value);
+				string command = String.Format (
+					"UPDATE Tasks set DueDate='{0}' where ID='{1}'",
+					this.dueDate,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
+				backend.UpdateTask (this);				
 			}
 		}
 		
-		
-		public override DateTime CompletionDate
-		{
-			get { return Database.ToDateTime(this.completionDate); }
+		public override DateTime CompletionDate {
+			get { return Database.ToDateTime (this.completionDate); }
 			set {
-				this.completionDate = Database.FromDateTime(value);
-				string command = String.Format("UPDATE Tasks set CompletionDate='{0}' where ID='{1}'", this.completionDate, id);
-				backend.Database.ExecuteScalar(command);
-				backend.UpdateTask(this);
+				this.completionDate = Database.FromDateTime (value);
+				string command = String.Format (
+					"UPDATE Tasks set CompletionDate='{0}' where ID='{1}'",
+					this.completionDate,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
+				backend.UpdateTask (this);
 			}
-		}		
-		
+		}
 		
-		public override bool IsComplete
-		{
+		public override bool IsComplete {
 			get {
 				if (CompletionDate == DateTime.MinValue)
 					return false;
@@ -107,69 +110,80 @@ namespace Tasque.Backends.Sqlite
 			}
 		}
 		
-		public override TaskPriority Priority
-		{
-			get { return (TaskPriority) this.priority; }
+		public override TaskPriority Priority {
+			get { return (TaskPriority)this.priority; }
 			set {
-				this.priority = (int) value;
-				string command = String.Format("UPDATE Tasks set Priority='{0}' where ID='{1}'", this.priority, id);
-				backend.Database.ExecuteScalar(command);
-				backend.UpdateTask(this);
+				this.priority = (int)value;
+				string command = String.Format (
+					"UPDATE Tasks set Priority='{0}' where ID='{1}'",
+					this.priority,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
+				backend.UpdateTask (this);
 			}
 		}
 
-		public override bool HasNotes
-		{
+		public override bool HasNotes {
 			get {
-				string command = String.Format("SELECT COUNT(*) FROM Notes WHERE Task='{0}'", id);
-				return backend.Database.GetSingleInt(command) > 0;
+				string command = String.Format (
+					"SELECT COUNT(*) FROM Notes WHERE Task='{0}'",
+					id
+				);
+				return backend.Database.GetSingleInt (command) > 0;
 			}
 		}
 		
-		public override bool SupportsMultipleNotes
-		{
+		public override bool SupportsMultipleNotes {
 			get { return true; }
 		}
 		
-		public override TaskState State
-		{
+		public override TaskState State {
 			get { return LocalState; }
 		}
 		
-		public TaskState LocalState
-		{
-			get { return (TaskState) this.state; }
+		public TaskState LocalState {
+			get { return (TaskState)this.state; }
 			set {
-				this.state = (int) value;
-				string command = String.Format("UPDATE Tasks set State='{0}' where ID='{1}'", this.state, id);
-				backend.Database.ExecuteScalar(command);
-				backend.UpdateTask(this);
+				this.state = (int)value;
+				string command = String.Format (
+					"UPDATE Tasks set State='{0}' where ID='{1}'",
+					this.state,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
+				backend.UpdateTask (this);
 			}
 		}
 
-		public override Category Category
-		{
-			get { return new SqliteCategory(backend, this.category); }
+		public override Category Category {
+			get { return new SqliteCategory (backend, this.category); }
 			set {
 				this.category = (int)(value as SqliteCategory).ID;
- 				string command = String.Format("UPDATE Tasks set Category='{0}' where ID='{1}'", category, id);
-				backend.Database.ExecuteScalar(command);
-				backend.UpdateTask(this);
+				string command = String.Format (
+					"UPDATE Tasks set Category='{0}' where ID='{1}'",
+					category,
+					id
+				);
+				backend.Database.ExecuteScalar (command);
+				backend.UpdateTask (this);
 			}
 		}
 		
-		public override List<TaskNote> Notes
-		{
+		public override List<TaskNote> Notes {
 			get {
-				List<TaskNote> notes = new List<TaskNote>();
+				List<TaskNote> notes = new List<TaskNote> ();
 
-				string command = String.Format("SELECT ID, Text FROM Notes WHERE Task='{0}'", id);
-				SqliteCommand cmd = backend.Database.Connection.CreateCommand();
+				string command = String.Format (
+					"SELECT ID, Text FROM Notes WHERE Task='{0}'",
+					id
+				);
+				SqliteCommand cmd = backend.Database.Connection.CreateCommand ();
 				cmd.CommandText = command;
-				SqliteDataReader dataReader = cmd.ExecuteReader();
-				while(dataReader.Read()) {
-					int taskId = dataReader.GetInt32(0);
-					string text = dataReader.GetString(1);
+				SqliteDataReader dataReader = cmd.ExecuteReader ();
+				while (dataReader.Read()) {
+					int taskId = dataReader.GetInt32 (0);
+					string text = dataReader.GetString (1);
 					notes.Add (new SqliteNote (taskId, text));
 				}
 
@@ -211,31 +225,42 @@ namespace Tasque.Backends.Sqlite
 			backend.UpdateTask (this);
 		}
 		
-		public override TaskNote CreateNote(string text)
+		public override TaskNote CreateNote (string text)
 		{
-			Debug.WriteLine("Creating New Note Object : {0} (id={1})", text, id);
+			Debug.WriteLine ("Creating New Note Object : {0} (id={1})", text, id);
 			text = backend.SanitizeText (text);
-			string command = String.Format("INSERT INTO Notes (Task, Text) VALUES ('{0}','{1}'); SELECT last_insert_rowid();", id, text);
-			int taskId = Convert.ToInt32 (backend.Database.ExecuteScalar(command));
+			string command = String.Format (
+				"INSERT INTO Notes (Task, Text) VALUES ('{0}','{1}'); SELECT last_insert_rowid();",
+				id,
+				text
+			);
+			int taskId = Convert.ToInt32 (backend.Database.ExecuteScalar (command));
 
 			return new SqliteNote (taskId, text);
 		}
 		
-		public override void DeleteNote(TaskNote note)
+		public override void DeleteNote (TaskNote note)
 		{
 			SqliteNote sqNote = (note as SqliteNote);
 
- 			string command = String.Format("DELETE FROM Notes WHERE ID='{0}'", sqNote.ID);
-			backend.Database.ExecuteScalar(command);
+			string command = String.Format (
+				"DELETE FROM Notes WHERE ID='{0}'",
+				sqNote.ID
+			);
+			backend.Database.ExecuteScalar (command);
 		}
 
-		public override void SaveNote(TaskNote note)
+		public override void SaveNote (TaskNote note)
 		{
 			SqliteNote sqNote = (note as SqliteNote);
 
 			string text = backend.SanitizeText (sqNote.Text);
-			string command = String.Format("UPDATE Notes SET Text='{0}' WHERE ID='{1}'", text, sqNote.ID);
-			backend.Database.ExecuteScalar(command);
+			string command = String.Format (
+				"UPDATE Notes SET Text='{0}' WHERE ID='{1}'",
+				text,
+				sqNote.ID
+			);
+			backend.Database.ExecuteScalar (command);
 		}
 
 		#endregion // Public Methods



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]