This commit is contained in:
2020-06-29 13:15:05 +02:00
parent 40c2024a2e
commit da5cbb0d3a
7 changed files with 40 additions and 26 deletions

View File

@@ -22,7 +22,9 @@ Public Class PropertyValues
Public Class ValidProperty
Public MessageId As String
Public TableName As String
Public TableColumn As String
Public ISRequired As Boolean
Public GroupCounter As Integer = -1
Public Description As String
@@ -60,11 +62,11 @@ Public Class PropertyValues
' get properties as a nested object, see `oPropertyList`
For Each oProperty As KeyValuePair(Of String, XmlItemProperty) In oGroup
Dim oPropertyValues As List(Of Object)
_logger.Debug($"Fetching value for itemSpecification [{oProperty.Value.TableColumn}].")
Try
oPropertyValues = GetPropValue(Document, oProperty.Key)
Catch ex As Exception
_logger.Warn("Unknown error occurred while fetching property [{0}] in group [{1}]:", oProperty.Value.Description, oGroupScope)
_logger.Warn("Unknown error occurred while fetching property/TColumn [{0}] in group [{1}]:", oProperty.Value.TableColumn, oGroupScope)
_logger.Error(ex)
oPropertyValues = New List(Of Object)
End Try
@@ -92,6 +94,8 @@ Public Class PropertyValues
For Each oColumn As KeyValuePair(Of XmlItemProperty, List(Of Object)) In oPropertyList
Dim oTableName As String = oColumn.Key.TableName
Dim oTableColumn As String = oColumn.Key.TableColumn
Dim oIsRequired As Boolean = oColumn.Key.IsRequired
Dim oPropertyDescription As String = oColumn.Key.Description
Dim oRowCounter = oRowIndex + oGlobalGroupCounter + 1
If IsNothing(oRowCounter) Then
@@ -100,27 +104,29 @@ Public Class PropertyValues
' Returns nothing if oColumn.Value contains an empty list
Dim oPropertyValue = oColumn.Value.ElementAtOrDefault(oRowIndex)
_logger.Debug("Processing property [{0}].", oPropertyDescription)
_logger.Debug("Processing itemSpecification *TableColumn* [{0}].", oTableColumn)
If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then
If oColumn.Key.IsRequired Then
_logger.Warn($"Property [{oPropertyDescription}] is empty or not found but is required. Continuing with Empty String.")
_logger.Warn($"oPropertyValue for specification [{oTableColumn}] is empty or not found but is required. Continuing with Empty String.")
oResult.MissingProperties.Add(oPropertyDescription)
Else
_logger.Debug($"Property [{oPropertyDescription}] is empty or not found. Continuing with Empty String.")
_logger.Debug($"oPropertyValue for specification [{oTableColumn}] is empty or not found. Continuing with Empty String.")
End If
oPropertyValue = String.Empty
End If
_logger.Debug("Property [{0}] has value '{1}'", oPropertyDescription, oPropertyValue)
_logger.Debug("ItemSpecification [{0}] has value '{1}'", oTableColumn, oPropertyValue)
oResult.ValidProperties.Add(New ValidProperty() With {
.MessageId = MessageId,
.Description = oPropertyDescription,
.Value = oPropertyValue,
.GroupCounter = oRowCounter,
.TableName = oTableName
.TableName = oTableName,
.TableColumn = oTableColumn,
.ISRequired = oIsRequired
})
Next
Next
@@ -131,14 +137,15 @@ Public Class PropertyValues
' Iterate through default properties
For Each oItem As KeyValuePair(Of String, XmlItemProperty) In oDefaultProperties
Dim oPropertyValueList As List(Of Object)
Dim oPropertyDescription As String = oItem.Value.Description
Dim oTableColumn As String = oItem.Value.TableColumn
Dim oPropertyValue As Object = Nothing
Dim oTableName = oItem.Value.TableName
Dim oIsRequired = oItem.Value.IsRequired
Dim oDescription = oItem.Value.Description
Try
oPropertyValueList = GetPropValue(Document, oItem.Key)
Catch ex As Exception
_logger.Warn("Unknown error occurred while fetching property {0} in group {1}:", oPropertyDescription, oItem.Value.GroupScope)
_logger.Warn("Unknown error occurred while fetching specification {0} in group {1}:", oTableColumn, oItem.Value.GroupScope)
_logger.Error(ex)
oPropertyValueList = New List(Of Object)
End Try
@@ -156,34 +163,36 @@ Public Class PropertyValues
' This should hopefully show config errors
If TypeOf oPropertyValue Is List(Of Object) Then
_logger.Warn("Property with Description {0} may be configured incorrectly", oPropertyDescription)
_logger.Warn("Item with TableColumn [{0}] may be configured incorrectly", oTableColumn)
oPropertyValue = Nothing
End If
End Select
End If
Catch ex As Exception
_logger.Warn("Unknown error occurred while processing property {0}:", oPropertyDescription)
_logger.Warn("Unknown error occurred while processing specification [{0}]:", oTableColumn)
_logger.Error(ex)
oPropertyValue = Nothing
End Try
If IsNothing(oPropertyValue) OrElse String.IsNullOrEmpty(oPropertyValue) Then
If oItem.Value.IsRequired Then
_logger.Warn("Property {0} is empty but marked as required! Skipping.", oPropertyDescription)
oResult.MissingProperties.Add(oPropertyDescription)
_logger.Warn("Specification [{0}] is empty, but marked as required! Skipping.", oTableColumn)
oResult.MissingProperties.Add(oTableColumn)
Continue For
Else
_logger.Debug("Property [{0}] is empty or not found. Skipping.", oPropertyDescription)
_logger.Debug("oPropertyValue for specification [{0}] is empty or not found. Skipping.", oTableColumn)
Continue For
End If
End If
oResult.ValidProperties.Add(New ValidProperty() With {
.MessageId = MessageId,
.Description = oPropertyDescription,
.Description = oDescription,
.Value = oPropertyValue,
.TableName = oTableName
})
.TableName = oTableName,
.TableColumn = oTableColumn,
.ISRequired = oIsRequired
})
Next
Return oResult
@@ -202,7 +211,7 @@ Public Class PropertyValues
Dim oPropInfo As PropertyInfo = Obj.GetType().GetProperty(PropertyName)
If IsNothing(oPropInfo) Then
_logger.Debug("Property {0} does not exist.", PropertyName)
_logger.Debug("Property [{0}] does not exist(1).", PropertyName)
Return New List(Of Object)
Else
Dim oPropValue = oPropInfo.GetValue(Obj, Nothing)
@@ -224,7 +233,7 @@ Public Class PropertyValues
Dim oInfo As PropertyInfo = oType.GetProperty(oPartName)
If IsNothing(oInfo) OrElse IsNothing(oInfo.GetValue(Obj, Nothing)) Then
_logger.Debug("Property {0} does not exist.", oPartName)
_logger.Debug("Property {0} does not exist(2).", oPartName)
Return New List(Of Object)
End If