EXG , Datenserver move

This commit is contained in:
2026-10-18 11:07:37 +02:00
parent de6939c518
commit 205e6815d6
7 changed files with 601 additions and 119 deletions

View File

@@ -192,51 +192,80 @@ Public Class cDATENSERVER
Return False
End Function
Function moveTo_ARCHIVARCHIV()
Dim oldDIR = DATENVERVER_OPTIONS.getDescPath(rootDir, da_kategorie, da_ordner, da_uOrdner1, da_uOrdner2, da_uOrdner3, da_KundenNr, "", "", True)
Function moveTo_ARCHIVARCHIV() As Boolean
Dim oldDIR = DATENVERVER_OPTIONS.getDescPath(rootDir, da_kategorie, da_ordner, da_uOrdner1, da_uOrdner2, da_uOrdner3, da_KundenNr, "", "", True)
Dim newDIR = DATENVERVER_OPTIONS.getDescPath(rootDirARCHIVARCHIV, da_kategorie, da_ordner, da_uOrdner1, da_uOrdner2, da_uOrdner3, da_KundenNr, "", "", True)
Try
' My.Computer.FileSystem.RenameDirectory(oldDIR, newname)
Dim hasErrors As Boolean = False
Dim oldBase = System.IO.Path.GetFullPath(oldDIR).TrimEnd("\"c) & "\"
Dim newBase = System.IO.Path.GetFullPath(newDIR).TrimEnd("\"c) & "\"
Dim createdDirectories As New HashSet(Of String)(StringComparer.OrdinalIgnoreCase)
For Each li In DATA_LIST.LIST
Dim alterPfad As String = li.coll_pfad
Dim newPfad = li.coll_pfad.Replace(oldDIR, newDIR)
'MsgBox(li.coll_pfad)
' MsgBox(newPfad)
If Not System.IO.Directory.Exists(newDIR) Then System.IO.Directory.CreateDirectory(newDIR)
Try
If Not li.coll_pfad.ToLower.StartsWith("\\stor01.verag.ost.dmn\datenarchivarchiv") Then
If Not li.coll_pfad.Contains("?") Then
If System.IO.File.Exists(li.coll_pfad) Then
My.Computer.FileSystem.CopyFile(li.coll_pfad, newPfad, True)
My.Computer.FileSystem.DeleteFile(li.coll_pfad)
li.coll_pfad = newPfad
If Not li.UPDATE() Then
Return False
End If
Else
'Datei Existiert nicht!
li.coll_pfad = li.coll_pfad.Replace("\\datenarchiv.verag.ost.dmn\", "\\DELETED\")
If Not li.UPDATE() Then
Return False
End If
If String.IsNullOrWhiteSpace(alterPfad) Then Continue For
If alterPfad.StartsWith("\\stor01.verag.ost.dmn\datenarchivarchiv\", StringComparison.OrdinalIgnoreCase) Then Continue For
If alterPfad.StartsWith("\\DELETED\", StringComparison.OrdinalIgnoreCase) Then Continue For
If alterPfad.Contains("?") Then Continue For
If System.IO.File.Exists(alterPfad) Then
Dim fullPath = System.IO.Path.GetFullPath(alterPfad)
If Not fullPath.StartsWith(oldBase, StringComparison.OrdinalIgnoreCase) Then
Throw New Exception("Datei liegt nicht im Quellverzeichnis: " & alterPfad)
End If
Dim newPfad = newBase & fullPath.Substring(oldBase.Length)
Dim zielOrdner = System.IO.Path.GetDirectoryName(newPfad)
If createdDirectories.Add(zielOrdner) Then
System.IO.Directory.CreateDirectory(zielOrdner)
End If
System.IO.File.Copy(alterPfad, newPfad, True)
li.coll_pfad = newPfad
If Not li.UPDATE() Then
li.coll_pfad = alterPfad
Throw New Exception("Datenbankupdate fehlgeschlagen: " & alterPfad)
End If
System.IO.File.Delete(alterPfad)
Else
li.coll_pfad = alterPfad.Replace("\\datenarchiv.verag.ost.dmn\", "\\DELETED\")
If li.coll_pfad <> alterPfad Then
If Not li.UPDATE() Then
li.coll_pfad = alterPfad
Throw New Exception("Datenbankupdate fehlgeschlagen: " & alterPfad)
End If
End If
End If
Catch ex2 As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex2.Message, li.coll_pfad & vbNewLine & newPfad & vbNewLine & vbNewLine & ex2.Message & vbNewLine & ex2.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
hasErrors = True
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex2.Message, alterPfad & vbNewLine & ex2.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Next
Return UPDATE()
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, "Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
If hasErrors Then Return False
Return UPDATE()
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return False
End Function
Function UPDATE() As Boolean
Try
'If coll_id < 0 Then 'Wenn noch keine ID vergeben