EDMI: Add GetAttributeValue Method

This commit is contained in:
Jonathan Jenne
2022-02-04 13:40:48 +01:00
parent f0ab3527f6
commit 4bb95bb52b
11 changed files with 282 additions and 42 deletions

View File

@@ -375,46 +375,22 @@ Public Class Client
pOptions = New Options.GetVariableValueOptions()
End If
' Check if ObjectId exists
Try
Dim oResponse = Channel.TestObjectIdExists(New TestObjectIdExistsRequest With {.ObjectId = pObjectId})
If oResponse.Exists = False Then
Dim oArgs = New GetAttributeValueRequest With {
.ObjectId = pObjectId,
.AttributeName = pAttributeName,
.User = New UserState() With {
.UserName = pOptions.Username,
.Language = pOptions.Language
}
}
Dim oResponse = Channel.GetAttributeValue(oArgs)
If oResponse.OK = False Then
Return New VariableValue()
End If
Catch ex As Exception
Logger.Error(ex)
Return New VariableValue()
End Try
Try
' Get Attributes and Values from Database
Dim oAttributes As List(Of ObjectAttribute) = GetAttributesForObject(pObjectId, pOptions.Language)
If oAttributes Is Nothing Then
Return New VariableValue()
End If
Dim oValues = oAttributes.AsEnumerable().
Where(Function(pAttr)
Return pAttr.Title.ToUpper = pAttributeName.ToUpper
End Function).
Select(Function(pAttr) pAttr.Value).
ToList()
' Either return a list or a single value or nothing, always wrapped in VariableValue
If oValues.Count > 1 Then
Return New VariableValue(oValues)
ElseIf oValues.Count = 1 Then
Return New VariableValue(oValues.First())
Else
Return New VariableValue()
End If
Return New VariableValue(oResponse.Value)
Catch ex As Exception
Logger.Error(ex)