EDMI: Add GetAttributeValue Method
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user