DLL windream resultHandler Version 2.5
Service.exe 2.1
This commit is contained in:
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.1.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyVersion("2.5.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.5.0.0")>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
Public Class clsCURRENT
|
||||
Public Shared EXPORTED_FILENAME As String
|
||||
Public Shared FILE_Extension As String
|
||||
Public Shared WDLAUFWERK, _profObjekttyp, _profwdSuche, _profDay, _profRunType, _Profilname As String
|
||||
Public Shared SQLSERVER_CS As String = ""
|
||||
Public Shared LOG_ERRORS_ONLY As Boolean = True
|
||||
Public Shared DEBUG As Boolean = False
|
||||
Public Shared PROFILE_HandledFiles() = Nothing
|
||||
Public Shared DT_TBWMRH_KONFIGURATION As DataTable = Nothing
|
||||
Public Shared DT_TBDD_EMAIL As DataTable = Nothing
|
||||
|
||||
@@ -133,31 +133,39 @@ Public Class clsDateiverarbeitung
|
||||
Return String.Empty
|
||||
End Try
|
||||
End Function
|
||||
|
||||
' Neu geschriebene version 25.03.19
|
||||
Public Function Export_WMFile2HDD(WMObject As WMObject, ExportPath As String) As Boolean
|
||||
Public Function Export_WMFile2HDD(pWMObject As WMObject, pExportPath As String, Optional pFilename As String = "") As Boolean
|
||||
Try
|
||||
Dim oWMObject As IWMObject6 = DirectCast(WMObject, IWMObject6)
|
||||
Dim oWMObject As IWMObject6 = DirectCast(pWMObject, IWMObject6)
|
||||
|
||||
Dim oFilenameFull As String = oWMObject.aName
|
||||
Dim oFilenameWM As String = oWMObject.aName
|
||||
Dim oFilenameExport As String
|
||||
Dim oSplitIndex = oFilenameFull.LastIndexOf(".")
|
||||
Dim oSplitIndex
|
||||
If pFilename = String.Empty Then
|
||||
oSplitIndex = oFilenameWM.LastIndexOf(".")
|
||||
Else
|
||||
oSplitIndex = pFilename.LastIndexOf(".")
|
||||
End If
|
||||
|
||||
Dim oVersion = 1
|
||||
Dim oFilename As String
|
||||
If pFilename <> String.Empty Then
|
||||
oFilename = pFilename.Substring(0, oSplitIndex)
|
||||
Else
|
||||
oFilename = oFilenameWM.Substring(0, oSplitIndex)
|
||||
End If
|
||||
|
||||
Dim oFilename = oFilenameFull.Substring(0, oSplitIndex)
|
||||
Dim oExtension = oFilenameFull.Substring(oSplitIndex)
|
||||
|
||||
Logger.Debug("Preparing export of file {0}..", oFilenameFull)
|
||||
Logger.Debug("Preparing export of WMFile {0}..", oFilenameWM)
|
||||
Logger.Debug("Filename: {0}", oFilename)
|
||||
Logger.Debug("Extension: {0}", oExtension)
|
||||
Logger.Debug("Extension: {0}", clsCURRENT.FILE_Extension)
|
||||
|
||||
' build the file path in case the exported file doesn't already exist
|
||||
oFilenameExport = BuildExportPath(ExportPath, oFilename, oExtension)
|
||||
oFilenameExport = BuildExportPath(pExportPath, oFilename, clsCURRENT.FILE_Extension)
|
||||
|
||||
' Add version until we find the version that does NOT exist
|
||||
Do While File.Exists(oFilenameExport)
|
||||
oVersion += 1
|
||||
oFilenameExport = BuildExportPath(ExportPath, oFilename, oExtension, oVersion)
|
||||
oFilenameExport = BuildExportPath(pExportPath, oFilename, clsCURRENT.FILE_Extension, oVersion)
|
||||
Loop
|
||||
|
||||
Logger.Debug("File will be exported to {0}", oFilenameExport)
|
||||
@@ -647,7 +655,7 @@ Public Class clsDateiverarbeitung
|
||||
End Function
|
||||
Public Function REGEX_REPLACE(WMFile As WMObject, _STRING As String)
|
||||
Try
|
||||
Logger.Debug("REGEX_String before replacing: '" & _STRING & "'")
|
||||
Logger.Debug("REGEX_REPLACE before replacing: '" & _STRING & "'")
|
||||
' Regulären Ausdruck zum Auslesen der windream-Indexe definieren
|
||||
Dim preg As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}"
|
||||
' einen Regulären Ausdruck laden
|
||||
@@ -668,7 +676,6 @@ Public Class clsDateiverarbeitung
|
||||
ElseIf reg_element_Ohne_SZ = "ENV_USERNAME" Then
|
||||
_STRING = _STRING.Replace(reg_element.Value, Environment.UserName)
|
||||
Else
|
||||
|
||||
Dim wdIndexwert
|
||||
' den Wert des Indexes für das aktuelle Dokument auslesen
|
||||
wdIndexwert = WMFile.GetVariableValue(reg_element_Ohne_SZ)
|
||||
@@ -706,9 +713,8 @@ Public Class clsDateiverarbeitung
|
||||
_STRING = _STRING.Replace(reg_element.Value, "0")
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
Logger.Debug("REGEX_REPLACE AFTER replacing: '" & _STRING & "'")
|
||||
Return _STRING
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
|
||||
@@ -14,67 +14,60 @@ Public Class clsEmail
|
||||
Sub New(MyLogger As LogConfig)
|
||||
Logger = MyLogger.GetLogger()
|
||||
End Sub
|
||||
Public Function Email_Send(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,
|
||||
AUTH_TYPE As String, Optional attment As String = "", Optional Test As Boolean = False)
|
||||
Public Function Email_Send(ByVal pMailSubject As String, ByVal pMailBody As String, pMailto As String,
|
||||
pMailfrom As String, pMailSmtp As String, pMailport As Integer, pMailUser As String, pMailPW As String,
|
||||
pAUTH_TYPE As String, Optional pAttment As String = "", Optional pTest As Boolean = False)
|
||||
Try
|
||||
Dim oError As Boolean = False
|
||||
Dim oReceipiants As String()
|
||||
If mailto.Contains(";") Then
|
||||
oReceipiants = mailto.Split(";")
|
||||
If pMailto.Contains(";") Then
|
||||
oReceipiants = pMailto.Split(";")
|
||||
Else
|
||||
ReDim Preserve oReceipiants(0)
|
||||
oReceipiants(0) = mailto
|
||||
oReceipiants(0) = pMailto
|
||||
End If
|
||||
For Each oMailReceipiant As String In oReceipiants
|
||||
Dim sClient = New Net.Mail.SmtpClient(mailsmtp)
|
||||
Dim sClient = New Net.Mail.SmtpClient(pMailSmtp)
|
||||
Dim mymesssage As New MailMessage
|
||||
sClient.Port = mailport
|
||||
If AUTH_TYPE = "SSL" Then
|
||||
sClient.Port = pMailport
|
||||
If pAUTH_TYPE = "SSL" Then
|
||||
sClient.EnableSsl = True
|
||||
Else
|
||||
sClient.EnableSsl = False
|
||||
End If
|
||||
|
||||
sClient.Credentials = New NetworkCredential(mailUser, mailPW)
|
||||
sClient.Credentials = New NetworkCredential(pMailUser, pMailPW)
|
||||
sClient.UseDefaultCredentials = False
|
||||
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}"
|
||||
If pTest = True Then
|
||||
mymesssage.Body = $"This is the body (text will be replaced within profile)! <br> mailsmtp: {pMailSmtp} <br> mailport: {pMailport} <br> mailUser: {pMailUser} <br> mailPW: XXXX <br> AUTH_TYPE: {pAUTH_TYPE}"
|
||||
Else
|
||||
mymesssage.Body = mailBody
|
||||
mymesssage.Body = pMailBody
|
||||
End If
|
||||
|
||||
'mymesssage.IsBodyHtml = True
|
||||
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(mymesssage.Body)
|
||||
htmlView.ContentType = New System.Net.Mime.ContentType("text/html")
|
||||
mymesssage.AlternateViews.Add(htmlView)
|
||||
attment = attment.Replace("W:\", "\\windream\objects\")
|
||||
If attment <> String.Empty Then
|
||||
If System.IO.File.Exists(attment) Then
|
||||
Logger.Info($"working on attachment {attment.ToString}...")
|
||||
Dim oAttachment As New System.Net.Mail.Attachment(attment)
|
||||
|
||||
'If attment.ToLower.EndsWith("pdf") Then
|
||||
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "pdf")
|
||||
'ElseIf attment.ToLower.EndsWith("jpg") Then
|
||||
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "jpg")
|
||||
'ElseIf attment.ToLower.EndsWith("docx") Then
|
||||
' oAttachment.ContentType = New Independentsoft.Email.Mime.ContentType("application", "MS-word")
|
||||
'End If
|
||||
pAttment = pAttment.Replace("W:\", "\\windream\objects\")
|
||||
If pAttment <> String.Empty Then
|
||||
If System.IO.File.Exists(pAttment) Then
|
||||
Logger.Debug($"working on attachment {pAttment.ToString}...")
|
||||
Dim oAttachment As New System.Net.Mail.Attachment(pAttment)
|
||||
mymesssage.Attachments.Add(oAttachment)
|
||||
Else
|
||||
Logger.Warn($"Attachment {attment.ToString} is not existing - Mail won't be send!")
|
||||
Logger.Warn($"Attachment {pAttment.ToString} is not existing - Mail won't be send!")
|
||||
oError = True
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
mymesssage.From = New MailAddress(mailfrom)
|
||||
mymesssage.Subject = mailSubject
|
||||
mymesssage.From = New MailAddress(pMailfrom)
|
||||
mymesssage.Subject = pMailSubject
|
||||
mymesssage.To.Add(New MailAddress(oMailReceipiant))
|
||||
sClient.Send(mymesssage)
|
||||
Logger.Info($"Email successfully send to: [{oMailReceipiant}]!")
|
||||
Logger.Debug($"Email successfully send to: [{oMailReceipiant}]!")
|
||||
Next
|
||||
If oError = False Then
|
||||
Return True
|
||||
|
||||
@@ -167,7 +167,11 @@ Public Class clsProfil
|
||||
Dim oCountDocs As Integer = 0
|
||||
For Each WMdok As WMObject In windreamSucheErgebnisse
|
||||
oCountDocs += 1
|
||||
oFileRunNo = "#DocRun" & oCountDocs.ToString
|
||||
Logger.Debug($"Working on Doc {oCountDocs.ToString}/{windreamSucheErgebnisse.Count}")
|
||||
oFileRunNo = "#Doc " & oCountDocs.ToString
|
||||
Dim oPointIndex = WMdok.aName.LastIndexOf(".")
|
||||
clsCURRENT.FILE_Extension = WMdok.aName.Substring(oPointIndex)
|
||||
|
||||
For Each DR_PR_JB As DataRow In DT_PROFIL_JOB.Rows
|
||||
Select Case DR_PR_JB.Item("JOB_TYP").ToString.ToUpper
|
||||
Case "Create Mail Attachment".ToUpper
|
||||
@@ -182,12 +186,21 @@ Public Class clsProfil
|
||||
Logger.Debug("Email_Body: " & Email_Body)
|
||||
Dim EMAIL_PROFIL = DR_PR_JB.Item("STRING4")
|
||||
Logger.Debug("EMAIL_PROFIL: " & EMAIL_PROFIL)
|
||||
Dim oRENAMEFILE = DR_PR_JB.Item("STRING5")
|
||||
Dim oAttachment_FullFilename As String = ""
|
||||
|
||||
If Not IsDBNull(oRENAMEFILE) Then
|
||||
If oRENAMEFILE.ToString <> String.Empty Then
|
||||
Logger.Debug("Attached file shall be renamed...")
|
||||
oRENAMEFILE = _dateiverarbeitung.REGEX_REPLACE(WMdok, oRENAMEFILE)
|
||||
oAttachment_FullFilename = oRENAMEFILE & clsCURRENT.FILE_Extension
|
||||
Logger.Debug($"oAttachment: {oAttachment_FullFilename}")
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not IsNothing(clsCURRENT.DT_TBDD_EMAIL) And clsCURRENT.DT_TBDD_EMAIL.Rows.Count >= 1 Then
|
||||
Dim oAttachment = clsCURRENT.WDLAUFWERK & ":" & WMdok.aPath
|
||||
|
||||
If _dateiverarbeitung.Export_WMFile2HDD(WMdok, Path.GetTempPath()) = True Then
|
||||
oAttachment = clsCURRENT.EXPORTED_FILENAME
|
||||
|
||||
If _dateiverarbeitung.Export_WMFile2HDD(WMdok, Path.GetTempPath(), oAttachment_FullFilename) = True Then
|
||||
oAttachment_FullFilename = clsCURRENT.EXPORTED_FILENAME
|
||||
Else
|
||||
Logger.Warn($"Could not create a tempfile...")
|
||||
FileJobSuccessful = False
|
||||
@@ -212,18 +225,21 @@ Public Class clsProfil
|
||||
MAIL_PORT = emailrow.Item("PORT")
|
||||
End If
|
||||
Next
|
||||
|
||||
Dim wrapper As New clsEncryption("!35452didalog=")
|
||||
|
||||
Dim PWPlain = wrapper.DecryptData(MAIL_USER_PW)
|
||||
If Not IsNothing(PWPlain) Then
|
||||
MAIL_USER_PW = PWPlain
|
||||
|
||||
Logger.Debug("Email-Profil Used: " & EMAIL_PROFIL)
|
||||
Logger.Debug("EMAIL_AUTH_TYPE: " & MAIL_AUTH_TYPE)
|
||||
If MAIL_AUTH_TYPE.ToUpper <> "NONE" Then
|
||||
Dim wrapper As New clsEncryption("!35452didalog=")
|
||||
Dim PWPlain = wrapper.DecryptData(MAIL_USER_PW)
|
||||
If Not IsNothing(PWPlain) Then
|
||||
MAIL_USER_PW = PWPlain
|
||||
Else
|
||||
Logger.Warn("PWPlain is Nothing - Could not decrypt passwort188")
|
||||
Return False
|
||||
End If
|
||||
Else
|
||||
Logger.Warn("PWPlain is Nothing - Could not decrypt passwort188")
|
||||
|
||||
Return False
|
||||
Logger.Debug("## No AUTHENTIFICATION in EMail...!##")
|
||||
End If
|
||||
|
||||
If Email_Empfänger.ToString.Contains("[%") Then
|
||||
Email_Empfänger = _dateiverarbeitung.REGEX_REPLACE(WMdok, Email_Empfänger)
|
||||
Logger.Debug("Email_Empfänger: " & Email_Empfänger)
|
||||
@@ -233,7 +249,8 @@ Public Class clsProfil
|
||||
Email_Body = _dateiverarbeitung.REGEX_REPLACE(WMdok, Email_Body)
|
||||
oEmail_Betreff = $"{oEmail_Betreff} [eMail {oCountDocs} von {oGesamtFiles}]"
|
||||
|
||||
If _email.Email_Send(oEmail_Betreff, Email_Body, Email_Empfänger, MAILFROM, MAILSMTP, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_AUTH_TYPE, oAttachment) = True Then
|
||||
If _email.Email_Send(oEmail_Betreff, Email_Body, Email_Empfänger, MAILFROM, MAILSMTP, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_AUTH_TYPE, oAttachment_FullFilename) = True Then
|
||||
|
||||
FileJobSuccessful = True
|
||||
Else
|
||||
|
||||
@@ -612,13 +629,13 @@ Public Class clsProfil
|
||||
End If
|
||||
Case "Send to printer".ToUpper
|
||||
Logger.Info("Working on CASE Send to printer.... ")
|
||||
Dim printername = DR_PR_JB.Item("STRING1")
|
||||
Dim oPrintername = DR_PR_JB.Item("STRING1")
|
||||
For Each oFileString As String In clsCURRENT.PROFILE_HandledFiles
|
||||
Try
|
||||
Dim myproc As Process = New Process()
|
||||
myproc.StartInfo.FileName = """" & oFileString & """"
|
||||
myproc.StartInfo.Verb = "printto"
|
||||
myproc.StartInfo.Arguments = printername
|
||||
myproc.StartInfo.Arguments = oPrintername
|
||||
myproc.StartInfo.UseShellExecute = True
|
||||
myproc.Start()
|
||||
Dim p As Process
|
||||
@@ -634,6 +651,7 @@ Public Class clsProfil
|
||||
End If
|
||||
Loop
|
||||
Logger.Debug("...process has exited: ")
|
||||
Logger.Info($"Send2Printer [{ myproc.StartInfo.FileName} # Verb:{myproc.StartInfo.Verb} # Arguments: {myproc.StartInfo.Arguments}]successfull! ")
|
||||
FileJobSuccessful = True
|
||||
sw.Stop()
|
||||
' myproc.Kill()
|
||||
|
||||
Reference in New Issue
Block a user