Improve Validation, Report, Transfer document with selected mandator

This commit is contained in:
Jonathan Jenne
2021-11-17 16:25:00 +01:00
parent 47c22e9361
commit 1366343cdf
7 changed files with 119 additions and 44 deletions

View File

@@ -137,7 +137,15 @@ Namespace Documents
' The first level of Elements are the document Rows
Dim oTopLevelElements As List(Of XElement) = oRootElement.Elements.ToList
Dim oDocumentRows As New List(Of DocumentRow)
Dim oSortKey As Integer = 0
' TODO: Somehow add all fields in the correct order
'
' Right now, the method of
' - first the filled field from xml
' - then the rest from schema
'
' leads to unordered fields.
For Each oTopLevelElement As XElement In oTopLevelElements
Dim oFields As New Dictionary(Of String, DocumentRow.FieldValue)
Dim oSubElements = oTopLevelElement.Descendants().ToList()
@@ -145,15 +153,12 @@ Namespace Documents
Where(Function(t) t.Name = oTopLevelElement.Name).
FirstOrDefault()
For Each oSubElement As XElement In oSubElements
Dim oSchemaField = oTable.Columns.
Where(Function(c) c.Name = oSubElement.Name).
SingleOrDefault()
Dim oRequired = oSchemaField.IsRequired
Dim oValue = oSubElement.Value.Trim()
' TODO: Needed when we have time for date times
@@ -165,12 +170,13 @@ Namespace Documents
oFields.Add(oSubElement.Name.ToString, New DocumentRow.FieldValue With {
.Original = oValue,
.Final = oValue,
.DataType = oSchemaField.DataType
.DataType = oSchemaField.DataType,
.Required = oRequired
})
Next
' TODO: All fields in the schema should be generated,
' All fields in the schema are generated,
' only creating the ones with values leads to wrong visual cues when asking for
' docs/rows/fields with errors
For Each oColumn In oTable.Columns
@@ -190,10 +196,12 @@ Namespace Documents
' Create a DocumentRow object for each Top Level Element
Dim oRow = New DocumentRow With {
.SortKey = oSortKey,
.Name = oTopLevelElement.Name.ToString,
.Fields = oFields
}
oSortKey += 1
oDocumentRows.Add(oRow)
Next