MS HTTPS, Log,

This commit is contained in:
Digital Data - Marlon Schreiber 2018-12-12 11:42:55 +01:00
parent 24f052f5b5
commit fd30d75e9f
9 changed files with 382 additions and 283 deletions

View File

@ -4,22 +4,23 @@ Imports DigitalData.Modules.Logging
Public Class clsDatabase Public Class clsDatabase
Private Shared MSSQL_inited As Boolean = False Private Shared MSSQL_inited As Boolean = False
Dim Logger As Logger Dim Logger As Logger
Sub New(MyLogger As LogConfig, ConStr As String) Sub New(MyLogger As LogConfig)
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
Init(ConStr)
End Sub End Sub
Public Function Init(CONSTRING As String) Public Function Init(CONSTRING As String, pSaveCS As Boolean)
Try Try
Dim SQLconnect As New SqlClient.SqlConnection Dim SQLconnect As New SqlClient.SqlConnection
SQLconnect.ConnectionString = CONSTRING SQLconnect.ConnectionString = CONSTRING
SQLconnect.Open() SQLconnect.Open()
SQLconnect.Close() SQLconnect.Close()
If pSaveCS = True Then
clsCURRENT.SQLSERVER_CS = CONSTRING clsCURRENT.SQLSERVER_CS = CONSTRING
MSSQL_inited = True
End If
MSSQL_inited = True
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex, $"CONSTRING: {CONSTRING}")
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True) 'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
Return False Return False
End Try End Try
@ -219,15 +220,19 @@ Public Class clsDatabase
End Function End Function
Public Function Return_Datatable(Select_anweisung As String) Public Function Return_Datatable(Select_anweisung As String, Optional pSQLConnection As String = "")
Try Try
Logger.Debug("Select_anweisung: " & Select_anweisung) Logger.Debug("Select_anweisung: " & Select_anweisung)
If MSSQL_inited = False Then Return Nothing If MSSQL_inited = False Then Return Nothing
Dim SQLconnect As New SqlClient.SqlConnection Dim SQLconnect As New SqlClient.SqlConnection
Dim SQLcommand As SqlClient.SqlCommand Dim SQLcommand As SqlClient.SqlCommand
If pSQLConnection <> "" Then
SQLconnect.ConnectionString = pSQLConnection
Else
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
End If
SQLconnect.Open() SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand SQLcommand = SQLconnect.CreateCommand
SQLcommand.CommandText = Select_anweisung SQLcommand.CommandText = Select_anweisung
@ -240,20 +245,30 @@ Public Class clsDatabase
Return dt Return dt
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex, $"SQL: {Select_anweisung}")
'clsLogger.Add("Error in Return_Datatable: " & ex.Message, True) 'clsLogger.Add("Error in Return_Datatable: " & ex.Message, True)
'clsLogger.Add(">> SQL: " & Select_anweisung, False) 'clsLogger.Add(">> SQL: " & Select_anweisung, False)
Return Nothing Return Nothing
End Try End Try
End Function End Function
Public Function Execute_non_Query(ExecuteCMD As String) Public Function Execute_non_Query(ExecuteCMD As String, Optional pSQLConnection As String = "")
If MSSQL_inited = False Then Return False If MSSQL_inited = False Then Return False
Dim oSQLCON As String
Try Try
Logger.Debug("ExecuteCMD: " & ExecuteCMD) Logger.Debug("ExecuteCMD: " & ExecuteCMD)
Dim SQLconnect As New SqlClient.SqlConnection Dim SQLconnect As New SqlClient.SqlConnection
Dim SQLcommand As SqlClient.SqlCommand Dim SQLcommand As SqlClient.SqlCommand
If pSQLConnection <> "" Then
SQLconnect.ConnectionString = pSQLConnection
oSQLCON = pSQLConnection
Else
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
oSQLCON = clsCURRENT.SQLSERVER_CS
End If
SQLconnect.ConnectionString = oSQLCON
SQLconnect.Open() SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand SQLcommand = SQLconnect.CreateCommand
@ -268,7 +283,10 @@ Public Class clsDatabase
Return True Return True
Catch ex As Exception Catch ex As Exception
Dim msg = $"Unexpected error in Execute_non_Query: SQL: {ExecuteCMD}, oSQLCON: {oSQLCON}"
Logger.Error(ex) Logger.Error(ex)
Logger.Debug(msg)
Logger.Info(msg)
'clsLogger.Add("Error in Execute_non_Query: " & ex.Message, True) 'clsLogger.Add("Error in Execute_non_Query: " & ex.Message, True)
'clsLogger.Add("SQL: " & ExecuteCMD, False) 'clsLogger.Add("SQL: " & ExecuteCMD, False)
@ -276,7 +294,7 @@ Public Class clsDatabase
End Try End Try
End Function End Function
Public Function Execute_Scalar(cmdscalar As String) Public Function Execute_Scalar(cmdscalar As String, Optional pSQLConnection As String = "")
If MSSQL_inited = False Then Return Nothing If MSSQL_inited = False Then Return Nothing
Dim result Dim result
Try Try
@ -285,7 +303,11 @@ Public Class clsDatabase
Dim SQLconnect As New SqlClient.SqlConnection Dim SQLconnect As New SqlClient.SqlConnection
Dim SQLcommand As SqlClient.SqlCommand Dim SQLcommand As SqlClient.SqlCommand
If pSQLConnection <> "" Then
SQLconnect.ConnectionString = pSQLConnection
Else
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
End If
SQLconnect.Open() SQLconnect.Open()
@ -300,7 +322,7 @@ Public Class clsDatabase
Return result Return result
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex, $"SQL: {cmdscalar}")
'clsLogger.Add("Error in Execute_Scalar: " & ex.Message, True) 'clsLogger.Add("Error in Execute_Scalar: " & ex.Message, True)
'clsLogger.Add("SQL: " & cmdscalar, False) 'clsLogger.Add("SQL: " & cmdscalar, False)
Return Nothing Return Nothing

View File

