Mark documents as imported and clean them up when closing app, update to DevExpress 21, small tweaks
This commit is contained in:
@@ -20,6 +20,7 @@ Namespace Documents
|
||||
Public Property Rows As New List(Of DocumentRow)
|
||||
|
||||
Public Property Selected As Boolean = False
|
||||
Public Property Imported As Boolean = False
|
||||
|
||||
Public ReadOnly Property HasErrors As Boolean
|
||||
Get
|
||||
|
||||
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
|
||||
@@ -247,7 +247,7 @@ Namespace Documents
|
||||
Logger.Warn("Mandator not found for File [{0}]", pDocument.File.Name)
|
||||
Else
|
||||
pDocument = MatchDocumentDataFromHardcodedMappings(pDocument, oMandator, pTemplate)
|
||||
pDocument = MatchDocumentDataFromDynamicMappings(pDocument, oMandator, MappingConfig)
|
||||
pDocument = MatchDocumentDataFromDynamicMappings(pDocument, oMandator)
|
||||
End If
|
||||
|
||||
pDocument.Mandator = oMandator
|
||||
@@ -289,7 +289,7 @@ Namespace Documents
|
||||
Return pDocument
|
||||
End Function
|
||||
|
||||
Private Function MatchDocumentDataFromDynamicMappings(pDocument As Document, pMandator As Mandator, pMappingConfig As MappingConfig) As Document
|
||||
Private Function MatchDocumentDataFromDynamicMappings(pDocument As Document, pMandator As Mandator) As Document
|
||||
If pMandator Is Nothing Then
|
||||
Return pDocument
|
||||
End If
|
||||
@@ -326,18 +326,6 @@ Namespace Documents
|
||||
' don't do anything
|
||||
|
||||
End If
|
||||
|
||||
'Dim oRow = pDocument.Rows.Where(Function(row)
|
||||
' Dim oTempRow = row.Fields.Where(Function(field) field.Key = oMapping.SourceItem).FirstOrDefault()
|
||||
' If IsNothing(oTempRow) Then
|
||||
' Return False
|
||||
' Else Return True
|
||||
' End If
|
||||
' End Function).FirstOrDefault()
|
||||
'Dim oField = oRow.Fields.Where(Function(field) field.Key = oMapping.SourceItem).FirstOrDefault()
|
||||
|
||||
Console.WriteLine()
|
||||
|
||||
Next
|
||||
|
||||
Return pDocument
|
||||
|
||||
Reference in New Issue
Block a user