EDMI: Bring Service and Client up to date
This commit is contained in:
parent
a2374ce427
commit
6963505fe9
@ -5,9 +5,12 @@ Imports System.ServiceModel
|
||||
Imports System.IO
|
||||
|
||||
Public Class Client
|
||||
Private Const INVALID_OBEJCT_ID As Long = 0
|
||||
Private Const KIND_TYPE_DOC = "DOC"
|
||||
|
||||
Private ReadOnly _logger As Logger
|
||||
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
|
||||
Private _IPAddressServer As String
|
||||
Private ReadOnly _IPAddressServer As String
|
||||
Private _channel As IEDMIServiceChannel
|
||||
|
||||
Public Class StreamedFile
|
||||
@ -25,10 +28,10 @@ Public Class Client
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Creates a new EDMIAPI object
|
||||
''' Creates a new EDMI Client object
|
||||
''' </summary>
|
||||
''' <param name="LogConfig">LogConfig object</param>
|
||||
''' <param name="ServiceAdress">The full service url to connect to</param>
|
||||
''' <param name="ServiceAdress">The full service url to connect to, for example: net.tcp://1.1.1.1:1111/some/path</param>
|
||||
Public Sub New(LogConfig As LogConfig, ServiceAdress As String)
|
||||
_logger = LogConfig.GetLogger()
|
||||
|
||||
@ -43,6 +46,12 @@ Public Class Client
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Creates a new EDMI Client object
|
||||
''' </summary>
|
||||
''' <param name="LogConfig">LogConfig object</param>
|
||||
''' <param name="IPAddress">The IP address to connect to</param>
|
||||
''' <param name="PortNumber">The Port number to use for the connection</param>
|
||||
Public Sub New(LogConfig As LogConfig, IPAddress As String, PortNumber As Integer)
|
||||
_logger = LogConfig.GetLogger()
|
||||
|
||||
@ -79,34 +88,33 @@ Public Class Client
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Import options for NewFileAsync
|
||||
''' Import options for NewFileAsync. Contains default values for all options
|
||||
''' </summary>
|
||||
Public Class ImportFileOptions
|
||||
Public KeepExtension As Boolean
|
||||
Public KeepExtension As Boolean = True
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' TODO: Platzhalter
|
||||
''' TODO: Creates a new object
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Async Function NewObjectAsync() As Task
|
||||
Throw New NotImplementedException()
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Imports a file from a filepath, creating a IDB ObjectId and Filesystem Object
|
||||
''' </summary>
|
||||
''' <param name="pFilePath">Local filepath to a file.</param>
|
||||
''' <param name="pWho">Windows username of the user responsible for the import.</param>
|
||||
''' <param name="pWhen">Date when the file was imported. Can be in the past.</param>
|
||||
''' <param name="pAddedWho">Windows username of the user responsible for the import.</param>
|
||||
''' <param name="pAddedWhen">Date when the file was imported. Can be in the past.</param>
|
||||
''' <param name="pObjectStoreType">Type of ObjectStore. Can be WORK or ARCHIVE.</param>
|
||||
''' <param name="pBusinessEntity">Business entity that the new file object should belong to.</param>
|
||||
''' <param name="ImportOptions">Other file import options</param>
|
||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
||||
''' <param name="pImportOptions">Other file import options</param>
|
||||
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
|
||||
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
|
||||
Public Async Function NewFileAsync(pFilePath As String, pWho As String, pWhen As Date, pObjectStoreType As String, pBusinessEntity As String, ImportOptions As ImportFileOptions) As Task(Of FileMeta)
|
||||
Const oKindType = "DOC"
|
||||
|
||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
||||
Public Async Function NewFileAsync(pFilePath As String, pAddedWho As String, pAddedWhen As Date, pObjectStoreType As String, pBusinessEntity As String, pImportOptions As ImportFileOptions) As Task(Of Long)
|
||||
Try
|
||||
If File.Exists(pFilePath) = False Then
|
||||
Throw New FileNotFoundException("ImportFileAsync: Path does not exist")
|
||||
@ -117,8 +125,8 @@ Public Class Client
|
||||
|
||||
Dim oObjectIdResponse = Await _channel.NewObjectIdAsync(New NewObjectIdRequest With {
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.KindType = oKindType,
|
||||
.Who = pWho
|
||||
.KindType = KIND_TYPE_DOC,
|
||||
.Who = pAddedWho
|
||||
})
|
||||
|
||||
If oObjectIdResponse.ObjectId = Nothing OrElse oObjectIdResponse.ObjectId = 0 Then
|
||||
@ -126,9 +134,9 @@ Public Class Client
|
||||
End If
|
||||
|
||||
Dim oFilePathResponse = Await _channel.NewFileObjectAsync(New NewFileObjectRequest With {
|
||||
.DateImported = pWhen,
|
||||
.DateImported = pAddedWhen,
|
||||
.Extension = oExtension,
|
||||
.KeepExtension = ImportOptions.KeepExtension,
|
||||
.KeepExtension = pImportOptions.KeepExtension,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.StoreType = pObjectStoreType
|
||||
})
|
||||
@ -146,7 +154,7 @@ Public Class Client
|
||||
.FilePath = oFilePathResponse.FileObjectPath,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.ObjectStoreType = pObjectStoreType,
|
||||
.Who = pWho,
|
||||
.Who = pAddedWho,
|
||||
.Contents = oContents
|
||||
})
|
||||
|
||||
@ -156,24 +164,20 @@ Public Class Client
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Return New FileMeta With {
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.FilePath = oFilePathResponse.FileObjectPath
|
||||
}
|
||||
Return oObjectIdResponse.ObjectId
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
Return INVALID_OBEJCT_ID
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function CreateObjectId(pKindType As String, pWho As String, pBusinessEntity As String) As Long
|
||||
Try
|
||||
Dim oArgs As New NewObjectIdRequest With {
|
||||
Dim oResponse = _channel.NewObjectId(New NewObjectIdRequest With {
|
||||
.KindType = pKindType,
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.Who = pWho
|
||||
}
|
||||
Dim oResponse = _channel.NewObjectId(oArgs)
|
||||
})
|
||||
Return oResponse.ObjectId
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
Public Class FileMeta
|
||||
Public FilePath As String
|
||||
Public ObjectId As String
|
||||
End Class
|
||||
@ -65,27 +65,29 @@ Public Class DataWithFallback
|
||||
End Function
|
||||
|
||||
Public Function GetUserData(UserName As String, ModuleCode As String, Client As Integer) As UserData
|
||||
Dim oSQL = $"SELECT * FROM FNDD_CHECK_USER_MODULE('{UserName}','{ModuleCode}',{Client})"
|
||||
Dim oTable As DataTable = GetDatatable("TBDD_USER_MODULE", $"USERNAME = '{UserName.ToLower}' AND MODULE_SHORT = '{ModuleCode}'", "", oSQL, DatabaseType.ECM)
|
||||
'Dim oSQL = $"SELECT * FROM FNDD_CHECK_USER_MODULE('{UserName}','{ModuleCode}',{Client})"
|
||||
'Dim oTable As DataTable = GetDatatable("TBDD_USER_MODULE", $"USERNAME = '{UserName.ToLower}' AND MODULE_SHORT = '{ModuleCode}'", "", oSQL, DatabaseType.ECM)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
'If oTable Is Nothing Then
|
||||
' Return Nothing
|
||||
'End If
|
||||
|
||||
If oTable.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
'If oTable.Rows.Count = 0 Then
|
||||
' Return Nothing
|
||||
'End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oUserData As New UserData With {
|
||||
.Id = NotNull(oRow, "USER_ID", -1),
|
||||
.Surname = NotNull(oRow, "USER_SURNAME", String.Empty),
|
||||
.Prename = NotNull(oRow, "USER_PRENAME", String.Empty),
|
||||
.Shortname = NotNull(oRow, "USER_SHORTNAME", String.Empty),
|
||||
.Email = NotNull(oRow, "USER_EMAIL", String.Empty),
|
||||
.Language = NotNull(oRow, "USER_LANGUAGE", "de-DE"),
|
||||
.DateFormat = NotNull(oRow, "USER_DATE_FORMAT", "dd.MM.yyyy")
|
||||
}
|
||||
'Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
'Dim oUserData As New UserData With {
|
||||
' .Id = NotNull(oRow, "USER_ID", -1),
|
||||
' .Surname = NotNull(oRow, "USER_SURNAME", String.Empty),
|
||||
' .Prename = NotNull(oRow, "USER_PRENAME", String.Empty),
|
||||
' .Shortname = NotNull(oRow, "USER_SHORTNAME", String.Empty),
|
||||
' .Email = NotNull(oRow, "USER_EMAIL", String.Empty),
|
||||
' .Language = NotNull(oRow, "USER_LANGUAGE", "de-DE"),
|
||||
' .DateFormat = NotNull(oRow, "USER_DATE_FORMAT", "dd.MM.yyyy")
|
||||
'}
|
||||
|
||||
Throw New NotImplementedException()
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
@ -81,7 +81,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Client.vb" />
|
||||
<Compile Include="DataWithFallback.vb" />
|
||||
<Compile Include="Client\FileMeta.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
@ -445,65 +445,6 @@ Public Class EDMIService
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetFullPathForObjectId(ObjectId As Long) As String
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then
|
||||
_Logger.Warn("GetFullPathForObjectId: Document info table does not exist!")
|
||||
Return String.Empty
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId}").ToList()
|
||||
|
||||
Dim oFullPath As String
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetFullPathForObjectId: Full path does not exist for object [{0}]", ObjectId)
|
||||
oFullPath = String.Empty
|
||||
Else
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
oFullPath = oRow.Item("FULL_PATH")
|
||||
End If
|
||||
|
||||
Return oFullPath
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetFullPathForObjectId: Unexpected Error while getting full path for object [{0}].", ObjectId)
|
||||
_Logger.Error(ex)
|
||||
Return String.Empty
|
||||
End Try
|
||||
End Function
|
||||
Private Function GetAccessRightForObjectId(UserId As Long, ObjectId As Long) As AccessRight
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_ACCESSRIGHT) Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: Access right table does not exist!")
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_ACCESSRIGHT)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId} AND USR_ID = {UserId}").ToList()
|
||||
Dim oRight As AccessRight
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: Access right assignment does not exist for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
Else
|
||||
If oRows.Count > 1 Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: More than one access right assignment found for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
Dim oRightAsInt = oRow.Item("ACCESSRIGHT")
|
||||
|
||||
oRight = Utils.ToEnum(Of AccessRight)(oRightAsInt)
|
||||
End If
|
||||
|
||||
Return oRight
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetAccessRightForObjectId: Unexpected Error while getting access right for object [{0}].", ObjectId)
|
||||
_Logger.Error(ex)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewObjectId(Data As NewObjectIdRequest) As NewObjectIdResponse Implements IEDMIService.NewObjectId
|
||||
Try
|
||||
@ -613,6 +554,7 @@ Public Class EDMIService
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "=== Private ==="
|
||||
Private Function GetFileObjectFileName(IDB_OBJ_ID As Long, pExtension As String, pKeepExtension As Boolean) As String
|
||||
If Not pExtension.StartsWith("."c) Then
|
||||
pExtension &= "."c
|
||||
@ -652,4 +594,67 @@ Public Class EDMIService
|
||||
Return New FaultException(Of UnexpectedErrorFault)(oFault, New FaultReason(oFault.InnerException.Message))
|
||||
End Function
|
||||
|
||||
Private Function GetFullPathForObjectId(ObjectId As Long) As String
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then
|
||||
_Logger.Warn("GetFullPathForObjectId: Document info table does not exist!")
|
||||
Return String.Empty
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId}").ToList()
|
||||
|
||||
Dim oFullPath As String
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetFullPathForObjectId: Full path does not exist for object [{0}]", ObjectId)
|
||||
oFullPath = String.Empty
|
||||
Else
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
oFullPath = oRow.Item("FULL_PATH")
|
||||
End If
|
||||
|
||||
Return oFullPath
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetFullPathForObjectId: Unexpected Error while getting full path for object [{0}].", ObjectId)
|
||||
_Logger.Error(ex)
|
||||
Return String.Empty
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetAccessRightForObjectId(UserId As Long, ObjectId As Long) As AccessRight
|
||||
Try
|
||||
If Not GlobalState.TableStore.Tables.Contains(TBIDB_ACCESSRIGHT) Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: Access right table does not exist!")
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_ACCESSRIGHT)
|
||||
Dim oRows As List(Of DataRow) = oTable.Select($"IDB_OBJ_ID = {ObjectId} AND USR_ID = {UserId}").ToList()
|
||||
Dim oRight As AccessRight
|
||||
|
||||
If oRows.Count = 0 Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: Access right assignment does not exist for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
Else
|
||||
If oRows.Count > 1 Then
|
||||
_Logger.Warn("GetAccessRightForObjectId: More than one access right assignment found for user [{0}] on object [{1}]", UserId, ObjectId)
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
Dim oRightAsInt = oRow.Item("ACCESSRIGHT")
|
||||
|
||||
oRight = Utils.ToEnum(Of AccessRight)(oRightAsInt)
|
||||
End If
|
||||
|
||||
Return oRight
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetAccessRightForObjectId: Unexpected Error while getting access right for object [{0}].", ObjectId)
|
||||
_Logger.Error(ex)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user