This commit is contained in:
2021-07-13 17:24:31 +02:00
parent 2d8f5fe192
commit 2936b1fcbd
145 changed files with 94345 additions and 118148 deletions

View File

@@ -70,7 +70,8 @@
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.5.8\lib\net45\NLog.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\NLog.dll</HintPath>
</Reference>
<Reference Include="S22.Imap, Version=3.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\S22.Imap.3.6.0.0\lib\net40\S22.Imap.dll</HintPath>

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.9.0.0")>
<Assembly: AssemblyFileVersion("2.9.0.0")>
<Assembly: AssemblyVersion("3.2.0.0")>
<Assembly: AssemblyFileVersion("3.0.0.0")>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="EntityFramework.Firebird.FbConnectionFactory, EntityFramework.Firebird" />

View File

@@ -103,6 +103,13 @@ DigitalData.Modules.Database
<param name="SqlCommand">The command to execute</param>
<returns>True, if command was executed sucessfully. Otherwise false.</returns>
</member>
<member name="M:DigitalData.Modules.Database.Firebird.ExecuteNonQuery(System.String,FirebirdSql.Data.FirebirdClient.FbTransaction)">
<summary>
Executes a non-query command inside the specified transaction.
</summary>
<param name="SqlCommand">The command to execute</param>
<returns>True, if command was executed sucessfully. Otherwise false.</returns>
</member>
<member name="M:DigitalData.Modules.Database.Firebird.GetScalarValueWithConnection(System.String,FirebirdSql.Data.FirebirdClient.FbConnection,DigitalData.Modules.Database.Firebird.TransactionMode,FirebirdSql.Data.FirebirdClient.FbTransaction)">
<summary>
Executes a sql query resulting in a scalar value.
@@ -199,6 +206,27 @@ DigitalData.Modules.Database
<param name="executeStatement">the sql statement</param>
<returns>Returns the scalarvalue</returns>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.EncryptConnectionString(System.String)">
<summary>
Encrypts a connection string password.
</summary>
<param name="ConnectionString">A connection string with a plain-text password</param>
<returns>The connection string with the password encrypted.</returns>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.DecryptConnectionString(System.String)">
<summary>
Decrypts a connection string password.
</summary>
<param name="ConnectionString">A connection string with a encrypted password</param>
<returns>The connection string with the password decrypted.</returns>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.OpenSQLConnection(System.Data.SqlClient.SqlConnection)">
<summary>
This Function intentionally has no try..catch block to have any errors caught outside
</summary>
<param name="Connection"></param>
<returns></returns>
</member>
<member name="M:DigitalData.Modules.Database.MSSQLServer.GetDatatable(System.String,System.Int32)">
<summary>
Returns a datatable for a sql-statement

View File

@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>
DigitalData.Modules.Encryption
</name>
</assembly>
<members>
<member name="T:DigitalData.Modules.Encryption.My.Resources.Resources">
<summary>
Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
</summary>
</member>
<member name="P:DigitalData.Modules.Encryption.My.Resources.Resources.ResourceManager">
<summary>
Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
</summary>
</member>
<member name="P:DigitalData.Modules.Encryption.My.Resources.Resources.Culture">
<summary>
Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
</summary>
</member>
<member name="T:DigitalData.Modules.Encryption.Encryption">
<summary>
https://stackoverflow.com/questions/10168240/encrypting-decrypting-a-string-in-c-sharp
</summary>
</member>
</members>
</doc>

View File

