Compare commits
21 Commits
28e70226e5
...
Database_S
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
543097c59d | ||
|
|
5481763eb1 | ||
|
|
95a0e578da | ||
|
|
4b098622d2 | ||
|
|
882824d80f | ||
|
|
b9328d45f8 | ||
|
|
06f64e9c04 | ||
| 0fe90141b1 | |||
|
|
8cb54c0373 | ||
|
|
d366e6095f | ||
|
|
80ac12a2d6 | ||
| c8b20d3a8c | |||
|
|
25a4156429 | ||
|
|
dbb155a849 | ||
|
|
6be8dc54f5 | ||
|
|
b4528788e3 | ||
|
|
2a53d24a91 | ||
|
|
cd6402e726 | ||
|
|
b6659b991b | ||
|
|
375a67bbb4 | ||
|
|
410cae21ea |
@@ -75,7 +75,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BaseClass.vb" />
|
||||
<Compile Include="ECM.vb" />
|
||||
<Compile Include="ECM\ECM.vb" />
|
||||
<Compile Include="IDB\Attributes.vb" />
|
||||
<Compile Include="IDB\Database.vb" />
|
||||
<Compile Include="IDB\FileStore.vb" />
|
||||
@@ -95,6 +95,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Performance.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' indem Sie "*" wie unten gezeigt eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyVersion("1.0.0.1")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.1")>
|
||||
|
||||
44
Base/Performance.vb
Normal file
44
Base/Performance.vb
Normal file
@@ -0,0 +1,44 @@
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Security.Cryptography
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Performance
|
||||
Public Sub New(pLogConfig As LogConfig, pAppDataPath As String)
|
||||
Dim savedHash = String.Empty
|
||||
Dim assemblyLocation = Assembly.GetEntryAssembly().Location
|
||||
|
||||
Dim hashPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hash.txt")
|
||||
If Not File.Exists(hashPath) Then
|
||||
File.Create(hashPath)
|
||||
Else
|
||||
savedHash = File.ReadAllText(hashPath)
|
||||
End If
|
||||
|
||||
Dim hash = String.Concat(SHA1.Create().ComputeHash(File.ReadAllBytes(assemblyLocation)).Select(Function(x) x.ToString("x2")))
|
||||
If hash.Equals(savedHash) Then
|
||||
Return
|
||||
End If
|
||||
|
||||
Dim dotNetRuntimePath = RuntimeEnvironment.GetRuntimeDirectory()
|
||||
Dim ngenPath = Path.Combine(dotNetRuntimePath, "ngen.exe")
|
||||
|
||||
Dim process = New Process With {
|
||||
.StartInfo = New ProcessStartInfo With {
|
||||
.FileName = ngenPath,
|
||||
.Arguments = $"install ""{assemblyLocation}"" /nologo",
|
||||
.CreateNoWindow = True,
|
||||
.UseShellExecute = True,
|
||||
.Verb = "runas"
|
||||
}
|
||||
}
|
||||
Try
|
||||
process.Start()
|
||||
process.WaitForExit()
|
||||
File.WriteAllText(hashPath, hash)
|
||||
Catch
|
||||
' ...
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
17
Database.Test/Database.Test.vbproj
Normal file
17
Database.Test/Database.Test.vbproj
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<RootNamespace>Database.Test</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
12
Database.Test/UnitTest1.vb
Normal file
12
Database.Test/UnitTest1.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Imports Microsoft.VisualStudio.TestTools.UnitTesting
|
||||
|
||||
Namespace Database.Test
|
||||
<TestClass>
|
||||
Public Class UnitTest1
|
||||
<TestMethod>
|
||||
Sub TestSub()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
@@ -4,6 +4,7 @@ Imports System.Data.SqlClient
|
||||
Imports DigitalData.Modules.Encryption
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports System.Threading
|
||||
|
||||
Public Class MSSQLServer
|
||||
Implements IDatabase
|
||||
@@ -264,118 +265,174 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetDatatable(SqlCommand As String) As DataTable Implements IDatabase.GetDatatable
|
||||
Return GetDatatable(SqlCommand, QueryTimeout)
|
||||
''' <summary>
|
||||
''' Returns a Datatable for a SQL Statement
|
||||
''' </summary>
|
||||
''' <param name="pSqlCommand">SQL Command Text for Datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>A datatable</returns>
|
||||
Public Function GetDatatable(pSqlCommand As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable Implements IDatabase.GetDatatable
|
||||
Using oSqlConnection = GetSQLConnection()
|
||||
Return GetDatatableWithConnectionObject(pSqlCommand, oSqlConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns a datatable for a sql-statement
|
||||
''' Returns a datatable for a SQL Statement
|
||||
''' </summary>
|
||||
''' <param name="SqlCommand">sqlcommand for datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>Returns a datatable</returns>
|
||||
Public Function GetDatatable(SqlCommand As String, Timeout As Integer) As DataTable Implements IDatabase.GetDatatable
|
||||
''' <param name="pSqlCommandObject">SQL Command Object for Datatable (select XYZ from TableORView)</param>
|
||||
''' <returns>A datatable</returns>
|
||||
Public Function GetDatatable(pSqlCommandObject As SqlCommand, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable Implements IDatabase.GetDatatable
|
||||
Using oSqlConnection = GetSQLConnection()
|
||||
Return GetDatatableWithConnectionObject(SqlCommand, oSqlConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
Return GetDatatableWithConnectionObject(pSqlCommandObject, oSqlConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetDatatable(SqlCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Public Function GetDatatable(pSqlCommand As String, pTransaction As SqlTransaction, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Using oSqlConnection = GetSQLConnection()
|
||||
Return GetDatatableWithConnectionObject(SqlCommand, oSqlConnection, TransactionMode.ExternalTransaction, Transaction, Timeout)
|
||||
Return GetDatatableWithConnectionObject(pSqlCommand, oSqlConnection, TransactionMode.ExternalTransaction, pTransaction, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
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))
|
||||
Public Function GetDatatable(pSqlCommandObject As SqlCommand, pTransaction As SqlTransaction, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Using oSqlConnection = GetSQLConnection()
|
||||
Return GetDatatableWithConnectionObject(pSqlCommandObject, oSqlConnection, TransactionMode.ExternalTransaction, pTransaction, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetDatatableWithConnection(SqlCommand As String, pConnectionString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Public Async Function GetDatatableAsync(pSqlCommand As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of DataTable)
|
||||
Return Await Task.Run(Function() GetDatatable(pSqlCommand, pTimeout))
|
||||
End Function
|
||||
|
||||
Public Async Function GetDatatableAsync(pSqlCommandObject As SqlCommand, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of DataTable)
|
||||
Return Await Task.Run(Function() GetDatatable(pSqlCommandObject, pTimeout))
|
||||
End Function
|
||||
|
||||
Public Function GetDatatableWithConnection(pSqlCommand As String, pConnectionString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Using oConnection = GetConnection(pConnectionString)
|
||||
Return GetDatatableWithConnectionObject(SqlCommand, oConnection, Timeout:=Timeout)
|
||||
Return GetDatatableWithConnectionObject(pSqlCommand, oConnection, pTimeout:=Timeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Function GetDatatableWithConnectionObject(SqlCommand As String, SqlConnection As SqlConnection,
|
||||
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional Transaction As SqlTransaction = Nothing,
|
||||
Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
|
||||
Public Function GetDatatableWithConnection(pSqlCommandObject As SqlCommand, pConnectionString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Using oConnection = GetConnection(pConnectionString)
|
||||
Return GetDatatableWithConnectionObject(pSqlCommandObject, oConnection, pTimeout:=Timeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Function GetDatatableWithConnectionObject(pSqlCommand As String, pSqlConnection As SqlConnection,
|
||||
Optional pTransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional pTransaction As SqlTransaction = Nothing,
|
||||
Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Dim oSQLCommand As New SqlCommand(pSqlCommand)
|
||||
Return GetDatatableWithConnectionObject(oSQLCommand, pSqlConnection, pTransactionMode, pTransaction, pTimeout)
|
||||
End Function
|
||||
|
||||
Public Function GetDatatableWithConnectionObject(pSqlCommandObject As SqlCommand, pSqlConnection As SqlConnection,
|
||||
Optional pTransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional pTransaction As SqlTransaction = Nothing,
|
||||
Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(pSqlConnection, pTransactionMode, pTransaction)
|
||||
Dim oTable As New DataTable() With {.TableName = Constants.DEFAULT_TABLE}
|
||||
|
||||
Try
|
||||
Dim oAdapter As New SqlDataAdapter(New SqlCommand With {
|
||||
.CommandText = SqlCommand,
|
||||
.Connection = SqlConnection,
|
||||
.Transaction = oTransaction,
|
||||
.CommandTimeout = Timeout
|
||||
})
|
||||
pSqlCommandObject.Connection = pSqlConnection
|
||||
pSqlCommandObject.Transaction = oTransaction
|
||||
pSqlCommandObject.CommandTimeout = pTimeout
|
||||
|
||||
Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", SqlCommand)
|
||||
Using oAdapter As New SqlDataAdapter(pSqlCommandObject)
|
||||
Logger.Debug("GetDatatableWithConnectionObject: Running Query [{0}]", pSqlCommandObject.CommandText)
|
||||
oAdapter.Fill(oTable)
|
||||
End Using
|
||||
|
||||
oAdapter.Fill(oTable)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
|
||||
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", pSqlCommandObject)
|
||||
Throw ex
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
MaybeCommitTransaction(oTransaction, pTransactionMode)
|
||||
End Try
|
||||
|
||||
Return oTable
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function ExecuteNonQuery(SQLCommand As String) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, QueryTimeout)
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, QueryTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Public Function ExecuteNonQuery(pSQLCommandObject As SqlCommand) As Boolean
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommandObject, oConnection, TransactionMode.WithTransaction, Nothing, QueryTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function ExecuteNonQuery(SQLCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String, pTimeout As Integer) As Boolean Implements IDatabase.ExecuteNonQuery
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(SQLCommand, Transaction.Connection, TransactionMode.ExternalTransaction, Transaction, Timeout)
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
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))
|
||||
Public Function ExecuteNonQuery(pSQLCommandObject As SqlCommand, pTimeout As Integer) As Boolean
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommandObject, oConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String, pTransaction As SqlTransaction, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommand, pTransaction.Connection, TransactionMode.ExternalTransaction, pTransaction, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(pSQLCommandObject As SqlCommand, pTransaction As SqlTransaction, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommandObject, pTransaction.Connection, TransactionMode.ExternalTransaction, pTransaction, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Async Function ExecuteNonQueryAsync(pSQLCommand As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of Boolean)
|
||||
Return Await Task.Run(Function() ExecuteNonQuery(pSQLCommand, pTimeout))
|
||||
End Function
|
||||
|
||||
Public Async Function ExecuteNonQueryAsync(pSQLCommandObject As SqlCommand, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of Boolean)
|
||||
Return Await Task.Run(Function() ExecuteNonQuery(pSQLCommandObject, pTimeout))
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
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
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQueryWithConnectionObject(SqlCommand As String, SqlConnection As SqlConnection,
|
||||
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional Transaction As SqlTransaction = Nothing,
|
||||
Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
|
||||
Public Function ExecuteNonQueryWithConnection(pSQLCommandObject As SqlCommand, ConnString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Using oConnection = GetConnection(ConnString)
|
||||
Return ExecuteNonQueryWithConnectionObject(pSQLCommandObject, oConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQueryWithConnectionObject(pSqlCommand As String, pSqlConnection As SqlConnection,
|
||||
Optional pTransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional pTransaction As SqlTransaction = Nothing,
|
||||
Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Dim oSQLCommand As New SqlCommand(pSqlCommand)
|
||||
Return ExecuteNonQueryWithConnectionObject(oSQLCommand, pSqlConnection, pTransactionMode, pTransaction, pTimeout)
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQueryWithConnectionObject(pSqlCommandObject As SqlCommand, pSqlConnection As SqlConnection,
|
||||
Optional pTransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional pTransaction As SqlTransaction = Nothing,
|
||||
Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Boolean
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(pSqlConnection, pTransactionMode, pTransaction)
|
||||
|
||||
Try
|
||||
Logger.Debug("ExecuteNonQueryWithConnectionObject: Running Command [{0}]", SqlCommand)
|
||||
Logger.Debug("ExecuteNonQueryWithConnectionObject: Running Command [{0}]", pSqlCommandObject.CommandText)
|
||||
|
||||
Using oSQLCOmmand = SqlConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SqlCommand
|
||||
oSQLCOmmand.CommandTimeout = Timeout
|
||||
oSQLCOmmand.Transaction = oTransaction
|
||||
oSQLCOmmand.ExecuteNonQuery()
|
||||
End Using
|
||||
pSqlCommandObject.Connection = pSqlConnection
|
||||
pSqlCommandObject.Transaction = oTransaction
|
||||
pSqlCommandObject.CommandTimeout = pTimeout
|
||||
pSqlCommandObject.ExecuteNonQuery()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
@@ -383,96 +440,126 @@ Public Class MSSQLServer
|
||||
Logger.Warn("ExecuteNonQueryWithConnectionObject: Error in ExecuteNonQueryWithConnectionObject while executing command: [{0}]-[{1}]", SqlCommand, SqlConnection.ConnectionString)
|
||||
Return False
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
MaybeCommitTransaction(oTransaction, pTransactionMode)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValue(SQLQuery As String) As Object Implements IDatabase.GetScalarValue
|
||||
Public Function GetScalarValue(pSqlQuery As String) As Object Implements IDatabase.GetScalarValue
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(SQLQuery, oConnection)
|
||||
Return GetScalarValueWithConnectionObject(pSqlQuery, oConnection)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValue(SQLCommand As String, Timeout As Integer) As Object Implements IDatabase.GetScalarValue
|
||||
Public Function GetScalarValue(pSqlCommandObject As SqlCommand) As Object
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(pSqlCommandObject, oConnection)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(pSqlCommand As String, pTimeout As Integer) As Object Implements IDatabase.GetScalarValue
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
Return GetScalarValueWithConnectionObject(pSqlCommand, oConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValue(SQLCommand As String, Transaction As SqlTransaction, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Public Function GetScalarValue(pSqlCommandObject As SqlCommand, pTimeout As Integer) As Object
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(SQLCommand, oConnection, TransactionMode.ExternalTransaction, Transaction, Timeout)
|
||||
Return GetScalarValueWithConnectionObject(pSqlCommandObject, oConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
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))
|
||||
Public Function GetScalarValue(pSQLCommand As String, pTransaction As SqlTransaction, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(pSQLCommand, oConnection, TransactionMode.ExternalTransaction, pTransaction, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Public Function GetScalarValueWithConnection(SQLCommand As String, pConnectionString As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Public Function GetScalarValue(pSQLCommandObject As SqlCommand, pTransaction As SqlTransaction, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Using oConnection = GetSQLConnection()
|
||||
Return GetScalarValueWithConnectionObject(pSQLCommandObject, oConnection, TransactionMode.ExternalTransaction, pTransaction, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Async Function GetScalarValueAsync(pSQLCommand As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of Object)
|
||||
Return Await Task.Run(Function() GetScalarValue(pSQLCommand, pTimeout))
|
||||
End Function
|
||||
|
||||
Public Async Function GetScalarValueAsync(pSQLCommandObject As SqlCommand, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Task(Of Object)
|
||||
Return Await Task.Run(Function() GetScalarValue(pSQLCommandObject, pTimeout))
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValueWithConnection(pSQLCommand As String, pConnectionString As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Using oConnection = GetConnection(pConnectionString)
|
||||
Return GetScalarValueWithConnectionObject(SQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, Timeout)
|
||||
Return GetScalarValueWithConnectionObject(pSQLCommand, oConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValueWithConnectionObject(SqlCommand As String, SqlConnection As SqlConnection,
|
||||
Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional Transaction As SqlTransaction = Nothing,
|
||||
Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Public Function GetScalarValueWithConnection(pSqlCommandObject As SqlCommand, pConnectionString As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Using oConnection = GetConnection(pConnectionString)
|
||||
Return GetScalarValueWithConnectionObject(pSqlCommandObject, oConnection, TransactionMode.WithTransaction, Nothing, pTimeout)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(SqlConnection, TransactionMode, Transaction)
|
||||
Public Function GetScalarValueWithConnectionObject(pSqlCommand As String, pSqlConnection As SqlConnection,
|
||||
Optional pTransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional pTransaction As SqlTransaction = Nothing,
|
||||
Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Dim oSQLCommand As New SqlCommand(pSqlCommand)
|
||||
Return GetScalarValueWithConnectionObject(oSQLCommand, pSqlConnection, pTransactionMode, pTransaction, pTimeout)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValueWithConnectionObject(pSqlCommandObject As SqlCommand, pSqlConnection As SqlConnection,
|
||||
Optional pTransactionMode As TransactionMode = TransactionMode.WithTransaction,
|
||||
Optional pTransaction As SqlTransaction = Nothing,
|
||||
Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
|
||||
Dim oTransaction As SqlTransaction = MaybeGetTransaction(pSqlConnection, pTransactionMode, pTransaction)
|
||||
Dim oResult As Object = Nothing
|
||||
|
||||
Try
|
||||
Using oSQLCOmmand = SqlConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SqlCommand
|
||||
oSQLCOmmand.CommandTimeout = Timeout
|
||||
oSQLCOmmand.Transaction = oTransaction
|
||||
pSqlCommandObject.Connection = pSqlConnection
|
||||
pSqlCommandObject.CommandTimeout = pTimeout
|
||||
pSqlCommandObject.Transaction = oTransaction
|
||||
oResult = pSqlCommandObject.ExecuteScalar()
|
||||
|
||||
oResult = oSQLCOmmand.ExecuteScalar()
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", SqlCommand)
|
||||
Logger.Warn("GetDatatableWithConnectionObject: Error in GetDatatableWithConnection while executing command: [{0}]", pSqlCommandObject)
|
||||
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
MaybeCommitTransaction(oTransaction, pTransactionMode)
|
||||
End Try
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String, Timeout As Integer) As Object
|
||||
Public Function GetScalarValue(pSqlCommand As SqlCommand, pOutputParameter As String, Optional pTimeout As Integer = Constants.DEFAULT_TIMEOUT) As Object
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Logger.Debug("GetScalarValue: Running Query [{0}]", SQLCommand)
|
||||
Logger.Debug("GetScalarValue: Running Query [{0}]", pSqlCommand)
|
||||
|
||||
If SQLCommand.CommandText.Contains(" ") Then
|
||||
SQLCommand.CommandType = CommandType.Text
|
||||
If pSqlCommand.CommandText.Contains(" ") Then
|
||||
pSqlCommand.CommandType = CommandType.Text
|
||||
Else
|
||||
SQLCommand.CommandType = CommandType.StoredProcedure
|
||||
pSqlCommand.CommandType = CommandType.StoredProcedure
|
||||
End If
|
||||
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
|
||||
SQLCommand.Connection = oConnection
|
||||
SQLCommand.Parameters(OutputParameter).Direction = ParameterDirection.Output
|
||||
SQLCommand.CommandTimeout = Timeout
|
||||
SQLCommand.ExecuteNonQuery()
|
||||
pSqlCommand.Connection = oConnection
|
||||
pSqlCommand.Parameters(pOutputParameter).Direction = ParameterDirection.Output
|
||||
pSqlCommand.CommandTimeout = pTimeout
|
||||
pSqlCommand.ExecuteNonQuery()
|
||||
oConnection.Close()
|
||||
|
||||
Return SQLCommand.Parameters(OutputParameter).Value
|
||||
Return pSqlCommand.Parameters(pOutputParameter).Value
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"GetScalarValue failed SQLCommand [{SQLCommand}]")
|
||||
Logger.Warn($"GetScalarValue failed SQLCommand [{pSqlCommand}]")
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
@@ -509,7 +596,6 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'<DebuggerStepThrough()>
|
||||
Private Sub NewExecuteNonQueryAsync_Callback(ByVal result As IAsyncResult)
|
||||
Dim command As SqlCommand = CType(result.AsyncState, SqlCommand)
|
||||
Dim res = command.EndExecuteNonQuery(result)
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
Public Const PROVIDER_MSSQL = "MS-SQL"
|
||||
Public Const PROVIDER_ORACLE = "ORACLE"
|
||||
Public Const PROVIDER_ODBC = "ODBC"
|
||||
Public Const PROVIDER_FIREBIRD = "FIREBIRD"
|
||||
|
||||
Public Const DEFAULT_TIMEOUT = 120
|
||||
Public Const DEFAULT_TABLE = "DDRESULT"
|
||||
Public Const DEFAULT_CONNECTION_ID = 1
|
||||
End Class
|
||||
|
||||
@@ -69,6 +69,9 @@
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Data.Odbc, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Data.Odbc.6.0.1\lib\net461\System.Data.Odbc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
@@ -96,6 +99,7 @@
|
||||
<Compile Include="Dispatcher.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Adapters\Firebird.vb" />
|
||||
<Compile Include="Helpers.vb" />
|
||||
<Compile Include="IDatabase.vb" />
|
||||
<Compile Include="Adapters\ODBC.vb" />
|
||||
<Compile Include="Adapters\Oracle.vb" />
|
||||
@@ -115,6 +119,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Queries.vb" />
|
||||
<Compile Include="TableCache.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Oracle.ManagedDataAccess.Client
|
||||
|
||||
Public Class Dispatcher
|
||||
Public ReadOnly Property Connections As New List(Of DispatcherConnection)
|
||||
@@ -7,27 +7,121 @@ Public Class Dispatcher
|
||||
Public ReadOnly Logger As Logger
|
||||
Public ReadOnly LogConfig As LogConfig
|
||||
|
||||
''' <summary>
|
||||
''' Create a new instance of Dispatcher. This is the preferred way to create the dispatcher.
|
||||
''' </summary>
|
||||
''' <param name="pLogConfig">An instance of LogConfig</param>
|
||||
''' <param name="pConnectionString">Initial connectionstring for connecting to DD_ECM database.</param>
|
||||
''' <returns>An instance of Dispatcher with connections</returns>
|
||||
Public Shared Function Create(pLogConfig As LogConfig, pConnectionString As String) As Dispatcher
|
||||
Dim oDecryptedConnectionString As String = MSSQLServer.DecryptConnectionString(pConnectionString)
|
||||
Dim oDatabase As MSSQLServer = New MSSQLServer(pLogConfig, oDecryptedConnectionString)
|
||||
Dim oTable As DataTable = oDatabase.GetDatatable(Queries.DD_ECM.Connections.AllConnections)
|
||||
|
||||
Dim oConnections As New List(Of DispatcherConnection)
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oConnection As DispatcherConnection = CreateFromDataRow(oRow)
|
||||
|
||||
If oConnection IsNot Nothing Then
|
||||
oConnections.Add(oConnection)
|
||||
End If
|
||||
Next
|
||||
|
||||
Return New Dispatcher(pLogConfig, oConnections)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Create a new instance of Dispatcher. Needs a manually constructed list of connection objects.
|
||||
''' </summary>
|
||||
''' <param name="pLogConfig">An instance of LogConfig</param>
|
||||
''' <param name="pConnections">A list of DispatcherConnection objects</param>
|
||||
''' <seealso cref="Create"/>
|
||||
Public Sub New(pLogConfig As LogConfig, pConnections As List(Of DispatcherConnection))
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
Connections = pConnections
|
||||
End Sub
|
||||
|
||||
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
|
||||
|
||||
''' <summary>
|
||||
''' Returns a Datatable from the database with the specified connection id
|
||||
''' </summary>
|
||||
''' <param name="pSQLCommand">The SQL query</param>
|
||||
''' <param name="pConnectionId">The connection id</param>
|
||||
''' <returns>A datatable with the results or nothing if an error occurred</returns>
|
||||
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
|
||||
''' <summary>
|
||||
''' Returns a Datatable from the database
|
||||
''' </summary>
|
||||
''' <param name="pSQLCommand">The SQL query</param>
|
||||
''' <returns>A datatable with the results or nothing if an error occurred</returns>
|
||||
Public Function GetDatatable(pSQLCommand As String) As DataTable
|
||||
Return GetDatatable(pSQLCommand, Constants.DEFAULT_CONNECTION_ID)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes a query without return value like INSERT or UPDATE from the database with the specified connection id and
|
||||
''' returns a boolean value indicating success or failure of the query
|
||||
''' </summary>
|
||||
''' <param name="pSQLCommand">The SQL query</param>
|
||||
''' <param name="pConnectionId">The connection id</param>
|
||||
''' <returns>True if the query was successful, otherwise false</returns>
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String, pConnectionId As Integer) As Boolean
|
||||
Dim oAdapter As IDatabase = GetAdapterClass(pConnectionId)
|
||||
Return oAdapter.ExecuteNonQuery(pSQLCommand)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Executes a query without return value like INSERT or UPDATE from the database and
|
||||
''' returns a boolean value indicating success or failure of the query
|
||||
''' </summary>
|
||||
''' <param name="pSQLCommand">The SQL query</param>
|
||||
''' <returns>True if the query was successful, otherwise false</returns>
|
||||
Public Function ExecuteNonQuery(pSQLCommand As String) As Boolean
|
||||
Return ExecuteNonQuery(pSQLCommand, Constants.DEFAULT_CONNECTION_ID)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns a single value from the database specified by the connection id
|
||||
''' </summary>
|
||||
''' <param name="pSQLCommand">The SQL query</param>
|
||||
''' <param name="pConnectionId">The connection id</param>
|
||||
''' <returns>A value of type object</returns>
|
||||
Public Function GetScalarValue(pSQLCommand As String, pConnectionId As Integer) As Object
|
||||
Dim oAdapter As IDatabase = GetAdapterClass(pConnectionId)
|
||||
Return oAdapter.GetScalarValue(pSQLCommand)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns a single value from the database
|
||||
''' </summary>
|
||||
''' <param name="pSQLCommand">The SQL query</param>
|
||||
''' <returns>A value of type object</returns>
|
||||
Public Function GetScalarValue(pSQLCommand As String) As Object
|
||||
Return GetScalarValue(pSQLCommand, Constants.DEFAULT_CONNECTION_ID)
|
||||
End Function
|
||||
|
||||
Private Function GetConnection(pConnectionId As Integer) As DispatcherConnection
|
||||
Dim oConnection As DispatcherConnection = Connections.
|
||||
Where(Function(conn) conn.Id = pConnectionId).
|
||||
@@ -49,7 +143,8 @@ Public Class Dispatcher
|
||||
|
||||
Select Case oConnection.ConnectionType
|
||||
Case ConnectionType.MSSQL
|
||||
Return New MSSQLServer(LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT)
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(oConnection.ConnectionString)
|
||||
Return New MSSQLServer(LogConfig, oConnectionString, Constants.DEFAULT_TIMEOUT)
|
||||
|
||||
Case ConnectionType.Oracle
|
||||
Return New Oracle(LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT)
|
||||
@@ -68,22 +163,66 @@ Public Class Dispatcher
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Enum ConnectionType
|
||||
MSSQL
|
||||
Oracle
|
||||
ODBC
|
||||
Firebird
|
||||
End Enum
|
||||
Private Shared Function CreateFromDataRow(pConnectionDataRow As DataRow) As DispatcherConnection
|
||||
Try
|
||||
Dim oGuid = pConnectionDataRow.Item("GUID")
|
||||
Dim oName = pConnectionDataRow.Item("BEZEICHNUNG")
|
||||
Dim oUser = pConnectionDataRow.Item("USERNAME")
|
||||
Dim oPassword = pConnectionDataRow.Item("PASSWORD")
|
||||
Dim oServer = pConnectionDataRow.Item("SERVER")
|
||||
Dim oDatabase = pConnectionDataRow.Item("DATENBANK")
|
||||
|
||||
Dim oConnectionType As ConnectionType
|
||||
Dim oConnectionString As String
|
||||
|
||||
Select Case pConnectionDataRow.Item("SQL_PROVIDER")
|
||||
Case "Oracle"
|
||||
' TODO: Test Oracle Connection
|
||||
oConnectionType = ConnectionType.Oracle
|
||||
oConnectionString = New OracleConnectionStringBuilder() With {
|
||||
.UserID = oUser,
|
||||
.Password = oPassword,
|
||||
.DataSource = oServer
|
||||
}.ToString()
|
||||
|
||||
Case "ODBC"
|
||||
' TODO: Test ODBC Connection
|
||||
oConnectionType = ConnectionType.ODBC
|
||||
oConnectionString = New Data.Odbc.OdbcConnectionStringBuilder() With {
|
||||
.ConnectionString = oServer
|
||||
}.ToString()
|
||||
|
||||
Case "Firebird"
|
||||
oConnectionType = ConnectionType.Firebird
|
||||
oConnectionString = New FirebirdSql.Data.FirebirdClient.FbConnectionStringBuilder() With {
|
||||
.UserID = oUser,
|
||||
.Password = oPassword,
|
||||
.DataSource = oServer,
|
||||
.Database = oDatabase
|
||||
}.ToString()
|
||||
|
||||
Case Else ' MSSQL
|
||||
oConnectionType = ConnectionType.MSSQL
|
||||
oConnectionString = New SqlClient.SqlConnectionStringBuilder() With {
|
||||
.UserID = oUser,
|
||||
.Password = oPassword,
|
||||
.DataSource = oServer,
|
||||
.InitialCatalog = oDatabase
|
||||
}.ToString()
|
||||
|
||||
End Select
|
||||
|
||||
Return New DispatcherConnection With {
|
||||
.Id = oGuid,
|
||||
.Name = oName,
|
||||
.ConnectionType = oConnectionType,
|
||||
.ConnectionString = oConnectionString
|
||||
}
|
||||
Catch ex As Exception
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
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
|
||||
|
||||
|
||||
10
Database/Helpers.vb
Normal file
10
Database/Helpers.vb
Normal file
@@ -0,0 +1,10 @@
|
||||
Public Class Helpers
|
||||
|
||||
Public Shared Function MaybeEscapeSQLCommand(pSQLCommand As String) As String
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports System.Data.Common
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Public Interface IDatabase
|
||||
''' <summary>
|
||||
@@ -7,8 +8,8 @@ Public Interface IDatabase
|
||||
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
|
||||
Function GetDatatable(SqlCommand As String, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
Function GetDatatable(SqlCommand As SqlCommand, Optional Timeout As Integer = Constants.DEFAULT_TIMEOUT) As DataTable
|
||||
|
||||
Function ExecuteNonQuery(SQLCommand As String, Timeout As Integer) As Boolean
|
||||
Function ExecuteNonQuery(SQLCommand As String) As Boolean
|
||||
|
||||
@@ -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.3")>
|
||||
<Assembly: AssemblyTrademark("2.2.7.5")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.2.7.3")>
|
||||
<Assembly: AssemblyFileVersion("2.2.7.3")>
|
||||
<Assembly: AssemblyVersion("2.2.7.5")>
|
||||
<Assembly: AssemblyFileVersion("2.2.7.5")>
|
||||
|
||||
11
Database/Queries.vb
Normal file
11
Database/Queries.vb
Normal file
@@ -0,0 +1,11 @@
|
||||
Public Class Queries
|
||||
Public Class DD_ECM
|
||||
Public Class ThirdPartyModules
|
||||
Public Const GdPictureLicense As String = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"
|
||||
End Class
|
||||
|
||||
Public Class Connections
|
||||
Public Const AllConnections As String = "SELECT * FROM TBDD_CONNECTION"
|
||||
End Class
|
||||
End Class
|
||||
End Class
|
||||
@@ -4,4 +4,5 @@
|
||||
<package id="EntityFramework.Firebird" version="6.4.0" targetFramework="net461" />
|
||||
<package id="FirebirdSql.Data.FirebirdClient" version="7.5.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.7.15" targetFramework="net461" />
|
||||
<package id="System.Data.Odbc" version="6.0.1" targetFramework="net461" />
|
||||
</packages>
|
||||
@@ -30,11 +30,46 @@ Public Class GraphQLInterface
|
||||
_userEmail = Email
|
||||
_userPassword = Password
|
||||
|
||||
Dim oStore As New X509Store(StoreName.Root, StoreLocation.CurrentUser)
|
||||
Dim oStoreNames As New List(Of StoreName) From {StoreName.Root, StoreName.My}
|
||||
Dim oStoreLocations As New List(Of StoreLocation) From {StoreLocation.CurrentUser, StoreLocation.LocalMachine}
|
||||
|
||||
Dim oCertificate As X509Certificate2 = Nothing
|
||||
|
||||
For Each oStoreLocation In oStoreLocations
|
||||
_logger.Debug("Checking Stores in Location [{0}]", oStoreLocation.ToString)
|
||||
|
||||
For Each oStoreName In oStoreNames
|
||||
oCertificate = FindCertificateByFingerprint(oStoreLocation, oStoreName, CertificateFingerprint, False)
|
||||
|
||||
If oCertificate IsNot Nothing Then
|
||||
_logger.Info("Certificate found in Store [{0}]/[{1}]!", oStoreName.ToString, oStoreLocation.ToString)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
|
||||
If oCertificate Is Nothing Then
|
||||
_logger.Warn("Certificate could not be found! Exiting.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_certificate = oCertificate
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function FindCertificateByFingerprint(pLocation As StoreLocation, pStoreName As StoreName, pFingerprint As String, pValidOnly As Boolean) As X509Certificate2
|
||||
Try
|
||||
Dim oStore As New X509Store(pStoreName, pLocation)
|
||||
Dim oLocation As String = pLocation.ToString
|
||||
|
||||
_logger.Info("Opening Store [{0}]/[{1}]..", oLocation, oStore.Name)
|
||||
oStore.Open(OpenFlags.ReadOnly)
|
||||
|
||||
|
||||
_logger.Debug("Available Certificates ({0}):", oStore.Certificates.Count)
|
||||
_logger.Info("Available Certificates in Store [{0}]/[{1}]: [{2}]", oLocation, oStore.Name, oStore.Certificates.Count)
|
||||
|
||||
For Each oCert In oStore.Certificates
|
||||
_logger.Debug("FriendlyName: {0}", oCert.FriendlyName)
|
||||
@@ -43,20 +78,24 @@ Public Class GraphQLInterface
|
||||
_logger.Debug("Fingerprint: {0}", oCert.Thumbprint)
|
||||
Next
|
||||
|
||||
_logger.Debug("Looking for Certificate with Fingerprint [{0}]", CertificateFingerprint)
|
||||
_logger.Debug("Looking for Certificate with Fingerprint [{0}]", pFingerprint)
|
||||
Dim oFoundCerts = oStore.Certificates.Find(X509FindType.FindByThumbprint, pFingerprint, pValidOnly)
|
||||
|
||||
Dim oFoundCerts = oStore.Certificates.Find(X509FindType.FindByThumbprint, CertificateFingerprint, False)
|
||||
_logger.Debug("Closing store..")
|
||||
oStore.Close()
|
||||
|
||||
If oFoundCerts.Count = 0 Then
|
||||
_logger.Warn("Certificate could not be found! Exiting.")
|
||||
Exit Sub
|
||||
_logger.Debug("Certificate with Fingerprint [{0}] not found in Store [{1}]/[{2}]", pFingerprint, oLocation, oStore.Name)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_certificate = oFoundCerts.Item(0)
|
||||
Return oFoundCerts.Item(0)
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Unexpected error while searching for certificate with Fingerprint [{0}].", pFingerprint)
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Public Sub SaveCookies(Cookie As Cookie)
|
||||
GetCookies().Add(Cookie)
|
||||
@@ -144,13 +183,18 @@ Public Class GraphQLInterface
|
||||
|
||||
Private Function GetRequest(Url As String, PostData As Byte()) As HttpWebRequest
|
||||
Try
|
||||
' Set supported TLS versions for WebRequest
|
||||
' Source: https://stackoverflow.com/questions/10822509/the-request-was-aborted-could-not-create-ssl-tls-secure-channel
|
||||
'SetSecurityOptions()
|
||||
'SetSecurityOptionsInsecure()
|
||||
'SetSecurityOptionsModern()
|
||||
|
||||
Dim oRequest As HttpWebRequest = WebRequest.Create($"{_baseUrl}{Url}")
|
||||
oRequest.Method = "POST"
|
||||
oRequest.ContentType = "application/json"
|
||||
oRequest.ContentLength = PostData.Length
|
||||
oRequest.ClientCertificates.Add(_certificate)
|
||||
oRequest.CookieContainer = GetCookies()
|
||||
|
||||
oRequest.Proxy = Nothing
|
||||
|
||||
If Proxy Is Nothing Then
|
||||
@@ -167,6 +211,26 @@ Public Class GraphQLInterface
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub SetSecurityOptions()
|
||||
ServicePointManager.SecurityProtocol =
|
||||
SecurityProtocolType.Tls Or
|
||||
SecurityProtocolType.Tls11 Or
|
||||
SecurityProtocolType.Tls12
|
||||
End Sub
|
||||
|
||||
Private Sub SetSecurityOptionsInsecure()
|
||||
ServicePointManager.SecurityProtocol =
|
||||
SecurityProtocolType.Tls Or
|
||||
SecurityProtocolType.Tls11 Or
|
||||
SecurityProtocolType.Tls12 Or
|
||||
SecurityProtocolType.Ssl3
|
||||
End Sub
|
||||
|
||||
Private Sub SetSecurityOptionsModern()
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
|
||||
End Sub
|
||||
|
||||
Private Function GetCookies() As CookieContainer
|
||||
If _cookieJar Is Nothing Then
|
||||
_cookieJar = New CookieContainer(MAX_COOKIE_COUNT, MAX_COOKIE_COUNT_PER_DOMAIN, MAX_COOKIE_SIZE)
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
<AssemblyName>DigitalData.Modules.Interfaces</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -98,6 +99,7 @@
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
@@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("Modules.Interfaces")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2021")>
|
||||
<Assembly: AssemblyTrademark("1.7.0.0")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("1.7.4.0")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.7.1.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.1.0")>
|
||||
<Assembly: AssemblyVersion("1.7.4.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.4.0")>
|
||||
|
||||
2
Interfaces/My Project/Resources.Designer.vb
generated
2
Interfaces/My Project/Resources.Designer.vb
generated
@@ -22,7 +22,7 @@ Namespace My.Resources
|
||||
'''<summary>
|
||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
|
||||
2
Interfaces/My Project/Settings.Designer.vb
generated
2
Interfaces/My Project/Settings.Designer.vb
generated
@@ -15,7 +15,7 @@ Option Explicit On
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<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-7.5.0.0" newVersion="7.5.0.0" />
|
||||
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.0.0" newVersion="7.5.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
<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-7.5.0.0" newVersion="7.5.0.0" />
|
||||
<assemblyIdentity name="FirebirdSql.Data.FirebirdClient" publicKeyToken="3750abcc3150b00c" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.5.0.0" newVersion="7.5.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
<AssemblyName>DigitalData.Modules.Jobs</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Empty</MyType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
||||
2
Jobs/My Project/Settings.Designer.vb
generated
2
Jobs/My Project/Settings.Designer.vb
generated
@@ -14,7 +14,7 @@ Option Explicit On
|
||||
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class Settings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Public Class Mail
|
||||
Private LogConfig As LogConfig
|
||||
Private Logger As DigitalData.Modules.Logging.Logger
|
||||
Public Sub New(LogConfig As LogConfig)
|
||||
LogConfig = LogConfig
|
||||
Logger = LogConfig.GetLogger()
|
||||
Logger.Info("MailingClass initialized")
|
||||
End Sub
|
||||
Public Function Connecttest()
|
||||
|
||||
End Function
|
||||
End Class
|
||||
@@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C9827B8D-9EF9-411A-A6BF-4807794F8C8F}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Mailfunctions</RootNamespace>
|
||||
<AssemblyName>Mailfunctions</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Windows</MyType>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>Mailfunctions.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>Mailfunctions.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mail">
|
||||
<HintPath>P:\Visual Studio Projekte\Bibliotheken\Limilabs\Mail.dll\Mail.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.7.15\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Mail.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Logging\Logging.vbproj">
|
||||
<Project>{903b2d7d-3b80-4be9-8713-7447b704e1b0}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
13
Mailfunctions/My Project/Application.Designer.vb
generated
13
Mailfunctions/My Project/Application.Designer.vb
generated
@@ -1,13 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>false</MySubMain>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>1</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
@@ -1,35 +0,0 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
' die einer Assembly zugeordnet sind.
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("Mailfunctions")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("Mailfunctions")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2021")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID wird für die typelib-ID verwendet, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("ba66c227-214d-4a87-9134-1f93f51d8bf9")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
' Hauptversion
|
||||
' Nebenversion
|
||||
' Buildnummer
|
||||
' Revision
|
||||
'
|
||||
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
' indem Sie "*" wie unten gezeigt eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
62
Mailfunctions/My Project/Resources.Designer.vb
generated
62
Mailfunctions/My Project/Resources.Designer.vb
generated
@@ -1,62 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
'class via a tool like ResGen or Visual Studio.
|
||||
'To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
'with the /str option, or rebuild your VS project.
|
||||
'''<summary>
|
||||
''' A strongly-typed resource class, for looking up localized strings, etc.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Returns the cached ResourceManager instance used by this class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Mailfunctions.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Overrides the current thread's CurrentUICulture property for all
|
||||
''' resource lookups using this strongly typed resource class.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set(ByVal value As Global.System.Globalization.CultureInfo)
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
Mailfunctions/My Project/Settings.Designer.vb
generated
73
Mailfunctions/My Project/Settings.Designer.vb
generated
@@ -1,73 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
|
||||
|
||||
#Region "My.Settings Auto-Save Functionality"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.Mailfunctions.My.MySettings
|
||||
Get
|
||||
Return Global.Mailfunctions.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.7.15" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -294,9 +294,12 @@ Public Class Email
|
||||
_logger.Debug("SSL = false")
|
||||
myClient.EnableSsl = False
|
||||
End If
|
||||
_logger.Debug($"mailUser [{mailUser}]")
|
||||
myClient.Credentials = New NetworkCredential(mailUser, mailPW)
|
||||
myClient.UseDefaultCredentials = False
|
||||
If mailUser <> String.Empty Then
|
||||
_logger.Debug($"mailUser [{mailUser}]")
|
||||
myClient.Credentials = New NetworkCredential(mailUser, mailPW)
|
||||
myClient.UseDefaultCredentials = False
|
||||
End If
|
||||
|
||||
|
||||
If Test = True Then
|
||||
myMesssage.Body = $"This is the body (text will be replaced within profile)! <br> mailsmtp: {mailsmtp} <br> mailport: {mailport} <br> mailUser: {mailUser} <br> mailPW: XXXX <br> AUTH_TYPE: {AUTH_TYPE}"
|
||||
|
||||
@@ -5,7 +5,6 @@ Imports Limilabs.Mail
|
||||
Imports Limilabs.Mail.MIME
|
||||
Imports Limilabs.Mail.MSG
|
||||
Imports Limilabs.Client.IMAP
|
||||
Imports Limilabs.Client.SMTP
|
||||
Imports Limilabs.Client
|
||||
|
||||
Public Class Email2
|
||||
@@ -41,17 +40,17 @@ Public Class Email2
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function New_SMTPConnection(pSMTP As Smtp, pServer As String, pUsername As String, pPassword As String, pSecurity As EmailSecurity, Optional pPort As Integer = 0) As Smtp
|
||||
Public Function New_SMTPConnection(pSMTP As Limilabs.Client.SMTP.Smtp, pServer As String, pUsername As String, pPassword As String, pSecurity As EmailSecurity, Optional pPort As Integer = 0) As Limilabs.Client.SMTP.Smtp
|
||||
Try
|
||||
Logger.Info("Connecting to SMTP server [{0}:{1}] with user [{2}]", pServer, pPort, pUsername)
|
||||
|
||||
Dim oPort As Integer
|
||||
If pPort = 0 Then
|
||||
If pSecurity = EmailSecurity.SSL Then
|
||||
oPort = Smtp.DefaultSSLPort
|
||||
oPort = Limilabs.Client.SMTP.Smtp.DefaultSSLPort
|
||||
|
||||
Else
|
||||
oPort = Smtp.DefaultPort
|
||||
oPort = Limilabs.Client.SMTP.Smtp.DefaultPort
|
||||
|
||||
End If
|
||||
|
||||
@@ -70,9 +69,10 @@ Public Class Email2
|
||||
pSMTP.StartTLS()
|
||||
End If
|
||||
Logger.Debug("Connection to SMTP Server [{0}] established!", pServer)
|
||||
|
||||
Logger.Debug("Logging in with user [{0}]", pUsername)
|
||||
pSMTP.UseBestLogin(pUsername, pPassword)
|
||||
If pUsername <> String.Empty Then
|
||||
Logger.Debug("Logging in with user [{0}]", pUsername)
|
||||
pSMTP.UseBestLogin(pUsername, pPassword)
|
||||
End If
|
||||
|
||||
Return pSMTP
|
||||
|
||||
@@ -146,7 +146,7 @@ Public Class Email2
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Test_SMTPLogin(pClient As Smtp) As Boolean
|
||||
Public Function Test_SMTPLogin(pClient As Limilabs.Client.SMTP.Smtp) As Boolean
|
||||
Logger.Info("Testing Login to IMAP Server")
|
||||
|
||||
Try
|
||||
@@ -241,7 +241,7 @@ Public Class Email2
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Send_SMTPMessage(pClient As Smtp, pSender As String, pReceiver As String, pSubject As String, pBody As String) As Boolean
|
||||
Public Function Send_SMTPMessage(pClient As Limilabs.Client.SMTP.Smtp, pSender As String, pReceiver As String, pSubject As String, pBody As String) As Boolean
|
||||
Logger.Info("Sending Message with Subject [{0}]", pSubject)
|
||||
|
||||
Try
|
||||
@@ -252,9 +252,9 @@ Public Class Email2
|
||||
oBuilder.Text = pBody
|
||||
|
||||
Dim oMail As IMail = oBuilder.Create()
|
||||
Dim oResult As ISendMessageResult = pClient.SendMessage(oMail)
|
||||
Dim oResult As Limilabs.Client.SMTP.ISendMessageResult = pClient.SendMessage(oMail)
|
||||
|
||||
If oResult.Status = SendMessageStatus.Success Then
|
||||
If oResult.Status = Limilabs.Client.SMTP.SendMessageStatus.Success Then
|
||||
Logger.Debug("Message sent successful!")
|
||||
Return True
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ Public Class Limilab
|
||||
|
||||
Dim email As IMail = oMailBuilder.Create()
|
||||
' Send the message
|
||||
Using oSmtp As New Smtp()
|
||||
Using oSmtp As New Limilabs.Client.SMTP.Smtp()
|
||||
AddHandler oSmtp.ServerCertificateValidate, AddressOf Validate
|
||||
Logger.Debug($"AUTH_TYPE [{AUTH_TYPE}]")
|
||||
If AUTH_TYPE = "SSL" Then
|
||||
|
||||
254
Messaging/MailSender.vb
Normal file
254
Messaging/MailSender.vb
Normal file
@@ -0,0 +1,254 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports System.Net.Security
|
||||
Imports Limilabs.Client.SMTP
|
||||
Imports Limilabs.Client
|
||||
|
||||
Public Class MailSender
|
||||
Inherits BaseClass
|
||||
|
||||
Private Server As String
|
||||
Private Port As Integer
|
||||
Private User As String
|
||||
Private Password As String
|
||||
Private AuthType As String
|
||||
|
||||
Private Session As Smtp = Nothing
|
||||
Public Connected2Server As Boolean = False
|
||||
|
||||
Const SMTP_IGNORED_ERRORS As SslPolicyErrors =
|
||||
SslPolicyErrors.RemoteCertificateChainErrors Or ' self-signed
|
||||
SslPolicyErrors.RemoteCertificateNameMismatch ' name mismatch
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Start a connection with the specified server and return the SMTP client. Throws if there was an error.
|
||||
''' </summary>
|
||||
''' <param name="pServer"></param>
|
||||
''' <param name="pPort"></param>
|
||||
''' <param name="pUser"></param>
|
||||
''' <param name="pPassword"></param>
|
||||
''' <param name="pAuthType"></param>
|
||||
''' <returns></returns>
|
||||
Public Function ConnectToServer(pServer As String, pPort As Integer, pUser As String, pPassword As String, pAuthType As String) As Boolean
|
||||
Server = pServer
|
||||
Port = pPort
|
||||
User = pUser
|
||||
Password = pPassword
|
||||
AuthType = pAuthType
|
||||
|
||||
Logger.Debug("Connecting to Server..")
|
||||
Logger.Debug("SMTP Server: [{0}]", Server)
|
||||
Logger.Debug("SMTP Port: [{0}]", Port)
|
||||
Logger.Debug("SMTP User: [{0}]", User)
|
||||
Logger.Debug("SMTP AuthType: [{0}]", AuthType)
|
||||
|
||||
Dim oSession As New Smtp()
|
||||
AddHandler oSession.ServerCertificateValidate, AddressOf Session_ServerCertificateValidate
|
||||
|
||||
Logger.Debug("Initializing Connection with Auth type [{0}].", pAuthType)
|
||||
|
||||
If pAuthType = "SSL" Then
|
||||
Try
|
||||
If pPort = 465 Then
|
||||
Logger.Debug("Connecting with [ConnectSSL] on [{0}/{1}]", pServer, pPort)
|
||||
oSession.ConnectSSL(pServer)
|
||||
Else
|
||||
Logger.Debug("Connecting with [Connect] on [{0}/{1}]", pServer, pPort)
|
||||
oSession.Connect(pServer, pPort)
|
||||
End If
|
||||
Logger.Info("Connection Successful!")
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while connecting with Auth type SSL!")
|
||||
Logger.Error(ex)
|
||||
|
||||
Return False
|
||||
End Try
|
||||
|
||||
ElseIf AuthType = "SSL/TLS" Or AuthType = "STARTTLS" Then
|
||||
|
||||
Try
|
||||
Logger.Debug("Connecting with [Connect] on [{0}/{1}]", pServer, pPort)
|
||||
oSession.Connect(pServer, pPort)
|
||||
Logger.Info("Connection Successful!")
|
||||
|
||||
Dim oSupportsSTARTTLS As Boolean = oSession.SupportedExtensions.Contains(Limilabs.Client.SMTP.SmtpExtension.StartTLS)
|
||||
Logger.Debug("Server supports STARTTLS: [{0}]", oSupportsSTARTTLS)
|
||||
|
||||
If oSupportsSTARTTLS Then
|
||||
oSession.StartTLS()
|
||||
Logger.Info("STARTTLS Successful!")
|
||||
Else
|
||||
Logger.Debug("Server does not support STARTTLS. Enabling TLS1.2 instead.")
|
||||
oSession.SSLConfiguration.EnabledSslProtocols = Security.Authentication.SslProtocols.Tls12
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while connecting with Auth type STARTTLS!")
|
||||
Logger.Error(ex)
|
||||
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Else
|
||||
Try
|
||||
Logger.Debug("Unknown Auth type. Using PLAINTEXT connection.")
|
||||
oSession.Connect(pServer)
|
||||
Logger.Info("Connection Successful!")
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while connecting with Auth type PLAINTEXT!")
|
||||
Logger.Error(ex)
|
||||
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End If
|
||||
|
||||
Try
|
||||
If pUser <> String.Empty Then
|
||||
Logger.Info("Logging in with user [{0}]", pUser)
|
||||
oSession.UseBestLogin(pUser, pPassword)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while connecting with Auth type PLAINTEXT!")
|
||||
Logger.Error(ex)
|
||||
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Session = oSession
|
||||
Connected2Server = True
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Public Function DisconnectFromServer() As Boolean
|
||||
Try
|
||||
If Session IsNot Nothing Then
|
||||
Logger.Debug("Closing connection to Server [{0}].", Server)
|
||||
Session.Close()
|
||||
Session = Nothing
|
||||
Logger.Info("Connection to Server [{0}] closed.", Server)
|
||||
Else
|
||||
Logger.Debug("No connection currently open. Exiting.")
|
||||
End If
|
||||
|
||||
Return True
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub Session_ServerCertificateValidate(sender As Object, e As ServerCertificateValidateEventArgs)
|
||||
' i dont know why it works but it does
|
||||
If (e.SslPolicyErrors And Not SMTP_IGNORED_ERRORS) = SslPolicyErrors.None Then
|
||||
e.IsValid = True
|
||||
Return
|
||||
End If
|
||||
e.IsValid = False
|
||||
End Sub
|
||||
|
||||
Public Function SendMail(pSendTo As List(Of String), pSendFrom As String, pSubject As String, pBody As String, pCreationTime As Date, pAttachments As List(Of String), pTest As Boolean) As Boolean
|
||||
Dim oSuccessfulSends As New List(Of String)
|
||||
Dim oFailedSends As New List(Of String)
|
||||
|
||||
For Each oSendToAddress In pSendTo
|
||||
Dim oResult = SendMailTo(Session, oSendToAddress, pSendFrom, pSubject, pBody, pCreationTime, pAttachments, pTest)
|
||||
|
||||
If oResult = True Then
|
||||
oSuccessfulSends.Add(oSendToAddress)
|
||||
Else
|
||||
oFailedSends.Add(oSendToAddress)
|
||||
End If
|
||||
Next
|
||||
|
||||
Logger.Debug("Sent [{0}] mails.", pSendTo.Count)
|
||||
Logger.Debug("Successful [{0}]", oSuccessfulSends.Count)
|
||||
Logger.Debug("Failed [{0}]", oFailedSends.Count)
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function SendMailTo(pSession As Smtp, pSendTo As String, pSendFrom As String, pSubject As String, pBody As String, pCreationTime As Date, pAttachments As List(Of String), pTest As Boolean)
|
||||
Try
|
||||
If IsNothing(pSession) Then
|
||||
Logger.Info("ATTENTION-ERROR: pSession is nothing!")
|
||||
Return False
|
||||
End If
|
||||
Logger.Debug("Preparing to send mail to [{0}]", pSendTo)
|
||||
|
||||
Dim oMailBuilder As New Limilabs.Mail.MailBuilder()
|
||||
oMailBuilder.From.Add(New Limilabs.Mail.Headers.MailBox(pSendFrom))
|
||||
oMailBuilder.To.Add(New Limilabs.Mail.Headers.MailBox(pSendTo))
|
||||
oMailBuilder.Subject = pSubject
|
||||
|
||||
Logger.Debug("Setting body for mail")
|
||||
SetBody(oMailBuilder, pBody, pCreationTime, pTest)
|
||||
|
||||
Logger.Debug("Adding [{0}] attachments to mail", pAttachments.Count)
|
||||
oMailBuilder = AddAttachments(oMailBuilder, pAttachments)
|
||||
|
||||
Logger.Debug("Now sending mail..")
|
||||
If IsNothing(oMailBuilder) Then
|
||||
Logger.Info("ATTENTION-ERROR: oMailBuilder is nothing!")
|
||||
Return False
|
||||
End If
|
||||
Dim oMail = oMailBuilder.Create()
|
||||
pSession.SendMessage(oMail)
|
||||
Logger.Info("Mail to [{0}] has been sent.", pSendTo)
|
||||
|
||||
Return True
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error while sending mail to [{0}]", pSendTo)
|
||||
Logger.Error(ex)
|
||||
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function SetBody(pMailBuilder As Limilabs.Mail.MailBuilder, pBody As String, pCreationTime As Date, pTest As Boolean) As Limilabs.Mail.MailBuilder
|
||||
If pCreationTime <> Date.MinValue Then
|
||||
pBody &= $"<p>Creation-time: {pCreationTime}</p>"
|
||||
End If
|
||||
|
||||
If pTest Then
|
||||
pBody = $"<p>This Is a Testmail!<br/>
|
||||
The body-text will be replaced within profile!<br/>
|
||||
Server/Port: {Server}/{Port}<br/>
|
||||
User: {User}<br/>
|
||||
Password: XXXX<br/>
|
||||
Auth Type: {AuthType}</p>"
|
||||
End If
|
||||
|
||||
Logger.Debug("Final Mailbody is: [{0}]", pBody)
|
||||
pMailBuilder.Html = pBody
|
||||
|
||||
Return pMailBuilder
|
||||
End Function
|
||||
|
||||
Private Function AddAttachments(pMailBuilder As Limilabs.Mail.MailBuilder, pAttachments As List(Of String)) As Limilabs.Mail.MailBuilder
|
||||
For Each oAttachment In pAttachments
|
||||
Try
|
||||
' Read attachment from disk, add it to Attachments collection
|
||||
If IO.File.Exists(oAttachment) Then
|
||||
Logger.Debug("Adding attachment [{0}] to mail.", oAttachment)
|
||||
pMailBuilder.AddAttachment(oAttachment)
|
||||
Else
|
||||
Logger.Warn("Attachment [{0}] does not exist. Skipping.", oAttachment)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Could not read or add attachment [{0}]!", oAttachment)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
Return pMailBuilder
|
||||
End Function
|
||||
End Class
|
||||
@@ -95,7 +95,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="SMS.vb" />
|
||||
<Compile Include="MailSender.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
@@ -118,6 +118,10 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Base\Base.vbproj">
|
||||
<Project>{6ea0c51f-c2b1-4462-8198-3de0b32b74f8}</Project>
|
||||
<Name>Base</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Filesystem\Filesystem.vbproj">
|
||||
<Project>{991d0231-4623-496d-8bd0-9ca906029cbc}</Project>
|
||||
<Name>Filesystem</Name>
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.7.3.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.3.0")>
|
||||
<Assembly: AssemblyVersion("1.7.4.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.4.0")>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Public Class SMS
|
||||
|
||||
End Class
|
||||
16
Modules.sln
16
Modules.sln
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31005.135
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32929.385
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Base", "Base\Base.vbproj", "{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}"
|
||||
EndProject
|
||||
@@ -27,8 +27,6 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Logging", "Logging\Logging.
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Logging.Test", "Logging.Test\Logging.Test.vbproj", "{3207D8E7-36E3-4714-9B03-7B5B3D6D351A}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Mailfunctions", "Mailfunctions\Mailfunctions.vbproj", "{C9827B8D-9EF9-411A-A6BF-4807794F8C8F}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Patterns", "Patterns\Patterns.vbproj", "{7C3B0C7E-59FE-4E1A-A655-27AE119F9444}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Windows", "Windows\Windows.vbproj", "{5EFAEF9B-90B9-4F05-9F70-F79AD77FFF86}"
|
||||
@@ -39,6 +37,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ZooFlow", "ZooFlow\ZooFlow.
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Messaging", "Messaging\Messaging.vbproj", "{AF664D85-0A4B-4BAB-A2F8-83110C06553A}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Database.Test", "Database.Test\Database.Test.vbproj", "{91B4DFC0-543C-43A7-A9E0-6817DCA277EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -93,10 +93,6 @@ Global
|
||||
{3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3207D8E7-36E3-4714-9B03-7B5B3D6D351A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C9827B8D-9EF9-411A-A6BF-4807794F8C8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C9827B8D-9EF9-411A-A6BF-4807794F8C8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C9827B8D-9EF9-411A-A6BF-4807794F8C8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C9827B8D-9EF9-411A-A6BF-4807794F8C8F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7C3B0C7E-59FE-4E1A-A655-27AE119F9444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7C3B0C7E-59FE-4E1A-A655-27AE119F9444}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7C3B0C7E-59FE-4E1A-A655-27AE119F9444}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -117,6 +113,10 @@ Global
|
||||
{AF664D85-0A4B-4BAB-A2F8-83110C06553A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AF664D85-0A4B-4BAB-A2F8-83110C06553A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AF664D85-0A4B-4BAB-A2F8-83110C06553A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{91B4DFC0-543C-43A7-A9E0-6817DCA277EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{91B4DFC0-543C-43A7-A9E0-6817DCA277EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{91B4DFC0-543C-43A7-A9E0-6817DCA277EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{91B4DFC0-543C-43A7-A9E0-6817DCA277EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
37
Patterns/Modules/Custom.vb
Normal file
37
Patterns/Modules/Custom.vb
Normal file
@@ -0,0 +1,37 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Modules
|
||||
''' <summary>
|
||||
''' Custom Patterns that are defined at runtime
|
||||
''' </summary>
|
||||
Public Class Custom
|
||||
Inherits BaseModule
|
||||
Implements IModule
|
||||
|
||||
Public Property PatternIdentifier As String = "CUST" Implements IModule.PatternIdentifier
|
||||
Public Property IsComplex As Boolean = False Implements IModule.IsComplex
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function Replace(pInput As String, pCustomValues As Dictionary(Of String, String)) As String
|
||||
Dim oResult = pInput
|
||||
Dim oCounter = 0
|
||||
Dim oNow As Date = Now
|
||||
|
||||
Logger.Trace("Replacing Custom Patterns")
|
||||
|
||||
While HasPattern(oResult, PatternIdentifier)
|
||||
For Each oCustomValue In pCustomValues
|
||||
If ContainsPatternAndValue(oResult, PatternIdentifier, oCustomValue.Key) Then
|
||||
oResult = ReplacePattern(oResult, PatternIdentifier, oCustomValue.Value)
|
||||
End If
|
||||
Next
|
||||
IncrementCounterOrThrow(oCounter)
|
||||
End While
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.1.0.1")>
|
||||
<Assembly: AssemblyFileVersion("1.1.0.1")>
|
||||
<Assembly: AssemblyVersion("1.2.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.2.0.0")>
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
<Compile Include="Modules\Globix\GlobixAutomatic.vb" />
|
||||
<Compile Include="Modules\IDB.vb" />
|
||||
<Compile Include="Modules\Globix\GlobixManual.vb" />
|
||||
<Compile Include="Modules\Custom.vb" />
|
||||
<Compile Include="Modules\Windream.vb" />
|
||||
<Compile Include="Modules\User.vb" />
|
||||
<Compile Include="IModule.vb" />
|
||||
|
||||
@@ -139,6 +139,23 @@ Public Class Patterns2
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReplaceCustomValues(pInput As String, pCustomValues As Dictionary(Of String, String)) As String
|
||||
Logger.Debug("Replacing Custom Values")
|
||||
|
||||
Dim oResult = pInput
|
||||
|
||||
Try
|
||||
Dim oCustom = New Modules.Custom(LogConfig)
|
||||
oResult = oCustom.Replace(oResult, pCustomValues)
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while replacing Globix Values")
|
||||
Logger.Error(ex)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
|
||||
#Region "Helper Functions"
|
||||
''' <summary>
|
||||
''' Wraps a pattern-type and -value in the common format: {#type#value}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
|
||||
Public Class Environment
|
||||
Public Property User As State.UserState
|
||||
Public Property Settings As State.SettingsState
|
||||
Public Property Service As State.ServiceState
|
||||
Public Property User As New State.UserState
|
||||
Public Property Settings As New State.SettingsState
|
||||
Public Property Service As New State.ServiceState
|
||||
Public Property Database As MSSQLServer
|
||||
Public Property DatabaseIDB As MSSQLServer
|
||||
Public Property Modules As Dictionary(Of String, State.ModuleState)
|
||||
Public Property Modules As New Dictionary(Of String, State.ModuleState)
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user