MS Service und WMDLL

This commit is contained in:
Digital Data - Marlon Schreiber 2018-08-21 10:36:59 +02:00
parent 379a36fba2
commit 8cde9f0119
5 changed files with 44 additions and 30 deletions

View File

@ -44,6 +44,7 @@ Partial Class MyNewService
'
'MyNewService
'
Me.CanPauseAndContinue = True
Me.CanShutdown = True
Me.ServiceName = "MyNewService"

View File

@ -5,17 +5,32 @@ Public Class MyNewService
Private Shared _MyLoggerConfig As LogConfig
Public Shared threadRunner As BackgroundWorker
Private Shared Logger As Logger = LogManager.GetCurrentClassLogger
Private eventId As Integer = 1
Protected Overrides Sub OnStart(ByVal args() As String)
' Code zum Starten des Dienstes hier einfügen. Diese Methode sollte Vorgänge
' ausführen, damit der Dienst gestartet werden kann.
_MyLoggerConfig = New LogConfig(LogConfig.PathType.CurrentDirectory)
' clsLogger.Init(My.Application.Info.DirectoryPath & "\Log", "_SERVICEResultHandler")
Logger.Info("Service started")
' Set up a timer to trigger every minute.
Dim timer As System.Timers.Timer = New System.Timers.Timer()
timer.Interval = 60000 ' 60 seconds
AddHandler timer.Elapsed, AddressOf Me.OnTimer
timer.Start()
End Sub
Private Sub OnTimer(sender As Object, e As Timers.ElapsedEventArgs)
' TODO: Insert monitoring activities here.
Logger.Info("Monitoring the System - eventId: " & eventId)
eventId = eventId + 1
End Sub
Protected Overrides Sub OnStop()
' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen.
Logger.Info("Service stopped")
End Sub
Protected Overrides Sub OnPause()
Logger.Info("In OnPause...")
End Sub
Protected Overrides Sub OnContinue()
Logger.Info("In OnContinue...")
End Sub
End Class

View File

@ -18,17 +18,14 @@ Public Class Email
'Für jeden Empfänger eine Neue Mail erzeugen
For Each _mailempfaenger As String In empfaenger
Try
Dim message As New Message With {
.From = New Mailbox(mailfrom, mailfrom)
}
Dim message As New Message()
message.From = New Mailbox(mailfrom, mailfrom)
message.[To].Add(New Mailbox(_mailempfaenger))
message.Subject = mailSubject
Dim textBodyPart As New BodyPart With {
.ContentType = New ContentType("text", "plain", "utf-8"),
.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable,
.Body = mailBody
}
Dim textBodyPart As New BodyPart()
textBodyPart.ContentType = New ContentType("text", "html", "utf-8")
textBodyPart.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable
textBodyPart.Body = mailBody
message.BodyParts.Add(textBodyPart)
If attment <> String.Empty Then
If System.IO.File.Exists(attment) Then

View File

@ -595,11 +595,14 @@ Public Class Windream
''' <returns>Returns datatable</returns>
''' <remarks></remarks>
Public Function GetSearchDocuments(ByVal wdfLocation As String, NameIndexDocID As String) As DataTable
Dim dt As New DataTable
dt.Columns.Add("DOC_ID", GetType(Integer))
dt.Columns.Add("PATH", GetType(String))
If CurrentSession.aLoggedin Then
dt
Dim dtresult As New DataTable
dtresult.Columns.Add("DOC_ID", GetType(Integer))
dtresult.Columns.Add("PATH", GetType(String))
If Not CurrentSession.aLoggedin Then
Return dtresult
End If
If TestWMFileExists(wdfLocation) = False Then
Return dtresult
End If
Try
Dim ProfileName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1)
@ -654,7 +657,7 @@ Public Class Windream
Case Else
Logger.Warn("No valid WM-SearchType")
Return dt
Return dtresult
End Select
Dim WMObjects As Object
WMObjects = oSearch.Execute
@ -665,15 +668,15 @@ Public Class Windream
Dim path As String = dok.aPath
Dim DOC_ID = dok.GetVariableValue(NameIndexDocID)
Logger.Info("Adding DocInfo for DocID: " & DOC_ID.ToString)
dt.Rows.Add(DOC_ID, path)
dtresult.Rows.Add(DOC_ID, path)
Next
dt.AcceptChanges()
dtresult.AcceptChanges()
End If
Return dt
Return dtresult
Catch ex As Exception
Logger.Error(ex)
Return dt
Return dtresult
End Try
End Function
''' <summary>
@ -825,7 +828,7 @@ Public Class Windream
Public Function GetWMObjectForFile(ByVal WMPath As String) As WMObject
Try
If CurrentSession.aLoggedin Then
Return False
Return Nothing
End If
WMPath = NormalizePath(WMPath)
Dim oWMObject As WINDREAMLib.WMObject
@ -872,19 +875,17 @@ Public Class Windream
''' <param name="WMPath">full path to the file</param>
''' <returns>Returns true when file was deleted, false if not</returns>
''' <remarks></remarks>
Public Function TestFileExists(ByVal WMPath As String)
Public Function TestWMFileExists(ByVal WMPath As String)
Try
If CurrentSession.aLoggedin Then
Return False
End If
WMPath = NormalizePath(WMPath)
Try
Dim WMObject As WINDREAMLib.WMObject = CurrentSession.GetWMObjectByPath(WINDREAMLib.WMEntity.WMEntityDocument, WMPath)
Catch ex As Exception
Logger.Warn("Could not create WMObject for file '" & WMPath & "' - so it is not existing")
If IsNothing(GetWMObjectForFile(WMPath)) Then
Return False
End Try
Return True
Else
Return True
End If
Catch ex As Exception
Logger.Error(ex)
Return False

View File

@ -17,7 +17,7 @@ Public Class Form1
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
MyLogger = New LogConfig(LogConfig.PathType.CurrentDirectory)
MyLogger = New LogConfig(LogConfig.PathType.AppData,)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles GetValue.Click