EDMIService: fix paths on import

This commit is contained in:
Jonathan Jenne 2020-04-14 10:34:30 +02:00
parent bb9dd66d1f
commit 52a6d103e6
2 changed files with 10 additions and 9 deletions

View File

@ -16,23 +16,24 @@ Public Class Path
_BasePath = DatastoreBasePath _BasePath = DatastoreBasePath
End Sub End Sub
Public Function GetActivePath(DocumentType As String) Public Function GetActivePath(DocumentType As String, Optional FileName As String = "")
Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ACTIVE} Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ACTIVE}
oPathParts.AddRange(GetRelativePath(DocumentType)) oPathParts.AddRange(GetRelativePath(DocumentType, FileName))
Return IO.Path.Combine(oPathParts.ToArray()) Return IO.Path.Combine(oPathParts.ToArray())
End Function End Function
Public Function GetArchivePath(DocumentType As String) Public Function GetArchivePath(DocumentType As String, Optional FileName As String = "")
Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ARCHIVE} Dim oPathParts As New List(Of String) From {_BasePath, PATH_EDMI, PATH_ARCHIVE}
oPathParts.AddRange(GetRelativePath(DocumentType)) oPathParts.AddRange(GetRelativePath(DocumentType, FileName))
Return IO.Path.Combine(oPathParts.ToArray()) Return IO.Path.Combine(oPathParts.ToArray())
End Function End Function
Public Function GetRelativePath(DocumentType As String) Public Function GetRelativePath(DocumentType As String, Optional FileName As String = "")
Dim oPathParts As New List(Of String) From {DocumentType} Dim oPathParts As New List(Of String) From {DocumentType}
oPathParts.AddRange(GetDatePath()) oPathParts.AddRange(GetDatePath())
oPathParts.Add(FileName)
Return IO.Path.Combine(oPathParts.ToArray()) Return IO.Path.Combine(oPathParts.ToArray())
End Function End Function

View File

@ -303,9 +303,9 @@ Public Class EDMIService
#Region "Document" #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 DocumentResult2 Implements IEDMIService.ImportFile
Dim oDocumentType As String = "DummyDocumentType" Dim oDocumentType As String = "DummyDocumentType"
Dim oRelativePath As String = EDMIPath.GetRelativePath(oDocumentType, FileName)
Dim oAbsolutePath As String = EDMIPath.GetActivePath(oDocumentType)
Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType) Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType)
Dim oAbsPath = Path.Combine(oDirectoryPath, FileName)
Dim oRelativePath = EDMIPath.GetRelativePath(oDocumentType)
Dim oDocument = New DocumentResult2.DocumentObject With {.FileName = FileName} Dim oDocument = New DocumentResult2.DocumentObject With {.FileName = FileName}
Try Try
@ -316,7 +316,7 @@ Public Class EDMIService
End Try End Try
Try Try
Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oAbsPath) Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oAbsolutePath)
_logger.Info("Saving file [{0}] to path [{1}]", FileName, oVersionedFileName) _logger.Info("Saving file [{0}] to path [{1}]", FileName, oVersionedFileName)
Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew) Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew)
@ -328,7 +328,7 @@ Public Class EDMIService
' insert into db ' insert into db
Dim oCommand As New SqlCommand("PRIDB_NEW_DOCUMENT") Dim oCommand As New SqlCommand("PRIDB_NEW_DOCUMENT")
oCommand.Parameters.AddWithValue("@OBJ_ST_ID", 1) oCommand.Parameters.AddWithValue("@OBJ_ST_ID", 1)
oCommand.Parameters.AddWithValue("@REL_PATH", oDirectoryPath) oCommand.Parameters.AddWithValue("@REL_PATH", oRelativePath)
oCommand.Parameters.AddWithValue("@WHO", AddedWho) oCommand.Parameters.AddWithValue("@WHO", AddedWho)
oCommand.Parameters.AddWithValue("@REF_DOCID", 0) oCommand.Parameters.AddWithValue("@REF_DOCID", 0)
oCommand.Parameters.Add(New SqlParameter("@IDB_OBJ_ID", SqlDbType.BigInt)) oCommand.Parameters.Add(New SqlParameter("@IDB_OBJ_ID", SqlDbType.BigInt))