4 Commits

Author SHA1 Message Date
Jonathan Jenne
a856f5f1b3 Database: Version 2.3.3.0 2023-05-16 08:48:03 +02:00
Jonathan Jenne
5ced396e3f Base: Version 1.2.0.0 2023-05-16 08:47:35 +02:00
Jonathan Jenne
10d8e7749a Database: Fix Logging of errors with sql queries 2023-05-16 08:47:24 +02:00
Jonathan Jenne
cd3646dca0 Base: Add Language Module 2023-05-15 16:02:39 +02:00
5 changed files with 66 additions and 22 deletions

View File

@@ -79,6 +79,7 @@
<Compile Include="IDB\Attributes.vb" /> <Compile Include="IDB\Attributes.vb" />
<Compile Include="IDB\Database.vb" /> <Compile Include="IDB\Database.vb" />
<Compile Include="IDB\FileStore.vb" /> <Compile Include="IDB\FileStore.vb" />
<Compile Include="Language.vb" />
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb"> <Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>

32
Base/Language.vb Normal file
View File

@@ -0,0 +1,32 @@
Imports System.Globalization
Imports System.Threading
Imports DigitalData.Modules.Logging
Public Class Language
Public Shared Sub SetApplicationLanguage(pLogger As Logger, pUserLanguage As String, Optional pUserDateFormat As String = Nothing)
Try
pLogger.Debug("Setting application language..")
'Dim Culture = CultureInfo.CreateSpecificCulture(pUserLanguage)
Dim Culture As New CultureInfo(pUserLanguage)
Culture.DateTimeFormat.ShortDatePattern = pUserDateFormat
pLogger.Debug("Culture object for language [{0}] created", pUserLanguage)
' The following line provides localization for data formats.
Thread.CurrentThread.CurrentCulture = Culture
' The following line provides localization for the application's user interface.
Thread.CurrentThread.CurrentUICulture = Culture
' Set this culture as the default culture for all threads in this application.
' Note: The following properties are supported in the .NET Framework 4.5+
CultureInfo.DefaultThreadCurrentCulture = Culture
CultureInfo.DefaultThreadCurrentUICulture = Culture
pLogger.Debug("Application language set to [{0}]", Culture.Name)
Catch ex As Exception
pLogger.Warn("Could not set application language!")
pLogger.Error(ex)
End Try
End Sub
End Class

View File

@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")> <Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")> <Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Base")> <Assembly: AssemblyProduct("Base")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2023")>
<Assembly: AssemblyTrademark("1.1.0.0")> <Assembly: AssemblyTrademark("1.2.0.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben: ' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.1.0.0")> <Assembly: AssemblyVersion("1.2.0.0")>
<Assembly: AssemblyFileVersion("1.1.0.0")> <Assembly: AssemblyFileVersion("1.2.0.0")>

View File

