Modules.Database

This commit is contained in:
Digital Data - Marlon Schreiber 2018-08-16 15:27:46 +02:00
parent f8e3b3628e
commit b8c28b516c
12 changed files with 427 additions and 64 deletions

View File

@ -1,16 +1,15 @@
Imports DD_FirebirdDLL
Imports Modules.Database
Public Class ClassCurrentUser
Public Username As String
Public Language As String
Private DB As ClassFirebird
Private DBFirebird As Firebird
Public Sub New(DB As ClassFirebird)
Public Sub New(DBFirebird As Firebird)
Username = Environment.UserName
DB = DB
Dim sql As String = $"SELECT FNGET_USER_ACCESS('edm','{Username}') FROM rdb$database"
Dim result = DB.ReturnScalar(sql)
Dim result = DBFirebird.GetExecuteScalar(sql)
End Sub
End Class

View File

@ -1,22 +1,22 @@
Imports System.IO
Imports DD_FirebirdDLL
Imports Modules.Database
Public Class ClassInit
Public Shared Function Init_user()
Try
USER_USERNAME = Environment.UserName
Dim sql = String.Format("select FNGET_USER_ACCESS('edm','{0}') from rdb$database", USER_USERNAME)
Dim result = ClassDBFirebird.ExecuteScalar(sql, LOGGERFilePath)
'Dim result = Firebird.ExecuteScalar(sql, LOGGERFilePath)
sql = String.Format("SELECT * FROM VW_TBEDM_USER WHERE UPPER(LOGIN_NAME) = UPPER('{0}')", USER_USERNAME)
DT_USER = ClassDBFirebird.ReturnDatatable(sql, LOGGERFilePath)
If Not IsNothing(result) Then
If Not IsNothing(DT_USER) Then
USER_LANGUAGE = DT_USER.Rows(0).Item("LANGUAGE")
End If
Return result
Else
Return False
End If
'sql = String.Format("SELECT * FROM VW_TBEDM_USER WHERE UPPER(LOGIN_NAME) = UPPER('{0}')", USER_USERNAME)
'DT_USER = ClassDBFirebird.ReturnDatatable(sql, LOGGERFilePath)
'If Not IsNothing(result) Then
' If Not IsNothing(DT_USER) Then
' USER_LANGUAGE = DT_USER.Rows(0).Item("LANGUAGE")
' End If
' Return result
'Else
' Return False
'End If
Catch ex As Exception
End Try

View File

@ -47,9 +47,6 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="DD_FirebirdDLL">
<HintPath>..\..\DDFirebirdDLL\DD_FirebirdDLL\bin\Debug\DD_FirebirdDLL.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Data.v18.1, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Pdf.v18.1.Core, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Office.v18.1.Core, Version=18.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
@ -78,6 +75,9 @@
<HintPath>..\packages\FirebirdSql.Data.FirebirdClient.6.1.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Modules.Database">
<HintPath>..\Modules.Database\bin\Debug\Modules.Database.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.5.8\lib\net45\NLog.dll</HintPath>
</Reference>

View File

@ -1,4 +1,4 @@
Imports DD_FirebirdDLL
Imports Modules.Database
Public Class FrmConnection
Private Sub FrmConnection_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@ -11,7 +11,7 @@ Public Class FrmConnection
Private Sub BtnConnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
My.Settings.Save()
Dim dbTest As New ClassFirebird(My.Settings.fbDatasource, My.Settings.fbDatabaseLocation, My.Settings.fbUser, My.Settings.fbPassword)
Dim dbTest As New Firebird(My.Settings.fbDatasource, My.Settings.fbDatabaseLocation, My.Settings.fbUser, My.Settings.fbPassword)
If dbTest.ConnectionFailed Then
MsgBox("Connection failed!", MsgBoxStyle.Information, "Database Connection")

View File