@ -33,7 +33,7 @@ Public Class clsDateiverarbeitung
MyLoggerConf = MyLogger MyLoggerConf = MyLogger
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
_windream = New clsWindream_allgemein(MyLogger) _windream = New clsWindream_allgemein(MyLogger)
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS) _database = New clsDatabase(MyLogger)
End Sub End Sub
Public Function InitProfilData() Public Function InitProfilData()
Try Try
@ -319,6 +319,7 @@ Public Class clsDateiverarbeitung
''' <param name="WMFile">Das WMObject, dass das aktuelle Dokument repräsentiert</param> ''' <param name="WMFile">Das WMObject, dass das aktuelle Dokument repräsentiert</param>
''' <param name="userId">Die eindeutige Benutzer Kennung für die Authentifizierung in Windream</param> ''' <param name="userId">Die eindeutige Benutzer Kennung für die Authentifizierung in Windream</param>
Public Function BNSjsonDownload(WMFile As WMObject, userId As String, apiAddress As String) Public Function BNSjsonDownload(WMFile As WMObject, userId As String, apiAddress As String)
Dim url As String
Try Try
Logger.Info("handling BNSjsonDownload.....") Logger.Info("handling BNSjsonDownload.....")
' Indizes für das aktuelle Dokument auslesen ' Indizes für das aktuelle Dokument auslesen
@ -352,26 +353,40 @@ Public Class clsDateiverarbeitung
Dim geschaeftsObjekt = "Sendung" Dim geschaeftsObjekt = "Sendung"
' Für Tests wird hier die Sendungsnummer verwendet, später hängt der verwendete Index von 'geschaeftsObjekt' ab ' Für Tests wird hier die Sendungsnummer verwendet, später hängt der verwendete Index von 'geschaeftsObjekt' ab
Dim geschaeftsId = SENDUNGNR Dim geschaeftsId = SENDUNGNR
Dim url As String = $"http://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument" url = $"https://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
' Logger.Debug($">> Generiertes JSON: {json}") ' Logger.Debug($">> Generiertes JSON: {json}")
Logger.Debug($">> Creating WebRequest for {url}") Logger.Debug($">> Creating WebRequest for {url}")
Dim req As HttpWebRequest
Try
req = WebRequest.Create(url)
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - CreatingWebRequest ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return False
End Try
Dim req As HttpWebRequest = WebRequest.CreateHttp(url)
req.Method = "POST" req.Method = "POST"
req.ContentType = "application/json" req.ContentType = "application/json"
req.ContentLength = bytes.Length req.ContentLength = bytes.Length
req.Timeout = 3000 req.Timeout = 3000
req.ServicePoint.Expect100Continue = False req.ServicePoint.Expect100Continue = False
Dim reqStream As Stream
Try
reqStream = req.GetRequestStream()
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - GetRequestStream ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return False
End Try
Dim reqStream As Stream = req.GetRequestStream()
reqStream.Write(bytes, 0, bytes.Length) reqStream.Write(bytes, 0, bytes.Length)
reqStream.Close() reqStream.Close()
'Logger.Debug($">> Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}") 'Logger.Debug($">> Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
'Logger.Debug($">> Upload URL: {url}") 'Logger.Debug($">> Upload URL: {url}")
Try
Using res As HttpWebResponse = req.GetResponse() Using res As HttpWebResponse = req.GetResponse()
Dim code As HttpStatusCode = res.StatusCode Dim code As HttpStatusCode = res.StatusCode
Dim text As String = res.StatusDescription Dim text As String = res.StatusDescription
@ -383,11 +398,17 @@ Public Class clsDateiverarbeitung
Logger.Warn($"Server Error (HTTP {code}: {text})") Logger.Warn($"Server Error (HTTP {code}: {text})")
End If End If
End Using End Using
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - GetResponse ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return False
End Try
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - Profile ({clsCURRENT._Profilname}) {ex.Message}") Logger.Warn($"Unhandled Exception in BNSjsonDownload - Url ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex) Logger.Error(ex)
Return True Return False
End Try End Try
End Function End Function
Public Function RUN_ORACLE_COMMAND(WMFile As WMObject, OracleCS As String, OracleCommandRAW As String) Public Function RUN_ORACLE_COMMAND(WMFile As WMObject, OracleCS As String, OracleCommandRAW As String)

View File

@ -39,14 +39,9 @@ Public Class clsJob_Work
Dim oPWPlain = owrapper.DecryptData(oMAIL_USER_PW) Dim oPWPlain = owrapper.DecryptData(oMAIL_USER_PW)
If Not IsNothing(oPWPlain) Then If Not IsNothing(oPWPlain) Then
If oPWPlain <> "" Then
oMAIL_USER_PW = oPWPlain oMAIL_USER_PW = oPWPlain
Else Else
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort 42") Logger.Warn("PWPlain is Nothing - Could not decrypt passwort 44")
Return False
End If
Else
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort 46")
Return False Return False
End If End If
If _mail.Email_Send_Independentsoft(Email_subject, Email_Body, Email_receipiants, oMAILFROM, oMAILSMTP, oMAIL_PORT, oMAIL_USER, oMAIL_USER_PW, oMAIL_AUTH_TYPE, Attachment_Filename) = True Then If _mail.Email_Send_Independentsoft(Email_subject, Email_Body, Email_receipiants, oMAILFROM, oMAILSMTP, oMAIL_PORT, oMAIL_USER, oMAIL_USER_PW, oMAIL_AUTH_TYPE, Attachment_Filename) = True Then

View File

@ -21,7 +21,7 @@ Public Class clsProfil
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
windream = New clsWindream_allgemein(MyLogger) windream = New clsWindream_allgemein(MyLogger)
windream_index = New clsWindream_Index(MyLogger) windream_index = New clsWindream_Index(MyLogger)
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS) _database = New clsDatabase(MyLogger)
_dateiverarbeitung = New clsDateiverarbeitung(MyLogger) _dateiverarbeitung = New clsDateiverarbeitung(MyLogger)
_email = New clsEmail(MyLogger) _email = New clsEmail(MyLogger)
_JobWork = New clsJob_Work(MyLogger, _email) _JobWork = New clsJob_Work(MyLogger, _email)
@ -115,7 +115,7 @@ Public Class clsProfil
'Den Durchlauf erlauben 'Den Durchlauf erlauben
Run_Profile = True Run_Profile = True
Else Else
Logger.Info("No run as DiffMin (" & DiffMin & ") <= Intervall(" & arr(1) & ")") Logger.Debug("No run as DiffMin (" & DiffMin & ") <= Intervall(" & arr(1) & ")")
End If End If
Case Else Case Else
Logger.Warn("_profRunType konnte nicht ausgewertet werden - " & arr(0)) Logger.Warn("_profRunType konnte nicht ausgewertet werden - " & arr(0))
@ -305,7 +305,7 @@ Public Class clsProfil
'Für jeden File-Job 'Für jeden File-Job
For Each DR_PR_FILE_JOB As DataRow In DT_PROFIL_FILE_JOB.Rows For Each DR_PR_FILE_JOB As DataRow In DT_PROFIL_FILE_JOB.Rows
If FileJobSuccessful = False Then If FileJobSuccessful = False Then
Logger.Info("AUSSTIEG FOR SCHLEIFE...") Logger.Info("AUSSTIEG FOR SCHLEIFE cause FileJobSuccessful = False...")
Exit For Exit For
End If End If
Select Case DR_PR_FILE_JOB.Item("TYP").ToString.ToLower Select Case DR_PR_FILE_JOB.Item("TYP").ToString.ToLower
@ -607,7 +607,8 @@ Public Class clsProfil
End Try End Try
Next Next
Case "Send InfoMail with WM-Search".ToUpper Case "Send InfoMail with WM-Search".ToUpper
Dim oWMResults As WMObjects = windream.GetSearchDocuments(_profwdSuche) Logger.Info("Working on CASE Send InfoMail with WM-Search.... ")
Dim oWMResults As WMObjects = windream.GetSearchDocuments(DR_PR_JB.Item("STRING5"))
If oWMResults Is Nothing Then If oWMResults Is Nothing Then
Logger.Warn("windreamSucheErgebnisse is nothing ( Send InfoMail with WM-Search)!", True, "clsProfil.Profil_Durchlauf") Logger.Warn("windreamSucheErgebnisse is nothing ( Send InfoMail with WM-Search)!", True, "clsProfil.Profil_Durchlauf")
Return False Return False
@ -625,6 +626,8 @@ Public Class clsProfil
End If End If
End If End If
Else
Logger.Info("Send InfoMail with WM-Search - oWMResults.Count = 0")
End If End If
End Select End Select
@ -640,7 +643,7 @@ Public Class clsProfil
End If End If
Else Else
' keine Dateien zum Importieren ' keine Dateien zum Importieren
Logger.Info("Keine windream-Dokumente für Profil '" & _Profilname & "' vorhanden/gefunden.") Logger.Debug("Keine windream-Dokumente für Profil '" & _Profilname & "' vorhanden/gefunden.")
End If End If
End If End If