@@ -1,10 +1,7 @@
Imports System.ComponentModel Imports System.ComponentModel
Imports System.Data.Common
Imports System.Data.SqlClient Imports System.Data.SqlClient
Imports DigitalData.Modules.Encryption Imports DigitalData.Modules.Encryption
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Base
Imports System.Threading
Public Class MSSQLServer Public Class MSSQLServer
Implements IDatabase Implements IDatabase
@@ -206,10 +203,13 @@ Public Class MSSQLServer
Dim oDecryptedConnectionString = DecryptConnectionString(pConnectionString) Dim oDecryptedConnectionString = DecryptConnectionString(pConnectionString)
Dim oConnection As New SqlConnection(oDecryptedConnectionString) Dim oConnection As New SqlConnection(oDecryptedConnectionString)
OpenSQLConnection(oConnection) OpenSQLConnection(oConnection)
oConnection.Close() oConnection?.Close()
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Error("Error while testing connection!")
Logger.Error(ex) Logger.Error(ex)
Return False Return False
End Try End Try
End Function End Function
@@ -220,11 +220,18 @@ Public Class MSSQLServer
''' <param name="Connection"></param> ''' <param name="Connection"></param>
''' <returns></returns> ''' <returns></returns>
Private Function OpenSQLConnection(Connection As SqlConnection) As SqlConnection Private Function OpenSQLConnection(Connection As SqlConnection) As SqlConnection
If Connection.State = ConnectionState.Closed Then Try
Connection.Open() If Connection.State = ConnectionState.Closed Then
End If Connection.Open()
End If
Return Connection Return Connection
Catch ex As Exception
Logger.Error("Error while opening Connection!")
Logger.Error(ex)
Throw ex
End Try
End Function End Function
<DebuggerStepThrough()> <DebuggerStepThrough()>
@@ -242,6 +249,7 @@ Public Class MSSQLServer
Return oConnection Return oConnection
Catch ex As Exception Catch ex As Exception
Logger.Error("Connection could not be created or opened!")
Logger.Error(ex) Logger.Error(ex)
Return Nothing Return Nothing
@@ -260,7 +268,9 @@ Public Class MSSQLServer
Dim oConnectionString = pConnectionString.Replace(oBuilder.Password, "XXXXX") Dim oConnectionString = pConnectionString.Replace(oBuilder.Password, "XXXXX")
Return oConnectionString Return oConnectionString
Catch ex As Exception Catch ex As Exception
Logger.Error("ConnectionString is invalid and could not be masked!")
Logger.Error(ex) Logger.Error(ex)
Return "Invalid ConnectionString" Return "Invalid ConnectionString"
End Try End Try
End Function End Function
@@ -345,8 +355,8 @@ Public Class MSSQLServer
End Using End Using
Catch ex As Exception Catch ex As Exception
Logger.Error("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", pSqlCommandObject.CommandText)
Logger.Error(ex) Logger.Error(ex)
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", pSqlCommandObject.CommandText)
Throw ex Throw ex
Finally Finally
MaybeCommitTransaction(oTransaction, pTransactionMode) MaybeCommitTransaction(oTransaction, pTransactionMode)
@@ -436,8 +446,9 @@ Public Class MSSQLServer
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Error("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]", pSqlCommandObject.CommandText)
Logger.Error(ex) Logger.Error(ex)
Logger.Warn("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]", pSqlCommandObject.CommandText)
Return False Return False
Finally Finally
MaybeCommitTransaction(oTransaction, pTransactionMode) MaybeCommitTransaction(oTransaction, pTransactionMode)
@@ -518,7 +529,7 @@ Public Class MSSQLServer
Try Try
Logger.Debug("GetScalarValueWithConnectionObject: Running Query [{0}] with Parameters [{1}]", pSqlCommandObject, GetParameterListAsString(pSqlCommandObject)) Logger.Debug("GetScalarValueWithConnectionObject: Running Query [{0}] with Parameters [{1}]", pSqlCommandObject.CommandText, GetParameterListAsString(pSqlCommandObject))
pSqlCommandObject.Connection = pSqlConnection pSqlCommandObject.Connection = pSqlConnection
pSqlCommandObject.CommandTimeout = pTimeout pSqlCommandObject.CommandTimeout = pTimeout
@@ -527,7 +538,7 @@ Public Class MSSQLServer
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", pSqlCommandObject) Logger.Error("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", pSqlCommandObject.CommandText)
Finally Finally
MaybeCommitTransaction(oTransaction, pTransactionMode) MaybeCommitTransaction(oTransaction, pTransactionMode)
@@ -562,7 +573,7 @@ Public Class MSSQLServer
End Using End Using
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn($"GetScalarValue failed SQLCommand [{pSqlCommand}]") Logger.Error($"GetScalarValue failed SQLCommand [{pSqlCommand}]")
Return Nothing Return Nothing
End Try End Try
@@ -594,7 +605,7 @@ Public Class MSSQLServer
End Using End Using
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn($"NewExecuteNonQueryAsync failed SQLCommand [{SqlCommand}]") Logger.Error($"NewExecuteNonQueryAsync failed SQLCommand [{SqlCommand}]")
End Try End Try
End Sub End Sub

View File

@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")> <Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Database")> <Assembly: AssemblyProduct("Modules.Database")>
<Assembly: AssemblyCopyright("Copyright © 2022")> <Assembly: AssemblyCopyright("Copyright © 2023")>
<Assembly: AssemblyTrademark("2.3.1.0")> <Assembly: AssemblyTrademark("2.3.3.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.3.2.0")> <Assembly: AssemblyVersion("2.3.3.0")>
<Assembly: AssemblyFileVersion("2.3.2.0")> <Assembly: AssemblyFileVersion("2.3.3.0")>