@ -1,11 +1,11 @@
Imports DD_FirebirdDLL
Imports Modules.Database
Imports Modules.Logging
Public Class FrmMain
Private SelectedTable As Integer
Private Logger As NLog.Logger
Private LogWrapper As Logger
Private DB As ClassFirebird
Private DBFirebird As Firebird
Private Sub CreateTableNodesFromDatatable(dt As DataTable)
' Node der Datenbank erstellen
@ -40,7 +40,7 @@ Public Class FrmMain
End Sub
Private Function LoadTables()
Return DB.ReturnDatatable("SELECT DISTINCT T.TABLE_ID,T.""TABLE"" from VWEDM_TABLE_COLUMN T")
Return DBFirebird.GetDatatable("SELECT DISTINCT T.TABLE_ID,T.""TABLE"" from VWEDM_TABLE_COLUMN T")
End Function
Private Function DatabaseSettingsExist()
@ -48,15 +48,15 @@ Public Class FrmMain
End Function
Private Sub Init()
DB = New ClassFirebird(My.Settings.fbDatasource, My.Settings.fbDatabaseLocation, My.Settings.fbUser, My.Settings.fbPassword)
DBFirebird = New Firebird(My.Settings.fbDatasource, My.Settings.fbDatabaseLocation, My.Settings.fbUser, My.Settings.fbPassword)
If DB.ConnectionFailed Then
If DBFirebird.ConnectionFailed Then
MsgBox("Database connection failed. Please check the log.", vbCritical)
Exit Sub
End If
' Get info about the logged in user
CurrentUser = New ClassCurrentUser(DB)
CurrentUser = New ClassCurrentUser(DBFirebird)
Dim dt As DataTable = LoadTables()
CreateTableNodesFromDatatable(dt)
@ -65,7 +65,7 @@ Public Class FrmMain
Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
LogWrapper = New Logger("EDMDesigner", ClassLogger.PathType.CurrentDirectory)
LogWrapper = New Logger(ClassLogger.PathType.CurrentDirectory)
Logger = NLog.LogManager.GetCurrentClassLogger()
@ -120,7 +120,7 @@ Public Class FrmMain
End Sub
Private Sub SpaltenBearbeitenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SpaltenBearbeitenToolStripMenuItem.Click
Dim dt As DataTable = DB.ReturnDatatable($"SELECT * FROM VWEDM_TABLE_COLUMN WHERE TABLE_ID = {SelectedTable}")
Dim dt As DataTable = DBFirebird.GetDatatable($"SELECT * FROM VWEDM_TABLE_COLUMN WHERE TABLE_ID = {SelectedTable}")
gridControlTableProperties.DataSource = dt
End Sub

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="FirebirdSql.Data.FirebirdClient" type="EntityFramework.Firebird.FbProviderServices, EntityFramework.Firebird" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="FirebirdSql.Data.FirebirdClient" />
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,4 +1,167 @@
Public Class Firebird
Imports FirebirdSql.Data.FirebirdClient
Public Class Firebird
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
Public DBInitialized As Boolean = False
Private _connectionEstablished As Boolean = False
Private _connectionFailed As Boolean = False
Private ReadOnly dataSource As String
Private ReadOnly database As String
Private ReadOnly user As String
Private ReadOnly password As String
Public CurrentFBDConnectionString As String = ""
Public ReadOnly Property ConnectionString As String
Public ReadOnly Property ConnectionEstablished As Boolean
Get
Return _connectionEstablished
End Get
End Property
Public ReadOnly Property ConnectionFailed As Boolean
Get
Return _connectionFailed
End Get
End Property
Public Sub New(dataSource As String, database As String, user As String, password As String)
ConnectionString = BuildConnectionString(dataSource, database, user, password)
' Save connection credentials
dataSource = dataSource
database = database
user = user
password = password
' Test the connection first
Dim conn = Connect(ConnectionString)
' If initial connection was successfully, close it
conn?.Close()
End Sub
Private Function Connect(ConnectionString As String) As FbConnection
Try
Dim conn = New FbConnection(ConnectionString)
conn.Open()
_connectionEstablished = True
_connectionFailed = False
Logger.Debug("Connection established!")
Logger.Debug($"User: {user}")
Logger.Debug($"DatabaseLocation: {database}")
Logger.Debug($"DatabaseServer: {dataSource}")
Return conn
Catch ex As Exception
_connectionFailed = True
_connectionEstablished = False
Logger.Error(ex)
Return Nothing
End Try
End Function
''' <summary>
''' Builds a connectionstring from the provided arguments.
''' </summary>
''' <param name="dataSource">The database server where to connect to</param>
''' <param name="database">The datasource, eg. the path of the FDB-file</param>
''' <param name="user">The user used to connect to the database</param>
''' <param name="password">The password of the connecting user</param>
''' <returns>A connectionstring</returns>
Private Function BuildConnectionString(dataSource As String, database As String, user As String, password As String) As String
Dim connectionStringBuilder = New FbConnectionStringBuilder With {
.DataSource = dataSource,
.Database = database,
.UserID = user,
.Password = password
}
Return connectionStringBuilder.ConnectionString
End Function
''' <summary>
''' Executes a non-query command.
''' </summary>
''' <param name="sqlCommand">The command to execute</param>
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
Public Function NewExecuteNonQuery(sqlCommand As String) As Boolean
Try
Dim conn As FbConnection = Connect(ConnectionString)
If conn Is Nothing Then
Return False
End If
Dim transaction As FbTransaction = conn.BeginTransaction()
Dim command As New FbCommand With {
.CommandText = sqlCommand,
.Connection = conn,
.Transaction = transaction
}
command.ExecuteNonQuery()
transaction.Commit()
conn.Close()
Return True
Catch ex As Exception
Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: '{sqlCommand}'")
Return False
End Try
End Function
''' <summary>
''' Executes a sql query resulting in a scalar value.
''' </summary>
''' <param name="sqlQuery">The query to execute</param>
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
Public Function GetExecuteScalar(sqlQuery As String) As Object
Try
Dim conn As FbConnection = Connect(ConnectionString)
If conn Is Nothing Then
Return Nothing
End If
Dim transaction As FbTransaction = conn.BeginTransaction()
Dim command As New FbCommand With {
.CommandText = sqlQuery,
.Connection = conn,
.Transaction = transaction
}
Dim result As Object = command.ExecuteScalar()
transaction.Commit()
conn.Close()
Return result
Catch ex As Exception
Logger.Error(ex, $"Error in ReturnScalar while executing command: '{sqlQuery}'")
Return Nothing
End Try
End Function
''' <summary>
''' Executes a sql query resulting in a table of values.
''' </summary>
''' <param name="sqlQuery">The query to execute</param>
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
Public Function GetDatatable(sqlQuery As String) As DataTable
Try
Dim conn As FbConnection = Connect(ConnectionString)
If conn Is Nothing Then
Return Nothing
End If
Dim command As New FbCommand With {
.CommandText = sqlQuery,
.Connection = conn
}
Dim adapter As New FbDataAdapter(command)
Dim dt As New DataTable()
adapter.Fill(dt)
conn.Close()
Return dt
Catch ex As Exception
Logger.Error(ex, $"Error in ReturnDatatable while executing command: '{sqlQuery}'")
Return Nothing
End Try
End Function
End Class

