9 Commits

Author SHA1 Message Date
Jonathan Jenne
25a4156429 Messaging: Version 1.7.4.0 2022-10-17 10:41:47 +02:00
Jonathan Jenne
dbb155a849 Messaging: Add MailSender class 2022-10-17 10:41:07 +02:00
Jonathan Jenne
6be8dc54f5 Patterns: Version 1.2.0.0 2022-10-17 10:40:38 +02:00
Jonathan Jenne
b4528788e3 Patterns: Add Custom module 2022-10-17 10:40:10 +02:00
Jonathan Jenne
2a53d24a91 Zooflow: fix environment 2022-10-17 10:39:56 +02:00
Jonathan Jenne
cd6402e726 Database: Version 2.2.7.4 2022-10-17 10:39:41 +02:00
Jonathan Jenne
b6659b991b Version 1.0.0.1 2022-10-17 10:39:05 +02:00
Jonathan Jenne
375a67bbb4 Database: Improve dispatcher 2022-10-17 10:38:37 +02:00
Jonathan Jenne
410cae21ea Base: Add Performance class for calling ngen 2022-10-17 10:37:42 +02:00
21 changed files with 545 additions and 44 deletions

View File

@@ -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">

View File

@@ -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
View 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

View File

@@ -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

View File

@@ -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" />
@@ -115,6 +118,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Queries.vb" />
<Compile Include="TableCache.vb" />
</ItemGroup>
<ItemGroup>

View File

@@ -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

View File

@@ -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.4")>
<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.4")>
<Assembly: AssemblyFileVersion("2.2.7.4")>

11
Database/Queries.vb Normal file
View 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

View File

@@ -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>

View File

@@ -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
@@ -146,7 +145,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 +240,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 +251,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

View File

@@ -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

244
Messaging/MailSender.vb Normal file
View File

@@ -0,0 +1,244 @@
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
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.Info("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
Logger.Info("Logging in with user [{0}]", pUser)
oSession.UseBestLogin(pUser, pPassword)
Catch ex As Exception
Logger.Warn("Error while connecting with Auth type PLAINTEXT!")
Logger.Error(ex)
Return False
End Try
Session = oSession
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
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..")
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

View File

@@ -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>

View File

@@ -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")>

View File

@@ -1,3 +0,0 @@
Public Class SMS
End Class

View 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

View File

@@ -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")>

View File

@@ -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" />

View File

@@ -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}

View File

@@ -1,8 +1,8 @@
Imports DigitalData.Modules.Database
Public Class Environment
Public Property User As State.UserState
Public Property Settings As State.SettingsState
Public Property User As New State.UserState
Public Property Settings As New State.SettingsState
Public Property Service As State.ServiceState
Public Property Database As MSSQLServer
Public Property DatabaseIDB As MSSQLServer