diff --git a/DDZUGFeRDService/App.config b/DDZUGFeRDService/App.config
index c60c3482..e496d645 100644
--- a/DDZUGFeRDService/App.config
+++ b/DDZUGFeRDService/App.config
@@ -1,7 +1,7 @@
-
+
-
+
@@ -39,4 +39,9 @@
-
\ No newline at end of file
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DDZUGFeRDService/DDZUGFeRDService.vbproj b/DDZUGFeRDService/DDZUGFeRDService.vbproj
index 7f98a253..7aea1100 100644
--- a/DDZUGFeRDService/DDZUGFeRDService.vbproj
+++ b/DDZUGFeRDService/DDZUGFeRDService.vbproj
@@ -47,6 +47,9 @@
On
+
+ ..\packages\FirebirdSql.Data.FirebirdClient.6.4.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll
+
..\packages\NLog.4.6.7\lib\net45\NLog.dll
diff --git a/DDZUGFeRDService/packages.config b/DDZUGFeRDService/packages.config
index 99e34262..7a05eafe 100644
--- a/DDZUGFeRDService/packages.config
+++ b/DDZUGFeRDService/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file
diff --git a/Filesystem/File.vb b/Filesystem/File.vb
index 94a446a1..2f4365a6 100644
--- a/Filesystem/File.vb
+++ b/Filesystem/File.vb
@@ -96,6 +96,11 @@ Public Class File
IO.File.Move(FilePath, Path.Combine(Directory, oFileInfo.Name))
End Sub
+ Public Sub MoveTo(FilePath As String, NewFileName As String, Directory As String)
+ Dim oFileInfo As New FileInfo(FilePath)
+ IO.File.Move(FilePath, Path.Combine(Directory, NewFileName))
+ End Sub
+
'''
''' Tries to create a directory and returns its path.
''' Returns a temp path if `DirectoryPath` can not be created or written to.
diff --git a/GUIs.Test.ZUGFeRDTest/App.config b/GUIs.Test.ZUGFeRDTest/App.config
index 8e3a399c..ee850a55 100644
--- a/GUIs.Test.ZUGFeRDTest/App.config
+++ b/GUIs.Test.ZUGFeRDTest/App.config
@@ -102,4 +102,9 @@
-
\ No newline at end of file
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj b/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj
index c1d84664..4fe0733a 100644
--- a/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj
+++ b/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj
@@ -47,6 +47,9 @@
On
+
+ ..\packages\FirebirdSql.Data.FirebirdClient.6.4.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll
+
..\packages\NLog.4.5.11\lib\net45\NLog.dll
diff --git a/GUIs.Test.ZUGFeRDTest/packages.config b/GUIs.Test.ZUGFeRDTest/packages.config
index f89fa324..9204b8da 100644
--- a/GUIs.Test.ZUGFeRDTest/packages.config
+++ b/GUIs.Test.ZUGFeRDTest/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file
diff --git a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb
index 07a9af46..15daad38 100644
--- a/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb
+++ b/Jobs/EDMI/ZUGFeRD/ImportZUGFeRDFiles.vb
@@ -567,19 +567,42 @@ Public Class ImportZUGFeRDFiles
Private Sub MoveFiles(Args As WorkerArgs, Files As List(Of FileInfo), AttachmentFiles As List(Of FileInfo), MoveDirectory As String)
For Each oFile In Files
- Dim oFinalMoveDirectory As String = MoveDirectory
+ Try
+ Dim oFinalMoveDirectory As String = MoveDirectory
- If AttachmentFiles.Contains(oFile) Then
- oFinalMoveDirectory = Path.Combine(MoveDirectory, Args.AttachmentsSubDirectory)
+ If AttachmentFiles.Contains(oFile) Then
+ oFinalMoveDirectory = Path.Combine(MoveDirectory, Args.AttachmentsSubDirectory)
- If Not Directory.Exists(oFinalMoveDirectory) Then
- Directory.CreateDirectory(oFinalMoveDirectory)
+ If Not Directory.Exists(oFinalMoveDirectory) Then
+ Directory.CreateDirectory(oFinalMoveDirectory)
+ End If
End If
- End If
- _filesystem.MoveTo(oFile.FullName, oFinalMoveDirectory)
- _logger.Info("Finished processing file {0}", oFile.Name)
- _logger.Info("File moved to {0}", oFinalMoveDirectory)
+ Dim oVersion As Integer = 0
+ Dim oFileName As String = Path.Combine(oFinalMoveDirectory, oFile.Name)
+
+ Do While File.Exists(oFileName)
+ If oVersion > 29 Then
+ Throw New ApplicationException("Max. Move-Retries of 30 exceeded! Move will be aborted!")
+ End If
+
+ oVersion += 1
+
+ Dim oExtension = Path.GetExtension(oFileName)
+ Dim oRootName = Path.GetFileNameWithoutExtension(oFile.Name)
+ Dim oNewName As String = oRootName & "~" & oVersion & oExtension
+ oFileName = Path.Combine(oFinalMoveDirectory, oNewName)
+ Loop
+
+ _filesystem.MoveTo(oFile.FullName, oFileName, oFinalMoveDirectory)
+
+ _logger.Info("Finished processing file {0}", oFile.Name)
+ _logger.Info("File moved to {0}", oFileName)
+
+ Catch ex As Exception
+ _logger.Warn("Could not move file {0}", oFile.FullName)
+ _logger.Error(ex)
+ End Try
Next
End Sub