View File

@ -1,9 +1,10 @@
Imports System.Data.SqlClient
Public Class SQLServer
Public Class MSSQLServer
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
Public DBInitialized As Boolean = False
Public CurrentSQLConnectionString As String = ""
Private CurrentSQLConnection As SqlClient.SqlConnection
Public Sub New(CONSTRING As String)
Init(CONSTRING)
End Sub
@ -17,11 +18,38 @@ Public Class SQLServer
DBInitialized = True
Return True
Catch ex As Exception
DBInitialized = False
Logger.Error(ex)
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
Return False
End Try
End Function
Private Function GetSQLConnection()
Try
If IsNothing(CurrentSQLConnection) Then
Dim oSQLconnect As New SqlClient.SqlConnection
oSQLconnect.ConnectionString = CurrentSQLConnectionString
CurrentSQLConnection = oSQLconnect
CurrentSQLConnection.Open()
Else
If CurrentSQLConnection.State <> ConnectionState.Open Then
Logger.Warn($"Actual ConnectionState is: '{CurrentSQLConnection.State.ToString}'")
Try
CurrentSQLConnection.Open()
Return True
Catch ex As Exception
Logger.Warn("Could not reconnect to database!")
Return False
End Try
End If
End If
Return True
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
''' <summary>
''' Returns a datatable for a sql-statement
''' </summary>
@ -31,17 +59,19 @@ Public Class SQLServer
''' <remarks></remarks>
Public Function GetDatatable(sqlcommand As String, Optional commandtimeout As Integer = 120) As DataTable
Try
Dim oSQLconnect As New SqlClient.SqlConnection
Dim dt As DataTable = New DataTable()
If GetSQLConnection() = False Then
Return Nothing
End If
Dim oSQLCOmmand As SqlClient.SqlCommand
oSQLconnect.ConnectionString = CurrentSQLConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
oSQLCOmmand.CommandText = sqlcommand
oSQLCOmmand.CommandTimeout = commandtimeout
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(oSQLCOmmand)
Dim dt As DataTable = New DataTable()
adapter1.Fill(dt)
oSQLconnect.Close()
Return dt
Catch ex As Exception
Logger.Error(ex)
@ -58,16 +88,17 @@ Public Class SQLServer
''' <remarks></remarks>
Public Function NewExecutenonQuery(executeStatement As String, Optional commandtimeout As Integer = 120) As Boolean
Try
Dim oSQLconnect As New SqlClient.SqlConnection
If GetSQLConnection() = False Then
Return Nothing
End If
'Dim oSQLconnect As New SqlClient.SqlConnection
Dim oSQLCOmmand As SqlClient.SqlCommand
oSQLconnect.ConnectionString = CurrentSQLConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
oSQLCOmmand.CommandText = executeStatement
oSQLCOmmand.CommandTimeout = commandtimeout
oSQLCOmmand.ExecuteNonQuery()
oSQLCOmmand.Dispose()
oSQLconnect.Close()
Return True
Catch ex As Exception
Logger.Error(ex)
@ -82,22 +113,21 @@ Public Class SQLServer
''' <param name="commandtimeout">Optional Timeout</param>
''' <remarks></remarks>
Public Sub NewExecuteNonQueryAsync(executeStatement As String, Optional commandtimeout As Integer = 120)
Dim oSQLconnect As New SqlClient.SqlConnection
If GetSQLConnection() = False Then
Exit Sub
End If
Dim oSQLCOmmand As SqlClient.SqlCommand
Dim callback As New AsyncCallback(AddressOf Execute_non_Query_Async_Callback)
Try
oSQLconnect.ConnectionString = CurrentSQLConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
oSQLCOmmand.CommandText = executeStatement
oSQLCOmmand.CommandTimeout = commandtimeout
oSQLCOmmand.BeginExecuteNonQuery(callback, oSQLCOmmand)
oSQLCOmmand.Dispose()
Catch ex As Exception
Logger.Error(ex)
Logger.Debug("executeStatement: " & executeStatement)
Finally
oSQLCOmmand.Dispose()
oSQLconnect.Close()
End Try
End Sub
@ -116,18 +146,16 @@ Public Class SQLServer
Public Function NewExecuteScalar(executeStatement As String, Optional commandtimeout As Integer = 120)
Dim result
Try
Dim oSQLconnect As New SqlClient.SqlConnection
Dim oSQLCOmmand As SqlClient.SqlCommand
oSQLconnect.ConnectionString = CurrentSQLConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
If GetSQLConnection() = False Then
Return Nothing
End If
Dim oSQLCOmmand As SqlClient.SqlCommand
oSQLCOmmand = CurrentSQLConnection.CreateCommand()
oSQLCOmmand.CommandText = executeStatement
oSQLCOmmand.CommandTimeout = commandtimeout
result = oSQLCOmmand.ExecuteScalar()
oSQLCOmmand.Dispose()
oSQLconnect.Close()
Return result
Catch ex As Exception
Logger.Error(ex)

View File

@ -43,6 +43,18 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.Firebird, Version=6.1.0.0, Culture=neutral, PublicKeyToken=42d22d092898e5f8, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.Firebird.6.1.0\lib\net452\EntityFramework.Firebird.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=6.0.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
<HintPath>..\packages\FirebirdSql.Data.FirebirdClient.6.0.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.5.8\lib\net45\NLog.dll</HintPath>
@ -51,6 +63,7 @@
<HintPath>P:\Visual Studio Projekte\Bibliotheken\Oracle.ManagedDataAccess.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
@ -77,7 +90,7 @@
<ItemGroup>
<Compile Include="Firebird.vb" />
<Compile Include="Oracle.vb" />
<Compile Include="SQLServer.vb" />
<Compile Include="MSSQLServer.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
@ -103,6 +116,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>

View File

@ -3,4 +3,133 @@ Public Class Oracle
Private Shared Logger As NLog.Logger = NLog.LogManager.GetCurrentClassLogger
Public DBInitialized As Boolean = False
Public CurrentOracleConnectionString As String = ""
Public Sub New(CONSTRING As String)
Init(CONSTRING)
End Sub
Public Function Init(CONSTRING As String)
Try
Dim oSQLconnect As New OracleConnection
oSQLconnect.ConnectionString = CONSTRING
oSQLconnect.Open()
oSQLconnect.Close()
CurrentOracleConnectionString = CONSTRING
DBInitialized = True
Return True
Catch ex As Exception
DBInitialized = False
Logger.Error(ex)
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
Return False
End Try
End Function
''' <summary>
''' Returns a datatable for a sql-statement
''' </summary>
''' <param name="sqlcommand">sqlcommand for datatable (select XYZ from TableORView)</param>
''' <param name="commandtimeout">Optional Timeout</param>
''' <returns>Returns a datatable</returns>
''' <remarks></remarks>
Public Function GetDatatable(sqlcommand As String, Optional commandtimeout As Integer = 120) 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 = commandtimeout
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
End Function
''' <summary>
''' Executes the passed sql-statement
''' </summary>
''' <param name="executeStatement">the sql statement</param>
''' <param name="commandtimeout">Optional Timeout</param>
''' <returns>Returns true if properly executed, else false</returns>
''' <remarks></remarks>
Public Function NewExecutenonQuery(executeStatement As String, Optional commandtimeout As Integer = 120) As Boolean
Try
Dim oSQLconnect As New OracleConnection
Dim oSQLCOmmand As OracleCommand
oSQLconnect.ConnectionString = CurrentOracleConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
oSQLCOmmand.CommandText = executeStatement
oSQLCOmmand.CommandTimeout = commandtimeout
oSQLCOmmand.ExecuteNonQuery()
oSQLCOmmand.Dispose()
oSQLconnect.Close()
Return True
Catch ex As Exception
Logger.Error(ex)
Logger.Debug("executeStatement: " & executeStatement)
Return False
End Try
End Function
''' <summary>
''' Executes the passed sql-statement in asyncmode
''' </summary>
''' <param name="executeStatement">the sql statement</param>
''' <param name="commandtimeout">Optional Timeout</param>
''' <remarks></remarks>
Public Sub NewExecuteNonQueryAsync(executeStatement As String, Optional commandtimeout As Integer = 120)
Dim oSQLconnect As New OracleConnection
Dim oSQLCOmmand As OracleCommand
Dim callback As New AsyncCallback(AddressOf Execute_non_Query_Async_Callback)
Try
oSQLconnect.ConnectionString = CurrentOracleConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
oSQLCOmmand.CommandText = executeStatement
oSQLCOmmand.CommandTimeout = commandtimeout
oSQLCOmmand.ExecuteNonQuery()
oSQLCOmmand.Dispose()
oSQLconnect.Close()
Catch ex As Exception
Logger.Error(ex)
Logger.Debug("executeStatement: " & executeStatement)
End Try
End Sub
Private Sub Execute_non_Query_Async_Callback(ByVal result As IAsyncResult)
Dim command As OracleCommand = CType(result.AsyncState, OracleCommand)
Dim res = command.ExecuteNonQuery
Logger.Info(String.Format("Finished executing Async database operation: {0}", command.CommandText))
End Sub
''' <summary>
''' Executes the passed sql-statement as Scalar
''' </summary>
''' <param name="executeStatement">the sql statement</param>
''' <param name="commandtimeout">Optional Timeout</param>
''' <returns>Returns true if properly executed, else false</returns>
''' <remarks></remarks>
Public Function NewExecuteScalar(executeStatement As String, Optional commandtimeout As Integer = 120)
Dim result
Try
Dim oSQLconnect As New OracleConnection
Dim oSQLCOmmand As OracleCommand
oSQLconnect.ConnectionString = CurrentOracleConnectionString
oSQLconnect.Open()
oSQLCOmmand = oSQLconnect.CreateCommand()
oSQLCOmmand.CommandText = executeStatement
oSQLCOmmand.CommandTimeout = commandtimeout
result = oSQLCOmmand.ExecuteScalar()
oSQLCOmmand.Dispose()
oSQLconnect.Close()
Return result
Catch ex As Exception
Logger.Error(ex)
Logger.Debug("executeStatement: " & executeStatement)
Return Nothing
End Try
End Function
End Class