View File

@ -34,7 +34,12 @@ Public Class clsWindream_allgemein
''' </summary> ''' </summary>
''' <remarks></remarks> ''' <remarks></remarks>
Sub New(MyLogger As LogConfig) Sub New(MyLogger As LogConfig)
Try
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
Catch ex As Exception
End Try
' wenn ein Fehler bei der Initialisierung auftrat ' wenn ein Fehler bei der Initialisierung auftrat
If Not Init() Then If Not Init() Then
' Nachricht ausgeben ' Nachricht ausgeben
@ -474,20 +479,26 @@ Public Class clsWindream_allgemein
Return oSearch.execute Return oSearch.execute
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn($"WM-SEARCH ({wdfLocation})")
Return Nothing Return Nothing
End Try End Try
End Function End Function
Public Function GetSearchDocumentsDT(ByVal wdfLocation As String, NameIndexDocID As String, NameIndexCreated As String) As DataTable Public Function GetSearchDocumentsDT(ByVal wdfLocation As String, NameIndexDocID As String, NameIndexCreated As String, WMSearchLocal As Boolean) As DataTable
Dim dtresult As New DataTable Dim dtresult As New DataTable
dtresult.Columns.Add("DOC_ID", GetType(Integer)) dtresult.Columns.Add("DOC_ID", GetType(Integer))
dtresult.Columns.Add("PATH", GetType(String)) dtresult.Columns.Add("PATH", GetType(String))
dtresult.Columns.Add("CREATED", GetType(DateAndTime)) dtresult.Columns.Add("CREATED", GetType(String))
Logger.Debug($"Executing WMSearch: {wdfLocation}...") Logger.Debug($"Executing WMSearch: {wdfLocation}...")
Try Try
Dim SearchName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1) Dim SearchName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1)
Dim SearchPath = wdfLocation.Substring(0, wdfLocation.Length - SearchName.Length) Dim SearchPath = wdfLocation.Substring(0, wdfLocation.Length - SearchName.Length)
Dim oWMSZPath = wdfLocation.Substring(2).ToLower Dim oWMSZPath
If WMSearchLocal = False Then
oWMSZPath = wdfLocation.Substring(2).ToLower
Else
oWMSZPath = wdfLocation.ToLower
End If
Logger.Debug("oWMSZPath: " & oWMSZPath) Logger.Debug("oWMSZPath: " & oWMSZPath)
Try Try
@ -495,6 +506,11 @@ Public Class clsWindream_allgemein
Catch ex As Exception Catch ex As Exception
Dim msg As String = ex.Message Dim msg As String = ex.Message
Try Try
If WMSearchLocal = True Then
Logger.Error(ex)
Return dtresult
End If
Logger.Debug("Unexpected Error in Creating oController: " & msg) Logger.Debug("Unexpected Error in Creating oController: " & msg)
Logger.Debug("...NOW trying to implement \\windream\Objects ...") Logger.Debug("...NOW trying to implement \\windream\Objects ...")
Dim WmSearch_wmobject = "\\windream\Objects" & oWMSZPath Dim WmSearch_wmobject = "\\windream\Objects" & oWMSZPath
@ -559,18 +575,18 @@ Public Class clsWindream_allgemein
If WMObjects.Count > 0 Then If WMObjects.Count > 0 Then
For Each dok As WMObject In WMObjects For Each dok As WMObject In WMObjects
Dim path As String = dok.aPath Dim oPath As String = dok.aPath
Dim DOC_ID = dok.GetVariableValue(NameIndexDocID) Dim oDOC_ID = dok.GetVariableValue(NameIndexDocID)
Logger.Debug("Adding DocInfo for DocID: " & DOC_ID.ToString) Dim oCreated = dok.GetVariableValue(NameIndexCreated)
dtresult.Rows.Add(DOC_ID, path, dok.GetVariableValue(NameIndexCreated)) Logger.Debug($"Adding DocInfo {oDOC_ID.ToString}|{oPath}|{oCreated}")
dtresult.Rows.Add(oDOC_ID, oPath, oCreated)
Next Next
dtresult.AcceptChanges() dtresult.AcceptChanges()
Else
Logger.Info($"No results for WMSearch: {wdfLocation}!!")
End If End If
Return dtresult Return dtresult
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn($"WM-SEARCH ({wdfLocation})")
Return dtresult Return dtresult
End Try End Try
End Function End Function

View File

