EDMI: Add GetDocumentInfo

This commit is contained in:
Jonathan Jenne
2020-12-22 16:28:06 +01:00
parent 2800169251
commit 62ac7860ef
14 changed files with 379 additions and 267 deletions

View File

@@ -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