diff --git a/GUIs.Test.ZUGFeRDTest/Form1.vb b/GUIs.Test.ZUGFeRDTest/Form1.vb index fb8d9661..45fa9cd5 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.vb +++ b/GUIs.Test.ZUGFeRDTest/Form1.vb @@ -88,7 +88,7 @@ Public Class Form1 args = LoadFolderConfig(args) args = LoadPropertyMapFor(args, "DEFAULT") - Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _firebird, _mssql) + Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _firebird, 1, _mssql) job.Start(args) End Sub diff --git a/Modules.Jobs/EDMI/ZUGFeRD/EmailFunctions.vb b/Modules.Jobs/EDMI/ZUGFeRD/EmailFunctions.vb index 45c844aa..a34d866e 100644 --- a/Modules.Jobs/EDMI/ZUGFeRD/EmailFunctions.vb +++ b/Modules.Jobs/EDMI/ZUGFeRD/EmailFunctions.vb @@ -62,7 +62,7 @@ Public Class EmailFunctions _logger.Error(ex) End Try End Sub - Public Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, pEmailData As EmailData, SourceProcedure As String) + Public Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, pEmailData As EmailData, SourceProcedure As String, pEmailAccountId As Integer) If pEmailData Is Nothing Then _logger.Warn("EmailData is empty. Email will not be sent!") Exit Sub @@ -73,7 +73,6 @@ Public Class EmailFunctions Dim oReference = MessageId Dim oEmailTo = "" Dim oSubject = EmailStrings.EMAIL_SUBJECT - Dim oAccountId = 1 Dim oCreatedWho = "ZUGFeRD Service" Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT, BodyText) @@ -119,7 +118,7 @@ Public Class EmailFunctions ,EMAIL_ATTMT1) VALUES (77 - ,{oAccountId} + ,{pEmailAccountId} ,{oHistoryID} ,'{MessageId}' ,77 diff --git a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb index 0ebbc5a4..dbd3f404 100644 --- a/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Modules.Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -34,15 +34,18 @@ Public Class ImportZUGFeRDFiles Private ReadOnly _zugferd As ZUGFeRDInterface Private ReadOnly _firebird As Firebird Private ReadOnly _filesystem As Filesystem.File + Private ReadOnly _EmailOutAccountId As Integer Private ReadOnly _mssql As MSSQLServer Private ReadOnly _email As EmailFunctions - Public Sub New(LogConfig As LogConfig, Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing) + + Public Sub New(LogConfig As LogConfig, Firebird As Firebird, pEmailOutAccount As Integer, Optional MSSQL As MSSQLServer = Nothing) _logConfig = LogConfig _logger = LogConfig.GetLogger() _firebird = Firebird _filesystem = New Filesystem.File(_logConfig) _mssql = MSSQL + _EmailOutAccountId = pEmailOutAccount _email = New EmailFunctions(LogConfig, _mssql, _firebird) _logger.Debug("Registering GDPicture License") @@ -467,7 +470,7 @@ Public Class ImportZUGFeRDFiles Dim oBody = EmailStrings.EMAIL_MD5_ERROR Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId) - _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MD5HashException") + _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MD5HashException", _EmailOutAccountId) AddRejectedState(oMessageId, "MD5HashException", "Die gesendete Rechnung wurde bereits verarbeitet!", "") Catch ex As InvalidFerdException _logger.Error(ex) @@ -477,7 +480,7 @@ Public Class ImportZUGFeRDFiles _firebird.ExecuteNonQuery(oSQL) Dim oBody = EmailStrings.EMAIL_INVALID_DOCUMENT Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId) - _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "InvalidFerdException") + _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "InvalidFerdException", _EmailOutAccountId) AddRejectedState(oMessageId, "InvalidFerdException", "Inkorrekte Formate", "") Catch ex As TooMuchFerdsException _logger.Error(ex) @@ -487,7 +490,7 @@ Public Class ImportZUGFeRDFiles _firebird.ExecuteNonQuery(oSQL) Dim oBody = EmailStrings.EMAIL_TOO_MUCH_FERDS Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId) - _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "TooMuchFerdsException") + _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "TooMuchFerdsException", _EmailOutAccountId) AddRejectedState(oMessageId, "TooMuchFerdsException", "Email enthielt mehr als ein ZUGFeRD-Dokument", "") Catch ex As NoFerdsException _logger.Error(ex) @@ -497,7 +500,7 @@ Public Class ImportZUGFeRDFiles _firebird.ExecuteNonQuery(oSQL) Dim oBody = EmailStrings.EMAIL_NO_FERDS Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId) - _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "NoFerdsException") + _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId) AddRejectedState(oMessageId, "NoFerdsException", " Email enthielt keine ZUGFeRD-Dokumente", "") Catch ex As MissingValueException _logger.Error(ex) @@ -512,7 +515,7 @@ Public Class ImportZUGFeRDFiles Dim oBody = CreateBodyForMissingProperties(ex.File.Name, oMissingProperties) Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId) - _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MissingValueException") + _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MissingValueException", _EmailOutAccountId) AddRejectedState(oMessageId, "MissingValueException", "Es fehlten ZugferdSpezifikationen", oMessage) Catch ex As Exception diff --git a/Modules.Jobs/My Project/AssemblyInfo.vb b/Modules.Jobs/My Project/AssemblyInfo.vb index 8ad76b2c..bb2bef03 100644 --- a/Modules.Jobs/My Project/AssemblyInfo.vb +++ b/Modules.Jobs/My Project/AssemblyInfo.vb @@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' übernehmen, indem Sie "*" eingeben: - + diff --git a/Modules.Messaging/Email.vb b/Modules.Messaging/Email.vb index de8a6dc1..1d9dd7b5 100644 --- a/Modules.Messaging/Email.vb +++ b/Modules.Messaging/Email.vb @@ -261,6 +261,7 @@ Public Class Email AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attachmentString As String = "", Optional Test As Boolean = False) Dim myClient As Net.Mail.SmtpClient Dim myMesssage As New MailMessage + Try Dim oError As Boolean = False Dim oReceipiants As String() @@ -361,7 +362,7 @@ Public Class Email End Function Public Function New_EmailISoft(ByVal mailSubject As String, ByVal mailBody As String, mailto As String, - mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String, + from_mailaddress As String, from_name As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String, AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attment As String = "") Try ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 @@ -378,16 +379,17 @@ Public Class Email For Each _mailempfaenger As String In empfaenger _logger.Debug($"Working on email for {_mailempfaenger}..") Try - Dim message As New Message() - message.From = New Mailbox(mailfrom, mailfrom) - message.[To].Add(New Mailbox(_mailempfaenger)) - message.Subject = mailSubject + Dim oMessage As New Message() + oMessage.From = New Mailbox(from_mailaddress, from_name) + + oMessage.[To].Add(New Mailbox(_mailempfaenger)) + oMessage.Subject = mailSubject _logger.Debug($"Message created..") Dim textBodyPart As New BodyPart() textBodyPart.ContentType = New ContentType("text", "html", "utf-8") textBodyPart.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable textBodyPart.Body = mailBody - message.BodyParts.Add(textBodyPart) + oMessage.BodyParts.Add(textBodyPart) If attment <> String.Empty Then If System.IO.File.Exists(attment) Then Dim attachment1 As New Independentsoft.Email.Mime.Attachment(attment) @@ -398,7 +400,7 @@ Public Class Email ElseIf attment.ToLower.EndsWith("docx") Then attachment1.ContentType = New ContentType("application", "MS-word") End If - message.BodyParts.Add(attachment1) + oMessage.BodyParts.Add(attachment1) Else _logger.Warn($"Attachment {attment.ToString} is not existing!") End If @@ -469,7 +471,7 @@ Public Class Email End Try End Try Try - client.Send(message) + client.Send(oMessage) _logger.Info("Message to " & _mailempfaenger & " has been send.") _error = False Catch ex As Exception diff --git a/Modules.Windream/DDWindream.zip b/Modules.Windream/DDWindream.zip new file mode 100644 index 00000000..eea90865 Binary files /dev/null and b/Modules.Windream/DDWindream.zip differ diff --git a/Modules.Windream/My Project/AssemblyInfo.vb b/Modules.Windream/My Project/AssemblyInfo.vb index 912bc635..a81c9e3d 100644 --- a/Modules.Windream/My Project/AssemblyInfo.vb +++ b/Modules.Windream/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/Modules.Windream/Windream.vb b/Modules.Windream/Windream.vb index 0893f0c4..b7d30b6e 100644 --- a/Modules.Windream/Windream.vb +++ b/Modules.Windream/Windream.vb @@ -595,6 +595,7 @@ Public Class Windream If TestFolderExists(oCurrentPath) = False Then oFolderObject = Session.GetNewWMObjectFS(WMEntityFolder, oCurrentPath, WMObjectEditModeNoEdit) + _logger.Info($"new Folder [{oCurrentPath}] has been created!") End If Next diff --git a/Services.EmailService/EmailService.vb b/Services.EmailService/EmailService.vb index 57352603..c74effaa 100644 --- a/Services.EmailService/EmailService.vb +++ b/Services.EmailService/EmailService.vb @@ -29,7 +29,7 @@ Public Class EmailService Try ' === Initialize Logger === - _LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) + _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() @@ -203,7 +203,7 @@ Public Class EmailService End If Dim oEmailTo, oSubject, oBody As String - Dim oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, oAttachment + Dim oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, oAttachment, ofromName Dim oAccountId, oGuid, oJobId As Integer For Each oEmailToRow As DataRow In oEmailQueue.Rows @@ -224,6 +224,7 @@ Public Class EmailService 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") @@ -232,6 +233,7 @@ Public Class EmailService 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") @@ -296,7 +298,7 @@ Public Class EmailService End If Dim oEmailSent As Boolean = False - oEmailSent = _Email.New_EmailISoft(oSubject, oBody, oEmailTo, oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, "DDEmailService", oAttachment) + oEmailSent = _Email.New_EmailISoft(oSubject, oBody, oEmailTo, oMailFrom, ofromName, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, "DDEmailService", oAttachment) If oEmailSent Then diff --git a/Services.EmailService/My Project/AssemblyInfo.vb b/Services.EmailService/My Project/AssemblyInfo.vb index aeec5c32..683cbc22 100644 --- a/Services.EmailService/My Project/AssemblyInfo.vb +++ b/Services.EmailService/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/Services.ZUGFeRDService/App.config b/Services.ZUGFeRDService/App.config index 3caf5e6e..470c29cc 100644 --- a/Services.ZUGFeRDService/App.config +++ b/Services.ZUGFeRDService/App.config @@ -32,7 +32,7 @@ 10 - + False @@ -40,6 +40,9 @@ 1234567890_EXAMPLE_KEY + + 1 + diff --git a/Services.ZUGFeRDService/My Project/AssemblyInfo.vb b/Services.ZUGFeRDService/My Project/AssemblyInfo.vb index 301b5af9..6826f9b4 100644 --- a/Services.ZUGFeRDService/My Project/AssemblyInfo.vb +++ b/Services.ZUGFeRDService/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/Services.ZUGFeRDService/My Project/Settings.Designer.vb b/Services.ZUGFeRDService/My Project/Settings.Designer.vb index 039b8db7..23e76424 100644 --- a/Services.ZUGFeRDService/My Project/Settings.Designer.vb +++ b/Services.ZUGFeRDService/My Project/Settings.Designer.vb @@ -143,6 +143,15 @@ Namespace My Return CType(Me("GDPICTURE_KEY"),String) End Get End Property + + _ + Public ReadOnly Property MSSQLEmailOutAccountID() As Integer + Get + Return CType(Me("MSSQLEmailOutAccountID"),Integer) + End Get + End Property End Class End Namespace diff --git a/Services.ZUGFeRDService/My Project/Settings.settings b/Services.ZUGFeRDService/My Project/Settings.settings index 2358b177..15771199 100644 --- a/Services.ZUGFeRDService/My Project/Settings.settings +++ b/Services.ZUGFeRDService/My Project/Settings.settings @@ -32,5 +32,8 @@ 1234567890_EXAMPLE_KEY + + 1 + \ No newline at end of file diff --git a/Services.ZUGFeRDService/ThreadRunner.vb b/Services.ZUGFeRDService/ThreadRunner.vb index 8650ce47..d312fd77 100644 --- a/Services.ZUGFeRDService/ThreadRunner.vb +++ b/Services.ZUGFeRDService/ThreadRunner.vb @@ -112,7 +112,7 @@ Public Class ThreadRunner Dim args As WorkerArgs = e.Argument _logger.Debug("Background worker running..") - Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql) + Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, My.Settings.MSSQLEmailOutAccountID, _mssql) job.Start(args) Catch ex As Exception _logger.Warn("Background worker failed!") diff --git a/Services.ZUGFeRDService/ZUGFeRDService.vb b/Services.ZUGFeRDService/ZUGFeRDService.vb index 7240e66e..bce07056 100644 --- a/Services.ZUGFeRDService/ZUGFeRDService.vb +++ b/Services.ZUGFeRDService/ZUGFeRDService.vb @@ -12,7 +12,7 @@ Public Class ZUGFeRDService Private _threadRunner As ThreadRunner Protected Overrides Sub OnStart(ByVal args() As String) - _logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) + _logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, "Digital Data", "DDZUGFeRDService") _logConfig.Debug = True _logger = _logConfig.GetLogger() _logger.Info($"{My.Settings.SERVICE_NAME} is starting.")