Improve Validation, Report, Transfer document with selected mandator
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
EAN = 2
|
||||
End Enum
|
||||
|
||||
Public Const FUNCTION_GLN = "GLN"
|
||||
Public Const FUNCTION_EAN = "EAN"
|
||||
|
||||
Public Const SCHEMA_TYPE_DATE = "xs:date"
|
||||
Public Const SCHEMA_TYPE_INTEGER = "xs:integer"
|
||||
Public Const SCHEMA_TYPE_DECIMAL = "xs:decimal"
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,16 +1,37 @@
|
||||
Namespace Documents
|
||||
Public Class DocumentRow
|
||||
Implements IComparable
|
||||
|
||||
''' <summary>
|
||||
''' GUID to match DocumentRow with Row from Grid/DataTable
|
||||
''' </summary>
|
||||
Public Property Id As New Guid
|
||||
''' <summary>
|
||||
''' Counter to ensure consistency and order when writing XML
|
||||
''' </summary>
|
||||
Public Property SortKey As Integer
|
||||
''' <summary>
|
||||
''' Tabellen/Elementname aus XML
|
||||
''' </summary>
|
||||
Public Property Name As String
|
||||
Public Property Id As New Guid
|
||||
|
||||
Public Property Fields As Dictionary(Of String, FieldValue)
|
||||
|
||||
Public ReadOnly Property HasErrors As Boolean
|
||||
Get
|
||||
Return Fields.Any(Function(f) f.Value.HasError)
|
||||
If Errors.Count > 0 Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property Errors As List(Of String)
|
||||
Get
|
||||
Return Fields.
|
||||
Where(Function(f) f.Value.HasError).
|
||||
Select(Function(f) f.Key).ToList()
|
||||
End Get
|
||||
End Property
|
||||
|
||||
@@ -18,6 +39,10 @@
|
||||
Id = Guid.NewGuid()
|
||||
End Sub
|
||||
|
||||
Public Function CompareTo(other As Object) As Integer Implements IComparable.CompareTo
|
||||
Return SortKey.CompareTo(DirectCast(other, DocumentRow).SortKey)
|
||||
End Function
|
||||
|
||||
Public Enum FieldError
|
||||
None
|
||||
MissingValue
|
||||
@@ -26,16 +51,16 @@
|
||||
End Enum
|
||||
|
||||
Public Class FieldValue
|
||||
Public [Error] As FieldError = FieldError.None
|
||||
|
||||
Public Original As String = ""
|
||||
Public External As String = ""
|
||||
Public Final As String = ""
|
||||
Public Property DataType As Constants.ColumnType = Constants.ColumnType.String
|
||||
Public Property [Error] As FieldError = FieldError.None
|
||||
Public Property Original As String = ""
|
||||
Public Property External As String = ""
|
||||
Public Property Final As String = ""
|
||||
Public Property Required As Boolean = False
|
||||
|
||||
Public ReadOnly Property HasError As Boolean
|
||||
Get
|
||||
Return [Error] <> FieldError.None
|
||||
Return [Error] <> FieldError.None Or (Required = True And Final = String.Empty)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ Namespace Winline
|
||||
AppDataPath = pAppDataPath
|
||||
End Sub
|
||||
|
||||
Public Async Function TransferDocumentToWinline(pDocument As Document) As Task(Of Boolean)
|
||||
Public Async Function TransferDocumentToWinline(pDocument As Document, pMandator As Mandator) As Task(Of Boolean)
|
||||
Dim oBytes As Byte() = GetBytesFromDocument(pDocument)
|
||||
Dim oWS As Config.WebServiceConfig = Config.Webservice
|
||||
|
||||
@@ -163,8 +163,6 @@ Namespace Winline
|
||||
"Fakt_Name"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Using oStream As New IO.MemoryStream()
|
||||
Dim w = XmlWriter.Create(oStream)
|
||||
|
||||
@@ -175,6 +173,8 @@ Namespace Winline
|
||||
w.WriteAttributeString("option", pDocument.Option)
|
||||
w.WriteAttributeString("printVoucher", pDocument.PrintVoucher)
|
||||
|
||||
pDocument.Rows.Sort()
|
||||
|
||||
For Each oRow In pDocument.Rows
|
||||
w.WriteStartElement(oRow.Name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user