diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb
index 18407700..3498a658 100644
--- a/Modules.EDMIAPI/Client.vb
+++ b/Modules.EDMIAPI/Client.vb
@@ -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
'''
- ''' Creates a new EDMIAPI object
+ ''' Creates a new EDMI Client object
'''
''' LogConfig object
- ''' The full service url to connect to
+ ''' The full service url to connect to, for example: net.tcp://1.1.1.1:1111/some/path
Public Sub New(LogConfig As LogConfig, ServiceAdress As String)
_logger = LogConfig.GetLogger()
@@ -43,6 +46,12 @@ Public Class Client
End Try
End Sub
+ '''
+ ''' Creates a new EDMI Client object
+ '''
+ ''' LogConfig object
+ ''' The IP address to connect to
+ ''' The Port number to use for the connection
Public Sub New(LogConfig As LogConfig, IPAddress As String, PortNumber As Integer)
_logger = LogConfig.GetLogger()
@@ -79,34 +88,33 @@ Public Class Client
End Function
'''
- ''' Import options for NewFileAsync
+ ''' Import options for NewFileAsync. Contains default values for all options
'''
Public Class ImportFileOptions
- Public KeepExtension As Boolean
+ Public KeepExtension As Boolean = True
End Class
'''
- ''' TODO: Platzhalter
+ ''' TODO: Creates a new object
'''
'''
Public Async Function NewObjectAsync() As Task
+ Throw New NotImplementedException()
End Function
'''
''' Imports a file from a filepath, creating a IDB ObjectId and Filesystem Object
'''
''' Local filepath to a file.
- ''' Windows username of the user responsible for the import.
- ''' Date when the file was imported. Can be in the past.
+ ''' Windows username of the user responsible for the import.
+ ''' Date when the file was imported. Can be in the past.
''' Type of ObjectStore. Can be WORK or ARCHIVE.
''' Business entity that the new file object should belong to.
- ''' Other file import options
- ''' The ObjectId of the newly generated filesystem object
+ ''' Other file import options
''' When local filepath was not found
''' When there was a error in the Service
- 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"
-
+ ''' The ObjectId of the newly generated filesystem object
+ 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)
diff --git a/Modules.EDMIAPI/Client/FileMeta.vb b/Modules.EDMIAPI/Client/FileMeta.vb
deleted file mode 100644
index 23bfdedd..00000000
--- a/Modules.EDMIAPI/Client/FileMeta.vb
+++ /dev/null
@@ -1,4 +0,0 @@
-Public Class FileMeta
- Public FilePath As String
- Public ObjectId As String
-End Class
diff --git a/Modules.EDMIAPI/DataWithFallback.vb b/Modules.EDMIAPI/DataWithFallback.vb
index 7f2ea153..eaa2f564 100644
--- a/Modules.EDMIAPI/DataWithFallback.vb
+++ b/Modules.EDMIAPI/DataWithFallback.vb
@@ -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
diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj
index 95d7d127..95b88971 100644
--- a/Modules.EDMIAPI/EDMI.API.vbproj
+++ b/Modules.EDMIAPI/EDMI.API.vbproj
@@ -81,7 +81,6 @@
-
True
diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb
index 175ca994..6d3c27a7 100644
--- a/Service.EDMIService/EDMIService.vb
+++ b/Service.EDMIService/EDMIService.vb
@@ -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
\ No newline at end of file