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
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}
oPathParts.AddRange(GetRelativePath(DocumentType))
oPathParts.AddRange(GetRelativePath(DocumentType, FileName))
Return IO.Path.Combine(oPathParts.ToArray())
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}
oPathParts.AddRange(GetRelativePath(DocumentType))
oPathParts.AddRange(GetRelativePath(DocumentType, FileName))
Return IO.Path.Combine(oPathParts.ToArray())
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}
oPathParts.AddRange(GetDatePath())
oPathParts.Add(FileName)
Return IO.Path.Combine(oPathParts.ToArray())
End Function

View File

@ -303,9 +303,9 @@ Public Class EDMIService
#Region "Document"
Public Function ImportFile(FileName As String, Contents() As Byte, AddedWho As String) As DocumentResult2 Implements IEDMIService.ImportFile
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 oAbsPath = Path.Combine(oDirectoryPath, FileName)
Dim oRelativePath = EDMIPath.GetRelativePath(oDocumentType)
Dim oDocument = New DocumentResult2.DocumentObject With {.FileName = FileName}
Try
@ -316,7 +316,7 @@ Public Class EDMIService
End 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)
Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew)
@ -328,7 +328,7 @@ Public Class EDMIService
' insert into db
Dim oCommand As New SqlCommand("PRIDB_NEW_DOCUMENT")
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("@REF_DOCID", 0)
oCommand.Parameters.Add(New SqlParameter("@IDB_OBJ_ID", SqlDbType.BigInt))