MS HTTPS, Log,
This commit is contained in:
parent
24f052f5b5
commit
fd30d75e9f
@ -4,22 +4,23 @@ Imports DigitalData.Modules.Logging
|
||||
Public Class clsDatabase
|
||||
Private Shared MSSQL_inited As Boolean = False
|
||||
Dim Logger As Logger
|
||||
Sub New(MyLogger As LogConfig, ConStr As String)
|
||||
Sub New(MyLogger As LogConfig)
|
||||
Logger = MyLogger.GetLogger()
|
||||
Init(ConStr)
|
||||
End Sub
|
||||
Public Function Init(CONSTRING As String)
|
||||
Public Function Init(CONSTRING As String, pSaveCS As Boolean)
|
||||
Try
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
SQLconnect.ConnectionString = CONSTRING
|
||||
SQLconnect.Open()
|
||||
SQLconnect.Close()
|
||||
clsCURRENT.SQLSERVER_CS = CONSTRING
|
||||
MSSQL_inited = True
|
||||
If pSaveCS = True Then
|
||||
clsCURRENT.SQLSERVER_CS = CONSTRING
|
||||
|
||||
End If
|
||||
MSSQL_inited = True
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"CONSTRING: {CONSTRING}")
|
||||
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
@ -219,15 +220,19 @@ Public Class clsDatabase
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Return_Datatable(Select_anweisung As String)
|
||||
Public Function Return_Datatable(Select_anweisung As String, Optional pSQLConnection As String = "")
|
||||
Try
|
||||
Logger.Debug("Select_anweisung: " & Select_anweisung)
|
||||
If MSSQL_inited = False Then Return Nothing
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
SQLcommand.CommandText = Select_anweisung
|
||||
@ -240,20 +245,30 @@ Public Class clsDatabase
|
||||
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"SQL: {Select_anweisung}")
|
||||
'clsLogger.Add("Error in Return_Datatable: " & ex.Message, True)
|
||||
'clsLogger.Add(">> SQL: " & Select_anweisung, False)
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
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
|
||||
Dim oSQLCON As String
|
||||
Try
|
||||
Logger.Debug("ExecuteCMD: " & ExecuteCMD)
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
oSQLCON = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
oSQLCON = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
SQLconnect.ConnectionString = oSQLCON
|
||||
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
@ -268,7 +283,10 @@ Public Class clsDatabase
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Dim msg = $"Unexpected error in Execute_non_Query: SQL: {ExecuteCMD}, oSQLCON: {oSQLCON}"
|
||||
Logger.Error(ex)
|
||||
Logger.Debug(msg)
|
||||
Logger.Info(msg)
|
||||
'clsLogger.Add("Error in Execute_non_Query: " & ex.Message, True)
|
||||
'clsLogger.Add("SQL: " & ExecuteCMD, False)
|
||||
|
||||
@ -276,7 +294,7 @@ Public Class clsDatabase
|
||||
End Try
|
||||
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
|
||||
Dim result
|
||||
Try
|
||||
@ -285,7 +303,11 @@ Public Class clsDatabase
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
|
||||
SQLconnect.Open()
|
||||
@ -300,7 +322,7 @@ Public Class clsDatabase
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"SQL: {cmdscalar}")
|
||||
'clsLogger.Add("Error in Execute_Scalar: " & ex.Message, True)
|
||||
'clsLogger.Add("SQL: " & cmdscalar, False)
|
||||
Return Nothing
|
||||
|
||||
@ -33,7 +33,7 @@ Public Class clsDateiverarbeitung
|
||||
MyLoggerConf = MyLogger
|
||||
Logger = MyLogger.GetLogger()
|
||||
_windream = New clsWindream_allgemein(MyLogger)
|
||||
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
End Sub
|
||||
Public Function InitProfilData()
|
||||
Try
|
||||
@ -319,6 +319,7 @@ Public Class clsDateiverarbeitung
|
||||
''' <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>
|
||||
Public Function BNSjsonDownload(WMFile As WMObject, userId As String, apiAddress As String)
|
||||
Dim url As String
|
||||
Try
|
||||
Logger.Info("handling BNSjsonDownload.....")
|
||||
' Indizes für das aktuelle Dokument auslesen
|
||||
@ -352,42 +353,62 @@ Public Class clsDateiverarbeitung
|
||||
Dim geschaeftsObjekt = "Sendung"
|
||||
' Für Tests wird hier die Sendungsnummer verwendet, später hängt der verwendete Index von 'geschaeftsObjekt' ab
|
||||
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($">> 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.ContentType = "application/json"
|
||||
req.ContentLength = bytes.Length
|
||||
req.Timeout = 3000
|
||||
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.Close()
|
||||
|
||||
'Logger.Debug($">> Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
|
||||
'Logger.Debug($">> Upload URL: {url}")
|
||||
Try
|
||||
Using res As HttpWebResponse = req.GetResponse()
|
||||
Dim code As HttpStatusCode = res.StatusCode
|
||||
Dim text As String = res.StatusDescription
|
||||
|
||||
Using res As HttpWebResponse = req.GetResponse()
|
||||
Dim code As HttpStatusCode = res.StatusCode
|
||||
Dim text As String = res.StatusDescription
|
||||
' Status 201 Created bedeutet: Alles okay!
|
||||
If code = HttpStatusCode.Created Then
|
||||
Logger.Info($"File has been uploaded: docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
|
||||
Else
|
||||
Logger.Warn($"Server Error (HTTP {code}: {text})")
|
||||
End If
|
||||
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
|
||||
|
||||
' Status 201 Created bedeutet: Alles okay!
|
||||
If code = HttpStatusCode.Created Then
|
||||
Logger.Info($"File has been uploaded: docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
|
||||
Else
|
||||
Logger.Warn($"Server Error (HTTP {code}: {text})")
|
||||
End If
|
||||
End Using
|
||||
Return True
|
||||
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)
|
||||
Return True
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Public Function RUN_ORACLE_COMMAND(WMFile As WMObject, OracleCS As String, OracleCommandRAW As String)
|
||||
|
||||
@ -39,14 +39,9 @@ Public Class clsJob_Work
|
||||
|
||||
Dim oPWPlain = owrapper.DecryptData(oMAIL_USER_PW)
|
||||
If Not IsNothing(oPWPlain) Then
|
||||
If oPWPlain <> "" Then
|
||||
oMAIL_USER_PW = oPWPlain
|
||||
Else
|
||||
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort 42")
|
||||
Return False
|
||||
End If
|
||||
oMAIL_USER_PW = oPWPlain
|
||||
Else
|
||||
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort 46")
|
||||
Logger.Warn("PWPlain is Nothing - Could not decrypt passwort 44")
|
||||
Return False
|
||||
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
|
||||
|
||||
@ -21,7 +21,7 @@ Public Class clsProfil
|
||||
Logger = MyLogger.GetLogger()
|
||||
windream = New clsWindream_allgemein(MyLogger)
|
||||
windream_index = New clsWindream_Index(MyLogger)
|
||||
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
_dateiverarbeitung = New clsDateiverarbeitung(MyLogger)
|
||||
_email = New clsEmail(MyLogger)
|
||||
_JobWork = New clsJob_Work(MyLogger, _email)
|
||||
@ -115,7 +115,7 @@ Public Class clsProfil
|
||||
'Den Durchlauf erlauben
|
||||
Run_Profile = True
|
||||
Else
|
||||
Logger.Info("No run as DiffMin (" & DiffMin & ") <= Intervall(" & arr(1) & ")")
|
||||
Logger.Debug("No run as DiffMin (" & DiffMin & ") <= Intervall(" & arr(1) & ")")
|
||||
End If
|
||||
Case Else
|
||||
Logger.Warn("_profRunType konnte nicht ausgewertet werden - " & arr(0))
|
||||
@ -305,7 +305,7 @@ Public Class clsProfil
|
||||
'Für jeden File-Job
|
||||
For Each DR_PR_FILE_JOB As DataRow In DT_PROFIL_FILE_JOB.Rows
|
||||
If FileJobSuccessful = False Then
|
||||
Logger.Info("AUSSTIEG FOR SCHLEIFE...")
|
||||
Logger.Info("AUSSTIEG FOR SCHLEIFE cause FileJobSuccessful = False...")
|
||||
Exit For
|
||||
End If
|
||||
Select Case DR_PR_FILE_JOB.Item("TYP").ToString.ToLower
|
||||
@ -607,7 +607,8 @@ Public Class clsProfil
|
||||
End Try
|
||||
Next
|
||||
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
|
||||
Logger.Warn("windreamSucheErgebnisse is nothing ( Send InfoMail with WM-Search)!", True, "clsProfil.Profil_Durchlauf")
|
||||
Return False
|
||||
@ -625,6 +626,8 @@ Public Class clsProfil
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
Logger.Info("Send InfoMail with WM-Search - oWMResults.Count = 0")
|
||||
End If
|
||||
|
||||
End Select
|
||||
@ -640,7 +643,7 @@ Public Class clsProfil
|
||||
End If
|
||||
Else
|
||||
' 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
|
||||
|
||||
|
||||
@ -34,7 +34,12 @@ Public Class clsWindream_allgemein
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Sub New(MyLogger As LogConfig)
|
||||
Logger = MyLogger.GetLogger()
|
||||
Try
|
||||
Logger = MyLogger.GetLogger()
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
' wenn ein Fehler bei der Initialisierung auftrat
|
||||
If Not Init() Then
|
||||
' Nachricht ausgeben
|
||||
@ -474,20 +479,26 @@ Public Class clsWindream_allgemein
|
||||
Return oSearch.execute
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"WM-SEARCH ({wdfLocation})")
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
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
|
||||
dtresult.Columns.Add("DOC_ID", GetType(Integer))
|
||||
dtresult.Columns.Add("PATH", GetType(String))
|
||||
dtresult.Columns.Add("CREATED", GetType(DateAndTime))
|
||||
dtresult.Columns.Add("CREATED", GetType(String))
|
||||
Logger.Debug($"Executing WMSearch: {wdfLocation}...")
|
||||
Try
|
||||
Dim SearchName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1)
|
||||
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)
|
||||
Try
|
||||
@ -495,6 +506,11 @@ Public Class clsWindream_allgemein
|
||||
Catch ex As Exception
|
||||
Dim msg As String = ex.Message
|
||||
Try
|
||||
If WMSearchLocal = True Then
|
||||
Logger.Error(ex)
|
||||
Return dtresult
|
||||
End If
|
||||
|
||||
Logger.Debug("Unexpected Error in Creating oController: " & msg)
|
||||
Logger.Debug("...NOW trying to implement \\windream\Objects ...")
|
||||
Dim WmSearch_wmobject = "\\windream\Objects" & oWMSZPath
|
||||
@ -559,18 +575,18 @@ Public Class clsWindream_allgemein
|
||||
If WMObjects.Count > 0 Then
|
||||
|
||||
For Each dok As WMObject In WMObjects
|
||||
Dim path As String = dok.aPath
|
||||
Dim DOC_ID = dok.GetVariableValue(NameIndexDocID)
|
||||
Logger.Debug("Adding DocInfo for DocID: " & DOC_ID.ToString)
|
||||
dtresult.Rows.Add(DOC_ID, path, dok.GetVariableValue(NameIndexCreated))
|
||||
Dim oPath As String = dok.aPath
|
||||
Dim oDOC_ID = dok.GetVariableValue(NameIndexDocID)
|
||||
Dim oCreated = dok.GetVariableValue(NameIndexCreated)
|
||||
Logger.Debug($"Adding DocInfo {oDOC_ID.ToString}|{oPath}|{oCreated}")
|
||||
dtresult.Rows.Add(oDOC_ID, oPath, oCreated)
|
||||
Next
|
||||
dtresult.AcceptChanges()
|
||||
Else
|
||||
Logger.Info($"No results for WMSearch: {wdfLocation}!!")
|
||||
End If
|
||||
Return dtresult
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"WM-SEARCH ({wdfLocation})")
|
||||
Return dtresult
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@ -1,25 +1,23 @@
|
||||
Imports System.IO
|
||||
|
||||
'Imports System.Collections.ObjectModel
|
||||
'Imports System.Collections.ObjectModel
|
||||
Imports System.ComponentModel
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports System.IO
|
||||
Imports DD_WMResulthandler
|
||||
Imports DigitalData.Modules.Logging
|
||||
Public Class DDWDResultHandler
|
||||
#Region "+++++ Variablen +++++"
|
||||
Private _windream As DD_WMResulthandler.clsWindream_allgemein
|
||||
Private _windreamPMR As DD_WMResulthandler.clsWindream_allgemein
|
||||
Private _database As DD_WMResulthandler.clsDatabase
|
||||
Private _databasePMR As DD_WMResulthandler.clsDatabase
|
||||
Private _profil As clsProfil
|
||||
|
||||
Public Shared threadRunner As BackgroundWorker
|
||||
Public Shared threadPMRefresh As BackgroundWorker
|
||||
|
||||
Private Logger As Logger
|
||||
Private Shared MyLogger As LogConfig
|
||||
Private MyLogger As LogConfig
|
||||
|
||||
Private LoggerPMR As Logger
|
||||
Private Shared MyLoggerPMR As LogConfig
|
||||
'Private LoggerPMR As Logger
|
||||
'Private MyLoggerPMR As LogConfig
|
||||
Private PMRefresh As clsPMRefresh
|
||||
|
||||
Public Shared _PROFIL_ID As Integer
|
||||
Dim _INTERVALL As Integer
|
||||
@ -47,7 +45,7 @@ Public Class DDWDResultHandler
|
||||
Try
|
||||
MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
|
||||
Logger = MyLogger.GetLogger()
|
||||
_database = New clsDatabase(MyLogger, My.Settings.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
|
||||
Catch ex As Exception
|
||||
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
|
||||
Logger.Warn("Achtung: Es wurde noch kein Datenbank-ConnectionString hinterlegt.")
|
||||
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!")
|
||||
Else
|
||||
|
||||
@ -97,14 +95,14 @@ Public Class DDWDResultHandler
|
||||
Dim TimerPMRefresh As New System.Timers.Timer()
|
||||
'Das Event hinterlegen welches bei "Tick" ausgelöst wird
|
||||
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
|
||||
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
|
||||
Catch ex As Exception
|
||||
@ -119,7 +117,7 @@ Public Class DDWDResultHandler
|
||||
End If
|
||||
End Sub
|
||||
Public Sub ThreadPMRefreshRun()
|
||||
Logger.Info("In Tick of ThreadPMRefreshRun")
|
||||
Logger.Debug("In Tick of ThreadPMRefreshRun")
|
||||
If Not threadPMRefresh.IsBusy Then
|
||||
threadPMRefresh.RunWorkerAsync()
|
||||
Else
|
||||
@ -129,7 +127,8 @@ Public Class DDWDResultHandler
|
||||
Protected Overrides Sub OnStop()
|
||||
Try
|
||||
' 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)
|
||||
Catch ex As Exception
|
||||
EventLog.WriteEntry("DDWMResultHandler", "Unexpected error in OnStop: " & ex.ToString(), EventLogEntryType.Error)
|
||||
@ -140,18 +139,18 @@ Public Class DDWDResultHandler
|
||||
Try
|
||||
MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
|
||||
Logger = MyLogger.GetLogger()
|
||||
_database = New clsDatabase(MyLogger, My.Settings.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
|
||||
Dim notcompleted As Boolean = False
|
||||
'clsLogger.Init(My.Application.Info.DirectoryPath & "\Log", "_SERVICEResultHandler")
|
||||
Logger.Info("RUN_THREAD WMResulthandler started..")
|
||||
Logger.Debug("RUN_THREAD WMResulthandler started..")
|
||||
' Windream instanziieren
|
||||
_windream = New clsWindream_allgemein(MyLogger)
|
||||
'windream initialisieren
|
||||
If _windream.Init() = True Then
|
||||
Logger.Debug("windream vollumfänglich initialisiert!")
|
||||
'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")
|
||||
If DT.Rows.Count = 1 Then
|
||||
clsCURRENT.DT_TBWMRH_KONFIGURATION = DT
|
||||
@ -186,7 +185,7 @@ Public Class DDWDResultHandler
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
Logger.Warn("Keine aktiven Profile WMResulthandler vorhanden")
|
||||
Logger.Info("Keine aktiven Profile WMResulthandler vorhanden")
|
||||
notcompleted = True
|
||||
End If
|
||||
_database.Execute_non_Query("UPDATE TBWMRH_KONFIGURATION SET LAST_TICK = GETDATE() WHERE GUID = 1")
|
||||
@ -212,214 +211,16 @@ Public Class DDWDResultHandler
|
||||
End Sub
|
||||
Public Sub RUNPMRefresh(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
|
||||
Try
|
||||
MyLoggerPMR = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log_PMRefresh"))
|
||||
LoggerPMR = MyLoggerPMR.GetLogger()
|
||||
_databasePMR = New clsDatabase(MyLoggerPMR, My.Settings.SQLSERVER_CS_PMRefresh)
|
||||
_windreamPMR = New clsWindream_allgemein(MyLoggerPMR)
|
||||
If _windreamPMR.Init() = True Then
|
||||
|
||||
|
||||
|
||||
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
|
||||
Catch ex As Exception
|
||||
LoggerPMR.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
|
||||
'MyLoggerPMR = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log_PMRefresh"))
|
||||
'LoggerPMR = MyLoggerPMR.GetLogger()
|
||||
PMRefresh = New clsPMRefresh(MyLogger)
|
||||
Logger.Debug("PMRefresh.CheckRun....")
|
||||
If PMRefresh.CheckRun() = True Then
|
||||
Logger.Debug("PMRefresh.CheckRun = True....")
|
||||
PMRefresh.Refresh_Data()
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
LoggerPMR.Error(ex)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
#Region "*** BackgroundWorker beenden und Abbrechen ***"
|
||||
@ -434,7 +235,7 @@ Public Class DDWDResultHandler
|
||||
ElseIf e.Error IsNot Nothing Then
|
||||
Logger.Warn("Fehler bei Durchlauf. Der Vorgang wird abgebrochen: " & e.Error.Message)
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
'If DI_Verzeichnisloeschen Then
|
||||
' Try
|
||||
|
||||
@ -100,6 +100,7 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="clsPMRefresh.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
|
||||
240
app/DDWDResultHandler/clsPMRefresh.vb
Normal file
240
app/DDWDResultHandler/clsPMRefresh.vb
Normal 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
|
||||
@ -33,7 +33,7 @@ Public Class frmMain
|
||||
MyLogger = New LogConfig(LogConfig.PathType.AppData, Nothing, "Log")
|
||||
Logger = MyLogger.GetLogger()
|
||||
Load_Constring()
|
||||
_database = New clsDatabase(MyLogger, My.Settings.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
_email = New clsEmail(MyLogger)
|
||||
Logger.Info("Konfig started: " & Now.ToString)
|
||||
Try
|
||||
@ -670,7 +670,7 @@ Public Class frmMain
|
||||
Logger.Info("## Start Durchlauf WindreamResultHandler - " & Now & " ## ")
|
||||
_profil = New clsProfil(MyLogger, ID)
|
||||
'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")
|
||||
If DT.Rows.Count = 1 Then
|
||||
clsCURRENT.DT_TBWMRH_KONFIGURATION = DT
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user