@@ -105,7 +105,13 @@ DigitalData.Modules.Logging
</summary>
<returns>A list of log messages</returns>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.#ctor(DigitalData.Modules.Logging.LogConfig.PathType,System.String,System.String,System.String,System.String)">
<member name="M:DigitalData.Modules.Logging.LogConfig.#ctor(DigitalData.Modules.Logging.LogOptions)">
<summary>
Initializes a new LogConfig object with the options supplied as a LogOptions object
</summary>
<param name="Options"></param>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.#ctor(DigitalData.Modules.Logging.LogConfig.PathType,System.String,System.String,System.String,System.String,System.Int32)">
<summary>
Initializes a new LogConfig object with a logpath and optinally a filename-suffix.
</summary>
@@ -114,6 +120,14 @@ DigitalData.Modules.Logging
<param name="Suffix">If set to anything other than Nothing, extends the logfile name with this suffix.</param>
<param name="CompanyName">CompanyName is used to construct log-path in when LogPath is set to PathType:AppData</param>
<param name="ProductName">ProductName is used to construct log-path in when LogPath is set to PathType:AppData</param>
<param name="FileKeepRangeInDays">Amount of days where files are kept and not deleted.</param>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.ClearOldLogfiles(System.Int32)">
<summary>
Clears old LogFiles from the configured logpath for compliance with the GDPR
</summary>
<param name="FileKeepRange">Days in which logfiles should be kept. All files older than `Now - FileKeepInterval` will be deleted.</param>
<returns>True, if files were deleted as expected or no files were deleted. Otherwise false.</returns>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.GetLogger">
<summary>
@@ -122,6 +136,22 @@ DigitalData.Modules.Logging
<returns>An object of Logging.Logger</returns>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.GetLogger(System.String)">
<summary>
Returns the Logger for the specified classname
</summary>
<returns>An object of Logging.Logger</returns>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.GetLoggerFor(System.String)">
<summary>
Returns the Logger for the specified module using event-properties
</summary>
<remarks>
https://github.com/NLog/NLog/wiki/EventProperties-Layout-Renderer
https://stackoverflow.com/questions/31337030/separate-log-file-for-specific-class-instance-using-nlog/32065824#32065824
</remarks>
<returns>An object of Logging.Logger</returns>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.GetLogger(System.String,System.String)">
<summary>
Returns the Logger for a class specified by `ClassName`
</summary>
@@ -133,7 +163,7 @@ DigitalData.Modules.Logging
Clears the internal log
</summary>
</member>
<member name="M:DigitalData.Modules.Logging.LogConfig.GetClassFullName(System.Boolean)">
<member name="M:DigitalData.Modules.Logging.LogConfig.GetClassFullName(System.Boolean,System.Int32)">
<summary>
Gets the fully qualified name of the class invoking the calling method,
including the namespace but Not the assembly.
@@ -167,11 +197,5 @@ DigitalData.Modules.Logging
</summary>
<param name="Debug">Adds the Debug rule if true.</param>
</member>
<member name="M:DigitalData.Modules.Logging.Logger.NewBlock(System.String)">
<summary>
Prints a preformatted Block including a block identifier
</summary>
<param name="blockId">A unique Identifier for this block, eg. DocId, FullPath, ..</param>
</member>
</members>
</doc>

File diff suppressed because it is too large Load Diff

View File

@@ -32,13 +32,13 @@ Public Class clsDatabase
Try
WM_DRIVE = DT_ECM_BASE_CONFIG.Rows(0).Item("WM_DRIVE")
Catch ex As Exception
Logger.Warn("WM_DRIVE not part of DT_ECM_BASE_CONFIG: " & ex.Message)
Logger.Error("WM_DRIVE not part of DT_ECM_BASE_CONFIG: " & ex.Message)
WM_DRIVE = "W"
End Try
Logger.Debug("Database initialized")
Return True
Catch ex As Exception
Logger.Warn("Unexpected Error in DatabaseInit: " & ex.Message)
Logger.Error("Unexpected Error in DatabaseInit: " & ex.Message)
Return False
End Try
End Function
@@ -61,7 +61,7 @@ Public Class clsDatabase
SQLconnect.Close()
Return dt
Catch ex As Exception
Logger.Warn("Unexpected Error in Return_Datatable: " & ex.Message)
Logger.Error("Unexpected Error in Return_Datatable: " & ex.Message)
Logger.Warn("SQL: " & Select_anweisung)
Return Nothing
End Try
@@ -83,7 +83,7 @@ Public Class clsDatabase
SQLconnect.Close()
Return dt
Catch ex As Exception
Logger.Warn("Unexpected Error in Return_DatatableCS: " & ex.Message)
Logger.Error("Unexpected Error in Return_DatatableCS: " & ex.Message)
Logger.Warn("SQL: " & Select_anweisung)
Return Nothing
End Try
@@ -102,7 +102,7 @@ Public Class clsDatabase
SQLconnect.Close()
Return True
Catch ex As Exception
Logger.Warn("Unexpected Error in Execute_non_Query: " & ex.Message)
Logger.Error("Unexpected Error in Execute_non_Query: " & ex.Message)
Logger.Warn("SQL: " & ExecuteCMD)
Return False
End Try
@@ -122,7 +122,7 @@ Public Class clsDatabase
SQLconnect.Close()
Return result
Catch ex As Exception
Logger.Warn("Unexpected Error Execute_Scalar: " & ex.Message)
Logger.Error("Unexpected Error Execute_Scalar: " & ex.Message)
Logger.Warn("SQL: " & cmdscalar)
Return Nothing
End Try
@@ -142,7 +142,7 @@ Public Class clsDatabase
SQLconnect.Close()
Return result
Catch ex As Exception
Logger.Warn("Unexpected Error Execute_Scalar_CS: " & ex.Message)
Logger.Error("Unexpected Error Execute_Scalar_CS: " & ex.Message)
Logger.Warn("SQL: " & cmdscalar)
Return Nothing
End Try

View File

