From d760fc8bda73e74d1f83e163c524494d6fc57ba7 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Fri, 30 Jul 2021 12:59:35 +0200 Subject: [PATCH] EDMIAPI: WIP Improve Client --- Modules.EDMIAPI/Client.vb | 108 ++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 50 deletions(-) diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index e05bdac4..5bee249f 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -337,6 +337,11 @@ Public Class Client Try ' Get Attributes and Values from Database Dim oAttributes As List(Of ObjectAttribute) = GetAttributesForObject(pObjectId, pOptions.UserLanguage) + + If oAttributes Is Nothing Then + Return New VariableValue() + End If + Dim oValues = oAttributes.AsEnumerable(). Where(Function(pAttr) Return pAttr.Title.ToUpper = pAttributeName.ToUpper @@ -408,56 +413,6 @@ Public Class Client End Try End Function - Private Class ObjectAttribute - Public Property Id As Long - Public Property Title As String - Public Property Type As String - - Public Property ValueBigInt As Long - Public Property ValueText As String - Public Property ValueDecimal As Decimal - Public Property ValueDate As DateTime - - Public ReadOnly Property Value As Object - Get - Return GetValue() - End Get - End Property - - Private Function GetValue() As Object - Select Case Type - Case AttributeTypeName.VECTOR_INTEGER - Return ValueBigInt - - Case AttributeTypeName.BIG_INTEGER - Return ValueBigInt - - Case AttributeTypeName.VECTOR_STRING - Return ValueText - - Case AttributeTypeName.VARCHAR - Return ValueText - - Case AttributeTypeName.BIT - Return IIf(ValueBigInt = 1, True, False) - - Case AttributeTypeName.DATE - Return ValueDate - - Case AttributeTypeName.DATETIME - Return ValueDate - - Case AttributeTypeName.DECIMAL - Return ValueDecimal - - Case AttributeTypeName.FLOAT - Return ValueDecimal - - Case Else - Return Nothing - End Select - End Function - End Class Private Function GetAttributesForObject(pObjectId As Long, pLanguage As String) As List(Of ObjectAttribute) Dim oAttributes As New List(Of ObjectAttribute) @@ -757,5 +712,58 @@ Public Class Client Value = pValue End Sub End Class + + #End Region + + Private Class ObjectAttribute + Public Property Id As Long + Public Property Title As String + Public Property Type As String + + Public Property ValueBigInt As Long + Public Property ValueText As String + Public Property ValueDecimal As Decimal + Public Property ValueDate As DateTime + + Public ReadOnly Property Value As Object + Get + Return GetValue() + End Get + End Property + + Private Function GetValue() As Object + Select Case Type + Case AttributeTypeName.VECTOR_INTEGER + Return ValueBigInt + + Case AttributeTypeName.BIG_INTEGER + Return ValueBigInt + + Case AttributeTypeName.VECTOR_STRING + Return ValueText + + Case AttributeTypeName.VARCHAR + Return ValueText + + Case AttributeTypeName.BIT + Return IIf(ValueBigInt = 1, True, False) + + Case AttributeTypeName.DATE + Return ValueDate + + Case AttributeTypeName.DATETIME + Return ValueDate + + Case AttributeTypeName.DECIMAL + Return ValueDecimal + + Case AttributeTypeName.FLOAT + Return ValueDecimal + + Case Else + Return Nothing + End Select + End Function + End Class End Class