@ -1,25 +1,23 @@
Imports System.IO 'Imports System.Collections.ObjectModel
'Imports System.Collections.ObjectModel
Imports System.ComponentModel Imports System.ComponentModel
Imports DigitalData.Modules.Logging Imports System.IO
Imports DD_WMResulthandler Imports DD_WMResulthandler
Imports DigitalData.Modules.Logging
Public Class DDWDResultHandler Public Class DDWDResultHandler
#Region "+++++ Variablen +++++" #Region "+++++ Variablen +++++"
Private _windream As DD_WMResulthandler.clsWindream_allgemein Private _windream As DD_WMResulthandler.clsWindream_allgemein
Private _windreamPMR As DD_WMResulthandler.clsWindream_allgemein
Private _database As DD_WMResulthandler.clsDatabase Private _database As DD_WMResulthandler.clsDatabase
Private _databasePMR As DD_WMResulthandler.clsDatabase
Private _profil As clsProfil Private _profil As clsProfil
Public Shared threadRunner As BackgroundWorker Public Shared threadRunner As BackgroundWorker
Public Shared threadPMRefresh As BackgroundWorker Public Shared threadPMRefresh As BackgroundWorker
Private Logger As Logger Private Logger As Logger
Private Shared MyLogger As LogConfig Private MyLogger As LogConfig
Private LoggerPMR As Logger 'Private LoggerPMR As Logger
Private Shared MyLoggerPMR As LogConfig 'Private MyLoggerPMR As LogConfig
Private PMRefresh As clsPMRefresh
Public Shared _PROFIL_ID As Integer Public Shared _PROFIL_ID As Integer
Dim _INTERVALL As Integer Dim _INTERVALL As Integer
@ -47,7 +45,7 @@ Public Class DDWDResultHandler
Try Try
MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
_database = New clsDatabase(MyLogger, My.Settings.SQLSERVER_CS) _database = New clsDatabase(MyLogger)
Catch ex As Exception Catch ex As Exception
EventLog.WriteEntry("DDWMResultHandler", "ERROR in CREATING-LOG:" & ex.ToString(), EventLogEntryType.Error) EventLog.WriteEntry("DDWMResultHandler", "ERROR in CREATING-LOG:" & ex.ToString(), EventLogEntryType.Error)
@ -57,7 +55,7 @@ Public Class DDWDResultHandler
If My.Settings.SQLSERVER_CS = String.Empty Then If My.Settings.SQLSERVER_CS = String.Empty Then
Logger.Warn("Achtung: Es wurde noch kein Datenbank-ConnectionString hinterlegt.") Logger.Warn("Achtung: Es wurde noch kein Datenbank-ConnectionString hinterlegt.")
Else Else
If _database.Init(My.Settings.SQLSERVER_CS) = False Then If _database.Init(My.Settings.SQLSERVER_CS, True) = False Then
Logger.Warn("Achtung: Es konnte keine Verbindung zur Datenbank '" & My.Settings.SQLSERVER_CS & "' hergestellt werden!") Logger.Warn("Achtung: Es konnte keine Verbindung zur Datenbank '" & My.Settings.SQLSERVER_CS & "' hergestellt werden!")
Else Else
@ -97,14 +95,14 @@ Public Class DDWDResultHandler
Dim TimerPMRefresh As New System.Timers.Timer() Dim TimerPMRefresh As New System.Timers.Timer()
'Das Event hinterlegen welches bei "Tick" ausgelöst wird 'Das Event hinterlegen welches bei "Tick" ausgelöst wird
AddHandler TimerPMRefresh.Elapsed, AddressOf ThreadPMRefreshRun AddHandler TimerPMRefresh.Elapsed, AddressOf ThreadPMRefreshRun
' Set the Interval
TimerPMRefresh.Interval = 353000
'ClassLogger.Add("Timer - Intervall: " & clsSQLITE.konf_intervall & " Minuten", False)
TimerPMRefresh.Enabled = True
' Und den Durchlauf das erste Mal starten ' Und den Durchlauf das erste Mal starten
threadRunner.RunWorkerAsync() threadRunner.RunWorkerAsync()
' Set the Interval
TimerPMRefresh.Interval = 120000 '2 minutes
'ClassLogger.Add("Timer - Intervall: " & clsSQLITE.konf_intervall & " Minuten", False)
TimerPMRefresh.Enabled = True
End If End If
End If End If
Catch ex As Exception Catch ex As Exception
@ -119,7 +117,7 @@ Public Class DDWDResultHandler
End If End If
End Sub End Sub
Public Sub ThreadPMRefreshRun() Public Sub ThreadPMRefreshRun()
Logger.Info("In Tick of ThreadPMRefreshRun") Logger.Debug("In Tick of ThreadPMRefreshRun")
If Not threadPMRefresh.IsBusy Then If Not threadPMRefresh.IsBusy Then
threadPMRefresh.RunWorkerAsync() threadPMRefresh.RunWorkerAsync()
Else Else
@ -129,7 +127,8 @@ Public Class DDWDResultHandler
Protected Overrides Sub OnStop() Protected Overrides Sub OnStop()
Try Try
' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen. ' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen.
Logger.Warn("WindreamResultHandler wurde gestoppt - " & Now) Logger.Warn("WindreamResultHandler wurde gestoppt!")
'LoggerPMR.Warn("WindreamResultHandler has been stopped!")
_database.Execute_non_Query("Update TBWMRH_PROFIL SET Running = 1 WHERE GUID = " & _PROFIL_ID) _database.Execute_non_Query("Update TBWMRH_PROFIL SET Running = 1 WHERE GUID = " & _PROFIL_ID)
Catch ex As Exception Catch ex As Exception
EventLog.WriteEntry("DDWMResultHandler", "Unexpected error in OnStop: " & ex.ToString(), EventLogEntryType.Error) EventLog.WriteEntry("DDWMResultHandler", "Unexpected error in OnStop: " & ex.ToString(), EventLogEntryType.Error)
@ -140,18 +139,18 @@ Public Class DDWDResultHandler
Try Try
MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
_database = New clsDatabase(MyLogger, My.Settings.SQLSERVER_CS) _database = New clsDatabase(MyLogger)
Dim notcompleted As Boolean = False Dim notcompleted As Boolean = False
'clsLogger.Init(My.Application.Info.DirectoryPath & "\Log", "_SERVICEResultHandler") 'clsLogger.Init(My.Application.Info.DirectoryPath & "\Log", "_SERVICEResultHandler")
Logger.Info("RUN_THREAD WMResulthandler started..") Logger.Debug("RUN_THREAD WMResulthandler started..")
' Windream instanziieren ' Windream instanziieren
_windream = New clsWindream_allgemein(MyLogger) _windream = New clsWindream_allgemein(MyLogger)
'windream initialisieren 'windream initialisieren
If _windream.Init() = True Then If _windream.Init() = True Then
Logger.Debug("windream vollumfänglich initialisiert!") Logger.Debug("windream vollumfänglich initialisiert!")
'Zur sicherheit die DB nochmal initialiseren 'Zur sicherheit die DB nochmal initialiseren
If _database.Init(My.Settings.SQLSERVER_CS) = True Then If _database.Init(My.Settings.SQLSERVER_CS, True) = True Then
Dim DT As DataTable = _database.Return_Datatable("select * from TBWMRH_KONFIGURATION where GUID = 1") Dim DT As DataTable = _database.Return_Datatable("select * from TBWMRH_KONFIGURATION where GUID = 1")
If DT.Rows.Count = 1 Then If DT.Rows.Count = 1 Then
clsCURRENT.DT_TBWMRH_KONFIGURATION = DT clsCURRENT.DT_TBWMRH_KONFIGURATION = DT
@ -186,7 +185,7 @@ Public Class DDWDResultHandler
End If End If
Next Next
Else Else
Logger.Warn("Keine aktiven Profile WMResulthandler vorhanden") Logger.Info("Keine aktiven Profile WMResulthandler vorhanden")
notcompleted = True notcompleted = True
End If End If
_database.Execute_non_Query("UPDATE TBWMRH_KONFIGURATION SET LAST_TICK = GETDATE() WHERE GUID = 1") _database.Execute_non_Query("UPDATE TBWMRH_KONFIGURATION SET LAST_TICK = GETDATE() WHERE GUID = 1")
@ -212,214 +211,16 @@ Public Class DDWDResultHandler
End Sub End Sub
Public Sub RUNPMRefresh(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Public Sub RUNPMRefresh(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
Try Try
MyLoggerPMR = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log_PMRefresh")) 'MyLoggerPMR = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log_PMRefresh"))
LoggerPMR = MyLoggerPMR.GetLogger() 'LoggerPMR = MyLoggerPMR.GetLogger()
_databasePMR = New clsDatabase(MyLoggerPMR, My.Settings.SQLSERVER_CS_PMRefresh) PMRefresh = New clsPMRefresh(MyLogger)
_windreamPMR = New clsWindream_allgemein(MyLoggerPMR) Logger.Debug("PMRefresh.CheckRun....")
If _windreamPMR.Init() = True Then If PMRefresh.CheckRun() = True Then
Logger.Debug("PMRefresh.CheckRun = True....")
PMRefresh.Refresh_Data()
If _databasePMR.Init(My.Settings.SQLSERVER_CS_PMRefresh) = True Then
Dim oDTPM_CONFIG As DataTable = _databasePMR.Return_Datatable("select * from TBPM_KONFIGURATION where GUID = 1")
If oDTPM_CONFIG.Rows.Count = 1 Then
Dim oConfigschedule = oDTPM_CONFIG.Rows(0).Item("SERVICE_SCHEDULE").ToString
Dim oConfigIDXName_DocID = oDTPM_CONFIG.Rows(0).Item("SERVICE_IDXNAME_DOCID").ToString
Dim oConfigIDXName_Created = oDTPM_CONFIG.Rows(0).Item("SERVICE_IDXNAME_CREATED").ToString
Dim oConfigWMDrive = oDTPM_CONFIG.Rows(0).Item("SERVICE_WMDRIVE_LETTER").ToString
Dim oConfigLOGERRONLY As Boolean = oDTPM_CONFIG.Rows(0).Item("SERVICE_LOG_ERRORS_ONLY")
Dim oSplit As String()
oSplit = oConfigschedule.Split(";")
Dim oTimespan = oSplit(0)
Dim oDays = oSplit(1)
If oConfigLOGERRONLY = False Then
MyLoggerPMR.Debug = True
LoggerPMR.Info("Detaillog Service PMRefresh is ON!")
Else
MyLoggerPMR.Debug = False
End If
Dim oDayofweek As Integer = My.Computer.Clock.LocalTime.DayOfWeek
Dim oSubstringInteger As Integer = 0
Dim oRunToday As Integer = 0
Select Case oDayofweek
Case 6 'Saturday
Case 5 'Friday
Case 4 'Thursday
Case 3 'Wednesday
Case 2 'Tuesday
Case 1 'Monday
Case 0 'Sunday
End Select
If oDayofweek = 0 Then
oSubstringInteger = 6
Else
oSubstringInteger = oDayofweek - 1
End If
oRunToday = oDays.Substring(oSubstringInteger, 1)
Dim oStep As String
If oRunToday = 1 Then
Dim oHourSplit As String() = oTimespan.Split("-")
Dim oMinHour As Integer = oHourSplit(0)
Dim oMaxHour As Integer = oHourSplit(1)
If CInt(Now.Hour) >= oMinHour And CInt(Now.Hour) < oMaxHour Then
LoggerPMR.Info($"Now running PM-Refresh ({oMinHour.ToString}#{oMaxHour.ToString})")
Try
LoggerPMR.Debug("Check_Profiles gestartet", False)
Dim WD_Search As String
Dim oSQLCommand As String
oSQLCommand = "SELECT GUID,NAME,WD_OBJECTTYPE,WD_SEARCH FROM TBPM_PROFILE WHERE ACTIVE = 1"
oStep = 1
Dim oDTPROFILES As DataTable = _databasePMR.Return_Datatable(oSQLCommand)
oStep = 2
Console.WriteLine(">> Evtl alte nicht aktualisierte PROFILE-FILE Daten werden gelöscht")
'---------------------- Evtl alte nicht aktualisierte PROFILE-FILE Daten werden gelöscht ------------------------
Dim oDelete As String = "DELETE FROM TBPM_PROFILE_FILES WHERE ACTIVE = 0 AND IN_WORK = 0"
_databasePMR.Execute_non_Query(oDelete)
oSQLCommand = "select * from TBPM_PROFILE_FILES"
Dim oDTPROFILE_FILES As DataTable = _databasePMR.Return_Datatable(oSQLCommand)
If oDTPROFILE_FILES.Rows.Count = 0 Then
LoggerPMR.Info("TBPM_PROFILE_FILES is completely empty...")
End If
'delete = "DELETE FROM TBPM_PROFILE_FILES_TEMP"
'ClassDatabase.Execute_MSSQL(delete)
oStep = 3
If oDTPROFILES.Rows.Count > 0 Then
Dim Profile_Row As System.Data.DataRow
'---------------------- für jedes Profil die Dateien überprüfen ------------------------
For Each Profile_Row In oDTPROFILES.Rows
oStep = "4a"
Console.WriteLine(">> Dateien für Profil '" & Profile_Row.Item("NAME") & "' eintragen")
LoggerPMR.Debug("Add info for profile '" & Profile_Row.Item("NAME") & "'")
Dim oPROFILE_ID As Integer = Profile_Row.Item("GUID")
WD_Search = Nothing
WD_Search = Profile_Row.Item("WD_SEARCH")
oStep = "4b"
If WD_Search Is Nothing = False Then
'---------------------- Die Dateien auslesen ------------------------
Dim oDTWM_Results As DataTable
oStep = "4c"
oDTWM_Results = _windreamPMR.GetSearchDocumentsDT(WD_Search, oConfigIDXName_DocID, oConfigIDXName_Created)
oStep = "4d"
Dim oDocCount As Integer = 0
If IsNothing(oDTWM_Results) Then
Continue For
End If
'Die aktuellen Files auf refreshed = 0 setzten
oSQLCommand = "UPDATE TBPM_PROFILE_FILES SET REFRESHED = 0 WHERE PROFIL_ID = " & oPROFILE_ID
If _databasePMR.Execute_non_Query(oSQLCommand) = True Then
If oDTWM_Results Is Nothing = False Then
If oDTWM_Results.Rows.Count > 0 Then
oStep = "4e"
'Ein Array mit Dateiinformationen anlegen
Dim Profil_Docs(oDTWM_Results.Rows.Count - 1, 2) As String
For Each oRow As DataRow In oDTWM_Results.Rows
Dim oDOC_ID = oRow.Item(0)
Dim oWMFilePath As String = oConfigWMDrive & ":" & oRow.Item(1)
Profil_Docs(oDocCount, 0) = oRow.Item(0)
Profil_Docs(oDocCount, 1) = oWMFilePath
'------DMS Erstell-Datum holen --------
Dim oDMSErstellt = oRow.Item(2)
'ClassLogger.Add(">> DMSErstellt: '" & DMSErstellt.ToString, False)
Dim date_EN As String
If oConfigIDXName_Created.EndsWith("reated") Then
Dim arr() = oDMSErstellt.ToString.Split(".")
If arr.Length = 3 Then
date_EN = arr(2).Replace(" 00:00:00", "") & "-" & arr(1) & "-" & arr(0)
LoggerPMR.Debug("date_EN: '" & date_EN)
oDMSErstellt = date_EN
End If
End If
'-------------------- Überprüfen ob das Dokument bereits enthalten ist? Kann nur passieren wenn das Dok gerade in Bearbeitung ist ----------
oSQLCommand = $"SELECT GUID FROM TBPM_PROFILE_FILES WHERE PROFIL_ID = {oPROFILE_ID} AND FILE_PATH = '{oWMFilePath}'"
Dim oCheck = _databasePMR.Execute_Scalar(oSQLCommand)
'---------------------- Das Dokument inserten ------------------------
Try
If oCheck Is Nothing Or oDTPROFILE_FILES.Rows.Count = 0 Then
Dim oInsert As String = $"INSERT INTO TBPM_PROFILE_FILES (PROFIL_ID, FILE_PATH, ACTIVE, DMS_ERSTELLT_DATE,DOC_ID) VALUES ({oPROFILE_ID}, '{oWMFilePath}',1, CONVERT(DATE,'{oDMSErstellt}'),{oDOC_ID})"
If _databasePMR.Execute_non_Query(oInsert) = False Then
LoggerPMR.Info($"Unexpected Error while Inserting File-Record {oDOC_ID}")
End If
' aktuelles Dokument der Klasse mitteilen
Else
If CInt(oCheck) > 0 Then
oSQLCommand = $"UPDATE TBPM_PROFILE_FILES SET REFRESHED = 1, EDIT = 0 WHERE GUID = {CInt(oCheck)}"
_databasePMR.Execute_non_Query(oSQLCommand)
End If
End If End If
Catch ex As Exception Catch ex As Exception
LoggerPMR.Error(ex) Logger.Error(ex)
End Try
oDocCount += 1
Next
LoggerPMR.Info($"Profile '{Profile_Row.Item("NAME")} refreshed - FileCount {oDocCount.ToString}")
Else
oStep = "4g"
LoggerPMR.Info($"No Data for profile '{Profile_Row.Item("NAME")}'!")
End If
Else
LoggerPMR.Warn("oDTWM_Results IS NOTHING")
End If
oStep = "Step: vor Delete Refreshed = 0"
Dim oSQLDEL As String = "DELETE FROM TBPM_PROFILE_FILES WHERE PROFIL_ID = " & oPROFILE_ID & " AND REFRESHED = 0"
_databasePMR.Execute_non_Query(oSQLDEL)
'---------------------- Aktuelle Anzahl in Profiltabelle updaten ------------------------
oSQLCommand = $"UPDATE TBPM_PROFILE SET NO_OF_DOCUMENTS = {oDocCount} WHERE GUID = {oPROFILE_ID}"
oStep = "Step 4h AnzahlDocs: - " & oDocCount.ToString
_databasePMR.Execute_non_Query(oSQLCommand)
Else
LoggerPMR.Warn("ATTENTION: Refresh could not be executed " & oSQLCommand)
End If
End If
Next
oStep = "4i"
''------------------------------- Bearbeitete Daten löschen ------------------------
If _databasePMR.Execute_non_Query("DELETE FROM TBPM_PROFILE_FILES WHERE EDIT = 1") = True Then
' oStep = "i"
' Console.WriteLine(">> Alte PROFILE-FILE Daten geleert")
' '---------------------- DIE NEUEN DATEN AUF ACTIVE SETZEN ------------------------
' Dim update As String = "UPDATE TBPM_PROFILE_FILES SET ACTIVE = 1 WHERE ACTIVE = 0"
' ClassDatabase.Execute_MSSQL(update)
' oStep = "j"
' Console.WriteLine(">> Neue PROFILE-FILE Daten aktiv gesetzt")
End If
oStep = "4j"
_databasePMR.Execute_non_Query("EXEC PRPM_REMOVE_NE_FILES")
oStep = "4k"
Else
LoggerPMR.Debug("oDTPROFILES has no rows!")
End If
Catch ex As Exception
LoggerPMR.Info("Unexpected Error in RUNJob")
LoggerPMR.Warn("Error in RunJob- laststep: " & oStep)
LoggerPMR.Error(ex)
End Try
Else
LoggerPMR.Info($"No run of PMRefresh as hour is not in timespan ({CInt(Now.Hour)} >= {oMinHour} And {CInt(Now.Hour)} < {oMaxHour})")
End If
Else
LoggerPMR.Info($"No run of PMRefresh as today Is Not configured as RUN")
End If
End If
Else
LoggerPMR.Warn("Could not initialize the database of PMRefresh.")
End If
End If
Catch ex As Exception
LoggerPMR.Error(ex)
End Try End Try
End Sub End Sub
#Region "*** BackgroundWorker beenden und Abbrechen ***" #Region "*** BackgroundWorker beenden und Abbrechen ***"