@@ -22,21 +22,21 @@ Public Class clsEmailIMAP
' Logger.Info(e.Log)
'End Sub
Public Function FetchIMAPMessages(Server As String, Port As Integer, Username As String, Password As String, pInbox As String, Optional IsTest As Boolean = False, Optional DeleteinTest As Boolean = False, Optional MoveMailTo As String = "") As Boolean
Logger.Debug("S22FetchIMAPMessages - Connecting to Server {0}:{1} with user {2}", Server, Port, Username)
Public Function FetchIMAPMessagesS22(Server As String, Port As Integer, Username As String, Password As String, pInbox As String, Optional IsTest As Boolean = False, Optional DeleteinTest As Boolean = False, Optional MoveMailTo As String = "") As Boolean
Logger.Debug("FetchIMAPMessagesS22 - Connecting to Server {0}:{1} with user {2}", Server, Port, Username)
Try
Logger.Debug("S22FetchIMAPMessages - Connecting...")
Logger.Debug("FetchIMAPMessagesS22 - Connecting...")
Using oClient As New S22.Imap.ImapClient(Server, Port, Username, Password, S22.Imap.AuthMethod.Login, True)
If Not oClient.Authed Then
Logger.Warn("S22FetchIMAPMessages - Connected to server but authentication failed.")
Logger.Warn("FetchIMAPMessagesS22 - Connected to server but authentication failed.")
Return False
End If
Logger.Debug($"S22FetchIMAPMessages - Fetching unseen MessageIds from Inbox: {pInbox}")
Logger.Info($"FetchIMAPMessagesS22 - Fetching unseen MessageIds from Inbox: {pInbox}")
Dim oMessageIds As IEnumerable(Of UInteger) = oClient.Search(S22.Imap.SearchCondition.Unseen, pInbox)
Logger.Debug("S22FetchIMAPMessages - Found {0} messages", oMessageIds.Count)
Logger.Debug("S22FetchIMAPMessages - Fetching messages...")
Logger.Info("FetchIMAPMessagesS22 - Found [{0}] messages", oMessageIds.Count)
Logger.Debug("FetchIMAPMessagesS22 - Fetching messages...")
Dim oMessageCountRegular As Integer = 0
Dim oMessageCountWorked As Integer = 0
Dim oLastLog As String
@@ -57,13 +57,13 @@ Public Class clsEmailIMAP
oLastLog &= " # Extracting the MessageID"
oMessageREFGUID = oMsg.MessageID
Catch ex As Exception
Logger.Warn($"S22FetchIMAPMessages - Could not get a MessageID or create a MailObject - Error: {ex.Message} - Last Debug Log: [{oLastLog}]")
Logger.Warn($"FetchIMAPMessagesS22 - Could not get a MessageID or create a MailObject - Error: {ex.Message} - Last Debug Log: [{oLastLog}]")
Continue For
End Try
oLastLog &= " # Got the MessageID"
oMessageREFGUID = oMessageREFGUID.Replace(">", "").Replace("<", "")
Dim oCHECKSQL = $"SELECT * FROM TBEMLP_HISTORY WHERE lower(EMAIL_MSGID) = lower('{oMessageREFGUID}')"
Dim oCHECKSQL = $"SELECT * FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{oMessageREFGUID}'"
Dim oCHECKDT As DataTable = _DB_MSSQL.Return_Datatable(oCHECKSQL)
If Not IsNothing(oCHECKDT) Then
If oCHECKDT.Rows.Count = 0 Then
@@ -71,25 +71,25 @@ Public Class clsEmailIMAP
CURRENT_WORKMAIL_LIST.Add(oMsg)
oLastLog &= " # Added to CURRENT_WORKMAIL_LIST"
Else
Logger.Info("S22FetchIMAPMessages - Message has already been worked! Skipping!")
Logger.Info("FetchIMAPMessagesS22 - Message has already been worked! Skipping!")
Logger.Debug($"Message shall be deleted...")
oLastLog &= " # Message shall be deleted..."
oClient.DeleteMessage(oMessageId,)
Logger.Debug($"S22FetchIMAPMessages - Message has been deleted!")
oLastLog &= " # S22FetchIMAPMessages - Message has been deleted!"
Dim oUpd = $"UPDATE TBEMLP_HISTORY SET DATE_DELETED_INBOX = GETDATE() WHERE lower(EMAIL_MSGID) = lower('{oMessageId}')"
oClient.DeleteMessage(oMessageId)
Logger.Debug($"FetchIMAPMessagesS22 - Message has been deleted!")
oLastLog &= " # FetchIMAPMessagesS22 - Message has been deleted!"
Dim oUpd = $"UPDATE TBEMLP_HISTORY SET DATE_DELETED_INBOX = GETDATE() WHERE EMAIL_MSGID = '{oMessageId}'"
_DB_MSSQL.Execute_non_Query(oUpd)
oMessageCountWorked += 1
End If
If IsTest = True Then
Logger.Debug($"S22FetchIMAPMessages - IMAP-Test Message#: {oMessageCountRegular} - Msgsubject is: {oMsg.Subject} - MsgMessageID is: {oMessageREFGUID}")
Logger.Debug($"S22FetchIMAPMessages - message correctly fetched. Mail has been downloaded to {oTempPath}")
Logger.Debug($"FetchIMAPMessagesS22 - IMAP-Test Message#: {oMessageCountRegular} - Msgsubject is: {oMsg.Subject} - MsgMessageID is: {oMessageREFGUID}")
Logger.Debug($"FetchIMAPMessagesS22 - message correctly fetched. Mail has been downloaded to {oTempPath}")
End If
Try
If DeleteinTest = True Then
Logger.Debug($"Message shall be deleted...")
oClient.DeleteMessage(oMessageId,)
Logger.Debug($"S22FetchIMAPMessages - Message has been deleted!")
Logger.Debug($"FetchIMAPMessagesS22 - Message has been deleted!")
End If
Catch ex As Exception
Logger.Warn("Message could not be deleted: " & ex.Message)
@@ -98,9 +98,9 @@ Public Class clsEmailIMAP
Try
Logger.Debug($"Moving to [{MoveMailTo}] is active...")
oClient.MoveMessage(oMessageId, MoveMailTo)
Logger.Debug($"S22FetchIMAPMessages - successfully moved!")
Logger.Debug($"FetchIMAPMessagesS22 - successfully moved!")
Catch ex As Exception
Logger.Warn($"S22FetchIMAPMessages - Could not move message to folder [{MoveMailTo}] - Error: {ex.Message}")
Logger.Warn($"FetchIMAPMessagesS22 - Could not move message to folder [{MoveMailTo}] - Error: {ex.Message}")
End Try
End If
@@ -121,7 +121,7 @@ Public Class clsEmailIMAP
Next
oClient.Expunge()
Logger.Debug("S22FetchIMAPMessages - Finished Message-Fetch")
Logger.Debug("FetchIMAPMessagesS22 - Finished Message-Fetch")
If oMessageCountRegular > 0 Or oMessageCountWorked > 0 Then
Logger.Info($"###############################################")
If oMessageCountRegular > 0 Then

