Add virtual property to field value, improve ui when loading files, improve initial loading

This commit is contained in:
Jonathan Jenne
2022-04-08 13:17:46 +02:00
parent 623f75d0e5
commit 51912b36c2
7 changed files with 202 additions and 64 deletions

View File

@@ -1,4 +1,7 @@
Namespace Documents
Imports System.Text.RegularExpressions
Imports MultiTool.Common.Constants
Namespace Documents
Public Class DocumentRow
Implements IComparable
@@ -48,19 +51,45 @@
Return SortKey.CompareTo(DirectCast(other, DocumentRow).SortKey)
End Function
Public Enum FieldError
None
MissingValue
AccountNotFound
ArticleNotFound
End Enum
Public Class FieldValue
Private _Final As String = ""
Private _External As String = ""
Private _Original 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 Sub New()
End Sub
Public Property Original As String
Get
Return FormatValue(_Original, DataType)
End Get
Set(value As String)
_Original = value
End Set
End Property
Public Property External As String
Get
Return FormatValue(_External, DataType)
End Get
Set(value As String)
_External = value
End Set
End Property
Public Property Final As String
Get
Return FormatValue(_Final, DataType)
End Get
Set(value As String)
_Final = value
End Set
End Property
Public Property IsRequired As Boolean = False
Public Property IsVirtual As Boolean = False
Public Property SortKey As Integer = 0
@@ -87,6 +116,41 @@
Public Overrides Function ToString() As String
Return Final
End Function
Private Function FormatValue(pValue As String, pType As Constants.ColumnType) As String
Select Case pType
Case ColumnType.Decimal
Return FormatDecimalValue(pValue)
Case Else
Return pValue
End Select
End Function
''' <summary>
''' This function will capture values like below and format them according to winline format values
'''
''' 1000
''' 1.000.000
''' 1.000.000,00
''' </summary>
''' <param name="pValue">A string value that represents a number</param>
''' <returns>A string value which contains at dot (.) as the decimal divider</returns>
Private Function FormatDecimalValue(pValue As String) As String
If Not pValue.Contains(","c) Then
Return pValue
End If
Dim oRegex = New Regex("(?<Value>\d+(?:\.\d+)*(?:,\d+)?)")
Dim oMatch = oRegex.Match(pValue)
If oMatch.Success Then
Dim oValue = oMatch.Groups.Item("Value").Value
Return oValue.Replace(","c, "."c)
Else
Return pValue
End If
End Function
End Class
End Class