This commit is contained in:
Jonathan Jenne
2021-11-19 13:53:38 +01:00
parent 673a507d04
commit ee23cdd7e8
23 changed files with 291 additions and 97 deletions

View File

@@ -45,7 +45,7 @@ Namespace Documents
End Get
End Property
Public ReadOnly Property Name As String
Public ReadOnly Property FileName As String
Get
Return File?.Name
End Get

View File

@@ -137,7 +137,7 @@ 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
Dim oRowSortKey As Integer = 0
' TODO: Somehow add all fields in the correct order
'
@@ -147,12 +147,14 @@ Namespace Documents
'
' leads to unordered fields.
For Each oTopLevelElement As XElement In oTopLevelElements
Dim oColumnSortKey = 0
Dim oFields As New Dictionary(Of String, DocumentRow.FieldValue)
Dim oSubElements = oTopLevelElement.Descendants().ToList()
Dim oTable = pSchema.Tables.
Where(Function(t) t.Name = oTopLevelElement.Name).
FirstOrDefault()
For Each oColumn In oTable.Columns
Dim oSubElement = oSubElements.
Where(Function(e) e.Name = oColumn.Name).
@@ -172,7 +174,8 @@ Namespace Documents
.Original = oValue,
.Final = oValue,
.DataType = oColumn.DataType,
.Required = oRequired
.Required = oRequired,
.SortKey = oColumnSortKey
})
Else
Dim oColumnError = DocumentRow.FieldError.None
@@ -181,9 +184,12 @@ Namespace Documents
End If
oFields.Add(oColumn.Name, New DocumentRow.FieldValue With {
.[Error] = oColumnError
.[Error] = oColumnError,
.SortKey = oColumnSortKey
})
End If
oColumnSortKey += 1
Next
'For Each oSubElement As XElement In oSubElements
@@ -229,12 +235,12 @@ Namespace Documents
' Create a DocumentRow object for each Top Level Element
Dim oRow = New DocumentRow With {
.SortKey = oSortKey,
.SortKey = oRowSortKey,
.Name = oTopLevelElement.Name.ToString,
.Fields = oFields
}
oSortKey += 1
oRowSortKey += 1
oDocumentRows.Add(oRow)
Next

View File

@@ -57,6 +57,7 @@
Public Property External As String = ""
Public Property Final As String = ""
Public Property Required As Boolean = False
Public Property SortKey As Integer = 0
Public ReadOnly Property HasError As Boolean
Get