WIP: EDMI Service
This commit is contained in:
@@ -137,7 +137,7 @@ Public Class EDMIService
|
||||
|
||||
#End Region
|
||||
#Region "Document (with FileContainer)"
|
||||
Public Function NewFile(FileName As String, Contents() As Byte) As DocumentResult Implements IEDMIService.NewFile
|
||||
Public Function NewFile(FileName As String, Contents() As Byte) As DocumentResultOld Implements IEDMIService.NewFile
|
||||
Try
|
||||
Dim oContainer As FileContainer
|
||||
Dim oContainerId As String
|
||||
@@ -169,14 +169,14 @@ Public Class EDMIService
|
||||
_logger.Debug("File saved in Container!", FileName)
|
||||
|
||||
Dim oDocument = New DocumentObject(oContainerId, oDocId, FileName)
|
||||
Return New DocumentResult(oDocument)
|
||||
Return New DocumentResultOld(oDocument)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult(ex.Message)
|
||||
Return New DocumentResultOld(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function UpdateFile(DocObject As DocumentObject, Contents() As Byte) As DocumentResult Implements IEDMIService.UpdateFile
|
||||
Public Function UpdateFile(DocObject As DocumentObject, Contents() As Byte) As DocumentResultOld Implements IEDMIService.UpdateFile
|
||||
Try
|
||||
TestFileExists(DocObject.ContainerId)
|
||||
|
||||
@@ -189,14 +189,14 @@ Public Class EDMIService
|
||||
oFileContainer.Save()
|
||||
|
||||
|
||||
Return New DocumentResult(DocObject)
|
||||
Return New DocumentResultOld(DocObject)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFile(DocObject As DocumentObject) As DocumentResult Implements IEDMIService.GetFile
|
||||
Public Function GetFile(DocObject As DocumentObject) As DocumentResultOld Implements IEDMIService.GetFile
|
||||
Try
|
||||
TestFileExists(DocObject.ContainerId)
|
||||
|
||||
@@ -204,10 +204,10 @@ Public Class EDMIService
|
||||
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
Return New DocumentResult(DocObject, oContents)
|
||||
Return New DocumentResultOld(DocObject, oContents)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult(ex.Message)
|
||||
Return New DocumentResultOld(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -243,13 +243,13 @@ Public Class EDMIService
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IEDMIService.GetDocumentByDocumentId
|
||||
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 DocumentResult("Document not found")
|
||||
Return New DocumentResultOld("Document not found")
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
@@ -265,19 +265,19 @@ Public Class EDMIService
|
||||
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
Return New DocumentResult(oDocument, oContents)
|
||||
Return New DocumentResultOld(oDocument, oContents)
|
||||
Catch ex As Exception
|
||||
Return New DocumentResult(ex.Message)
|
||||
Return New DocumentResultOld(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult Implements IEDMIService.GetDocumentByContainerId
|
||||
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 DocumentResult("Document not found")
|
||||
Return New DocumentResultOld("Document not found")
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
@@ -293,26 +293,26 @@ Public Class EDMIService
|
||||
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
Return New DocumentResult(oDocument, oContents)
|
||||
Return New DocumentResultOld(oDocument, oContents)
|
||||
Catch ex As Exception
|
||||
Return New DocumentResult(ex.Message)
|
||||
Return New DocumentResultOld(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Document"
|
||||
Public Function ImportFile(FileName As String, Contents() As Byte, AddedWho As String) As DocumentResult2 Implements IEDMIService.ImportFile
|
||||
Public Function ImportFile(FileName As String, Contents() As Byte, AddedWho As String) As DocumentResult Implements IEDMIService.ImportFile
|
||||
Dim oDocumentType As String = "DummyDocumentType"
|
||||
Dim oRelativePath As String = EDMIPath.GetRelativePath(oDocumentType, FileName)
|
||||
Dim oAbsolutePath As String = EDMIPath.GetActivePath(oDocumentType, FileName)
|
||||
Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject With {.FileName = FileName}
|
||||
Dim oDocument = New DocumentResult.DocumentObject With {.FileName = FileName}
|
||||
|
||||
Try
|
||||
Directory.CreateDirectory(oDirectoryPath)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult2(ex.Message)
|
||||
Return New DocumentResult(ex.Message)
|
||||
End Try
|
||||
|
||||
Try
|
||||
@@ -337,16 +337,16 @@ Public Class EDMIService
|
||||
|
||||
oDocument.FileId = oObjectId
|
||||
|
||||
Return New DocumentResult2(oDocument)
|
||||
Return New DocumentResult(oDocument)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult2(ex.Message)
|
||||
Return New DocumentResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileByObjectId(ObjectId As Int64) As Stream Implements IEDMIService.GetFileByObjectId
|
||||
Public Function GetFileByObjectId(Data As Messages.DocumentStreamRequest) As Messages.DocumentStreamResponse Implements IEDMIService.GetFileByObjectId
|
||||
Try
|
||||
Dim oSQL As String = $"SELECT DocRelativePath FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {ObjectId}"
|
||||
Dim oSQL As String = $"SELECT DocRelativePath FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {Data.ObjectId}"
|
||||
Dim oPath As String = MSSQL.GetScalarValue(oSQL)
|
||||
|
||||
If IsNothing(oPath) Then
|
||||
@@ -357,8 +357,15 @@ Public Class EDMIService
|
||||
|
||||
_logger.Debug("GetFileByObjectId: Loading file [{0}]", oFullPath)
|
||||
|
||||
Dim oFileInfo As New FileInfo(oFullPath)
|
||||
Dim oSource As FileStream = IO.File.Open(oFullPath, FileMode.Open)
|
||||
Return oSource
|
||||
|
||||
Dim oMessage As New Messages.DocumentStreamResponse() With {
|
||||
.FileName = oFileInfo.Name,
|
||||
.FileContents = oSource
|
||||
}
|
||||
|
||||
Return oMessage
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
|
||||
@@ -103,13 +103,14 @@
|
||||
<Compile Include="AppConfig.vb" />
|
||||
<Compile Include="Database\IDatabase.vb" />
|
||||
<Compile Include="Database\MSSQL.vb" />
|
||||
<Compile Include="Messages.vb" />
|
||||
<Compile Include="Results\BaseResult.vb" />
|
||||
<Compile Include="Results\ContainerResult.vb" />
|
||||
<Compile Include="Results\DocumentResult.vb" />
|
||||
<Compile Include="Results\DocumentResultOld.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Results\DatabaseResult.vb" />
|
||||
<Compile Include="EDMIService.vb" />
|
||||
<Compile Include="Results\DocumentResult2.vb" />
|
||||
<Compile Include="Results\DocumentResult.vb" />
|
||||
<Compile Include="Results\IndexResult.vb" />
|
||||
<Compile Include="WindowsService.vb">
|
||||
<SubType>Component</SubType>
|
||||
|
||||
@@ -29,30 +29,30 @@ Interface IEDMIService
|
||||
|
||||
#Region "Document (with FileContainer)"
|
||||
<OperationContract>
|
||||
Function NewFile(FileName As String, Contents As Byte()) As DocumentResult
|
||||
Function NewFile(FileName As String, Contents As Byte()) As DocumentResultOld
|
||||
|
||||
<OperationContract>
|
||||
Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResult
|
||||
Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResultOld
|
||||
|
||||
<OperationContract>
|
||||
Function GetFile(DocObject As DocumentObject) As DocumentResult
|
||||
Function GetFile(DocObject As DocumentObject) As DocumentResultOld
|
||||
|
||||
<OperationContract>
|
||||
Function DeleteFile(DocObject As DocumentObject) As Boolean
|
||||
|
||||
<OperationContract>
|
||||
Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult
|
||||
Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResultOld
|
||||
|
||||
<OperationContract>
|
||||
Function GetDocumentByContainerId(ContainerId As String) As DocumentResult
|
||||
Function GetDocumentByContainerId(ContainerId As String) As DocumentResultOld
|
||||
#End Region
|
||||
|
||||
#Region "Document (New)"
|
||||
<OperationContract>
|
||||
Function ImportFile(FileName As String, Contents As Byte(), AddedWho As String) As DocumentResult2
|
||||
Function ImportFile(FileName As String, Contents As Byte(), AddedWho As String) As DocumentResult
|
||||
|
||||
<OperationContract>
|
||||
Function GetFileByObjectId(ObjectId As Int64) As Stream
|
||||
Function GetFileByObjectId(Data As Messages.DocumentStreamRequest) As Messages.DocumentStreamResponse
|
||||
#End Region
|
||||
|
||||
#Region "Index"
|
||||
|
||||
22
Service.EDMIService/Messages.vb
Normal file
22
Service.EDMIService/Messages.vb
Normal file
@@ -0,0 +1,22 @@
|
||||
Imports System.IO
|
||||
Imports System.ServiceModel
|
||||
|
||||
Namespace Messages
|
||||
<MessageContract>
|
||||
Public Class DocumentStreamRequest
|
||||
<MessageBodyMember>
|
||||
Public ObjectId As Int64
|
||||
End Class
|
||||
|
||||
<MessageContract>
|
||||
Public Class DocumentStreamResponse
|
||||
<MessageHeader(MustUnderstand:=True)>
|
||||
Public FileName As String
|
||||
|
||||
<MessageBodyMember(Order:=1)>
|
||||
Public FileContents As Stream
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports System.Xml.Serialization
|
||||
|
||||
<Serializable>
|
||||
Public Class DocumentResult
|
||||
@@ -23,4 +23,9 @@ Public Class DocumentResult
|
||||
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
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<Serializable>
|
||||
Public Class DocumentResult2
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
<Serializable>
|
||||
Public Class DocumentResultOld
|
||||
Inherits BaseResult
|
||||
|
||||
Public Document As DocumentObject
|
||||
@@ -21,9 +23,4 @@ Public Class DocumentResult2
|
||||
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
|
||||
Reference in New Issue
Block a user