View File

@ -100,6 +100,7 @@
<Import Include="System.Threading.Tasks" /> <Import Include="System.Threading.Tasks" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="clsPMRefresh.vb" />
<Compile Include="My Project\Application.Designer.vb"> <Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon> <DependentUpon>Application.myapp</DependentUpon>

View File

@ -0,0 +1,240 @@
Imports DigitalData.Modules.Logging
Imports DD_WMResulthandler
Public Class clsPMRefresh
Private Logger As Logger
Private Shared MyLogger As LogConfig
Private _database As clsDatabase
Private _windream As clsWindream_allgemein
Private oConfigschedule
Private oConfigIDXName_DocID
Private oConfigIDXName_Created
Private oConfigWMDrive
Private oConfigLOGERRONLY As Boolean
Sub New(theLogger As LogConfig)
MyLogger = theLogger
Logger = MyLogger.GetLogger()
End Sub
Public Function CheckRun() As Boolean
Try
_database = New clsDatabase(MyLogger)
_windream = New clsWindream_allgemein(MyLogger)
Logger.Debug("..in CheckRun..classes initialized")
If _windream.Init() = True Then
If _database.Init(My.Settings.SQLSERVER_CS_PMRefresh, False) = True Then
Dim oDTPM_CONFIG As DataTable = _database.Return_Datatable("select * from TBPM_KONFIGURATION where GUID = 1", My.Settings.SQLSERVER_CS_PMRefresh)
If oDTPM_CONFIG.Rows.Count = 1 Then
oConfigschedule = oDTPM_CONFIG.Rows(0).Item("SERVICE_SCHEDULE").ToString
oConfigIDXName_DocID = oDTPM_CONFIG.Rows(0).Item("SERVICE_IDXNAME_DOCID").ToString
oConfigIDXName_Created = oDTPM_CONFIG.Rows(0).Item("SERVICE_IDXNAME_CREATED").ToString
oConfigWMDrive = oDTPM_CONFIG.Rows(0).Item("SERVICE_WMDRIVE_LETTER").ToString
oConfigLOGERRONLY = oDTPM_CONFIG.Rows(0).Item("SERVICE_LOG_ERRORS_ONLY")
Dim oSplit As String()
oSplit = oConfigschedule.Split(";")
Dim oTimespan = oSplit(0)
Dim oDays = oSplit(1)
If oConfigLOGERRONLY = False Then
MyLogger.Debug = True
Logger.Info("Detaillog Service PMRefresh is ON!")
Else
MyLogger.Debug = False
End If
Dim oDayofweek As Integer = My.Computer.Clock.LocalTime.DayOfWeek
Dim oSubstringInteger As Integer = 0
Dim oRunToday As Integer = 0
Select Case oDayofweek
Case 6 'Saturday
Case 5 'Friday
Case 4 'Thursday
Case 3 'Wednesday
Case 2 'Tuesday
Case 1 'Monday
Case 0 'Sunday
End Select
Logger.Debug($"oDayofweek: {oDayofweek}...")
If oDayofweek = 0 Then
oSubstringInteger = 6
Else
oSubstringInteger = oDayofweek - 1
End If
Logger.Debug($"oSubstringInteger: {oSubstringInteger}...")
oRunToday = oDays.Substring(oSubstringInteger, 1)
Logger.Debug($"oRunToday: {oRunToday}...")
If oRunToday = 1 Then
Dim oHourSplit As String() = oTimespan.Split("-")
Dim oMinHour As Integer = oHourSplit(0)
Dim oMaxHour As Integer = oHourSplit(1)
If CInt(Now.Hour) >= oMinHour And CInt(Now.Hour) < oMaxHour Then
Logger.Debug($"Now running PM-Refresh ({oMinHour.ToString}#{oMaxHour.ToString})")
Return True
Else
Logger.Info($"No run of PMRefresh as hour is not in timespan ({CInt(Now.Hour)} >= {oMinHour} And {CInt(Now.Hour)} < {oMaxHour})")
End If
Else
Logger.Info($"No run of PMRefresh as today Is Not configured as RUN")
End If
Else
Logger.Warn("oDTPM_CONFIG.Rows.Count <> 1")
End If
Else
Logger.Warn($"Could not initialize the database of PMRefresh ({My.Settings.SQLSERVER_CS_PMRefresh})")
End If
Else
Logger.Warn("Could not initialize windream in PMRefresh.")
End If
'Return false as no criteria matched to execute the run
Return False
Catch ex As Exception
Logger.Info("Unexpected Error in CheckRun")
Logger.Error(ex)
Return False
End Try
End Function
Public Function Refresh_Data()
Dim oStep As String
Try
Logger.Debug("Check_Profiles gestartet", False)
Dim WD_Search As String
Dim oSQLCommand As String
oSQLCommand = "SELECT GUID,NAME,WD_OBJECTTYPE,WD_SEARCH FROM TBPM_PROFILE WHERE ACTIVE = 1"
oStep = 1
Dim oDTPROFILES As DataTable = _database.Return_Datatable(oSQLCommand, My.Settings.SQLSERVER_CS_PMRefresh)
oStep = 2
'---------------------- Evtl alte nicht aktualisierte PROFILE-FILE Daten werden gelöscht ------------------------
Dim oDelete As String = "DELETE FROM TBPM_PROFILE_FILES WHERE ACTIVE = 0 AND IN_WORK = 0"
_database.Execute_non_Query(oDelete, My.Settings.SQLSERVER_CS_PMRefresh)
oSQLCommand = "select * from TBPM_PROFILE_FILES"
Dim oDTPROFILE_FILES As DataTable = _database.Return_Datatable(oSQLCommand, My.Settings.SQLSERVER_CS_PMRefresh)
If oDTPROFILE_FILES.Rows.Count = 0 Then
Logger.Info("TBPM_PROFILE_FILES is completely empty...")
End If
'delete = "DELETE FROM TBPM_PROFILE_FILES_TEMP"
'ClassDatabase.Execute_MSSQL(delete)
oStep = 3
If oDTPROFILES.Rows.Count > 0 Then
Dim Profile_Row As System.Data.DataRow
'---------------------- für jedes Profil die Dateien überprüfen ------------------------
For Each Profile_Row In oDTPROFILES.Rows
oStep = "4a"
Console.WriteLine(">> Dateien für Profil '" & Profile_Row.Item("NAME") & "' eintragen")
Logger.Debug("Add info for profile '" & Profile_Row.Item("NAME") & "'")
Dim oPROFILE_ID As Integer = Profile_Row.Item("GUID")
WD_Search = Nothing
WD_Search = Profile_Row.Item("WD_SEARCH")
oStep = "4b"
If WD_Search Is Nothing = False Then
'---------------------- Die Dateien auslesen ------------------------
Dim oDTWM_Results As DataTable
oStep = "4c"
oDTWM_Results = _windream.GetSearchDocumentsDT(WD_Search, oConfigIDXName_DocID, oConfigIDXName_Created, True)
oStep = "4d"
Dim oDocCount As Integer = 0
If IsNothing(oDTWM_Results) Then
Continue For
End If
'Die aktuellen Files auf refreshed = 0 setzten
oSQLCommand = "UPDATE TBPM_PROFILE_FILES SET REFRESHED = 0 WHERE PROFIL_ID = " & oPROFILE_ID
If _database.Execute_non_Query(oSQLCommand, My.Settings.SQLSERVER_CS_PMRefresh) = True Then
If oDTWM_Results Is Nothing = False Then
If oDTWM_Results.Rows.Count > 0 Then
oStep = "4e"
'Ein Array mit Dateiinformationen anlegen
Dim Profil_Docs(oDTWM_Results.Rows.Count - 1, 2) As String
For Each oRow As DataRow In oDTWM_Results.Rows
Dim oDOC_ID = oRow.Item(0)
Dim oWMFilePath As String = oConfigWMDrive & ":" & oRow.Item(1)
Profil_Docs(oDocCount, 0) = oRow.Item(0)
Profil_Docs(oDocCount, 1) = oWMFilePath
'------DMS Erstell-Datum holen --------
Dim oDMSErstellt = oRow.Item(2)
'ClassLogger.Add(">> DMSErstellt: '" & DMSErstellt.ToString, False)
Dim date_EN As String
If oConfigIDXName_Created.EndsWith("reated") Then
Dim arr() = oDMSErstellt.ToString.Split(".")
If arr.Length = 3 Then
date_EN = arr(2).Replace(" 00:00:00", "") & "-" & arr(1) & "-" & arr(0)
Logger.Debug("date_EN: '" & date_EN)
oDMSErstellt = date_EN
End If
End If
'-------------------- Überprüfen ob das Dokument bereits enthalten ist? Kann nur passieren wenn das Dok gerade in Bearbeitung ist ----------
oSQLCommand = $"SELECT GUID FROM TBPM_PROFILE_FILES WHERE PROFIL_ID = {oPROFILE_ID} AND DOC_ID = {oDOC_ID}"
Dim oGUID = _database.Execute_Scalar(oSQLCommand, My.Settings.SQLSERVER_CS_PMRefresh)
'---------------------- Das Dokument inserten ------------------------
Try
If oGUID Is Nothing Or oDTPROFILE_FILES.Rows.Count = 0 Then
Logger.Debug($"DocID {oDOC_ID} not existing...INSERT")
Dim oInsert As String = $"INSERT INTO TBPM_PROFILE_FILES (PROFIL_ID, FILE_PATH, ACTIVE, DMS_ERSTELLT_DATE,DOC_ID) VALUES ({oPROFILE_ID}, '{oWMFilePath}',1, CONVERT(DATE,'{oDMSErstellt}'),{oDOC_ID})"
If _database.Execute_non_Query(oInsert, My.Settings.SQLSERVER_CS_PMRefresh) = False Then
Logger.Info($"Unexpected Error while Inserting File-Record {oDOC_ID}")
End If
' aktuelles Dokument der Klasse mitteilen
Else
Logger.Debug($"DocID {oDOC_ID} existing...UPDATE")
If CInt(oGUID) > 0 Then
oSQLCommand = $"UPDATE TBPM_PROFILE_FILES SET REFRESHED = 1, REFRESHED_WHEN = GETDATE(), EDIT = 0 WHERE GUID = {oGUID}"
_database.Execute_non_Query(oSQLCommand, My.Settings.SQLSERVER_CS_PMRefresh)
End If
End If
Catch ex As Exception
Logger.Error(ex)
End Try
oDocCount += 1
Next
Logger.Info($"Profile '{Profile_Row.Item("NAME")} refreshed - FileCount {oDocCount.ToString}")
Else
oStep = "4g"
Logger.Debug($"No Data for profile '{Profile_Row.Item("NAME")}'!")
End If
Else
Logger.Warn("oDTWM_Results IS NOTHING")
End If
oStep = "Step: vor Delete Refreshed = 0"
Dim oSQLDEL As String = "DELETE FROM TBPM_PROFILE_FILES WHERE PROFIL_ID = " & oPROFILE_ID & " AND REFRESHED = 0"
_database.Execute_non_Query(oSQLDEL, My.Settings.SQLSERVER_CS_PMRefresh)
'---------------------- Aktuelle Anzahl in Profiltabelle updaten ------------------------
oSQLCommand = $"UPDATE TBPM_PROFILE SET NO_OF_DOCUMENTS = {oDocCount} WHERE GUID = {oPROFILE_ID}"
oStep = "Step 4h AnzahlDocs: - " & oDocCount.ToString
_database.Execute_non_Query(oSQLCommand, My.Settings.SQLSERVER_CS_PMRefresh)
Else
Logger.Warn("ATTENTION: Refresh could not be executed " & oSQLCommand)
End If
End If
Next
oStep = "4i"
''------------------------------- Bearbeitete Daten löschen ------------------------
If _database.Execute_non_Query("DELETE FROM TBPM_PROFILE_FILES WHERE EDIT = 1", My.Settings.SQLSERVER_CS_PMRefresh) = True Then
' oStep = "i"
' Console.WriteLine(">> Alte PROFILE-FILE Daten geleert")
' '---------------------- DIE NEUEN DATEN AUF ACTIVE SETZEN ------------------------
' Dim update As String = "UPDATE TBPM_PROFILE_FILES SET ACTIVE = 1 WHERE ACTIVE = 0"
' ClassDatabase.Execute_MSSQL(update)
' oStep = "j"
' Console.WriteLine(">> Neue PROFILE-FILE Daten aktiv gesetzt")
End If
oStep = "4j"
_database.Execute_non_Query("EXEC PRPM_REMOVE_NE_FILES", My.Settings.SQLSERVER_CS_PMRefresh)
oStep = "4k"
Else
Logger.Debug("oDTPROFILES has no rows!")
End If
Catch ex As Exception
Logger.Info("Unexpected Error in RUNJob")
Logger.Warn("Error in RunJob- laststep: " & oStep)
Logger.Error(ex)
End Try
End Function
End Class

