Mark documents as imported and clean them up when closing app, update to DevExpress 21, small tweaks
This commit is contained in:
37
MultiTool.Shared/Documents/DocumentCleaner.vb
Normal file
37
MultiTool.Shared/Documents/DocumentCleaner.vb
Normal file
@@ -0,0 +1,37 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports MultiTool.Shared.Templates
|
||||
|
||||
Namespace Documents
|
||||
Public Class DocumentCleaner
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly GeneralConfig As GeneralConfig
|
||||
Private ReadOnly FileEx As DigitalData.Modules.Filesystem.File
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pGeneralConfig As GeneralConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
GeneralConfig = pGeneralConfig
|
||||
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
|
||||
End Sub
|
||||
|
||||
Public Function CleanImportedDocuments(pDocuments As List(Of Document)) As Boolean
|
||||
Dim oResult = True
|
||||
Dim oOutputDirectory = FileEx.GetDateDirectory(GeneralConfig.OutputXmlFileDirectory)
|
||||
|
||||
For Each oDocument As Document In pDocuments
|
||||
Try
|
||||
Dim oFileinfo = New FileInfo(oDocument.FullName)
|
||||
Dim oDestination = Path.Combine(oOutputDirectory, oFileinfo.Name)
|
||||
File.Move(oFileinfo.FullName, oDestination)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("File [{0}] could not be moved to output directory!", oDocument.FullName)
|
||||
Logger.Error(ex)
|
||||
oResult = False
|
||||
End Try
|
||||
Next
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user