[chronojump] Safer SQL open checking Mono.Data.Sqlite.SqliteConnection.State
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Safer SQL open checking Mono.Data.Sqlite.SqliteConnection.State
- Date: Tue, 10 Jan 2017 12:16:02 +0000 (UTC)
commit ff5b80dd6bae3fdb0090a9fb8dc235c83f8e4f07
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Jan 10 13:15:04 2017 +0100
Safer SQL open checking Mono.Data.Sqlite.SqliteConnection.State
src/logB.cs | 13 ++++++++++++-
src/sqlite/main.cs | 9 +++++++++
2 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/logB.cs b/src/logB.cs
index 90b3a1f..4c2eeab 100644
--- a/src/logB.cs
+++ b/src/logB.cs
@@ -58,7 +58,7 @@ public enum LogEntryType
Warning,
Error,
Information,
- SQL, SQLon, SQLoff,
+ SQL, SQLon, SQLoff, SQLonAlready, //already means: was not opened because it was already opened
ThreadStart, ThreadEnding, ThreadEnded,
TestStart, TestEnd
}
@@ -228,6 +228,10 @@ public static class LogB
ConsoleCrayon.BackgroundColor = ConsoleColor.DarkCyan;
ConsoleCrayon.ForegroundColor = ConsoleColor.Black;
break;
+ case LogEntryType.SQLonAlready:
+ ConsoleCrayon.BackgroundColor = ConsoleColor.DarkCyan;
+ ConsoleCrayon.ForegroundColor = ConsoleColor.Gray;
+ break;
case LogEntryType.ThreadStart:
ConsoleCrayon.BackgroundColor = ConsoleColor.Green;
ConsoleCrayon.ForegroundColor = ConsoleColor.Black;
@@ -305,6 +309,8 @@ public static class LogB
return "SQL ON";
case LogEntryType.SQLoff:
return "SQL OFF";
+ case LogEntryType.SQLonAlready:
+ return "SQL ON ALREADY!!!";
case LogEntryType.ThreadStart:
return "Thread Start -------------------------->";
case LogEntryType.ThreadEnding:
@@ -582,6 +588,11 @@ public static class LogB
Commit(LogEntryType.SQLoff, null, null, false);
}
+ public static void SQLonAlready()
+ {
+ Commit(LogEntryType.SQLonAlready, null, null, false);
+ }
+
#endregion
#region Public Thread Methods
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index bfb1126..f7eed9c 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -141,6 +141,14 @@ class Sqlite
//because lots of similar transactions have to be done
public static void Open()
{
+ if(dbcon.State == System.Data.ConnectionState.Closed)
+ {
+ LogB.SQLon();
+ dbcon.Open();
+ } else
+ LogB.SQLonAlready();
+
+ /*
try {
LogB.SQLon();
dbcon.Open();
@@ -155,6 +163,7 @@ class Sqlite
LogB.SQL("-- end of catched --");
}
+ */
IsOpened = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]