View File

@ -33,7 +33,7 @@ Public Class frmMain
MyLogger = New LogConfig(LogConfig.PathType.AppData, Nothing, "Log") MyLogger = New LogConfig(LogConfig.PathType.AppData, Nothing, "Log")
Logger = MyLogger.GetLogger() Logger = MyLogger.GetLogger()
Load_Constring() Load_Constring()
_database = New clsDatabase(MyLogger, My.Settings.SQLSERVER_CS) _database = New clsDatabase(MyLogger)
_email = New clsEmail(MyLogger) _email = New clsEmail(MyLogger)
Logger.Info("Konfig started: " & Now.ToString) Logger.Info("Konfig started: " & Now.ToString)
Try Try
@ -670,7 +670,7 @@ Public Class frmMain
Logger.Info("## Start Durchlauf WindreamResultHandler - " & Now & " ## ") Logger.Info("## Start Durchlauf WindreamResultHandler - " & Now & " ## ")
_profil = New clsProfil(MyLogger, ID) _profil = New clsProfil(MyLogger, ID)
'windream initialisieren 'windream initialisieren
If _database.Init(My.Settings.SQLSERVER_CS) = True Then If _database.Init(My.Settings.SQLSERVER_CS, True) = True Then
Dim DT As DataTable = _database.Return_Datatable("select * from TBWMRH_KONFIGURATION where GUID = 1") Dim DT As DataTable = _database.Return_Datatable("select * from TBWMRH_KONFIGURATION where GUID = 1")
If DT.Rows.Count = 1 Then If DT.Rows.Count = 1 Then
clsCURRENT.DT_TBWMRH_KONFIGURATION = DT clsCURRENT.DT_TBWMRH_KONFIGURATION = DT