82 lines
4.6 KiB
VB.net
82 lines
4.6 KiB
VB.net
Imports System.IO
|
|
Imports System.Net
|
|
|
|
Public Class cLDV_Interface
|
|
|
|
Public Shared Function copyLDV_BMD()
|
|
Dim Geschaeftsjahr = Now.Year ' Nicht Rg.-Jahr, sondern Jahr des Verarbeitungszeitpunkt
|
|
|
|
Dim LDV_PFAD = "\\ftps.verag.ag\FTP\LDV\IN\BMD\"
|
|
|
|
Dim pathArchivKD = "\\srv07.unisu.at\Unisped Daten\AWOR AR-Daten\" '"\\192.168.1.20\Daten\DVO - DATENORDNER MIT IMPORTDATEIEN\"
|
|
Dim pathKD = "\\share01\Datenarchiv\AWOR\BMD\STAMMDATEN\" & Geschaeftsjahr & "\" ' "\\192.168.1.20\Daten\DVO - DATENORDNER MIT IMPORTDATEIEN\Archiv\"
|
|
Dim pathArchiv = "\\srv07.unisu.at\Unisped Daten\AWOR AR-Daten\" '"\\192.168.1.20\Daten\DVO - DATENORDNER MIT IMPORTDATEIEN\"
|
|
Dim path = "\\share01\Datenarchiv\AWOR\BMD\BUCHUNGEN\" & Geschaeftsjahr & "\" ' "\\192.168.1.20\Daten\DVO - DATENORDNER MIT IMPORTDATEIEN\Archiv\"
|
|
|
|
Dim Dateiname = ""
|
|
|
|
Dim cnt = 0
|
|
Try
|
|
For Each f In IO.Directory.GetFiles(LDV_PFAD)
|
|
Dateiname = f
|
|
Dim FI As New FileInfo(f)
|
|
If Not FI.Name.StartsWith(".") Then
|
|
If FI.Name.StartsWith("KD") Then 'STAMMDATEN
|
|
'**** --> UNISPED möchte die KD Daten nicht bekommen.
|
|
If Not IO.Directory.Exists(pathKD) Then IO.Directory.CreateDirectory(pathKD)
|
|
If Not IO.Directory.Exists(pathArchivKD) Then IO.Directory.CreateDirectory(pathKD)
|
|
'Temp. DownloadPfad
|
|
Dim destFilenameTMP = pathKD + "." & If(IO.File.Exists(pathKD & "." & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
'**** Dim destFilenameTMP_archiv = pathArchivKD + "." & If(IO.File.Exists(pathArchivKD & "." & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
|
|
'Datei herunterladen
|
|
IO.File.Copy(f, destFilenameTMP)
|
|
'**** IO.File.Copy(f, destFilenameTMP_archiv)
|
|
If IO.File.Exists(destFilenameTMP) Then IO.File.Delete(f) 'Datei nach erfolgreichem Herunterladen vom Server löschen
|
|
|
|
'Gültiger Filename (Punkt entfernen)
|
|
Dim destFilename = pathKD & If(IO.File.Exists(pathKD & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
'**** Dim destFilename_archiv = pathArchivKD & If(IO.File.Exists(pathKD & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
IO.File.Move(destFilenameTMP, destFilename) 'Datei umbenennen
|
|
'**** IO.File.Move(destFilenameTMP_archiv, destFilename_archiv) 'Datei umbenennen
|
|
|
|
cnt += 1
|
|
|
|
|
|
Else ' BUCHUNGSDATEN
|
|
|
|
If Not IO.Directory.Exists(path) Then IO.Directory.CreateDirectory(path)
|
|
If Not IO.Directory.Exists(pathArchiv) Then IO.Directory.CreateDirectory(pathArchiv)
|
|
|
|
'Temp. DownloadPfad
|
|
Dim destFilenameTMP = path + "." & If(IO.File.Exists(path & "." & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
Dim destFilenameTMP_archiv = pathArchiv + "." & If(IO.File.Exists(pathArchiv & "." & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
|
|
'Datei herunterladen
|
|
IO.File.Copy(f, destFilenameTMP)
|
|
IO.File.Copy(f, destFilenameTMP_archiv)
|
|
If IO.File.Exists(destFilenameTMP) Then IO.File.Delete(f) 'Datei nach erfolgreichem Herunterladen vom Server löschen
|
|
|
|
'Gültiger Filename (Punkt entfernen)
|
|
Dim destFilename = path & If(IO.File.Exists(path & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
Dim destFilename_archiv = pathArchiv & If(IO.File.Exists(path & FI.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & FI.Name
|
|
IO.File.Move(destFilenameTMP, destFilename) 'Datei umbenennen
|
|
IO.File.Move(destFilenameTMP_archiv, destFilename_archiv) 'Datei umbenennen
|
|
|
|
' Dim fi_dest As FileInfo = New FileInfo(destFilename)
|
|
' ListBox3.Items.Add(frmStartOptions.cut_file(fi_dest.Name)) 'zur Liste hinzufügen
|
|
cnt += 1
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
End Try
|
|
|
|
Return cnt
|
|
|
|
End Function
|
|
|
|
End Class
|