MS HTTPS, Log,
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user