EDMI: Add GetDocumentInfo
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
Imports DigitalData.Modules.EDMI.API.Rights
|
||||
Imports System.ServiceModel
|
||||
Imports System.IO
|
||||
|
||||
@@ -17,6 +18,11 @@ Public Class Client
|
||||
Public Datatable As DataTable
|
||||
End Class
|
||||
|
||||
Public Class DocumentInfo
|
||||
Public FullPath As String
|
||||
Public AccessRight As AccessRight
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Creates a new EDMIAPI object
|
||||
''' </summary>
|
||||
@@ -151,16 +157,18 @@ Public Class Client
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function GetAccessRightAsync(UserId As Long, ObjectId As Long) As Task(Of Rights.AccessRight)
|
||||
Public Async Function GetDocumentInfo(UserId As Long, ObjectId As Long) As Task(Of DocumentInfo)
|
||||
Try
|
||||
Dim oResponse As AccessRightResult = Await _channel.GetAccessRightAsync(UserId, ObjectId)
|
||||
Dim oParams = New DocumentInfoRequest With {
|
||||
.ObjectId = ObjectId,
|
||||
.UserId = UserId
|
||||
}
|
||||
Dim oResponse As DocumentInfoResponse = Await _channel.GetFileInfoByObjectIdAsync(oParams)
|
||||
|
||||
If oResponse.OK Then
|
||||
Return oResponse.Right
|
||||
Else
|
||||
_logger.Warn("Rights from server could not be fetched for UserId [{0}] on Object [{1}]. Returning default Right View", UserId, ObjectId)
|
||||
Return Rights.AccessRight.VIEW_ONLY
|
||||
End If
|
||||
Return New DocumentInfo With {
|
||||
.AccessRight = oResponse.FileRight,
|
||||
.FullPath = oResponse.FullPath
|
||||
}
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Reference in New Issue
Block a user