View File

@@ -22,7 +22,9 @@ Public Class clsWorkEmail
Logger = LogConf.GetLogger
MyLogger = LogConf
_email = New clsEmail(LogConf)
Logger.Debug("clsWorkmail _email initialized")
_DB_MSSQL = New clsDatabase(LogConf, ConStr)
Logger.Debug("clsWorkmail _email initialized")
_USE_WM = USE_WM
If USE_WM Then
_windream = New clsWindream_allgemein(LogConf)
@@ -38,15 +40,15 @@ Public Class clsWorkEmail
End Try
End Sub
Public Function WORK_MAIL(MyEmailMessage As Message)
Public Function WorkEmailMessage(MyEmailMessage As Message) As Boolean
Try
Logger.Debug($"Starting WORK_MAIL...")
Logger.Debug($"Working on email from: {MyEmailMessage.From.EmailAddress}...Subject: {MyEmailMessage.Subject}")
CURRENT_MAIL_BODY_ALL = ""
CURRENT_MAIL_BODY_ANSWER1 = ""
CURRENT_MAIL_BODY_Substr2 = ""
CURRENT_MAIL_MESSAGE = MyEmailMessage
CURRENT_MAIL_SUBJECT = MyEmailMessage.Subject.ToUpper
Logger.Debug($"Working on email from: {MyEmailMessage.From.EmailAddress}...")
If IsNothing(CURRENT_MAIL_SUBJECT) Then
CURRENT_MAIL_SUBJECT = ""
Else
@@ -72,10 +74,15 @@ Public Class clsWorkEmail
ElseIf MyEmailMessage.Subject.Contains("[ADDI]") Then
Else
Logger.Info(String.Format("No relation configured for this email - Subject[{0}]", CURRENT_MAIL_SUBJECT))
COMMON_EMAIL_IN()
Logger.Info("CommonEmail-Process-Sniffer")
If COMMON_EMAIL_IN() = True Then
INSERT_HISTORY_MSSQL()
Return True
Else
Return False
End If
End If
INSERT_HISTORY_MSSQL()
End If
End If
@@ -112,8 +119,10 @@ Public Class clsWorkEmail
WM_IDX_BODY_SUBSTR_LENGTH = row("WM_IDX_BODY_SUBSTR_LENGTH")
oDel_email = row("DELETE_MAIL")
COPY2HDD(row("COPY_2_HDD"), row("PATH_ORIGINAL"), row("PATH_EMAIL_ERRORS"), False)
EXTRACT_BODY()
If COPY2HDD(row("COPY_2_HDD"), row("PATH_ORIGINAL"), row("PATH_EMAIL_ERRORS"), False) = True Then
EXTRACT_BODY()
End If
Next
@@ -148,7 +157,7 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Function COMMON_EMAIL_IN()
Function COMMON_EMAIL_IN() As Boolean
Try
Dim oDel_email As Boolean = False
Logger.Info(String.Format("COMMON_EMAIL_IN...Subject [{0}]", CURRENT_MAIL_MESSAGE.Subject))
@@ -178,8 +187,16 @@ Public Class clsWorkEmail
WM_IDX_BODY_TEXT = oDataRow("WM_IDX_BODY_TEXT")
WM_IDX_BODY_SUBSTR_LENGTH = oDataRow("WM_IDX_BODY_SUBSTR_LENGTH")
COPY2HDD(oDataRow("COPY_2_HDD"), oDataRow("PATH_ORIGINAL"), oDataRow("PATH_EMAIL_ERRORS"), True)
EXTRACT_ATTACHMENTS(oDataRow("PATH_EMAIL_TEMP"), oDataRow("PATH_EMAIL_ERRORS"))
If COPY2HDD(oDataRow("COPY_2_HDD"), oDataRow("PATH_ORIGINAL"), oDataRow("PATH_EMAIL_ERRORS"), True) = True Then
If EXTRACT_ATTACHMENTS(oDataRow("PATH_EMAIL_TEMP"), oDataRow("PATH_EMAIL_ERRORS")) = True Then
Return True
Else
Return False
End If
Else
Return False
End If
Next
If ClassCurrent.CURRENT_DEBUG_LOCAL_EMAIL = "" Then
@@ -253,7 +270,7 @@ Public Class clsWorkEmail
Return False
End Try
End Function
Private Function COPY2HDD(copy_2_hdd As Boolean, pathOriginal As String, pathemail_errors As String, messageid As Boolean)
Private Function COPY2HDD(copy_2_hdd As Boolean, pathOriginal As String, pathemail_errors As String, messageid As Boolean) As Boolean
Try
If copy_2_hdd = True Then
Logger.Debug("COPY_2_HDD is ACTIVE!")
@@ -269,9 +286,24 @@ Public Class clsWorkEmail
Dim cleanPath As String = String.Join("", oTempFilename.Split(Path.GetInvalidPathChars()))
If System.IO.File.Exists(cleanPath) = False Then
CURRENT_MAIL_MESSAGE.Save(cleanPath, True)
Logger.Info($"Email saved to ({cleanPath})")
Dim oFileInfo As New FileInfo(cleanPath)
Dim oFileLenth As Long = oFileInfo.Length
If oFileLenth > 0 Then
Logger.Info($"[COPY2HDD] Email saved to ({cleanPath})")
Return True
Else
Logger.Warn($"##!! oFileLenth is 0 !!##")
Try
File.Delete(cleanPath)
Catch ex As Exception
Logger.Error(ex)
End Try
Return False
End If
Else
Logger.Info("COPY2HDD - EMail (" & CURRENT_MAIL_MESSAGE.Subject & ") already existing!", False, "RUN_THREAD.COPY_2_HDD")
Return False
End If
End If
@@ -488,7 +520,7 @@ Public Class clsWorkEmail
Continue For
End If
Dim oAttachmentFileString
Logger.Debug(String.Format(" Working on Attachment [{0}]", oAttachment.GetFileName))
Logger.Info(String.Format(" Working on Attachment [{0}]", oAttachment.GetFileName))
Try
Dim oFilename = oAttachment.GetFileName
oFilename = CleanInput(oFilename)
@@ -503,9 +535,24 @@ Public Class clsWorkEmail
Logger.Debug(String.Format("Trying to save attachment [{0}]", oAttachmentFileString))
Try
oAttachment.Save(oAttachmentFileString)
Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFileString))
INSERT_HISTORY_FB(oMSGID, oAttachment.GetFileName)
INSERT_HISTORY_ATTMT_MSSQL(oMSGID, oAttachment.GetFileName)
Dim oFileInfo As New FileInfo(oAttachmentFileString)
Dim oFileLenth As Long = oFileInfo.Length
If oFileLenth > 0 Then
Logger.Info(String.Format("Attachment saved to [{0}]", oAttachmentFileString))
INSERT_HISTORY_FB(oMSGID, oAttachment.GetFileName)
INSERT_HISTORY_ATTMT_MSSQL(oMSGID, oAttachment.GetFileName)
Else
Logger.Warn($"##!! oFileLenth for AttachmentObjects is 0 !!##")
Try
File.Delete(oAttachmentFileString)
Catch ex As Exception
Logger.Error(ex)
End Try
MessageError = True
Return False
End If
Catch ex As Exception
Logger.Warn($"Error while saving attachment-name: {ex.Message} - AttachmentName: {oAttachmentFileString}")
MessageError = True
@@ -557,7 +604,7 @@ Public Class clsWorkEmail
End Function
Private Function INSERT_HISTORY_MSSQL()
Private Function INSERT_HISTORY_MSSQL() As Boolean
If MessageError = False Then
Dim ins = $"INSERT INTO TBEMLP_HISTORY (WORK_PROCESS,EMAIL_MSGID,EMAIL_SUBJECT,EMAIL_DATE,EMAIL_BODY,EMAIL_SUBSTRING1,EMAIL_SUBSTRING2,EMAIL_FROM,PROFILE_ID) VALUES " &
$"('{CURRENT_MAIL_PROCESS_NAME}'," &
@@ -569,12 +616,13 @@ Public Class clsWorkEmail
$"'{CURRENT_MAIL_BODY_Substr2}'," &
$"'{CURRENT_MAIL_FROM}'," &
$"{CURRENT_PROFILE_GUID})"
_DB_MSSQL.Execute_non_Query(ins)
Return _DB_MSSQL.Execute_non_Query(ins)
Else
Logger.Info("! No INSERT_HISTORY as MessageError = True")
Return False
End If
End Function
Private Function INSERT_HISTORY_FB(oGUID As String, ATTMT1 As String)
Private Function INSERT_HISTORY_FB(oGUID As String, ATTMT1 As String) As Boolean
If IsNothing(_firebird) Then
Logger.Info("INSERT_HISTORY_FB: _firebird is nothing ")
Return False
@@ -591,10 +639,11 @@ Public Class clsWorkEmail
$"'{CURRENT_MAIL_BODY_ANSWER1}'," &
$"'{CURRENT_MAIL_BODY_Substr2}'," &
$"'{ATTMT1}')"
_firebird.ExecuteNonQuery(ins)
Return _firebird.ExecuteNonQuery(ins)
End If
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function

