Get DocumentObject from DocId or ContainerId

This commit is contained in:
Jonathan Jenne
2019-03-05 12:16:16 +01:00
parent bbd761c0ad
commit ec616ac9b8
14 changed files with 323 additions and 38 deletions

View File

@@ -3,6 +3,7 @@ Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Filesystem
Imports System.IO
Imports DigitalData.Services.EDMService
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
Public Class EDMService
@@ -236,10 +237,56 @@ Public Class EDMService
End Sub
#End Region
#Region "Utils"
Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IEDMService.GetDocumentByDocumentId
Try
Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBICM_DOCUMENT WHERE GUID = {DocumentId}"
Dim oTable = Database.GetDatatable(oSQL)
If oTable.Rows.Count = 0 Then
Return New DocumentResult("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")
)
Return New DocumentResult(oDocument)
Catch ex As Exception
Return New DocumentResult(ex.Message)
End Try
End Function
Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult Implements IEDMService.GetDocumentByContainerId
Try
Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBICM_DOCUMENT WHERE CONTAINER_ID = '{ContainerId}'"
Dim oTable = Database.GetDatatable(oSQL)
If oTable.Rows.Count = 0 Then
Return New DocumentResult("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")
)
Return New DocumentResult(oDocument)
Catch ex As Exception
Return New DocumentResult(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 IEDMService.NewFileIndex
Try
Dim oSQL = $"SELECT FNICM_NEW_OBJECT_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;"
Dim oSQL = $"SELECT FNICM_NEW_DOC_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;"
Dim oIndexId As Int64 = Database.GetScalarValue(oSQL)
Return New IndexResult(oIndexId)

View File

@@ -40,6 +40,14 @@ Interface IEDMService
Function DeleteFile(DocObject As DocumentObject) As Boolean
#End Region
#Region "Utils"
<OperationContract>
Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult
<OperationContract>
Function GetDocumentByContainerId(ContainerId As String) As DocumentResult
#End Region
#Region "Index"
<OperationContract>
Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult

View File

@@ -10,7 +10,7 @@ Public Class BaseResult
Public Property ErrorMessage As String
Public Sub New()
Me.OK = OK
OK = True
End Sub
Public Sub New(ErrorMessage As String)

View File

@@ -36,8 +36,8 @@ Public Class WindowsService
_logger = _logConfig.GetLogger()
_logger.Info("Service {0} is starting", SERVICE_DISPLAY_NAME)
_logger.Info("Connecting to database")
_logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
_logger.Debug("Connecting to database...")
_db = New Firebird(
_logConfig,
@@ -47,20 +47,20 @@ Public Class WindowsService
AppConfig.FirebirdPassword
)
_logger.Info("Successfully connected to database!")
_logger.Info("Database connection established.")
EDMService.Database = _db
EDMService.LogConfig = _logConfig
EDMService.AppConfig = _config
_logger.Info("Starting the WCF Service")
_logger.Debug("Starting WCF ServiceHost...")
_serviceHost = New ServiceHost(GetType(EDMService))
_serviceHost.Open()
_logger.Info("Successfully started the WCF Service!")
_logger.Info("WCF ServiceHost started.")
_logger.Info("Service {0} successfully started!", SERVICE_DISPLAY_NAME)
_logger.Info("Service {0} successfully started.", SERVICE_DISPLAY_NAME)
Catch ex As Exception
_logger.Error(ex, "Failed to start the service host!")
End Try