diff --git a/GUIs.Test.EDMIBenchmark/Form1.vb b/GUIs.Test.EDMIBenchmark/Form1.vb
index aac64917..fd3aa573 100644
--- a/GUIs.Test.EDMIBenchmark/Form1.vb
+++ b/GUIs.Test.EDMIBenchmark/Form1.vb
@@ -15,7 +15,7 @@ Public Class Form1
Try
_LogConfig = New LogConfig(LogConfig.PathType.Temp, Nothing, "EDMIBenschmark")
_Logger = _LogConfig.GetLogger()
- _Client = New Client(_LogConfig, "net.tcp://172.24.12.39:9000/DigitalData/Services/Main")
+ _Client = New Client(_LogConfig, "172.24.12.39", 9000)
_Client.Connect()
DocumentViewer1.Init(_LogConfig, "21182889975216572111813147150675976632")
diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb
index 2ca1d33e..b0ff42e8 100644
--- a/Modules.EDMIAPI/Client.vb
+++ b/Modules.EDMIAPI/Client.vb
@@ -36,6 +36,18 @@ Public Class Client
End Try
End Sub
+ Public Sub New(LogConfig As LogConfig, IPAddress As String, PortNumber As Integer)
+ _logger = LogConfig.GetLogger()
+
+ Try
+ Dim oBinding = Channel.GetBinding()
+ Dim oAddress = New EndpointAddress($"net.tcp://{IPAddress}:{PortNumber}/DigitalData/Services/Main")
+ Dim oFactory = New ChannelFactory(Of IEDMIServiceChannel)(oBinding, oAddress)
+ Catch ex As Exception
+
+ End Try
+ End Sub
+
'''
''' Connect to the service
'''
diff --git a/Service.EDMIService/Database/IDatabase.vb b/Service.EDMIService/Database/IDatabase.vb
deleted file mode 100644
index 0b370d22..00000000
--- a/Service.EDMIService/Database/IDatabase.vb
+++ /dev/null
@@ -1,3 +0,0 @@
-Public Interface IDatabase
- Function NewDocument(RelativePath As String, AddedWho As String, ObjectStoreId As Int64, ReferenceId As Int64) As Int64
-End Interface
diff --git a/Service.EDMIService/Database/MSSQL.vb b/Service.EDMIService/Database/MSSQL.vb
deleted file mode 100644
index 3d4153b1..00000000
--- a/Service.EDMIService/Database/MSSQL.vb
+++ /dev/null
@@ -1,20 +0,0 @@
-Imports DigitalData.Modules.Database
-Imports DigitalData.Modules.Logging
-
-Public Class MSSQL
- Implements IDatabase
-
- Private ReadOnly LogConfig As LogConfig
- Private ReadOnly Database As MSSQLServer
- Private ReadOnly Logger As Logger
-
- Public Sub New(LogConfig As LogConfig, Database As MSSQLServer)
- Me.LogConfig = LogConfig
- Me.Database = Database
- Me.Logger = LogConfig.GetLogger()
- End Sub
-
- Public Function NewDocument(RelativePath As String, AddedWho As String, ObjectStoreId As Long, ReferenceId As Long) As Long Implements IDatabase.NewDocument
-
- End Function
-End Class
diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb
index 5c5ea456..01e344a8 100644
--- a/Service.EDMIService/EDMIService.vb
+++ b/Service.EDMIService/EDMIService.vb
@@ -47,7 +47,7 @@ Public Class EDMIService
End If
End Function
-#Region "Auth"
+#Region "=== Authorization ==="
Private Function TestUserAuth() As Boolean
Try
'Dim oSQL As String = $"SELECT FNIDB_AUTH_USER('{_username}') FROM RDB$DATABASE;"
@@ -60,12 +60,12 @@ Public Class EDMIService
End Try
End Function
#End Region
-#Region "Heartbeat"
+#Region "=== Heartbeat ==="
Public Function Heartbeat() As Boolean Implements IEDMIService.Heartbeat
Return True
End Function
#End Region
-#Region "Request"
+#Region "=== Database Request ==="
Public Sub CreateRequest(Name As String, Optional Debug As Boolean = False)
_request = New Request(Name, _username, Firebird, Debug)
_debug = Debug
@@ -90,7 +90,7 @@ Public Class EDMIService
End Sub
#End Region
-#Region "Database"
+#Region "=== Database (Firebird) ==="
Private Sub TestRequestCreated()
If IsNothing(_request) Then
Throw New Exceptions.NoRequestException()
@@ -144,174 +144,8 @@ Public Class EDMIService
Return New NonQueryResult(ex.Message)
End Try
End Function
-
-
#End Region
-#Region "Document (with FileContainer)"
- Public Function NewFile(FileName As String, Contents() As Byte) As DocumentResultOld Implements IEDMIService.NewFile
- Try
- Dim oContainer As FileContainer
- Dim oContainerId As String
-
- If Not TestUserAuth() Then
- Throw New Exception($"User {_username} not authorized.")
- End If
-
- oContainer = FileContainer.Create(LogConfig, AppConfig.ContainerPassword)
- oContainerId = oContainer.ContainerId
- _logger.Debug("Container created with id {0}", oContainerId)
-
- Dim oExtension As String = Path.GetExtension(FileName).Substring(1)
- _logger.Debug("File extension of file {0} is {1}", FileName, oExtension)
-
- Dim oSQL = $"SELECT FNICM_NEW_DOC('010', '{oContainerId}', '{GetContainerName(oContainerId)}', '{FileName}', '{oExtension}', '{_username}') FROM RDB$DATABASE;"
- Dim oDocId As Int64 = Firebird.GetScalarValue(oSQL)
-
- If oDocId = -1 Then
- _logger.Warn("Database returned -1 while creating Document Entry. File was not saved!")
- Return Nothing
- End If
-
- _logger.Debug("Database Entry created with DocId {0}", oDocId)
-
- oContainer.SetFile(Contents, FileName)
- oContainer.SaveAs(GetContainerPath(oContainerId))
-
- _logger.Debug("File saved in Container!", FileName)
-
- Dim oDocument = New DocumentObject(oContainerId, oDocId, FileName)
- Return New DocumentResultOld(oDocument)
- Catch ex As Exception
- _logger.Error(ex)
- Return New DocumentResultOld(ex.Message)
- End Try
- End Function
-
- Public Function UpdateFile(DocObject As DocumentObject, Contents() As Byte) As DocumentResultOld Implements IEDMIService.UpdateFile
- Try
- TestFileExists(DocObject.ContainerId)
-
- ' TODO: update db
-
- Dim oFilePath = GetContainerPath(DocObject.ContainerId)
- Dim oFileContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oFilePath)
-
- oFileContainer.SetFile(Contents, oFileContainer.GetFile.FileName)
- oFileContainer.Save()
-
-
- Return New DocumentResultOld(DocObject)
- Catch ex As Exception
- _logger.Error(ex)
- Return Nothing
- End Try
- End Function
-
- Public Function GetFile(DocObject As DocumentObject) As DocumentResultOld Implements IEDMIService.GetFile
- Try
- TestFileExists(DocObject.ContainerId)
-
- Dim oContainerPath = GetContainerPath(DocObject.ContainerId)
- Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
- Dim oContents As Byte() = oContainer.GetFile().Contents
-
- Return New DocumentResultOld(DocObject, oContents)
- Catch ex As Exception
- _logger.Error(ex)
- Return New DocumentResultOld(ex.Message)
- End Try
- End Function
-
- Public Function DeleteFile(DocObject As DocumentObject) As Boolean Implements IEDMIService.DeleteFile
- Try
- TestFileExists(DocObject.ContainerId)
-
- Dim oFilePath = GetContainerPath(DocObject.ContainerId)
- IO.File.Delete(oFilePath)
-
- 'TODO: Delete doc from db
-
- Return True
- Catch ex As Exception
- _logger.Error(ex)
- Return False
- End Try
- End Function
-
- Private Function GetContainerPath(ContainerId As String) As String
- Return Path.Combine(AppConfig.ContainerPath, GetContainerName(ContainerId))
- End Function
-
- Private Function GetContainerName(ContainerId As String) As String
- Return ContainerId & ".enc"
- End Function
-
- Private Sub TestFileExists(ContainerId)
- Dim oContainerPath = GetContainerPath(ContainerId)
-
- If Not IO.File.Exists(oContainerPath) Then
- Throw New FileNotFoundException("Container existiert nicht", oContainerPath)
- End If
- End Sub
-
- Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResultOld Implements IEDMIService.GetDocumentByDocumentId
- Try
- Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE GUID = {DocumentId}"
- Dim oTable = Firebird.GetDatatable(oSQL)
-
- If oTable.Rows.Count = 0 Then
- Return New DocumentResultOld("Document not found")
- End If
-
- Dim oRow As DataRow = oTable.Rows.Item(0)
- Dim oDocument As New DocumentObject(
- oRow.Item("CONTAINER_ID"),
- oRow.Item("GUID"),
- oRow.Item("ORIGINAL_FILENAME")
- )
-
- TestFileExists(oDocument.ContainerId)
-
- Dim oContainerPath = GetContainerPath(oDocument.ContainerId)
- Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
- Dim oContents As Byte() = oContainer.GetFile().Contents
-
- Return New DocumentResultOld(oDocument, oContents)
- Catch ex As Exception
- Return New DocumentResultOld(ex.Message)
- End Try
- End Function
-
- Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResultOld Implements IEDMIService.GetDocumentByContainerId
- Try
- Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE CONTAINER_ID = '{ContainerId}'"
- Dim oTable = Firebird.GetDatatable(oSQL)
-
- If oTable.Rows.Count = 0 Then
- Return New DocumentResultOld("Document not found")
- End If
-
- Dim oRow As DataRow = oTable.Rows.Item(0)
- Dim oDocument As New DocumentObject(
- oRow.Item("CONTAINER_ID"),
- oRow.Item("GUID"),
- oRow.Item("ORIGINAL_FILENAME")
- )
-
- TestFileExists(oDocument.ContainerId)
-
- Dim oContainerPath = GetContainerPath(oDocument.ContainerId)
- Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
- Dim oContents As Byte() = oContainer.GetFile().Contents
-
- Return New DocumentResultOld(oDocument, oContents)
- Catch ex As Exception
- Return New DocumentResultOld(ex.Message)
- End Try
- End Function
-#End Region
-
-#Region "Document"
+#Region "=== Document ==="
'''
''' Imports a file according to ObjectStoreId
'''
@@ -436,20 +270,5 @@ Public Class EDMIService
Throw New FaultException(ex.Message)
End Try
End Function
-
-#End Region
-
-#Region "Index"
- Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult Implements IEDMIService.NewFileIndex
- Try
- Dim oSQL = $"SELECT FNIDB_NEW_DOC_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;"
- Dim oIndexId As Int64 = Firebird.GetScalarValue(oSQL)
-
- Return New IndexResult(oIndexId)
- Catch ex As Exception
- _logger.Error(ex)
- Return New IndexResult(ex.Message)
- End Try
- End Function
#End Region
End Class
\ No newline at end of file
diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj
index 3cdbcc3a..444b5c26 100644
--- a/Service.EDMIService/EDMIService.vbproj
+++ b/Service.EDMIService/EDMIService.vbproj
@@ -102,18 +102,12 @@
-
-
-
-
-
-
Component
diff --git a/Service.EDMIService/Exceptions.vb b/Service.EDMIService/Exceptions.vb
index e1effc7e..750f7df2 100644
--- a/Service.EDMIService/Exceptions.vb
+++ b/Service.EDMIService/Exceptions.vb
@@ -1,7 +1,13 @@
-Public Class Exceptions
+Imports System.ServiceModel
+
+Public Class Exceptions
+
+ Public Class BaseException
+ Inherits FaultException
+ End Class
Public Class NoRequestException
- Inherits ApplicationException
+ Inherits BaseException
End Class
End Class
diff --git a/Service.EDMIService/IEDMIService.vb b/Service.EDMIService/IEDMIService.vb
index f862a87e..cef612e8 100644
--- a/Service.EDMIService/IEDMIService.vb
+++ b/Service.EDMIService/IEDMIService.vb
@@ -28,23 +28,23 @@ Interface IEDMIService
#End Region
#Region "Document (with FileContainer)"
-
- Function NewFile(FileName As String, Contents As Byte()) As DocumentResultOld
+ '
+ 'Function NewFile(FileName As String, Contents As Byte()) As DocumentResultOld
-
- Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResultOld
+ '
+ 'Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResultOld
-
- Function GetFile(DocObject As DocumentObject) As DocumentResultOld
+ '
+ 'Function GetFile(DocObject As DocumentObject) As DocumentResultOld
-
- Function DeleteFile(DocObject As DocumentObject) As Boolean
+ '
+ 'Function DeleteFile(DocObject As DocumentObject) As Boolean
-
- Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResultOld
+ '
+ 'Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResultOld
-
- Function GetDocumentByContainerId(ContainerId As String) As DocumentResultOld
+ '
+ 'Function GetDocumentByContainerId(ContainerId As String) As DocumentResultOld
#End Region
#Region "Document (New)"
@@ -59,9 +59,4 @@ Interface IEDMIService
Function ListFilesForUser() As Messages.DocumentListResponse
#End Region
-#Region "Index"
-
- Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult
-#End Region
-
End Interface
\ No newline at end of file
diff --git a/Service.EDMIService/Results/ContainerResult.vb b/Service.EDMIService/Results/ContainerResult.vb
deleted file mode 100644
index 5b5b17fa..00000000
--- a/Service.EDMIService/Results/ContainerResult.vb
+++ /dev/null
@@ -1,18 +0,0 @@
-Imports DigitalData.Modules.Filesystem
-
-
-Public Class ContainerResult
- Public ReadOnly OK As Boolean
- Public ReadOnly ErrorMessage As String
- Public Container As FileContainerInner
-
- Public Sub New()
- OK = True
- ErrorMessage = Nothing
- End Sub
-
- Public Sub New(ErrorMessage As String)
- OK = False
- Me.ErrorMessage = ErrorMessage
- End Sub
-End Class
diff --git a/Service.EDMIService/Results/DocumentResult.vb b/Service.EDMIService/Results/DocumentResult.vb
deleted file mode 100644
index 11332187..00000000
--- a/Service.EDMIService/Results/DocumentResult.vb
+++ /dev/null
@@ -1,31 +0,0 @@
-Imports System.Xml.Serialization
-
-
-Public Class DocumentResult
- Inherits BaseResult
-
- Public Document As DocumentObject
- Public HasContents As Boolean = False
- Public Contents As Byte()
-
- Public Sub New(Document As DocumentObject)
- MyBase.New()
- Me.Document = Document
- End Sub
-
- Public Sub New(Document As DocumentObject, Contents As Byte())
- MyBase.New()
- Me.Document = Document
- Me.Contents = Contents
- Me.HasContents = True
- End Sub
-
- Public Sub New(ErrorMessage As String)
- MyBase.New(ErrorMessage)
- End Sub
-
- Public Class DocumentObject
- Public FileName As String
- Public FileId As String
- End Class
-End Class
diff --git a/Service.EDMIService/Results/DocumentResultOld.vb b/Service.EDMIService/Results/DocumentResultOld.vb
deleted file mode 100644
index 02202516..00000000
--- a/Service.EDMIService/Results/DocumentResultOld.vb
+++ /dev/null
@@ -1,26 +0,0 @@
-Imports DigitalData.Modules.Filesystem
-
-
-Public Class DocumentResultOld
- Inherits BaseResult
-
- Public Document As DocumentObject
- Public HasContents As Boolean = False
- Public Contents As Byte()
-
- Public Sub New(Document As DocumentObject)
- MyBase.New()
- Me.Document = Document
- End Sub
-
- Public Sub New(Document As DocumentObject, Contents As Byte())
- MyBase.New()
- Me.Document = Document
- Me.Contents = Contents
- Me.HasContents = True
- End Sub
-
- Public Sub New(ErrorMessage As String)
- MyBase.New(ErrorMessage)
- End Sub
-End Class
diff --git a/Service.EDMIService/Results/IndexResult.vb b/Service.EDMIService/Results/IndexResult.vb
deleted file mode 100644
index ac31956b..00000000
--- a/Service.EDMIService/Results/IndexResult.vb
+++ /dev/null
@@ -1,15 +0,0 @@
-
-Public Class IndexResult
- Inherits BaseResult
-
- Public ReadOnly IndexId As Int64
-
- Public Sub New(IndexId As Int64)
- MyBase.New()
- Me.IndexId = IndexId
- End Sub
-
- Public Sub New(ErrorMessage As String)
- MyBase.New(ErrorMessage)
- End Sub
-End Class