Monorepo/Modules.EDMIAPI/Modules/IDB/SetAttributeValue.vb
2022-03-11 15:46:59 +01:00

38 lines
1.4 KiB
VB.net

Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Imports DigitalData.Modules.EDMI.API.Options
Imports DigitalData.Modules.Logging
Namespace Modules.IDB
Public Class SetAttributeValue
Inherits BaseMethod
Public Sub New(pLogConfig As LogConfig, pChannel As IEDMIServiceChannel)
MyBase.New(pLogConfig, pChannel)
End Sub
Public Async Function RunAsync(pObjectId As String, pAttributeName As String, pAttributeValue As Object, Optional pOptions As SetAttributeValueOptions = Nothing) As Task(Of Boolean)
Try
Dim oParams As New SetAttributeValueRequest With {
.ObjectId = pObjectId,
.Language = pOptions.Language,
.Who = pOptions.Username,
.AttributeName = pAttributeName,
.AttributeValue = pAttributeValue
}
Dim oResponse As SetAttributeValueResponse = Await Channel.SetAttributeValueAsync(oParams)
If oResponse.OK Then
Return True
End If
Logger.Warn("Error while setting Attribute Value: [{0}]", oResponse.ErrorMessage)
Return False
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
End Class
End Namespace