MS .Net Update

This commit is contained in:
2023-10-11 13:49:10 +02:00
parent 9a33f97c58
commit b9dbd3c4c3
31 changed files with 792 additions and 724 deletions

View File

@@ -3,6 +3,7 @@ Imports System.IO
Imports System.Text
Imports Newtonsoft.Json
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Messaging
Public Class clsProfil
Inherits clsCURRENT
@@ -14,7 +15,7 @@ Public Class clsProfil
Private _database As clsDatabase
Private _dateiverarbeitung As clsDateiverarbeitung
Private _JobWork As clsJob_Work
Private _email As clsEmail
Private _email As MailSender
Private Shared WD_aktivesDokument As WMObject
#End Region
Sub New(MyLogger As LogConfig, PROFIL_ID As Integer)
@@ -23,7 +24,7 @@ Public Class clsProfil
windream_index = New clsWindream_Index(MyLogger)
_database = New clsDatabase(MyLogger)
_dateiverarbeitung = New clsDateiverarbeitung(MyLogger)
_email = New clsEmail(MyLogger)
_email = New MailSender(MyLogger)
_JobWork = New clsJob_Work(MyLogger, _email)
End Sub
@@ -167,6 +168,7 @@ Public Class clsProfil
oGesamtFiles = windreamSucheErgebnisse.Count
Dim oCountDocs As Integer = 0
Dim oEmailAttachment_path As String
For Each WMdok As WMObject In windreamSucheErgebnisse
oEmailAttachment_path = String.Empty
@@ -256,14 +258,39 @@ Public Class clsProfil
If oAttachment_FullFilename <> String.Empty Then
Logger.Warn($"Email Attachment {oAttachment_FullFilename}")
End If
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
Dim oSendto As New List(Of String)
Dim oSplit = Email_Empfänger.split(";")
For Each oMailAdress In oSplit
oSendto.Add(oMailAdress)
Next
Dim oAttMt As New List(Of String)
If oAttachment_FullFilename <> String.Empty Then
oAttMt.Add(oAttachment_FullFilename)
clsCURRENT.TEMP_FILES.Add(oAttachment_FullFilename)
End If
If Not IsNothing(_email) And _email.Connected2Server = False Then
If _email.ConnectToServer(MAILSMTP, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_AUTH_TYPE) = True Then
Logger.Info($"MAIL: Connection to {MAILSMTP} successfull!")
Else
Logger.Warn($"{oFileRunNo} Email_ConnectToServer was not successfull!")
FileJobSuccessful = False
End If
End If
If Not IsNothing(_email) And _email.SendMail(oSendto, MAILFROM, oEmail_Betreff, Email_Body, Now, oAttMt, 0) = True Then
FileJobSuccessful = True
Else
Logger.Warn($"{oFileRunNo} Email_Send_Independentsoft 1 was not successfull!")
FileJobSuccessful = False
If IsNothing(_email) Then
Logger.Info($"_email is nothing")
Else
Logger.Info($"{oFileRunNo} Email_SendMail was not successfull!")
End If
End If
Else
Logger.Warn($"{oFileRunNo} DT_TBDD_EMAIL is nothing or contains no rows")
Return False
@@ -312,6 +339,8 @@ Public Class clsProfil
End Select
Next
'##################################
'JETZT DER DURCHLAUF DER DATEI-JOBS
'##################################
@@ -446,8 +475,18 @@ Public Class clsProfil
Else
Logger.Warn("KEINE File-JOBS für Profil '" & _Profilname & "' angelegt!")
End If
Next
Next
Try
If Not IsNothing(_email) Then
If _email.Connected2Server = True Then
_email.DisconnectFromServer()
End If
End If
Catch ex As Exception
End Try
'Jetzt nochmal ein Durchlauf für Profiljobs wo alle Dateien abgearbeitet wurden.
For Each DR_PR_JB As DataRow In DT_PROFIL_JOB.Rows
Logger.Info("New run for " & DR_PR_JB.Item("JOB_TYP").ToString.ToUpper)
@@ -594,14 +633,30 @@ Public Class clsProfil
Return False
End If
Dim oSendto As New List(Of String)
Dim oSplit = Email_Empfänger.split(";")
For Each oMailAdress In oSplit
oSendto.Add(oMailAdress)
Next
If _email.Email_Send(Email_Betreff, Email_Body, Email_Empfänger, MAILFROM, MAILSMTP, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_AUTH_TYPE, clsCURRENT.CONCATTED_FILE) = True Then
FileJobSuccessful = True
Else
Logger.Warn("Email_Send_Independentsoft 2 was not successfull!")
FileJobSuccessful = False
Dim oAttMt As New List(Of String)
If clsCURRENT.CONCATTED_FILE <> String.Empty Then
oAttMt.Add(clsCURRENT.CONCATTED_FILE)
clsCURRENT.TEMP_FILES.Add(clsCURRENT.CONCATTED_FILE)
End If
If _email.ConnectToServer(MAILSMTP, MAIL_PORT, MAIL_USER, MAIL_USER_PW, MAIL_AUTH_TYPE) = True Then
If _email.SendMail(oSendto, MAILFROM, Email_Betreff, Email_Body, Now, oAttMt, 0) = True Then
FileJobSuccessful = True
Else
Logger.Warn("Email_SendMail2 was not successfull!")
FileJobSuccessful = False
End If
_email.DisconnectFromServer()
Else
Logger.Warn($"Email_ConnectToServer2 was not successfull!")
FileJobSuccessful = False
End If
Else
Logger.Warn("DT_TBDD_EMAIL is nothing or contains no rows")
@@ -619,10 +674,12 @@ Public Class clsProfil
Try
Dim myproc As Process = New Process()
myproc.StartInfo.FileName = """" & oFileString & """"
myproc.StartInfo.Verb = "printto"
myproc.StartInfo.Verb = "printto" '"printto"
myproc.StartInfo.Arguments = oPrintername
myproc.StartInfo.UseShellExecute = True
Logger.Debug($"Send2Printer [{ myproc.StartInfo.FileName} # Verb:{myproc.StartInfo.Verb} # Arguments: {myproc.StartInfo.Arguments}] ")
myproc.Start()
System.Threading.Thread.Sleep(500)
Dim p As Process
p = Process.GetProcessById(myproc.Id)
Dim sw As Stopwatch = New Stopwatch()
@@ -636,15 +693,24 @@ 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()
Logger.Info($"Send2Printer successfully [{ myproc.StartInfo.FileName} # Verb:{myproc.StartInfo.Verb} # Arguments: {myproc.StartInfo.Arguments}] ")
File.Delete(oFileString)
Logger.Debug($"Deleted oFileString [{oFileString}]!")
Catch ex As Exception
Logger.Warn("Could not print (printto) file: " & oFileString)
Logger.Error(ex)
Dim omsg = "ERROR: Could not print (printto) file: " & oFileString
omsg &= vbNewLine & ex.Message
Logger.Info(omsg)
Logger.Error(ex, omsg)
FileJobSuccessful = False
Try
File.Delete(oFileString)
Catch ex1 As Exception
End Try
End Try
Next
Case "Send InfoMail with WM-Search".ToUpper