This commit is contained in:
Digital Data - Marlon Schreiber 2019-04-16 08:10:49 +02:00
parent fb142d4cef
commit 15d688cc89
6 changed files with 47 additions and 58 deletions

View File

@ -31,6 +31,9 @@
<setting name="JOB_INTERVAL" serializeAs="String"> <setting name="JOB_INTERVAL" serializeAs="String">
<value>10</value> <value>10</value>
</setting> </setting>
<setting name="MSSQL_CONNECTION" serializeAs="String">
<value>Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=ddd</value>
</setting>
</DDZUGFeRDService.My.MySettings> </DDZUGFeRDService.My.MySettings>
</applicationSettings> </applicationSettings>
</configuration> </configuration>

View File

@ -116,6 +116,16 @@ Namespace My
Return CType(Me("JOB_INTERVAL"),Integer) Return CType(Me("JOB_INTERVAL"),Integer)
End Get End Get
End Property 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;Persist Security Info=True;"& _
"User ID=sa;Password=ddd")> _
Public ReadOnly Property MSSQL_CONNECTION() As String
Get
Return CType(Me("MSSQL_CONNECTION"),String)
End Get
End Property
End Class End Class
End Namespace End Namespace

View File

@ -23,5 +23,8 @@
<Setting Name="JOB_INTERVAL" Type="System.Int32" Scope="Application"> <Setting Name="JOB_INTERVAL" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">10</Value> <Value Profile="(Default)">10</Value>
</Setting> </Setting>
<Setting Name="MSSQL_CONNECTION" Type="System.String" Scope="Application">
<Value Profile="(Default)">Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=ddd</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -164,7 +164,7 @@ Public Class frmEmailAccount
Dim PWPlain = wrapper.DecryptData(txtEMAIL_PW.Text) Dim PWPlain = wrapper.DecryptData(txtEMAIL_PW.Text)
If _Email.NewEmail(txtTestmail.Text, "Testmail DD Windream-ResultHandler", "This is the body (text will be replaced within profile)", txtEMAIL_FROM.Text, txtSERVER_OUT.Text, txtPORT_OUT.Text, txtEMAIL_USER.Text, PWPlain, cmbAUTH_TYPE.Text, "EDMI GUI") = True Then If _Email.NewEmail(txtTestmail.Text, "Testmail", "This is the bodytext", txtEMAIL_FROM.Text, txtSERVER_OUT.Text, txtPORT_OUT.Text, txtEMAIL_USER.Text, PWPlain, cmbAUTH_TYPE.Text, "EDMI GUI") = True Then
MsgBox("Email was send successfully.", MsgBoxStyle.Information) MsgBox("Email was send successfully.", MsgBoxStyle.Information)
Else Else
MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation) MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation)

View File