View File

@@ -63,12 +63,12 @@ Public Class clsWorker
Dim DT_TBDD_EMAIL As DataTable = _Database.Return_Datatable("SELECT * FROM TBDD_EMAIL_ACCOUNT WHERE ACTIVE = 1")
Dim DT_PROFILES = _Database.Return_Datatable(osql)
If Not IsNothing(DT_PROFILES) Then
If DT_PROFILES.Rows.Count > 0 Then
If DT_PROFILES.Rows.Count > 0 Then
Logger.Debug("count of active profiles: " & DT_PROFILES.Rows.Count.ToString)
For Each oDR_Profile As DataRow In DT_PROFILES.Rows
CURRENT_PROFILE_GUID = oDR_Profile.Item("GUID")
DT_POLL_PROCESS = Nothing
Dim sql = String.Format("SELECT * FROM TBEMLP_POLL_PROCESS WHERE PROFILE_ID = {0} AND ACTIVE = 1", CURRENT_PROFILE_GUID)
CURRENT_PROFILE_GUID = oDR_Profile.Item("GUID")
DT_POLL_PROCESS = Nothing
Dim sql = String.Format("SELECT * FROM TBEMLP_POLL_PROCESS WHERE PROFILE_ID = {0} AND ACTIVE = 1", CURRENT_PROFILE_GUID)
DT_POLL_PROCESS = _Database.Return_Datatable(sql)
If Not IsNothing(DT_POLL_PROCESS) Then
If DT_POLL_PROCESS.Rows.Count = 0 Then
@@ -76,130 +76,139 @@ Public Class clsWorker
Continue For
Else
DT_STEPS = Nothing
DT_STEPS = _Database.Return_Datatable(String.Format("SELECT T.* FROM TBEMLP_POLL_STEPS T,TBEMLP_POLL_PROCESS T1 WHERE T.PROCESS_ID = T1.GUID AND T1.PROFILE_ID = {0} AND T1.ACTIVE = 1", CURRENT_PROFILE_GUID))
DT_STEPS = _Database.Return_Datatable(String.Format("SELECT T.* FROM TBEMLP_POLL_STEPS T,TBEMLP_POLL_PROCESS T1 WHERE T.PROCESS_ID = T1.GUID AND T1.PROFILE_ID = {0} AND T1.ACTIVE = 1", CURRENT_PROFILE_GUID))
End If
Else
Logger.Warn("DT_POLL_PROCESS is nothing")
Continue For
End If
Else
Logger.Warn("DT_POLL_PROCESS is nothing")
Continue For
End If
CURRENT_EMAIL_GUID = 0
MAIL_FROM = ""
MAIL_SERVER = ""
MAIL_USER = ""
MAIL_USER_PW = ""
CURRENT_EMAIL_GUID = 0
MAIL_FROM = ""
MAIL_SERVER = ""
MAIL_USER = ""
MAIL_USER_PW = ""
CURRENT_POLL_TYPE = oDR_Profile.Item("POLL_TYPE")
Logger.Debug(String.Format("Working on profile: ({0}-{1}-{2}) ", oDR_Profile.Item("GUID"), oDR_Profile.Item("PROFILE_NAME"), CURRENT_POLL_TYPE))
CURRENT_EMAIL_GUID = oDR_Profile.Item("EMAIL_CONF_ID")
CURRENT_POLL_TYPE = oDR_Profile.Item("POLL_TYPE")
Logger.Debug(String.Format("Working on profile: ({0}-{1}-{2}) ", oDR_Profile.Item("GUID"), oDR_Profile.Item("PROFILE_NAME"), CURRENT_POLL_TYPE))
CURRENT_EMAIL_GUID = oDR_Profile.Item("EMAIL_CONF_ID")
Dim EMAIL_PROF_TABLE As DataTable = DT_TBDD_EMAIL
'Presuming the DataTable has a column named Date.
Dim expression As String
expression = "GUID = " & CURRENT_EMAIL_GUID
Logger.Debug("Expression Filter email: " & expression)
Logger.Debug("DT_TBDD_EMAIL.rowCount: " & DT_TBDD_EMAIL.Rows.Count)
'Filter the rows using Select() method of DataTable
Dim FilteredRows As DataRow() = EMAIL_PROF_TABLE.Select(expression)
If FilteredRows.Length = 1 Then
For Each row As DataRow In FilteredRows
MAIL_FROM = row("EMAIL_FROM")
MAIL_SERVER = row("EMAIL_SMTP")
MAIL_USER = row("EMAIL_USER")
MAIL_USER_PW = row("EMAIL_PW")
MAIL_PORT = row("PORT_IN")
MAIL_INBOX_NAME = "Inbox"
MAIL_ARCHIVE_FOLDER = row("ARCHIVE_FOLDER")
Logger.Debug(String.Format("{0}-{1}", MAIL_FROM, MAIL_SERVER))
Dim EMAIL_PROF_TABLE As DataTable = DT_TBDD_EMAIL
'Presuming the DataTable has a column named Date.
Dim expression As String
expression = "GUID = " & CURRENT_EMAIL_GUID
Logger.Debug("Expression Filter email: " & expression)
Logger.Debug("DT_TBDD_EMAIL.rowCount: " & DT_TBDD_EMAIL.Rows.Count)
'Filter the rows using Select() method of DataTable
Dim FilteredRows As DataRow() = EMAIL_PROF_TABLE.Select(expression)
If FilteredRows.Length = 1 Then
For Each row As DataRow In FilteredRows
MAIL_FROM = row("EMAIL_FROM")
MAIL_SERVER = row("EMAIL_SMTP")
MAIL_USER = row("EMAIL_USER")
MAIL_USER_PW = row("EMAIL_PW")
MAIL_PORT = row("PORT_IN")
MAIL_INBOX_NAME = "Inbox"
MAIL_ARCHIVE_FOLDER = row("ARCHIVE_FOLDER")
Logger.Debug(String.Format("{0}-{1}", MAIL_FROM, MAIL_SERVER))
Dim PWPlain = _wrapper.DecryptData(MAIL_USER_PW)
If Not IsNothing(PWPlain) Then
If PWPlain <> "" Then
MAIL_USER_PW = PWPlain
Else
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort")
End If
Dim PWPlain = _wrapper.DecryptData(MAIL_USER_PW)
If Not IsNothing(PWPlain) Then
If PWPlain <> "" Then
MAIL_USER_PW = PWPlain
Else
Logger.Warn("PWPlain is nothing - Could not decrypt passwort")
End If
Next
CURRENT_WORKMAIL_LIST.Clear()
If MAIL_SERVER <> "" Then
Dim pollresult As Boolean = False
If LocalEmail = True Then
pollresult = True
Dim oMessage As New Message(CURRENT_DEBUG_LOCAL_EMAIL)
CURRENT_WORKMAIL_LIST.Add(oMessage)
Else
Select Case CURRENT_POLL_TYPE
Case "POP"
pollresult = _email.POP3_COLLECT()
Case "IMAP"
'pollresult = _emailIMAP.IMAP_COLLECT()
pollresult = _emailIMAP.FetchIMAPMessagesIsoft(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME, MAIL_ARCHIVE_FOLDER)
End Select
End If
If pollresult = False Then
Logger.Info(String.Format("Error while polling emails...Trying S22...."))
pollresult = _emailIMAP.FetchIMAPMessages(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME)
If pollresult = False Then
Logger.Warn(String.Format("S22FetchIMAPMessages - also returned error!"))
End If
End If
If CURRENT_WORKMAIL_LIST.Count() > 0 Then
Logger.Info(String.Format("Worked/Pulled: {0} E-Mails", CURRENT_WORKMAIL_LIST.Count()))
For Each pulled_msg As Message In CURRENT_WORKMAIL_LIST
If _workmail.WORK_MAIL(pulled_msg) = True Then
End If
Next
Else
Logger.Info(String.Format("No emails for profile!"))
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort")
End If
Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found!")
Logger.Warn("PWPlain is nothing - Could not decrypt passwort")
End If
_Database.Execute_non_Query("UPDATE TBEMLP_POLL_PROFILES SET LAST_TICK = GETDATE() WHERE GUID = " & oDR_Profile.Item("GUID").ToString)
Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found! Check wether Email-Profile is active!")
End If
Next
Try
'Delete all Tempfiles
For Each _file In TEMP_FILES
If System.IO.File.Exists(_file) Then
System.IO.File.Delete(_file)
End If
Next
Try
Dim oDiTempPath As New IO.DirectoryInfo(System.IO.Path.GetTempPath)
Dim oaryFi As IO.FileInfo() = oDiTempPath.GetFiles()
Dim ofi As IO.FileInfo
CURRENT_WORKMAIL_LIST.Clear()
For Each fi In oaryFi
If MAIL_SERVER <> "" Then
Dim pollresult As Boolean = False
If LocalEmail = True Then
pollresult = True
Dim oMessage As New Message(CURRENT_DEBUG_LOCAL_EMAIL)
CURRENT_WORKMAIL_LIST.Add(oMessage)
Else
Select Case CURRENT_POLL_TYPE
Case "POP"
pollresult = _email.POP3_COLLECT()
Case "IMAP"
'pollresult = _emailIMAP.IMAP_COLLECT()
'pollresult = _emailIMAP.FetchIMAPMessagesIsoft(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME, MAIL_ARCHIVE_FOLDER)
pollresult = _emailIMAP.FetchIMAPMessagesS22(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME)
End Select
End If
'If pollresult = False Then
' Logger.Info(String.Format("Error while polling emails...Trying S22...."))
' pollresult = _emailIMAP.FetchIMAPMessages(MAIL_SERVER, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_INBOX_NAME)
' If pollresult = False Then
' Logger.Warn(String.Format("FetchIMAPMessagesS22 - also returned error!"))
' End If
'End If
If CURRENT_WORKMAIL_LIST.Count() > 0 Then
Logger.Info(String.Format("Worked/Pulled: [{0}] E-Mails", CURRENT_WORKMAIL_LIST.Count()))
Try
fi.Delete()
For Each pulled_msg As Message In CURRENT_WORKMAIL_LIST
_workmail.WorkEmailMessage(pulled_msg)
CURRENT_MAIL_MESSAGE = Nothing
Next
Catch ex As Exception
Logger.Warn($"TempFileDelete2 - Could not delete the tempfile: {ex.Message}")
Logger.Warn($"Error converting CURRENT_WORKMAIL_LIST to IsoftMesage: {ex.Message} ")
End Try
Next
Catch ex As Exception
Logger.Warn($"TempFileDelete3 - Could not delete the tempfile: {ex.Message}")
End Try
Else
Logger.Debug(String.Format("No emails for profile!"))
End If
Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found!")
End If
_Database.Execute_non_Query("UPDATE TBEMLP_POLL_PROFILES SET LAST_TICK = GETDATE() WHERE GUID = " & oDR_Profile.Item("GUID").ToString)
Else
Logger.Warn("For the Email-Profile ID " & CURRENT_EMAIL_GUID & " no record could be found! Check wether Email-Profile is active!")
End If
Next
Try
'Delete all Tempfiles
For Each _file In TEMP_FILES
If System.IO.File.Exists(_file) Then
Try
System.IO.File.Delete(_file)
Catch ex As Exception
Logger.Warn($"TempFileDelete - Could not delete the tempfile from TEMP_FILES: {ex.Message}")
End Try
End If
Next
'Try
' Dim oDiTempPath As New IO.DirectoryInfo(System.IO.Path.GetTempPath)
' Dim oaryFi As IO.FileInfo() = oDiTempPath.GetFiles()
' Dim ofi As IO.FileInfo
' For Each fi In oaryFi
' Try
' fi.Delete()
' Catch ex As Exception
' Logger.Warn($"TempFileDelete2 - Could not delete the tempfile: {ex.Message}")
' End Try
' Next
'Catch ex As Exception
' Logger.Warn($"TempFileDelete3 - Could not delete the tempfile: {ex.Message}")
'End Try
Catch ex As Exception
Logger.Info($"TempFileDelete - Could not delete the tempfile from TEMP_FILES: {ex.Message}")
End Try
Catch ex As Exception
Logger.Warn($"TempFileDelete(X) - Could not delete the tempfile from TEMP_FILES: {ex.Message}")
End Try
Else
Logger.Info("No active profiles")
Else
Logger.Info("No active profiles")
End If
End If

