Rename Shared to Common
This commit is contained in:
40
MultiTool.Common/Documents/DocumentCleaner.vb
Normal file
40
MultiTool.Common/Documents/DocumentCleaner.vb
Normal file
@@ -0,0 +1,40 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports MultiTool.Common.Templates
|
||||
|
||||
Namespace Documents
|
||||
Public Class DocumentCleaner
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly Template As Template
|
||||
Private ReadOnly FileEx As DigitalData.Modules.Filesystem.File
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pTemplate As Template)
|
||||
MyBase.New(pLogConfig)
|
||||
Template = pTemplate
|
||||
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.CreateDateDirectory(Template.ArchiveDirectory)
|
||||
Dim oImportedDocuments = pDocuments.
|
||||
Where(Function(doc) doc.Imported = True).
|
||||
ToList()
|
||||
|
||||
For Each oDocument As Document In oImportedDocuments
|
||||
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