create directory on import, version filename
This commit is contained in:
@@ -4,6 +4,8 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Modules
|
||||
Imports System.IO
|
||||
Imports System.ServiceModel.Description
|
||||
Imports System.ServiceModel.Channels
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
Public Class EDMIService
|
||||
@@ -12,6 +14,7 @@ Public Class EDMIService
|
||||
Public Shared LogConfig As LogConfig
|
||||
Public Shared Database 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
|
||||
|
||||
@@ -298,18 +301,28 @@ Public Class EDMIService
|
||||
#Region "Document"
|
||||
Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte, [Readonly] As Boolean, RetentionPeriod As Integer) As DocumentResult2 Implements IEDMIService.ImportFile
|
||||
Dim oDocumentType As String = "DummyDocumentType"
|
||||
Dim oFilePath = Path.Combine(EDMIPath.GetActivePath(oDocumentType), FileInfo.Name)
|
||||
Dim oDirectoryPath = EDMIPath.GetActivePath(oDocumentType)
|
||||
Dim oFilePath = Path.Combine(oDirectoryPath, FileInfo.Name)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name}
|
||||
|
||||
Try
|
||||
_logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oFilePath)
|
||||
Using oStream = New FileStream(oFilePath, FileMode.CreateNew)
|
||||
Directory.CreateDirectory(oDirectoryPath)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult2(ex.Message)
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oFilePath)
|
||||
|
||||
_logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oVersionedFileName)
|
||||
Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew)
|
||||
oStream.Write(Contents, 0, Contents.Length)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
|
||||
EDMIArchive.SetRetention(oFilePath, RetentionPeriod, [Readonly])
|
||||
EDMIArchive.SetRetention(oVersionedFileName, RetentionPeriod, [Readonly])
|
||||
|
||||
Return New DocumentResult2(oDocument)
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user