View File

@@ -1 +1 @@
5c442f91a6238bfda874aa2a69de6ef1e62a37ae
136cdd51591ed50b1b450959685bd8fafa36f167

View File

@@ -11,6 +11,7 @@ E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\S22.Imap.dll
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\FirebirdSql.Data.FirebirdClient.dll
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\Oracle.ManagedDataAccess.dll
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Encryption.dll
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\AE.Net.Mail.pdb
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Database.pdb
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Database.xml
@@ -18,8 +19,9 @@ E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Logging.pdb
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Logging.xml
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\Independentsoft.Email.xml
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\NLog.xml
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\S22.Imap.xml
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Encryption.pdb
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\bin\Debug\DigitalData.Modules.Encryption.xml
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.Resources.resources
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.vbproj.GenerateResource.cache
E:\SchreiberM\Visual Studio\GIT\DD_EmailProfiler\App\DigitalData.EMLProfiler\obj\Debug\DigitalData.EMLProfiler.vbproj.CoreCompileInputs.cache

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AE.Net.Mail" version="1.7.10.0" targetFramework="net461" />
<package id="NLog" version="4.5.8" targetFramework="net461" />
<package id="NLog" version="4.7.10" targetFramework="net461" />
<package id="S22.Imap" version="3.6.0.0" targetFramework="net461" />
</packages>