Compare commits
6 Commits
c7e95bcdc5
...
ff7b2c8612
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff7b2c8612 | ||
|
|
b9e96b1316 | ||
|
|
5b97238d66 | ||
|
|
bbd6704262 | ||
|
|
a8cfe8c909 | ||
|
|
d011f1b109 |
@@ -1,38 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="DDEmailService.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<applicationSettings>
|
||||
<DDEmailService.My.MySettings>
|
||||
<setting name="FB_ConnString" serializeAs="String">
|
||||
<value>172.24.12.41</value>
|
||||
</setting>
|
||||
<setting name="SQLSERVER_CS" serializeAs="String">
|
||||
<value>Data Source=172.24.12.41\Tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd</value>
|
||||
</setting>
|
||||
<setting name="SQLSERVER_CS_TEST" serializeAs="String">
|
||||
<value>Data Source=172.24.12.41\Tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd</value>
|
||||
</setting>
|
||||
<setting name="FB_DATABASE" serializeAs="String">
|
||||
<value>172.24.12.41:E:\DB\Firebird\Databases\EDMI_TEMPLATE\EDMI_MASTER.FDB</value>
|
||||
</setting>
|
||||
<setting name="FB_USER" serializeAs="String">
|
||||
<value>sysdba</value>
|
||||
</setting>
|
||||
<setting name="FB_PW" serializeAs="String">
|
||||
<value>dd</value>
|
||||
</setting>
|
||||
<setting name="DEBUG" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</DDEmailService.My.MySettings>
|
||||
</applicationSettings>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
|
||||
19
Services.EmailService/Config.vb
Normal file
19
Services.EmailService/Config.vb
Normal file
@@ -0,0 +1,19 @@
|
||||
Imports DigitalData.Modules.Config.ConfigAttributes
|
||||
|
||||
Public Class Config
|
||||
<ConnectionString>
|
||||
Public Property FirebirdServer As String = ""
|
||||
<ConnectionString>
|
||||
Public Property FirebirdDatabase As String = ""
|
||||
<ConnectionString>
|
||||
Public Property FirebirdUser As String = ""
|
||||
<ConnectionString>
|
||||
Public Property FirebirdPassword As String = ""
|
||||
|
||||
<ConnectionString>
|
||||
Public Property SQLServerConnectionString As String = ""
|
||||
<ConnectionString>
|
||||
Public Property SQLServerTestConnectionString As String = ""
|
||||
|
||||
Public Property Debug As Boolean = False
|
||||
End Class
|
||||
@@ -112,13 +112,13 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Config.vb" />
|
||||
<Compile Include="EmailService.Designer.vb">
|
||||
<DependentUpon>EmailService.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="EmailService.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="EmailServiceOld.vb" />
|
||||
<Compile Include="ModuleRuntime.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -166,5 +166,10 @@
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="MailLicense.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
@@ -6,10 +6,14 @@ Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Messaging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Encryption
|
||||
Imports DigitalData.Modules.Config
|
||||
|
||||
Public Class EmailService
|
||||
Private _Logger As Logger
|
||||
Private _LogConfig As LogConfig
|
||||
Private _ConfigManager As ConfigManager(Of Config)
|
||||
Private _Config As Config
|
||||
|
||||
Private _Firebird As Firebird
|
||||
Private _MSSQL As MSSQLServer
|
||||
Private _MSSQL_Test As MSSQLServer
|
||||
@@ -30,11 +34,15 @@ Public Class EmailService
|
||||
Try
|
||||
' === Initialize Logger ===
|
||||
Dim oLogPath = Path.Combine(My.Application.Info.DirectoryPath, "Log")
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, Nothing, "Digital Data", "EmailService") With {
|
||||
.Debug = My.Settings.DEBUG
|
||||
}
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, Nothing, "Digital Data", "EmailService")
|
||||
|
||||
Dim oCurrentDomain As AppDomain
|
||||
' === Initialize Config ===
|
||||
_ConfigManager = New ConfigManager(Of Config)(_LogConfig, My.Application.Info.DirectoryPath)
|
||||
_Config = _ConfigManager.Config
|
||||
|
||||
_LogConfig.Debug = _Config.Debug
|
||||
|
||||
Dim oCurrentDomain As AppDomain = AppDomain.CurrentDomain
|
||||
AddHandler oCurrentDomain.UnhandledException, AddressOf AppDomain_UnhandledException
|
||||
|
||||
_Logger = _LogConfig.GetLogger()
|
||||
@@ -50,25 +58,25 @@ Public Class EmailService
|
||||
|
||||
_Logger.Info("Inititalize Databases")
|
||||
|
||||
If My.Settings.FB_ConnString <> String.Empty Then
|
||||
_Firebird = New Firebird(_LogConfig, My.Settings.FB_ConnString, My.Settings.FB_DATABASE, My.Settings.FB_USER, My.Settings.FB_PW)
|
||||
If _Config.FirebirdServer <> String.Empty Then
|
||||
_Firebird = New Firebird(_LogConfig, _Config.FirebirdServer, _Config.FirebirdDatabase, _Config.FirebirdUser, _Config.FirebirdPassword)
|
||||
|
||||
If _Firebird._DBInitialized = False Then
|
||||
_Logger.Warn("Firebird Connection could not be established. Check the Error Log")
|
||||
End If
|
||||
End If
|
||||
|
||||
If My.Settings.SQLSERVER_CS <> String.Empty Then
|
||||
_MSSQL = New MSSQLServer(_LogConfig, My.Settings.SQLSERVER_CS)
|
||||
If _Config.SQLServerConnectionString <> String.Empty Then
|
||||
_MSSQL = New MSSQLServer(_LogConfig, _Config.SQLServerConnectionString)
|
||||
|
||||
If _MSSQL.DBInitialized = False Then
|
||||
_Logger.Warn("MSSQL Connection could not be established. Check the Error Log")
|
||||
End If
|
||||
End If
|
||||
|
||||
If My.Settings.SQLSERVER_CS_TEST <> String.Empty Then
|
||||
If _Config.SQLServerTestConnectionString <> String.Empty Then
|
||||
|
||||
_MSSQL_Test = New MSSQLServer(_LogConfig, My.Settings.SQLSERVER_CS_TEST)
|
||||
_MSSQL_Test = New MSSQLServer(_LogConfig, _Config.SQLServerTestConnectionString)
|
||||
|
||||
If _MSSQL_Test.DBInitialized = False Then
|
||||
_Logger.Warn("MSSQL Test Connection could not be established. Check the Error Log")
|
||||
@@ -130,6 +138,7 @@ Public Class EmailService
|
||||
|
||||
Private Sub AppDomain_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs)
|
||||
Dim oException As Exception = e.ExceptionObject
|
||||
_Logger.Warn("An unhandled exception has occurred.")
|
||||
_Logger.Error(oException)
|
||||
End Sub
|
||||
|
||||
@@ -168,6 +177,22 @@ Public Class EmailService
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub EmailQueue_Completed(sender As Object, e As RunWorkerCompletedEventArgs)
|
||||
Try
|
||||
If e.Cancelled Then
|
||||
_Logger.Warn("EmailQueue has been cancelled manually!")
|
||||
ElseIf e.Error IsNot Nothing Then
|
||||
_Logger.Warn("Unexpected Error in EmailQueue: {0}", e.Error.Message)
|
||||
_Logger.Error(e.Error)
|
||||
Else
|
||||
_Logger.Debug("Email Queue successfully processed.")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Error while processing result of Worker!")
|
||||
_Logger.Error(e.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Class EmailAccount
|
||||
Public Guid As Integer
|
||||
Public Sender As String
|
||||
@@ -301,7 +326,6 @@ Public Class EmailService
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, oErrorMsg, oMailADDED
|
||||
Dim oGuid, oJobId As Integer
|
||||
|
||||
For Each oAccount In oEmailAccounts
|
||||
@@ -345,7 +369,6 @@ Public Class EmailService
|
||||
For Each oRow As DataRow In oAccountQueue
|
||||
'Dim oAccountMatch As Boolean = False
|
||||
Dim oComment As String = String.Empty
|
||||
oErrorMsg = ""
|
||||
|
||||
Dim oAttachment = String.Empty
|
||||
Dim oEmailTo = String.Empty
|
||||
@@ -486,19 +509,7 @@ Public Class EmailService
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub EmailQueue_Completed(sender As Object, e As RunWorkerCompletedEventArgs)
|
||||
Try
|
||||
If e.Cancelled Then
|
||||
_Logger.Warn("EmailQueue has been cancelled manually!")
|
||||
ElseIf e.Error IsNot Nothing Then
|
||||
_Logger.Warn("Unexpected Error in EmailQueue: {0}", e.Error.Message)
|
||||
_Logger.Error(e.Error)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Error while processing result of Worker!")
|
||||
_Logger.Error(e.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Overrides Sub OnStop()
|
||||
Try
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
Imports System.ComponentModel
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Messaging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports System.Timers
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Encryption
|
||||
|
||||
Public Class EmailServiceOld
|
||||
Private _Logger As Logger
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Firebird As Firebird
|
||||
Private _MSSQL As MSSQLServer
|
||||
Private _MSSQL_Test As MSSQLServer
|
||||
Private _Encryption As EncryptionLegacy
|
||||
Private _EmailQueue As BackgroundWorker
|
||||
Private _QueueTimer As Timer
|
||||
Private _AnyDatabaseInitialized As Boolean = False
|
||||
Private _limilab As DigitalData.Modules.Messaging.Limilab
|
||||
Private _messageSend As Boolean = False
|
||||
|
||||
Private Enum DatabaseType
|
||||
Firebird
|
||||
MSSQL
|
||||
End Enum
|
||||
|
||||
' Original Line
|
||||
'Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
Protected Sub OnStart(ByVal args() As String)
|
||||
Try
|
||||
' === Initialize Logger ===
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, "Digital Data", "EmailService")
|
||||
_LogConfig.Debug = My.Settings.DEBUG
|
||||
|
||||
_Logger = _LogConfig.GetLogger()
|
||||
Try
|
||||
Dim directory As New IO.DirectoryInfo(_LogConfig.LogDirectory)
|
||||
|
||||
For Each file As IO.FileInfo In directory.GetFiles
|
||||
If (Now - file.CreationTime).Days > 29 Then
|
||||
file.Delete()
|
||||
Else
|
||||
Exit For
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
' Original Line
|
||||
'_Logger.Info("Starting {0}", ServiceName)
|
||||
_Logger.Info("Starting {0}", "Email Service")
|
||||
|
||||
' === Inititalize Encryption ===
|
||||
|
||||
_Logger.NewBlock("Inititalize Encryption")
|
||||
|
||||
_Encryption = New EncryptionLegacy()
|
||||
|
||||
_Logger.EndBlock()
|
||||
|
||||
' === Initialize Databases ===
|
||||
|
||||
_Logger.NewBlock("Inititalize Databases")
|
||||
|
||||
If My.Settings.FB_ConnString <> String.Empty Then
|
||||
_Firebird = New Firebird(_LogConfig, My.Settings.FB_ConnString, My.Settings.FB_DATABASE, My.Settings.FB_USER, My.Settings.FB_PW)
|
||||
|
||||
If _Firebird._DBInitialized = False Then
|
||||
_Logger.Warn("Firebird Connection could not be established. Check the Error Log")
|
||||
End If
|
||||
End If
|
||||
|
||||
If My.Settings.SQLSERVER_CS <> String.Empty Then
|
||||
_MSSQL = New MSSQLServer(_LogConfig, My.Settings.SQLSERVER_CS)
|
||||
|
||||
If _MSSQL.DBInitialized = False Then
|
||||
_Logger.Warn("MSSQL Connection could not be established. Check the Error Log")
|
||||
End If
|
||||
End If
|
||||
|
||||
If My.Settings.SQLSERVER_CS_TEST <> String.Empty Then
|
||||
|
||||
_MSSQL_Test = New MSSQLServer(_LogConfig, My.Settings.SQLSERVER_CS_TEST)
|
||||
|
||||
If _MSSQL_Test.DBInitialized = False Then
|
||||
_Logger.Warn("MSSQL Test Connection could not be established. Check the Error Log")
|
||||
End If
|
||||
End If
|
||||
|
||||
_AnyDatabaseInitialized = _Firebird?._DBInitialized Or _MSSQL?.DBInitialized Or _MSSQL_Test?.DBInitialized
|
||||
|
||||
_Logger.EndBlock()
|
||||
|
||||
' === Initialize Email ===
|
||||
|
||||
_Logger.NewBlock("Inititalize Email")
|
||||
|
||||
_limilab = New Limilab(_LogConfig)
|
||||
|
||||
_Logger.EndBlock()
|
||||
|
||||
' === Initialize Queue ===
|
||||
|
||||
_Logger.NewBlock("Inititalize Queue")
|
||||
|
||||
If _AnyDatabaseInitialized Then
|
||||
_EmailQueue = New BackgroundWorker() With {
|
||||
.WorkerReportsProgress = True,
|
||||
.WorkerSupportsCancellation = True
|
||||
}
|
||||
|
||||
AddHandler _EmailQueue.DoWork, AddressOf EmailQueue_DoWork
|
||||
AddHandler _EmailQueue.RunWorkerCompleted, AddressOf EmailQueue_Completed
|
||||
End If
|
||||
|
||||
_Logger.EndBlock()
|
||||
|
||||
' === Initialize & Start Timer ===
|
||||
|
||||
_Logger.NewBlock("Initialize & Start Timer")
|
||||
|
||||
If _AnyDatabaseInitialized Then
|
||||
_QueueTimer = New Timer With {
|
||||
.Interval = 60000,
|
||||
.Enabled = True
|
||||
}
|
||||
|
||||
AddHandler _QueueTimer.Elapsed, AddressOf QueueTimer_Elapsed
|
||||
End If
|
||||
|
||||
_Logger.EndBlock()
|
||||
|
||||
' === Initial Run ===
|
||||
|
||||
If _AnyDatabaseInitialized Then
|
||||
_Logger.Info("Starting Initial Run...")
|
||||
_EmailQueue.RunWorkerAsync()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub QueueTimer_Elapsed(sender As Object, e As ElapsedEventArgs)
|
||||
If Not _EmailQueue.IsBusy Then
|
||||
_EmailQueue.RunWorkerAsync()
|
||||
_Logger.Debug("Worker is ready, executing.")
|
||||
Else
|
||||
_Logger.Info("Worker is busy, skipping execution.")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub EmailQueue_DoWork(sender As Object, e As DoWorkEventArgs)
|
||||
Try
|
||||
If _Firebird?._DBInitialized Then
|
||||
_Logger.Debug("Starting Firebird Sending")
|
||||
SendEmailFrom(DatabaseType.Firebird, Nothing)
|
||||
End If
|
||||
|
||||
If _MSSQL?.DBInitialized Then
|
||||
_Logger.Debug("Starting MSSQL Sending")
|
||||
SendEmailFrom(DatabaseType.MSSQL, _MSSQL)
|
||||
End If
|
||||
|
||||
If _MSSQL_Test?.DBInitialized Then
|
||||
_Logger.Debug("Starting MSSQL Test Sending")
|
||||
SendEmailFrom(DatabaseType.MSSQL, _MSSQL_Test)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function SendEmailFrom(Database As DatabaseType, MSSQLInstance As MSSQLServer)
|
||||
Try
|
||||
Dim oSQL As String = String.Empty
|
||||
Dim oEmailAccounts As DataTable
|
||||
Dim oEmailQueue As DataTable
|
||||
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oSQL = "SELECT * FROM TBEDM_EMAIL_ACCOUNT WHERE ACTIVE = True"
|
||||
oEmailAccounts = _Firebird.GetDatatable(oSQL)
|
||||
Case DatabaseType.MSSQL
|
||||
oSQL = "SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE ACTIVE = 1"
|
||||
oEmailAccounts = MSSQLInstance.GetDatatable(oSQL)
|
||||
End Select
|
||||
|
||||
If IsNothing(oEmailAccounts) Then
|
||||
_Logger.Warn("Error in TBEDM_EMAIL_ACCOUNT Query. Exiting.")
|
||||
_Logger.Warn("Query: {0}", oSQL)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If oEmailAccounts.Rows.Count = 0 Then
|
||||
_Logger.Warn("No Active Email Accounts Configured! Exiting.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oSQL = "SELECT * FROM TBEDM_EMAIL_QUEUE WHERE EMAIL_SENT IS NULL and EMAIL_TO <> ''"
|
||||
oEmailQueue = _Firebird.GetDatatable(oSQL)
|
||||
Case DatabaseType.MSSQL
|
||||
oSQL = "SELECT * FROM TBEMLP_EMAIL_OUT WHERE EMAIL_SENT IS NULL and EMAIL_ADRESS <> ''"
|
||||
oEmailQueue = MSSQLInstance.GetDatatable(oSQL)
|
||||
End Select
|
||||
|
||||
If IsNothing(oEmailQueue) Then
|
||||
_Logger.Warn("Error in EmailQueue Query. Exiting.")
|
||||
_Logger.Warn("Query: {0}", oSQL)
|
||||
Return False
|
||||
End If
|
||||
|
||||
If oEmailQueue.Rows.Count = 0 Then
|
||||
_Logger.Debug("Email Queue is empty. Exiting.")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oEmailTo, oSubject, oBody As String
|
||||
Dim oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, oAttachment, ofromName, oErrorMsg, oMailADDED
|
||||
Dim oAccountId, oGuid, oJobId As Integer
|
||||
|
||||
For Each oEmailToRow As DataRow In oEmailQueue.Rows
|
||||
Dim oAccountMatch As Boolean = False
|
||||
Dim oComment As String = String.Empty
|
||||
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oAccountId = oEmailToRow.Item("EMAIL_ACCOUNT_ID")
|
||||
Case DatabaseType.MSSQL
|
||||
oAccountId = oEmailToRow.Item("SENDING_PROFILE")
|
||||
End Select
|
||||
oErrorMsg = ""
|
||||
For Each oAccountRow As DataRow In oEmailAccounts.Rows
|
||||
If oAccountRow.Item("GUID") = oAccountId Then
|
||||
oAccountMatch = True
|
||||
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oMailFrom = oAccountRow.Item("EMAIL_FROM")
|
||||
ofromName = oMailFrom
|
||||
oMailSMTP = oAccountRow.Item("SERVER_OUT")
|
||||
oMailport = oAccountRow.Item("PORT_OUT")
|
||||
oMailUser = oAccountRow.Item("EMAIL_USER")
|
||||
oAuthType = oAccountRow.Item("AUTH_TYPE")
|
||||
oMailPW = oAccountRow.Item("EMAIL_PW")
|
||||
oMailADDED = ""
|
||||
|
||||
Case DatabaseType.MSSQL
|
||||
oMailFrom = oAccountRow.Item("EMAIL_FROM")
|
||||
ofromName = oAccountRow.Item("EMAIL_FROM_NAME")
|
||||
oMailSMTP = oAccountRow.Item("EMAIL_SMTP")
|
||||
oMailport = oAccountRow.Item("PORT")
|
||||
oMailUser = oAccountRow.Item("EMAIL_USER")
|
||||
oAuthType = oAccountRow.Item("AUTH_TYPE")
|
||||
oMailPW = oAccountRow.Item("EMAIL_PW")
|
||||
oMailADDED = oAccountRow.Item("ADDED_WHEN").ToString
|
||||
Try
|
||||
oErrorMsg = IIf(IsDBNull(oAccountRow.Item("ERROR_MSG")), "", oAccountRow.Item("ERROR_MSG"))
|
||||
Catch ex As Exception
|
||||
oErrorMsg = ""
|
||||
End Try
|
||||
|
||||
End Select
|
||||
|
||||
Dim oPasswordPlain = _Encryption.DecryptData(oMailPW)
|
||||
If Not IsNothing(oPasswordPlain) Then
|
||||
oMailPW = oPasswordPlain
|
||||
Else
|
||||
_Logger.Warn("Could not decrypt email password. Exiting.")
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
If IsNothing(oMailFrom) Or IsNothing(oMailPW) Then
|
||||
If oAccountMatch Then
|
||||
_Logger.Warn("Account credentials are empty. Exiting.")
|
||||
Else
|
||||
_Logger.Warn("Account credentials are empty and account with Id {0} does not match the configuration. Exiting.", oAccountId)
|
||||
End If
|
||||
|
||||
Return False
|
||||
End If
|
||||
If oErrorMsg <> String.Empty Then
|
||||
|
||||
End If
|
||||
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oGuid = oEmailToRow.Item("GUID")
|
||||
oEmailTo = oEmailToRow.Item("EMAIL_TO")
|
||||
_Logger.Debug("oEmailTo: {0}", oEmailTo)
|
||||
oSubject = oEmailToRow.Item("EMAIL_SUBJ")
|
||||
_Logger.Debug("oSubject: {0}", oSubject)
|
||||
oBody = oEmailToRow.Item("EMAIL_BODY")
|
||||
_Logger.Debug("oBody: {0}", oBody)
|
||||
oJobId = oEmailToRow.Item("JOB_ID")
|
||||
_Logger.Debug("oJOB_ID: {0}", oJobId)
|
||||
oAttachment = Utils.NotNull(oEmailToRow.Item("EMAIL_ATTMT1"), String.Empty)
|
||||
|
||||
Case DatabaseType.MSSQL
|
||||
oGuid = oEmailToRow.Item("GUID")
|
||||
oEmailTo = oEmailToRow.Item("EMAIL_ADRESS")
|
||||
_Logger.Debug($"oEmailTo: {oEmailTo}")
|
||||
oSubject = oEmailToRow.Item("EMAIL_SUBJ")
|
||||
_Logger.Debug($"oSubject: {oSubject}")
|
||||
oBody = oEmailToRow.Item("EMAIL_BODY")
|
||||
_Logger.Debug($"oBody: {oBody}")
|
||||
oJobId = oEmailToRow.Item("REFERENCE_ID")
|
||||
_Logger.Debug($"oJOB_ID: {oJobId}")
|
||||
oAttachment = Utils.NotNull(oEmailToRow.Item("EMAIL_ATTMT1"), String.Empty)
|
||||
End Select
|
||||
|
||||
If oAttachment <> String.Empty Then
|
||||
If oAttachment.ToString.Contains("\") Then
|
||||
If IO.File.Exists(oAttachment) = False Then
|
||||
_Logger.Warn($"Email Attachment [{oAttachment}] not existing!")
|
||||
oComment = $"Email Attachment [{oAttachment}] not existing!"
|
||||
oAttachment = String.Empty
|
||||
Else
|
||||
_Logger.Debug("Email Attachment is: {0}", oAttachment)
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
_messageSend = _limilab.NewSMTPEmail(oEmailTo, oSubject, oBody, oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, "DDEmailService", oMailADDED, oAttachment)
|
||||
|
||||
If _messageSend Then
|
||||
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oSQL = $"UPDATE TBEDM_EMAIL_QUEUE SET EMAIL_SENT = CURRENT_TIMESTAMP,COMMENT = '{oComment}' WHERE GUID = {oGuid}"
|
||||
If oSQL.Contains(",COMMENT = ''") Then
|
||||
oSQL.Replace(",COMMENT = ''", "")
|
||||
End If
|
||||
_Firebird.ExecuteNonQuery(oSQL)
|
||||
Case DatabaseType.MSSQL
|
||||
oSQL = $"UPDATE TBEMLP_EMAIL_OUT SET EMAIL_SENT = GETDATE(),COMMENT = '{oComment}' WHERE GUID = {oGuid} "
|
||||
If oSQL.Contains(",COMMENT = ''") Then
|
||||
oSQL.Replace(",COMMENT = ''", "")
|
||||
End If
|
||||
MSSQLInstance.ExecuteNonQuery(oSQL)
|
||||
End Select
|
||||
_Logger.Info($"EmailID [{oGuid.ToString}] has been send to: {oEmailTo}")
|
||||
Threading.Thread.Sleep(500)
|
||||
Else
|
||||
Select Case Database
|
||||
'Case DatabaseType.Firebird
|
||||
' oSQL = $"UPDATE TBEDM_EMAIL_QUEUE SET EMAIL_SENT = CURRENT_TIMESTAMP,COMMENT = '{oComment}' WHERE GUID = {oGuid}"
|
||||
' If oSQL.Contains(",COMMENT = ''") Then
|
||||
' oSQL.Replace(",COMMENT = ''", "")
|
||||
' End If
|
||||
' _Firebird.ExecuteNonQuery(oSQL)
|
||||
Case DatabaseType.MSSQL
|
||||
oSQL = $"UPDATE TBEMLP_EMAIL_OUT SET ERROR_TIMESTAMP = GETDATE(),ERROR_MSG = '{_limilab.ErrorMessage}' WHERE GUID = {oGuid} "
|
||||
MSSQLInstance.ExecuteNonQuery(oSQL)
|
||||
If _messageSend = True Then
|
||||
Select Case Database
|
||||
Case DatabaseType.Firebird
|
||||
oSQL = $"UPDATE TBEDM_EMAIL_QUEUE SET EMAIL_SENT = CURRENT_TIMESTAMP,COMMENT = '{oComment}' WHERE GUID = {oGuid}"
|
||||
If oSQL.Contains(",COMMENT = ''") Then
|
||||
oSQL.Replace(",COMMENT = ''", "")
|
||||
End If
|
||||
_Firebird.ExecuteNonQuery(oSQL)
|
||||
Case DatabaseType.MSSQL
|
||||
oSQL = $"UPDATE TBEMLP_EMAIL_OUT SET EMAIL_SENT = GETDATE(),COMMENT = '{oComment}' WHERE GUID = {oGuid} "
|
||||
If oSQL.Contains(",COMMENT = ''") Then
|
||||
oSQL.Replace(",COMMENT = ''", "")
|
||||
End If
|
||||
MSSQLInstance.ExecuteNonQuery(oSQL)
|
||||
End Select
|
||||
_Logger.Info($"EmailID [{oGuid.ToString}] has been send to: {oEmailTo} - althogh there was an error in connection close!")
|
||||
|
||||
End If
|
||||
|
||||
End Select
|
||||
End If
|
||||
Next
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Error in SendEmailFrom. Email was not sent.")
|
||||
_Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Sub EmailQueue_Completed(sender As Object, e As RunWorkerCompletedEventArgs)
|
||||
Try
|
||||
If e.Cancelled Then
|
||||
_Logger.Warn("EmailQueue has been cancelled manually!")
|
||||
ElseIf e.Error IsNot Nothing Then
|
||||
_Logger.Warn("Unexpected Error in EmailQueue: {0}", e.Error.Message)
|
||||
_Logger.Error(e.Error)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_Logger.Error(e.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Original Line
|
||||
'Protected Overrides Sub OnStop()
|
||||
Protected Sub OnStop()
|
||||
Try
|
||||
'_Logger.Warn("Service {0} was stopped.", ServiceName)
|
||||
_Logger.Warn("Service {0} was stopped.", "Email Service")
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
23
Services.EmailService/MailLicense.xml
Normal file
23
Services.EmailService/MailLicense.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<License>
|
||||
<Id>4dc5ef40-f1a9-468b-994c-b7ed600ad878</Id>
|
||||
<ProductName>Mail.dll</ProductName>
|
||||
<SubscriptionUntil>2022-07-29</SubscriptionUntil>
|
||||
<RegisteredTo>Digital Data GmbH</RegisteredTo>
|
||||
<LicenseType>single developer</LicenseType>
|
||||
<BuyerName>Digital Data GmbH</BuyerName>
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
|
||||
<SignedInfo>
|
||||
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
|
||||
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
|
||||
<Reference URI="">
|
||||
<Transforms>
|
||||
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
|
||||
</Transforms>
|
||||
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
|
||||
<DigestValue>75MRtl4ipYelIZYlpT8O7QDX9Zc=</DigestValue>
|
||||
</Reference>
|
||||
</SignedInfo>
|
||||
<SignatureValue>Raxfkz6DfQVs/sMvH+F2nH0eHXD8FoUFSdP3t7AgBUdpABJQx86srlyuMSEhXPlc1THCqPouEVob4RsWnd9OXvTiPPSOUSK9zuNG6uz93KLAhpSD5PraAgBCF4jwZArlAp7aCNfZpHqQ3w6TRHS+CfravUU0AHHG3MZ1ZcRkGuo=</SignatureValue>
|
||||
</Signature>
|
||||
</License>
|
||||
@@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("DDEmailService")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2019")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2022")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.4.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.4.0.0")>
|
||||
<Assembly: AssemblyVersion("1.5.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.5.0.0")>
|
||||
|
||||
@@ -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", "16.8.1.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
@@ -53,71 +53,6 @@ Namespace My
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("172.24.12.41")> _
|
||||
Public ReadOnly Property FB_ConnString() As String
|
||||
Get
|
||||
Return CType(Me("FB_ConnString"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("Data Source=172.24.12.41\Tests;Initial Catalog=DD_ECM_TEST;Persist Security Info="& _
|
||||
"True;User ID=sa;Password=dd")> _
|
||||
Public ReadOnly Property SQLSERVER_CS() As String
|
||||
Get
|
||||
Return CType(Me("SQLSERVER_CS"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("Data Source=172.24.12.41\Tests;Initial Catalog=DD_ECM_TEST;Persist Security Info="& _
|
||||
"True;User ID=sa;Password=dd")> _
|
||||
Public ReadOnly Property SQLSERVER_CS_TEST() As String
|
||||
Get
|
||||
Return CType(Me("SQLSERVER_CS_TEST"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("172.24.12.41:E:\DB\Firebird\Databases\EDMI_TEMPLATE\EDMI_MASTER.FDB")> _
|
||||
Public ReadOnly Property FB_DATABASE() As String
|
||||
Get
|
||||
Return CType(Me("FB_DATABASE"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("sysdba")> _
|
||||
Public ReadOnly Property FB_USER() As String
|
||||
Get
|
||||
Return CType(Me("FB_USER"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("dd")> _
|
||||
Public ReadOnly Property FB_PW() As String
|
||||
Get
|
||||
Return CType(Me("FB_PW"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("True")> _
|
||||
Public ReadOnly Property DEBUG() As Boolean
|
||||
Get
|
||||
Return CType(Me("DEBUG"),Boolean)
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="FB_ConnString" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">172.24.12.41</Value>
|
||||
</Setting>
|
||||
<Setting Name="SQLSERVER_CS" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">Data Source=172.24.12.41\Tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd</Value>
|
||||
</Setting>
|
||||
<Setting Name="SQLSERVER_CS_TEST" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">Data Source=172.24.12.41\Tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd</Value>
|
||||
</Setting>
|
||||
<Setting Name="FB_DATABASE" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">172.24.12.41:E:\DB\Firebird\Databases\EDMI_TEMPLATE\EDMI_MASTER.FDB</Value>
|
||||
</Setting>
|
||||
<Setting Name="FB_USER" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">sysdba</Value>
|
||||
</Setting>
|
||||
<Setting Name="FB_PW" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">dd</Value>
|
||||
</Setting>
|
||||
<Setting Name="DEBUG" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
Reference in New Issue
Block a user