View File

@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
<package id="EntityFramework.Firebird" version="6.1.0" targetFramework="net461" />
<package id="FirebirdSql.Data.FirebirdClient" version="6.0.0" targetFramework="net461" />
<package id="NLog" version="4.5.8" targetFramework="net461" />
</packages>

View File

@ -202,7 +202,7 @@ Public Class Windream
Dim i As Integer = 0
Dim value = aValues(i)
Dim oWMValueConverted
Dim oWMValueConverted = Nothing
Dim vektor As Boolean = False
'Den Typ des Index-Feldes auslesen
@ -353,7 +353,7 @@ Public Class Windream
''' <param name="folderObjecttype">Obcjectype Name</param>
''' <returns>Returns true when Otype was set, false if not</returns>
''' <remarks></remarks>
Public Function NewObjecttypeForFolder(folderpath As String, folderObjecttype As String)
Public Function NewObjecttypeForFolder(folderpath As String, folderObjecttype As String) As Boolean
Try
Dim result As Boolean = False
Dim WMFolder As WINDREAMLib.WMObject
@ -397,9 +397,8 @@ Public Class Windream
Catch ex As Exception
' wenn das entsperren nicht geklappt hat, dann war die Datei auch nicht gesperrt
End Try
Return result
End If
Return result
Catch ex As Exception
Logger.Error(ex)
@ -733,7 +732,7 @@ Public Class Windream
Try
Dim missing As Boolean = False
Dim valueCount As Integer = 0
Dim ValueArray()
Dim ValueArray() = Nothing
'Jeden Wert des Vektorfeldes durchlaufen
Dim DT_RESULT = GetValueforIndex(oDocument.aPath, vktIndexName)
If DT_RESULT.Rows.Count > 0 Then
@ -922,7 +921,7 @@ Public Class Windream
Return False
End If
Dim containsvalue As Boolean = False
Dim ValueArray()
Dim ValueArray() = Nothing
'Jeden Wert des Vektorfeldes durchlaufen
Dim WMValue = oWMFile.GetVariableValue(vktIndexName)
If WMValue Is Nothing = False Then