Compare commits
12 Commits
790715d0a2
...
e87b97bfec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e87b97bfec | ||
|
|
072aef5f21 | ||
|
|
59cfbb1984 | ||
|
|
a40b22d891 | ||
|
|
727d68f9ac | ||
|
|
6fffd35625 | ||
|
|
711d0edd04 | ||
|
|
1632e86c1e | ||
|
|
07493124a2 | ||
|
|
2cc21a0fc0 | ||
|
|
d2ab705fbb | ||
|
|
2144d7e771 |
@@ -133,6 +133,10 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Modules.Base\Base\Base.vbproj">
|
||||
<Project>{6ea0c51f-c2b1-4462-8198-3de0b32b74f8}</Project>
|
||||
<Name>Base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Config\Config.vbproj">
|
||||
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
|
||||
<Name>Config</Name>
|
||||
|
||||
@@ -3,18 +3,16 @@ Imports System.Data.Common
|
||||
Imports System.Data.SqlClient
|
||||
Imports DigitalData.Modules.Encryption
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Base
|
||||
|
||||
Public Class MSSQLServer
|
||||
Implements IDatabase
|
||||
|
||||
Public DBInitialized As Boolean = False
|
||||
Public CurrentSQLConnectionString As String = ""
|
||||
Public Property DBInitialized As Boolean = False Implements IDatabase.DBInitialized
|
||||
Public Property CurrentConnectionString As String = "" Implements IDatabase.CurrentConnectionString
|
||||
|
||||
Public Const TIMEOUT_DEFAULT As Integer = 120
|
||||
Public Const TABLE_DEFAULT As String = "DDRESULT"
|
||||
|
||||
Private ReadOnly _Timeout As Integer
|
||||
Private ReadOnly _Logger As Logger
|
||||
Private ReadOnly QueryTimeout As Integer
|
||||
Private ReadOnly Logger As Logger
|
||||
|
||||
Public Enum TransactionMode
|
||||
<Description("Use no transaction, neither internal nor external")>
|
||||
@@ -25,43 +23,41 @@ Public Class MSSQLServer
|
||||
WithTransaction
|
||||
End Enum
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Timeout = Timeout
|
||||
|
||||
CurrentSQLConnectionString = ConnectionString
|
||||
Public Sub New(pLogConfig As LogConfig, pConnectionString As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT)
|
||||
Logger = pLogConfig.GetLogger()
|
||||
QueryTimeout = pTimeout
|
||||
|
||||
Try
|
||||
DBInitialized = TestCanConnect()
|
||||
CurrentConnectionString = pConnectionString
|
||||
DBInitialized = TestCanConnect(CurrentConnectionString)
|
||||
Catch ex As Exception
|
||||
DBInitialized = False
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Server As String, Database As String, UserId As String, Password As String, Optional Timeout As Integer = 120)
|
||||
_Logger = LogConfig.GetLogger()
|
||||
_Timeout = Timeout
|
||||
|
||||
CurrentSQLConnectionString = GetConnectionString(Server, Database, UserId, Password)
|
||||
Public Sub New(pLogConfig As LogConfig, Server As String, Database As String, UserId As String, Password As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT)
|
||||
Logger = pLogConfig.GetLogger()
|
||||
QueryTimeout = Timeout
|
||||
|
||||
Try
|
||||
DBInitialized = TestCanConnect()
|
||||
CurrentConnectionString = GetConnectionString(Server, Database, UserId, Password)
|
||||
DBInitialized = TestCanConnect(CurrentConnectionString)
|
||||
Catch ex As Exception
|
||||
DBInitialized = False
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Encrypts a connection string password.
|
||||
''' </summary>
|
||||
''' <param name="ConnectionString">A connection string with a plain-text password</param>
|
||||
''' <param name="pConnectionString">A connection string with a plain-text password</param>
|
||||
''' <returns>The connection string with the password encrypted.</returns>
|
||||
<DebuggerStepThrough()>
|
||||
Public Shared Function EncryptConnectionString(ConnectionString As String) As String
|
||||
Public Shared Function EncryptConnectionString(pConnectionString As String) As String
|
||||
Dim oEncryption As New EncryptionLegacy()
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = pConnectionString}
|
||||
Dim oEncryptedPassword = oEncryption.EncryptData(oBuilder.Password)
|
||||
oBuilder.Password = oEncryptedPassword
|
||||
|
||||
@@ -71,12 +67,12 @@ Public Class MSSQLServer
|
||||
''' <summary>
|
||||
''' Decrypts a connection string password.
|
||||
''' </summary>
|
||||
''' <param name="ConnectionString">A connection string with a encrypted password</param>
|
||||
''' <param name="pConnectionString">A connection string with a encrypted password</param>
|
||||
''' <returns>The connection string with the password decrypted.</returns>
|
||||
<DebuggerStepThrough()>
|
||||
Public Shared Function DecryptConnectionString(ConnectionString As String) As String
|
||||
Public Shared Function DecryptConnectionString(pConnectionString As String) As String
|
||||
Dim oEncryption As New EncryptionLegacy()
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = pConnectionString}
|
||||
Dim oDecryptedPassword = oEncryption.DecryptData(oBuilder.Password)
|
||||
oBuilder.Password = oDecryptedPassword
|
||||
|
||||
@@ -88,7 +84,7 @@ Public Class MSSQLServer
|
||||
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
|
||||
.DataSource = Server,
|
||||
.InitialCatalog = Database,
|
||||
.UserId = UserId,
|
||||
.UserID = UserId,
|
||||
.Password = Password
|
||||
}
|
||||
|
||||
@@ -101,7 +97,7 @@ Public Class MSSQLServer
|
||||
Dim oConnection = GetSQLConnection()
|
||||
Return oConnection
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
@@ -133,7 +129,7 @@ Public Class MSSQLServer
|
||||
Transaction.Commit()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
Case Else
|
||||
@@ -148,10 +144,10 @@ Public Class MSSQLServer
|
||||
Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String
|
||||
Dim oConnectionString As String = String.Empty
|
||||
|
||||
_Logger.Debug("Getting ConnectionString for ConnectionId [{0}]", pConnectionId)
|
||||
Logger.Debug("Getting ConnectionString for ConnectionId [{0}]", pConnectionId)
|
||||
|
||||
If pConnectionId = 0 Then
|
||||
_Logger.Warn("ConnectionId was 0. Falling back to default connection.")
|
||||
Logger.Warn("ConnectionId was 0. Falling back to default connection.")
|
||||
Return String.Empty
|
||||
End If
|
||||
|
||||
@@ -181,17 +177,17 @@ Public Class MSSQLServer
|
||||
End If
|
||||
|
||||
Case Else
|
||||
_Logger.Warn("Provider [{0}] not supported!", oProvider)
|
||||
Logger.Warn("Provider [{0}] not supported!", oProvider)
|
||||
|
||||
End Select
|
||||
|
||||
Else
|
||||
_Logger.Warn("No entry for Connection-ID: [{0}] ", pConnectionId.ToString)
|
||||
Logger.Warn("No entry for Connection-ID: [{0}] ", pConnectionId.ToString)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Error in Get_ConnectionStringforID")
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("Error in Get_ConnectionStringforID")
|
||||
End Try
|
||||
|
||||
Return DecryptConnectionString(oConnectionString)
|
||||
@@ -199,38 +195,20 @@ Public Class MSSQLServer
|
||||
|
||||
<DebuggerStepThrough()>
|
||||
Private Function TestCanConnect() As Boolean
|
||||
Return TestCanConnect(CurrentSQLConnectionString)
|
||||
Return TestCanConnect(CurrentConnectionString)
|
||||
End Function
|
||||
|
||||
Private Function TestCanConnect(ConnectionString As String) As Boolean
|
||||
Private Function TestCanConnect(pConnectionString As String) As Boolean
|
||||
Try
|
||||
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(ConnectionString))
|
||||
Logger.Debug("Testing connection to [{0}]", MaskConnectionString(pConnectionString))
|
||||
|
||||
Dim oDecryptedConnectionString = DecryptConnectionString(ConnectionString)
|
||||
Dim oDecryptedConnectionString = DecryptConnectionString(pConnectionString)
|
||||
Dim oConnection As New SqlConnection(oDecryptedConnectionString)
|
||||
OpenSQLConnection(oConnection)
|
||||
oConnection.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function TestCanConnect(Connection As SqlConnection) As Boolean
|
||||
Try
|
||||
If Connection Is Nothing Then
|
||||
_Logger.Warn("TestCanConnect: Connection is nothing!")
|
||||
Return False
|
||||
End If
|
||||
|
||||
_Logger.Debug("Testing connection to [{0}]", MaskConnectionString(Connection.ConnectionString))
|
||||
|
||||
OpenSQLConnection(Connection)
|
||||
Connection.Close()
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
@@ -250,44 +228,45 @@ Public Class MSSQLServer
|
||||
|
||||
<DebuggerStepThrough()>
|
||||
Private Function GetSQLConnection() As SqlConnection
|
||||
Return GetConnection(CurrentSQLConnectionString)
|
||||
Return GetConnection(CurrentConnectionString)
|
||||
End Function
|
||||
|
||||
Private Function GetConnection(ConnectionString As String) As SqlConnection
|
||||
Private Function GetConnection(pConnectionString As String) As SqlConnection
|
||||
Try
|
||||
Dim oConnection As New SqlConnection(ConnectionString)
|
||||
Dim oConnection As New SqlConnection(pConnectionString)
|
||||
oConnection = OpenSQLConnection(oConnection)
|
||||
|
||||
Dim oMaskedConnectionString = MaskConnectionString(ConnectionString)
|
||||
_Logger.Debug("The Following Connection is open: {0}", oMaskedConnectionString)
|
||||
Dim oMaskedConnectionString = MaskConnectionString(pConnectionString)
|
||||
Logger.Debug("The Following Connection is open: {0}", oMaskedConnectionString)
|
||||
|
||||
Return oConnection
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
<DebuggerStepThrough()>
|
||||
Private Function MaskConnectionString(ConnectionString As String) As String
|
||||
Private Function MaskConnectionString(pConnectionString As String) As String
|
||||
Try
|
||||
If ConnectionString Is Nothing OrElse ConnectionString.Length = 0 Then
|
||||
Throw New ArgumentNullException("ConnectionString")
|
||||
If pConnectionString Is Nothing OrElse pConnectionString.Length = 0 Then
|
||||
Logger.Warn("Connection String is empty!")
|
||||
Throw New ArgumentNullException("pConnectionString")
|
||||
End If
|
||||
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oConnectionString = ConnectionString.Replace(oBuilder.Password, "XXXXX")
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = pConnectionString}
|
||||
Dim oConnectionString = pConnectionString.Replace(oBuilder.Password, "XXXXX")
|
||||
Return oConnectionString
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Logger.Error(ex)
|
||||
Return "Invalid ConnectionString"
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetDatatable(SqlCommand As String) As DataTable Implements IDatabase.GetDatatable
|
||||
Return GetDatatable(SqlCommand, _Timeout)
|
||||
Return GetDatatable(SqlCommand, QueryTimeout)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
@@ -302,20 +281,20 @@ Public Class MSSQLServer
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetDatatable(SqlCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = 120) As DataTable
|
||||
Public Function GetDatatable(SqlCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Using oSqlConnection = GetSQLConnection()
|
||||
Return GetDatatableWithConnectionObject(SqlCommand, oSqlConnection, TransactionMode.ExternalTransaction, Transaction, Timeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Async Function GetDatatableAsync(SqlCommand As String, Optional Timeout As Integer = 120) As Task(Of DataTable)
|
||||
Public Async Function GetDatatableAsync(SqlCommand As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of DataTable)
|
||||
Return Await Task.Run(Function() GetDatatable(SqlCommand, Timeout))
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetDatatableWithConnection(SqlCommand As String, ConnectionString As String, Optional Timeout As Integer = 120) As DataTable
|
||||
Using oConnection = GetConnection(ConnectionString)
|
||||
Public Function GetDatatableWithConnection(SqlCommand As String, pConnectionString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Using oConnection = GetConnection(pConnectionString)
|
||||
Return GetDatatableWithConnectionObject(SqlCommand, oConnection, Timeout:=Timeout)
|
||||
End Using
|
||||
End Function
|
||||
@@ -323,9 +302,9 @@ Public Class MSSQLServer
|
||||
Public Function GetDatatableWithConnectionObject(SqlCommand As String, SqlConnection As SqlConnection,
|
||||
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional Transaction As SqlTransaction = Nothing,
|
||||
Optional Timeout As Integer = 120) As DataTable
|
||||
Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
|
||||
Dim oTable As New DataTable() With {.TableName = TABLE_DEFAULT}
|
||||
Dim oTable As New DataTable() With {.TableName = Constants.DEFAULT_TABLE}
|
||||
|
||||
Try
|
||||
Dim oAdapter As New SqlDataAdapter(New SqlCommand With {
|
||||
@@ -335,12 +314,12 @@ Public Class MSSQLServer
|
||||
.CommandTimeout = Timeout
|
||||
})
|
||||
|
||||
_Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", SqlCommand)
|
||||
Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", SqlCommand)
|
||||
|
||||
oAdapter.Fill(oTable)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
|
||||
Throw ex
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@@ -352,7 +331,7 @@ Public Class MSSQLServer
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function ExecuteNonQuery(SQLCommand As String) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, _Timeout)
|
||||
Return ExecuteNonQueryWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, QueryTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
@@ -364,19 +343,19 @@ Public Class MSSQLServer
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = 120) As Boolean
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(SQLCommand, Transaction.Connection, TransactionMode.ExternalTransaction, Transaction, Timeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Async Function ExecuteNonQueryAsync(SQLCommand As String, Optional Timeout As Integer = 120) As Task(Of Boolean)
|
||||
Public Async Function ExecuteNonQueryAsync(SQLCommand As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of Boolean)
|
||||
Return Await Task.Run(Function() ExecuteNonQuery(SQLCommand, Timeout))
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function ExecuteNonQueryWithConnection(pSQLCommand As String, ConnString As String, Optional Timeout As Integer = 120) As Boolean
|
||||
Public Function ExecuteNonQueryWithConnection(pSQLCommand As String, ConnString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Using oConnection = GetConnection(ConnString)
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
End Using
|
||||
@@ -385,11 +364,11 @@ Public Class MSSQLServer
|
||||
Public Function ExecuteNonQueryWithConnectionObject(SqlCommand As String, SqlConnection As SqlConnection,
|
||||
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional Transaction As SqlTransaction = Nothing,
|
||||
Optional Timeout As Integer = 120) As Boolean
|
||||
Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
|
||||
|
||||
Try
|
||||
_Logger.Debug("ExecuteNonQueryWithConnectionObject: Running Command [{0}]", SqlCommand)
|
||||
Logger.Debug("ExecuteNonQueryWithConnectionObject: Running Command [{0}]", SqlCommand)
|
||||
|
||||
Using oSQLCOmmand = SqlConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SqlCommand
|
||||
@@ -400,8 +379,8 @@ Public Class MSSQLServer
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]-[{1}]", SqlCommand, SqlConnection.ConnectionString)
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]-[{1}]", SqlCommand, SqlConnection.ConnectionString)
|
||||
Return False
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@@ -423,20 +402,20 @@ Public Class MSSQLServer
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValue(SQLCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = 120) As Object
|
||||
Public Function GetScalarValue(SQLCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(SQLCommand, oConnection, TransactionMode.ExternalTransaction, Transaction, Timeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Async Function GetScalarValueAsync(SQLQuery As String, Optional Timeout As Integer = 120) As Task(Of Object)
|
||||
Public Async Function GetScalarValueAsync(SQLQuery As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of Object)
|
||||
Return Await Task.Run(Function() GetScalarValue(SQLQuery, Timeout))
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValueWithConnection(SQLCommand As String, ConnectionString As String, Optional Timeout As Integer = 120) As Object
|
||||
Using oConnection = GetConnection(ConnectionString)
|
||||
Public Function GetScalarValueWithConnection(SQLCommand As String, pConnectionString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Using oConnection = GetConnection(pConnectionString)
|
||||
Return GetScalarValueWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
End Using
|
||||
End Function
|
||||
@@ -444,7 +423,7 @@ Public Class MSSQLServer
|
||||
Public Function GetScalarValueWithConnectionObject(SqlCommand As String, SqlConnection As SqlConnection,
|
||||
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional Transaction As SqlTransaction = Nothing,
|
||||
Optional Timeout As Integer = 120) As Object
|
||||
Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
|
||||
Dim oResult As Object = Nothing
|
||||
@@ -458,8 +437,8 @@ Public Class MSSQLServer
|
||||
oResult = oSQLCOmmand.ExecuteScalar()
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
End Try
|
||||
@@ -473,7 +452,7 @@ Public Class MSSQLServer
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_Logger.Debug("GetScalarValue: Running Query [{0}]", SQLCommand)
|
||||
Logger.Debug("GetScalarValue: Running Query [{0}]", SQLCommand)
|
||||
|
||||
If SQLCommand.CommandText.Contains(" ") Then
|
||||
SQLCommand.CommandType = CommandType.Text
|
||||
@@ -492,8 +471,8 @@ Public Class MSSQLServer
|
||||
Return SQLCommand.Parameters(OutputParameter).Value
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn($"GetScalarValue failed SQLCommand [{SQLCommand}]")
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"GetScalarValue failed SQLCommand [{SQLCommand}]")
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
@@ -501,7 +480,7 @@ Public Class MSSQLServer
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String) As Object
|
||||
Return GetScalarValue(SQLCommand, OutputParameter, _Timeout)
|
||||
Return GetScalarValue(SQLCommand, OutputParameter, QueryTimeout)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
@@ -510,8 +489,8 @@ Public Class MSSQLServer
|
||||
''' <param name="SqlCommand">the sql statement</param>
|
||||
''' <param name="commandtimeout">Optional Timeout</param>
|
||||
''' <remarks></remarks>
|
||||
Public Sub NewExecuteNonQueryAsync(SqlCommand As String, Optional commandtimeout As Integer = 120)
|
||||
_Logger.Debug("NewExecuteNonQueryAsync: Running Query [{0}]", SqlCommand)
|
||||
Public Sub NewExecuteNonQueryAsync(SqlCommand As String, Optional commandtimeout As Integer = Constants.DEFAULT_TIMEOUT)
|
||||
Logger.Debug("NewExecuteNonQueryAsync: Running Query [{0}]", SqlCommand)
|
||||
|
||||
Try
|
||||
Dim oCallback As New AsyncCallback(AddressOf NewExecuteNonQueryAsync_Callback)
|
||||
@@ -524,8 +503,8 @@ Public Class MSSQLServer
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn($"NewExecuteNonQueryAsync failed SQLCommand [{SqlCommand}]")
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"NewExecuteNonQueryAsync failed SQLCommand [{SqlCommand}]")
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
@@ -534,6 +513,6 @@ Public Class MSSQLServer
|
||||
Private Sub NewExecuteNonQueryAsync_Callback(ByVal result As IAsyncResult)
|
||||
Dim command As SqlCommand = CType(result.AsyncState, SqlCommand)
|
||||
Dim res = command.EndExecuteNonQuery(result)
|
||||
_Logger.Info("Finished executing Async database operation: {0}", command.CommandText)
|
||||
Logger.Info("Finished executing Async database operation: {0}", command.CommandText)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Encryption
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Oracle.ManagedDataAccess.Client
|
||||
|
||||
Public Class Oracle
|
||||
Public DBInitialized As Boolean = False
|
||||
Public CurrentOracleConnectionString As String = ""
|
||||
Implements IDatabase
|
||||
|
||||
Private _Timeout As Integer
|
||||
Private _Logger As Logger
|
||||
Public Property DBInitialized As Boolean = False Implements IDatabase.DBInitialized
|
||||
Public Property CurrentConnectionString As String = "" Implements IDatabase.CurrentConnectionString
|
||||
|
||||
Private ReadOnly _Timeout As Integer
|
||||
Private ReadOnly _Logger As Logger
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
||||
_Timeout = Timeout
|
||||
_Logger = LogConfig.GetLogger()
|
||||
|
||||
CurrentOracleConnectionString = ConnectionString
|
||||
DBInitialized = TestCanConnect(CurrentOracleConnectionString)
|
||||
ConnectionString = ConnectionString
|
||||
DBInitialized = TestCanConnect(ConnectionString)
|
||||
End Sub
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Server As String, Database As String, UserId As String, Password As String, Optional Timeout As Integer = 120)
|
||||
_Timeout = Timeout
|
||||
_Logger = LogConfig.GetLogger()
|
||||
|
||||
CurrentOracleConnectionString = GetConnectionString(Server, Database, UserId, Password)
|
||||
DBInitialized = TestCanConnect(CurrentOracleConnectionString)
|
||||
CurrentConnectionString = GetConnectionString(Server, Database, UserId, Password)
|
||||
DBInitialized = TestCanConnect(CurrentConnectionString)
|
||||
End Sub
|
||||
|
||||
Private Function TestCanConnect(ConnectionString As String) As Boolean
|
||||
@@ -43,30 +46,36 @@ Public Class Oracle
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns a datatable for a sql-statement
|
||||
''' Encrypts a connection string password.
|
||||
''' </summary>
|
||||
''' <param name="sqlcommand">sqlcommand for datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>Returns a datatable</returns>
|
||||
Public Function GetDatatable(sqlcommand As String) As DataTable
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = sqlcommand
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
Dim adapter1 As OracleDataAdapter = New OracleDataAdapter(oSQLCOmmand)
|
||||
Dim dt As DataTable = New DataTable()
|
||||
adapter1.Fill(dt)
|
||||
oSQLconnect.Close()
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Debug("sqlcommand: " & sqlcommand)
|
||||
Return Nothing
|
||||
End Try
|
||||
''' <param name="ConnectionString">A connection string with a plain-text password</param>
|
||||
''' <returns>The connection string with the password encrypted.</returns>
|
||||
<DebuggerStepThrough()>
|
||||
Public Shared Function EncryptConnectionString(ConnectionString As String) As String
|
||||
Dim oEncryption As New EncryptionLegacy()
|
||||
Dim oBuilder As New OracleConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oEncryptedPassword = oEncryption.EncryptData(oBuilder.Password)
|
||||
oBuilder.Password = oEncryptedPassword
|
||||
|
||||
Return oBuilder.ToString()
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Decrypts a connection string password.
|
||||
''' </summary>
|
||||
''' <param name="ConnectionString">A connection string with a encrypted password</param>
|
||||
''' <returns>The connection string with the password decrypted.</returns>
|
||||
<DebuggerStepThrough()>
|
||||
Public Shared Function DecryptConnectionString(ConnectionString As String) As String
|
||||
Dim oEncryption As New EncryptionLegacy()
|
||||
Dim oBuilder As New OracleConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oDecryptedPassword = oEncryption.DecryptData(oBuilder.Password)
|
||||
oBuilder.Password = oDecryptedPassword
|
||||
|
||||
Return oBuilder.ToString()
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Executes the passed sql-statement
|
||||
''' </summary>
|
||||
@@ -76,7 +85,7 @@ Public Class Oracle
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.ConnectionString = CurrentConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
@@ -102,7 +111,7 @@ Public Class Oracle
|
||||
Try
|
||||
Dim oSQLconnect As New OracleConnection
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLconnect.ConnectionString = CurrentOracleConnectionString
|
||||
oSQLconnect.ConnectionString = CurrentConnectionString
|
||||
oSQLconnect.Open()
|
||||
oSQLCOmmand = oSQLconnect.CreateCommand()
|
||||
oSQLCOmmand.CommandText = executeStatement
|
||||
@@ -117,4 +126,128 @@ Public Class Oracle
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetDatatable(pSQLCommand As String, pTimeout As Integer) As DataTable Implements IDatabase.GetDatatable
|
||||
Try
|
||||
Using oConnection = GetConnection(CurrentConnectionString)
|
||||
Dim oSQLCommand As OracleCommand
|
||||
oSQLCommand = oConnection.CreateCommand()
|
||||
oSQLCommand.CommandText = pSQLCommand
|
||||
oSQLCommand.CommandTimeout = pTimeout
|
||||
|
||||
Dim oAdapter As OracleDataAdapter = New OracleDataAdapter(oSQLCommand)
|
||||
Dim oTable As DataTable = New DataTable()
|
||||
|
||||
_Logger.Debug("GetDatatable: Running Query [{0}]", oSQLCommand)
|
||||
|
||||
oAdapter.Fill(oTable)
|
||||
|
||||
Return oTable
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("GetDatatable: Error in GetDatatable while executing command: [{0}]", pSQLCommand)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetDatatable(pSQLCommand As String) As DataTable Implements IDatabase.GetDatatable
|
||||
Return GetDatatable(pSQLCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String, pTimeout As Integer) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Try
|
||||
Using oConnection = GetConnection(CurrentConnectionString)
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = pSQLCommand
|
||||
oSQLCOmmand.CommandTimeout = pTimeout
|
||||
|
||||
|
||||
_Logger.Debug("ExecuteNonQuery: Running Query [{0}]", oSQLCOmmand)
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
oSQLCOmmand.Dispose()
|
||||
Return True
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("ExecuteNonQuery: Error in ExecuteNonQuery while executing command: [{0}]", pSQLCommand)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Return ExecuteNonQuery(pSQLCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(pSQLCommand As String, pTimeout As Integer) As Object Implements IDatabase.GetScalarValue
|
||||
Dim result
|
||||
Try
|
||||
Using oConnection = GetConnection(CurrentConnectionString)
|
||||
Dim oSQLCOmmand As OracleCommand
|
||||
oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = pSQLCommand
|
||||
oSQLCOmmand.CommandTimeout = pTimeout
|
||||
|
||||
_Logger.Debug("GetScalarValue: Running Query [{0}]", oSQLCOmmand)
|
||||
result = oSQLCOmmand.ExecuteScalar()
|
||||
|
||||
Return result
|
||||
End Using
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("GetScalarValue: Error in GetScalarValue while executing command: [{0}]", pSQLCommand)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(pSQLCommand As String) As Object Implements IDatabase.GetScalarValue
|
||||
Return GetScalarValue(pSQLCommand, _Timeout)
|
||||
End Function
|
||||
|
||||
Private Function GetConnection(ConnectionString As String) As OracleConnection
|
||||
Try
|
||||
Dim oConnection As New OracleConnection(ConnectionString)
|
||||
oConnection = OpenSQLConnection(oConnection)
|
||||
|
||||
Dim oMaskedConnectionString = MaskConnectionString(ConnectionString)
|
||||
_Logger.Debug("The Following Connection is open: {0}", oMaskedConnectionString)
|
||||
|
||||
Return oConnection
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' This Function intentionally has no try..catch block to have any errors caught outside
|
||||
''' </summary>
|
||||
''' <param name="Connection"></param>
|
||||
''' <returns></returns>
|
||||
Private Function OpenSQLConnection(Connection As OracleConnection) As OracleConnection
|
||||
If Connection.State = ConnectionState.Closed Then
|
||||
Connection.Open()
|
||||
End If
|
||||
|
||||
Return Connection
|
||||
End Function
|
||||
|
||||
<DebuggerStepThrough()>
|
||||
Private Function MaskConnectionString(ConnectionString As String) As String
|
||||
Try
|
||||
If ConnectionString Is Nothing OrElse ConnectionString.Length = 0 Then
|
||||
Throw New ArgumentNullException("ConnectionString")
|
||||
End If
|
||||
|
||||
Dim oBuilder As New OracleConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oConnectionString = ConnectionString.Replace(oBuilder.Password, "XXXXX")
|
||||
Return oConnectionString
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return "Invalid ConnectionString"
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
Public Const PROVIDER_ODBC = "ODBC"
|
||||
|
||||
Public Const DEFAULT_TIMEOUT = 120
|
||||
Public Const DEFAULT_TABLE = "DDRESULT"
|
||||
End Class
|
||||
|
||||
@@ -93,6 +93,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ConnectionString.vb" />
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Dispatcher.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Adapters\Firebird.vb" />
|
||||
<Compile Include="IDatabase.vb" />
|
||||
|
||||
89
Modules.Database/Dispatcher.vb
Normal file
89
Modules.Database/Dispatcher.vb
Normal file
@@ -0,0 +1,89 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Dispatcher
|
||||
Public ReadOnly Property Connections As New List(Of DispatcherConnection)
|
||||
|
||||
Public ReadOnly Logger As Logger
|
||||
Public ReadOnly LogConfig As LogConfig
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pConnections As List(Of DispatcherConnection))
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
Connections = pConnections
|
||||
End Sub
|
||||
|
||||
Public Function GetDatatable(pSQLCommand As String, pConnectionId As Integer) As DataTable
|
||||
Dim oAdapter As IDatabase = GetAdapterClass(pConnectionId)
|
||||
Return oAdapter.GetDatatable(pSQLCommand)
|
||||
End Function
|
||||
|
||||
Public Function ExectueNonQuery(pSQLCommand As String, pConnectionId As Integer) As Boolean
|
||||
Dim oAdapter As IDatabase = GetAdapterClass(pConnectionId)
|
||||
Return oAdapter.ExecuteNonQuery(pSQLCommand)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(pSQLCommand As String, pConnectionId As Integer) As Object
|
||||
Dim oAdapter As IDatabase = GetAdapterClass(pConnectionId)
|
||||
Return oAdapter.GetScalarValue(pSQLCommand)
|
||||
End Function
|
||||
|
||||
Private Function GetConnection(pConnectionId As Integer) As DispatcherConnection
|
||||
Dim oConnection As DispatcherConnection = Connections.
|
||||
Where(Function(conn) conn.Id = pConnectionId).
|
||||
FirstOrDefault()
|
||||
|
||||
If oConnection IsNot Nothing Then
|
||||
Logger.Debug("Resolved ConnectionId [{0}] into Connection [{1}]", pConnectionId, oConnection.Name)
|
||||
End If
|
||||
|
||||
Return oConnection
|
||||
End Function
|
||||
|
||||
Private Function GetAdapterClass(pConnectionId As Integer) As IDatabase
|
||||
Dim oConnection = GetConnection(pConnectionId)
|
||||
Dim oArgs As New List(Of Object) From {LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT}
|
||||
Logger.Debug("Creating database adapter object for type [{0}]", ConnectionType.MSSQL)
|
||||
|
||||
' TODO: Cache Database instances to avoid constructing them for every call
|
||||
|
||||
Select Case oConnection.ConnectionType
|
||||
Case ConnectionType.MSSQL
|
||||
Return New MSSQLServer(LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT)
|
||||
|
||||
Case ConnectionType.Oracle
|
||||
Return New Oracle(LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT)
|
||||
|
||||
Case ConnectionType.Firebird
|
||||
Dim oBuilder As New FirebirdSql.Data.FirebirdClient.FbConnectionStringBuilder(oConnection.ConnectionString)
|
||||
Return New Firebird(LogConfig, oBuilder.DataSource, oBuilder.Database, oBuilder.UserID, oBuilder.Password)
|
||||
|
||||
Case ConnectionType.ODBC
|
||||
'Dim oBuilder As New Data.Odbc.OdbcConnectionStringBuilder(pConnection.ConnectionString)
|
||||
'Return New ODBC(LogConfig)
|
||||
Return Nothing
|
||||
|
||||
Case Else
|
||||
Return Nothing
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Enum ConnectionType
|
||||
MSSQL
|
||||
Oracle
|
||||
ODBC
|
||||
Firebird
|
||||
End Enum
|
||||
|
||||
Public Class DispatcherOptions
|
||||
Public Property QueryTimeout As Integer = Constants.DEFAULT_TIMEOUT
|
||||
End Class
|
||||
|
||||
Public Class DispatcherConnection
|
||||
Public Property Id As Integer
|
||||
Public Property Name As String
|
||||
Public Property ConnectionString As String
|
||||
Public Property ConnectionType As ConnectionType
|
||||
End Class
|
||||
End Class
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
Imports System.Data.Common
|
||||
|
||||
Public Interface IDatabase
|
||||
''' <summary>
|
||||
''' Returns true if the initial connection to the configured database was successful.
|
||||
''' </summary>
|
||||
Property DBInitialized As Boolean
|
||||
Property CurrentConnectionString As String
|
||||
|
||||
Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable
|
||||
Function GetDatatable(SqlCommand As String) As DataTable
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("Modules.Database")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("2.2.7.0")>
|
||||
<Assembly: AssemblyTrademark("2.2.7.3")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.2.7.0")>
|
||||
<Assembly: AssemblyFileVersion("2.2.7.0")>
|
||||
<Assembly: AssemblyVersion("2.2.7.3")>
|
||||
<Assembly: AssemblyFileVersion("2.2.7.3")>
|
||||
|
||||
@@ -121,33 +121,6 @@ Public Class File
|
||||
|
||||
Dim oVersionSeparator As Char = "~"c
|
||||
|
||||
' Split Filename without extension at version separator to:
|
||||
' - Check if file is already versioned
|
||||
' - Get the file version of an already versioned file
|
||||
'
|
||||
' Example:
|
||||
' test1.pdf --> test1 --> ['test1'] --> no fileversion
|
||||
' test1~2.pdf --> test1~2 --> ['test1', '2'] --> version 2
|
||||
' test1~12345~2.pdf --> test1~12345~2 --> ['test1', '12345', '2'] --> still version 2
|
||||
'Dim oFileNameWithoutExtension = Path.GetFileNameWithoutExtension(oFileName)
|
||||
'Dim oSplitFilename = oFileNameWithoutExtension.Split(oVersionSeparator).ToList()
|
||||
|
||||
' if file is already versioned, extract file version
|
||||
' else just use the filename and set version to 1
|
||||
'If oSplitFilename.Count > 1 Then
|
||||
' Dim oVersion As Integer = 1
|
||||
' Try
|
||||
' oVersion = Integer.Parse(oSplitFilename.Last())
|
||||
' oFileNameWithoutExtension = String.Join("", oSplitFilename.Take(oSplitFilename.Count - 1))
|
||||
' Catch ex As Exception
|
||||
' ' oFilenameWithoutExtension does NOT change
|
||||
' oFileNameWithoutExtension = oFileNameWithoutExtension
|
||||
' Finally
|
||||
' oFileVersion = oVersion
|
||||
' End Try
|
||||
'Else
|
||||
' oFileVersion = 1
|
||||
'End If
|
||||
|
||||
Dim oFileNameWithoutExtension = Path.GetFileNameWithoutExtension(oFileName)
|
||||
Dim oSplitResult = GetVersionedString(oFileNameWithoutExtension, oVersionSeparator)
|
||||
@@ -157,7 +130,8 @@ Public Class File
|
||||
|
||||
' Shorten the filename (only filename, without extension or version)
|
||||
' by cutting the length in half. This should work no matter how long the path and/or filename are.
|
||||
If oFileName.Length > MAX_FILE_PATH_LENGTH Then
|
||||
' The initial check operates on the full path to catch all scenarios.
|
||||
If Destination.Length > MAX_FILE_PATH_LENGTH Then
|
||||
_Logger.Info("Filename is too long. Filename will be cut to prevent further errors.")
|
||||
_Logger.Info("Original Filename is: {0}", oFileNameWithoutExtension)
|
||||
Dim oNewLength As Integer = Math.Round(oFileNameWithoutExtension.Length / 2)
|
||||
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("Modules.Filesystem")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("1.3.1.0")>
|
||||
<Assembly: AssemblyTrademark("1.3.1.1")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.3.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.3.1.0")>
|
||||
<Assembly: AssemblyVersion("1.3.1.1")>
|
||||
<Assembly: AssemblyFileVersion("1.3.1.1")>
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Modules.Base\Base\Base.vbproj">
|
||||
<Project>{6ea0c51f-c2b1-4462-8198-3de0b32b74f8}</Project>
|
||||
<Name>Base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Config\Config.vbproj">
|
||||
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
|
||||
<Name>Config</Name>
|
||||
|
||||
@@ -156,8 +156,8 @@ Public Class GlobalState
|
||||
_Logger.Debug("ForceDirectDatabaseAccess: {0}", pConfig.ClientConfig.ForceDirectDatabaseAccess)
|
||||
ClientConfig.ForceDirectDatabaseAccess = pConfig.ClientConfig.ForceDirectDatabaseAccess
|
||||
ClientConfig.DocumentTypes = Doctypes
|
||||
ClientConfig.ConnectionStringECM = _MSSQL_ECM.CurrentSQLConnectionString
|
||||
ClientConfig.ConnectionStringIDB = _MSSQL_IDB.CurrentSQLConnectionString
|
||||
ClientConfig.ConnectionStringECM = _MSSQL_ECM.CurrentConnectionString
|
||||
ClientConfig.ConnectionStringIDB = _MSSQL_IDB.CurrentConnectionString
|
||||
End Sub
|
||||
|
||||
Public Class ObjectStore
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
Public Property MaxAttachmentSizeInMegaBytes As Integer = -1
|
||||
|
||||
|
||||
Public Property RejectionTransferEnabled As Boolean = True
|
||||
Public Property RejectionTransferTimeUnit As String = "HOUR"
|
||||
Public Property RejectionTransferTimeValue As Integer = 12
|
||||
End Class
|
||||
|
||||
@@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("DDZUGFeRDService")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("2.1.2.0")>
|
||||
<Assembly: AssemblyTrademark("2.1.2.1")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.1.2.0")>
|
||||
<Assembly: AssemblyFileVersion("2.1.2.0")>
|
||||
<Assembly: AssemblyVersion("2.1.2.1")>
|
||||
<Assembly: AssemblyFileVersion("2.1.2.1")>
|
||||
|
||||
@@ -182,7 +182,11 @@ Public Class ThreadRunner
|
||||
|
||||
Private Sub DoWork(sender As Object, e As DoWorkEventArgs) Handles _workerThread.DoWork
|
||||
Try
|
||||
MaybeUpdateRejected()
|
||||
If _config.Config.Custom.RejectionTransferEnabled = True Then
|
||||
MaybeUpdateRejected()
|
||||
Else
|
||||
_logger.Debug("Transferring rejection status to Firebird is disabled.")
|
||||
End If
|
||||
|
||||
Dim oArgs As WorkerArgs = e.Argument
|
||||
_logger.Debug("Background worker running..")
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace ZUGFeRDRESTService
|
||||
MSSQL = new MSSQLServer(LogConfig, AppConfig["MSSQLConnectionString"]);
|
||||
Firebird = new Firebird(LogConfig, FBConfig["Datasource"], FBConfig["Database"], FBConfig["Username"], FBConfig["Password"]);
|
||||
|
||||
Logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentSQLConnectionString);
|
||||
Logger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString);
|
||||
Logger.Debug("Firebird Connection: [{0}]", Firebird.ConnectionString);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user