EDMI: Load Object Store Paths

This commit is contained in:
Jonathan Jenne
2020-04-17 11:57:18 +02:00
parent 88dfb3fab1
commit 14194248ad
12 changed files with 183 additions and 121 deletions

View File

@@ -1,11 +1,9 @@
Imports System.ServiceModel
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Filesystem
Imports DigitalData.Modules
Imports System.IO
Imports System.ServiceModel.Description
Imports System.ServiceModel.Channels
Imports System.ServiceModel
Imports System.Data.SqlClient
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
@@ -17,8 +15,8 @@ Public Class EDMIService
Public Shared Firebird As Firebird
Public Shared AppConfig As AppConfig
Public Shared Filesystem As Filesystem.File
Public Shared EDMIPath As EDMI.File.Path
Public Shared EDMIArchive As EDMI.File.Archive
Public Shared GlobalState As GlobalState
Private ReadOnly _logger As Logger
@@ -34,7 +32,6 @@ Public Class EDMIService
_username = oUsername
_logger = LogConfig.GetLogger()
_logger.Debug("New Request by User [{0}]", _username)
End Sub
@@ -320,6 +317,16 @@ Public Class EDMIService
''' <param name="Contents"></param>
''' <returns></returns>
Public Function ImportFile(FileName As String, Contents() As Byte, ObjectStoreId As Int64, DocumentType As String, Optional RetentionDays As Int64 = Nothing) As DocumentResult Implements IEDMIService.ImportFile
Dim oObjectStore = GlobalState.ObjectStores.
Where(Function(s) s.Id = ObjectStoreId).
FirstOrDefault()
If oObjectStore Is Nothing Then
Return New DocumentResult($"Object Store with Id [{ObjectStoreId}] does not exist!")
End If
Dim EDMIPath = New EDMI.File.Path(LogConfig, oObjectStore.Path)
' TODO:
' - Get Object Store -> Object Catalog -> Catalog Path
' - If IS_ARCHIVE = True And RetentionDays <> Nothing:
@@ -328,10 +335,9 @@ Public Class EDMIService
' and return ObjectStore Path from ObjectStoreId + RelativePath
' VWIDB_OBJECTSTORE
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 oRelativePath As String = EDMIPath.GetRelativePath(DocumentType, FileName)
Dim oAbsolutePath As String = EDMIPath.GetFullPath(DocumentType, FileName)
Dim oDirectoryPath = EDMIPath.GetFullPath(DocumentType)
Dim oDocument = New DocumentResult.DocumentObject With {.FileName = FileName}
Try
@@ -372,14 +378,23 @@ Public Class EDMIService
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 = {Data.ObjectId}"
Dim oPath As String = MSSQL.GetScalarValue(oSQL)
Dim oSQL As String = $"SELECT ObjectStoreId FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {Data.ObjectId}"
Dim oObjectStoreId = MSSQL.GetScalarValue(oSQL)
Dim oObjectStore = GlobalState.ObjectStores.
Where(Function(s) s.Id = oObjectStoreId).
FirstOrDefault()
Dim oSQL2 As String = $"SELECT DocRelativePath FROM VWIDB_DOC_DATA WHERE IDB_OBJ_ID = {Data.ObjectId}"
Dim oPath As String = MSSQL.GetScalarValue(oSQL2)
If IsNothing(oPath) Then
Throw New FaultException($"Object [{Data.ObjectId}] does not exist in database!")
End If
Dim oFullPath = EDMIPath.GetActivePathFromRelativePath(oPath)
Dim EDMIPath As New EDMI.File.Path(LogConfig, oObjectStore.Path)
Dim oFullPath = EDMIPath.GetFullPathFromRelativePath(oPath)
_logger.Debug("GetFileByObjectId: Loading file [{0}]", oFullPath)