OmagPHOTO 1.9f1 :

- rese più sicure alcune chiamate a Sqlite (e con più log).
This commit is contained in:
Dario Sassi
2018-06-06 09:58:42 +00:00
parent 6de34b80e4
commit 4dcaf7a42a
4 changed files with 35 additions and 11 deletions
+8
View File
@@ -3,4 +3,12 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite"
description=".NET Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
+1
View File
@@ -184,6 +184,7 @@ Public Class MainWindowM
GetMainPrivateProfileString(S_GENERAL, K_PHOTODIR, sDataRoot & "\Data", m_sPhotoDir)
' Creo connessione al Db
If Not ManageDb.ConnectToDb(m_sPhotoDir & "\" & DB_FILENAME) Then
EgtOutLog("Error connecting to DB")
MessageBox.Show(EgtMsg(MSG_OMAGPHOTO + 1), EgtMsg(MSG_EGTMSGBOX + 15), MessageBoxButton.OK, MessageBoxImage.Error)
End
End If
+2 -2
View File
@@ -59,5 +59,5 @@ Imports System.Windows
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.9.2.1")>
<Assembly: AssemblyFileVersion("1.9.2.1")>
<Assembly: AssemblyVersion("1.9.6.1")>
<Assembly: AssemblyFileVersion("1.9.6.1")>
+24 -9
View File
@@ -1,5 +1,6 @@
Imports System.IO
Imports System.Data.SQLite
Imports EgtUILib
Module ManageDb
@@ -30,10 +31,21 @@ Module ManageDb
End Function
Friend Function ConnectToDb(DbPath As String) As Boolean
If Not File.Exists(DbPath) Then
EgtOutLog("Connecting to DB " & DbPath)
If Not File.Exists(DbPath) Then Return False
Try
m_DbConnection = New SQLiteConnection("Data Source = " & DbPath & "; Version = 3;")
' Verifica integrità del DB
m_DbConnection.Open()
Dim Command As SQLiteCommand = New SQLiteCommand("PRAGMA quick_check;", m_DbConnection)
Dim Reader As SQLiteDataReader = Command.ExecuteReader()
Reader.Read()
Dim sRes As String = Reader(0)
m_DbConnection.Close()
Catch ex As Exception
EgtOutLog(ex.Message)
Return False
End If
m_DbConnection = New SQLiteConnection("Data Source = " & DbPath & "; Version = 3;")
End Try
Return Not IsNothing(m_DbConnection)
End Function
@@ -64,13 +76,16 @@ Module ManageDb
End Function
Friend Function ExecuteSlabReaderQuery(SqlQuery As String) As List(Of Slab)
ManageDb.DbConnection.Open()
Dim Command As SQLiteCommand = New SQLiteCommand(SqlQuery, m_DbConnection)
Dim Reader As SQLiteDataReader = Command.ExecuteReader()
Dim SlabList As New List(Of Slab)
While Reader.Read()
SlabList.Add(New Slab(Reader))
End While
ManageDb.DbConnection.Open()
Try
Dim Command As SQLiteCommand = New SQLiteCommand(SqlQuery, m_DbConnection)
Dim Reader As SQLiteDataReader = Command.ExecuteReader()
While Reader.Read()
SlabList.Add(New Slab(Reader))
End While
Catch ex As Exception
End Try
ManageDb.DbConnection.Close()
Return SlabList
End Function