@ -6,6 +6,7 @@ Imports Independentsoft.Email.Imap
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports System.Net.Mail Imports System.Net.Mail
Imports System.Net Imports System.Net
Imports System.Security
Public Class Email Public Class Email
Private _logger As Logging.Logger Private _logger As Logging.Logger
@ -133,7 +134,6 @@ Public Class Email
mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String, mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String,
AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attachmentString As String = "", Optional Test As Boolean = False) AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attachmentString As String = "", Optional Test As Boolean = False)
Try Try
Dim oError As Boolean = False
Dim oReceipiants As String() Dim oReceipiants As String()
If mailto.Contains(";") Then If mailto.Contains(";") Then
oReceipiants = mailto.Split(";") oReceipiants = mailto.Split(";")
@ -141,42 +141,42 @@ Public Class Email
ReDim Preserve oReceipiants(0) ReDim Preserve oReceipiants(0)
oReceipiants(0) = mailto oReceipiants(0) = mailto
End If End If
_logger.Debug($"mailsmtp [{mailsmtp}]")
_logger.Debug($"mailfrom [{mailfrom}]")
_logger.Debug($"mailport [{mailport}]")
For Each oMailReceipiant As String In oReceipiants For Each oMailReceipiant As String In oReceipiants
_logger.Debug($"oMailReceipiant [{oMailReceipiant}]") _logger.Debug($"oMailReceipiant [{oMailReceipiant}]")
_logger.Debug($"mailsmtp [{mailsmtp}]")
Dim sClient As Net.Mail.SmtpClient
Try
sClient = New Net.Mail.SmtpClient(mailsmtp, mailport)
Catch ex As Exception
_logger.Warn($"Could not create SMTP-Client: [{ex.Message}]")
Return False
End Try
sClient.DeliveryMethod = SmtpDeliveryMethod.Network
Dim mymesssage As New MailMessage Dim oSmtp_Server As New Mail.SmtpClient
sClient.Port = mailport Dim oE_mail As New MailMessage()
_logger.Debug($"mailport [{mailport}]") oSmtp_Server.UseDefaultCredentials = False
oSmtp_Server.Credentials = New Net.NetworkCredential(mailUser, mailPW)
oSmtp_Server.Port = mailport
If AUTH_TYPE = "SSL" Then If AUTH_TYPE = "SSL" Then
_logger.Debug("SSL = true") _logger.Debug("SSL = true")
sClient.EnableSsl = True oSmtp_Server.EnableSsl = True
Else Else
_logger.Debug("SSL = false") _logger.Debug("SSL = false")
sClient.EnableSsl = False oSmtp_Server.EnableSsl = False
End If End If
_logger.Debug($"mailUser [{mailUser}]")
sClient.Credentials = New NetworkCredential(mailUser, mailPW)
sClient.UseDefaultCredentials = False
oSmtp_Server.Host = mailsmtp
oE_mail = New MailMessage()
oE_mail.From = New MailAddress(mailfrom)
oE_mail.To.Add(oMailReceipiant)
oE_mail.Subject = mailSubject
oE_mail.IsBodyHtml = False
If Test = True Then If Test = True Then
mymesssage.Body = $"This is the body (text will be replaced within profile)! <br> mailsmtp: {mailsmtp} <br> mailport: {mailport} <br> mailUser: {mailUser} <br> mailPW: XXXX <br> AUTH_TYPE: {AUTH_TYPE}" oE_mail.Body = $"This is the body (text will be replaced within profile)! <br> mailsmtp: {mailsmtp} <br> mailport: {mailport} <br> mailUser: {mailUser} <br> mailPW: XXXX <br> AUTH_TYPE: {AUTH_TYPE}"
Else Else
mymesssage.Body = mailBody oE_mail.Body = mailBody
End If End If
_logger.Debug($"mailBody [{mailBody}]") _logger.Debug($"mailBody [{mailBody}]")
'mymesssage.IsBodyHtml = True oE_mail.IsBodyHtml = True
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(mymesssage.Body) Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(oE_mail.Body)
htmlView.ContentType = New System.Net.Mime.ContentType("text/html") htmlView.ContentType = New System.Net.Mime.ContentType("text/html")
mymesssage.AlternateViews.Add(htmlView) oE_mail.AlternateViews.Add(htmlView)
_logger.Debug($"attachmentString [{attachmentString}]") _logger.Debug($"attachmentString [{attachmentString}]")
If attachmentString <> "" Then If attachmentString <> "" Then
_logger.Info($"Attachment Path is: {attachmentString}") _logger.Info($"Attachment Path is: {attachmentString}")
@ -189,29 +189,20 @@ Public Class Email
'ElseIf attment.ToLower.EndsWith("docx") Then 'ElseIf attment.ToLower.EndsWith("docx") Then
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "MS-word") ' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "MS-word")
'End If 'End If
mymesssage.Attachments.Add(oAttachment) oE_mail.Attachments.Add(oAttachment)
Else Else
_logger.Debug("No Attachment.") _logger.Debug("No Attachment.")
End If End If
_logger.Debug($"mailfrom [{mailfrom}]") _logger.Debug($"mailfrom [{mailfrom}]")
oSmtp_Server.Send(oE_mail)
mymesssage.From = New MailAddress(mailfrom)
_logger.Debug($"mailSubject [{mailSubject}]")
mymesssage.Subject = mailSubject
mymesssage.To.Add(New MailAddress(oMailReceipiant))
_logger.Debug($"Now Sending mail...")
sClient.Send(mymesssage)
_logger.Debug($"Mail has been sent!") _logger.Debug($"Mail has been sent!")
_logger.Info("Message to " & oMailReceipiant & " has been send.") _logger.Info("Message to " & oMailReceipiant & " has been send.")
Next Next
If oError = False Then
Return True
Else
Return False
End If
Catch ex As Exception Return True
_logger.Error(ex)
Catch error_t As Exception
_logger.Error(error_t)
Return False Return False
End Try End Try

View File

@ -1171,23 +1171,6 @@ Public Class Windream2
End Try End Try
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
_logger.Debug("ExportFileIO created...") _logger.Debug("ExportFileIO created...")
' Stream Interface bereitstellen
'Try
' oWMObject.LockFor(WMObjectEditModeMoveReadOnly) 'WMObjectEditModeFileSystem)
'Catch ex As Exception
' If Not oWMObject.aLocked Then
' Try
' oWMObject.lock()
' Catch ex1 As Exception
' _logger.Warn($"{ex1.Message} Could not lock document - DocID: {DocId}")
' Return False
' End Try
' End If
' '_logger.(ex)
'End Try
Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1) Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1)
'### VERSIONIERUNG ### '### VERSIONIERUNG ###
Dim version As Integer = 2 Dim version As Integer = 2
@ -1204,10 +1187,9 @@ Public Class Windream2
ExportFileIO.bstrOriginalFileName = tempFilename ExportFileIO.bstrOriginalFileName = tempFilename
'Das eigentliche kopieren 'Das eigentliche kopieren
ExportFileIO.ExportOriginal(True) ExportFileIO.ExportOriginal(True)
' close the windream file stream 'close the windream file stream
oWMStream.Close() oWMStream.Close()
_logger.Info($"WMFile DocID {DocId} has been exported to {tempFilename} ") _logger.Info($"WMFile DocID {DocId} has been exported to {tempFilename} ")
Return True Return True
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)