Bugfixing CountDocs

This commit is contained in:
SchreiberM 2019-10-31 10:17:21 +01:00
parent b3158f7a1e
commit 77ee901233
2 changed files with 52 additions and 45 deletions

View File

@ -189,66 +189,73 @@ Public Class frmStart
End If End If
End Sub End Sub
Sub CHECK_PROFILE_MATCH() Sub CHECK_PROFILE_MATCH()
Logger.Debug("...now CHECK_PROFILE_MATCH...")
Dim oProfiles = CURRENT_MATCHING_PROFILES Dim oProfiles = CURRENT_MATCHING_PROFILES
Dim oInvalidDocumentSQL = False 'Dim oInvalidDocumentSQL = False
Dim oInvalidDataSQL = False 'Dim oInvalidDataSQL = False
Dim oPatterns As New ClassPatterns(LogConfig) 'Dim oPatterns As New ClassPatterns(LogConfig)
Dim oEnv = GetEnvironment() Dim oEnv = GetEnvironment()
For Each oProfile In oProfiles 'For Each oProfile In oProfiles
Dim oResultDocs As Integer = 0 ' Dim oResultDocs As Integer = 0
Dim oResultData As Integer = 0 ' Dim oResultData As Integer = 0
Dim oDataSearches As DataTable = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}") ' Dim oDataSearches As DataTable = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
Dim oDocSearches As DataTable = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}") ' Dim oDocSearches As DataTable = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
For Each oRow As DataRow In oDataSearches.Rows ' For Each oRow As DataRow In oDataSearches.Rows
Dim oCountCommand = String.Empty ' Dim oCountCommand = String.Empty
Try ' Try
oCountCommand = oRow.Item("COUNT_COMMAND") ' oCountCommand = oRow.Item("COUNT_COMMAND")
If oCountCommand = String.Empty Then ' If oCountCommand = String.Empty Then
Continue For ' Continue For
End If ' End If
oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, oEnv.User) ' oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, oEnv.User)
oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand) ' oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand)
oResultData += Database.GetScalarValue(oCountCommand) ' oResultData += Database.GetScalarValue(oCountCommand)
Catch ex As Exception ' Catch ex As Exception
Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand) ' Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
oInvalidDataSQL = True ' oInvalidDataSQL = True
End Try ' End Try
Next ' Next
For Each oRow As DataRow In oDocSearches.Rows ' For Each oRow As DataRow In oDocSearches.Rows
Dim oCountCommand = String.Empty ' Dim oCountCommand = String.Empty
Try ' Try
oCountCommand = oRow.Item("COUNT_COMMAND") ' oCountCommand = oRow.Item("COUNT_COMMAND")
If oCountCommand = String.Empty Then ' If oCountCommand = String.Empty Then
Continue For ' Continue For
End If ' End If
oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, oEnv.User) ' oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, oEnv.User)
oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand) ' oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand)
' Logger.Debug($"Now again checking countDocs: sql so far: {oCountCommand}")
' oResultDocs += Database.GetScalarValue(oCountCommand)
' Logger.Debug($"Now oResultDocs is: {oResultDocs}")
' Catch ex As Exception
' Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
' oInvalidDocumentSQL = True
' End Try
' Next
oResultDocs += Database.GetScalarValue(oCountCommand) ' oProfile.CountData = oResultData
Catch ex As Exception ' If oProfile.CountDocs > 0 Then
Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand) ' Logger.Debug($"For hell no replacing JJ as CountDocs already has a result > 0!!!")
oInvalidDocumentSQL = True ' Else
End Try ' oProfile.CountDocs = oResultDocs
Next ' End If
oProfile.CountData = oResultData 'Next
oProfile.CountDocs = oResultDocs
Next
If oInvalidDocumentSQL Or oInvalidDataSQL Then 'If oInvalidDocumentSQL Or oInvalidDataSQL Then
MsgBox("Ein oder mehrere Abfragen konnten nicht ausgeführt werden. Bitte überprüfen Sie das Log.", MsgBoxStyle.Exclamation, "Warnung") ' MsgBox("Ein oder mehrere Abfragen konnten nicht ausgeführt werden. Bitte überprüfen Sie das Log.", MsgBoxStyle.Exclamation, "Warnung")
Exit Sub ' Exit Sub
End If 'End If
Dim oParams = New ClipboardWatcherParams() With { Dim oParams = New ClipboardWatcherParams() With {
.ClipboardContents = CURRENT_CLIPBOARD_CONTENTS, .ClipboardContents = CURRENT_CLIPBOARD_CONTENTS,