new
This commit is contained in:
@@ -66,7 +66,7 @@ Public Class frmMDMNachrichtenVerarbeitung
|
||||
Me.Enabled = False
|
||||
Try
|
||||
Label9.Visible = True
|
||||
Dim cnt = getNachrichtenDatenFromMDMServices()
|
||||
Dim cnt = getNachrichtenDatenFromMDMServices() ' If(VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM, getNachrichtenDatenFromMDMServicesTEST(), getNachrichtenDatenFromMDMServices())
|
||||
Label9.Text = cnt & " Datensätze empfangen."
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -108,125 +108,9 @@ Public Class frmMDMNachrichtenVerarbeitung
|
||||
|
||||
MDM_Worker.cMDMFunctions.getSFTPLoginData(MDM_server, MDM_name, MDM_pwd, MDM_port, "", MDM_PFAD_out)
|
||||
|
||||
DownloadFtpDirectory(MDM_server & "/"c & MDM_PFAD_out, New NetworkCredential(MDM_name, MDM_pwd), "", cnt, True)
|
||||
' DownloadFtpDirectory("ftp://80.16.102.180" & "/"c & MDM_PFAD_out, New NetworkCredential(MDM_name, MDM_pwd), "", cnt, True)
|
||||
|
||||
DownloadFtpDirectory("ftp://ftp.plose.it" & "/"c & MDM_PFAD_out, New NetworkCredential(MDM_name, MDM_pwd), "", cnt, True)
|
||||
'Dim request = WebRequest.Create("ftp://ftp.plose.it" & "/"c & MDM_PFAD_out)
|
||||
''request.Method = WebRequestMethods.Ftp.DownloadFile
|
||||
''request.Credentials = New NetworkCredential(MDM_name, MDM_pwd)
|
||||
|
||||
'request.Method = WebRequestMethods.Ftp.ListDirectory
|
||||
'request.Credentials = New NetworkCredential(MDM_name, MDM_pwd)
|
||||
|
||||
'Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
|
||||
'Dim responseStream As Stream = response.GetResponseStream
|
||||
|
||||
'Using reader As New StreamReader(responseStream)
|
||||
' Do While reader.Peek <> -1
|
||||
' Dim fName = reader.ReadLine
|
||||
|
||||
|
||||
' MsgBox(fName)
|
||||
' Loop
|
||||
'End Using
|
||||
|
||||
' Dim dest = Path.Combine(MDM_PFAD_out, fileName)
|
||||
' Using resp = request.GetResponse(), strmResp = resp.GetResponseStream,
|
||||
'strmFile = New FileStream(dest, FileMode.Create)
|
||||
' Dim buf(1023) As Byte
|
||||
' Do
|
||||
' Dim read = strmResp.Read(buf, 0, buf.Length)
|
||||
' If read = 0 Then Exit Do 'end of Transmission
|
||||
' strmFile.Write(buf, 0, read)
|
||||
' Loop
|
||||
' End Using
|
||||
' Return False
|
||||
|
||||
|
||||
'MsgBox(MDM_server & "/" & MDM_PFAD_out)
|
||||
'Dim Dirlist As New List(Of String) 'I prefer List() instead of an array
|
||||
'Dim request As New FtpWebRequest("http://ftp.plose.it") ' DirectCast(WebRequest.Create("http://ftp.plose.it"), FtpWebRequest) ' DirectCast(WebRequest.Create("ftp.plose.it"), FtpWebRequest)
|
||||
|
||||
'request.Method = WebRequestMethods.Ftp.ListDirectory
|
||||
'request.Credentials = New NetworkCredential(MDM_name, MDM_pwd)
|
||||
|
||||
'Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
|
||||
'Dim responseStream As Stream = response.GetResponseStream
|
||||
|
||||
'Using reader As New StreamReader(responseStream)
|
||||
' Do While reader.Peek <> -1
|
||||
' Dim fName = reader.ReadLine
|
||||
|
||||
' MsgBox(fName)
|
||||
' Loop
|
||||
'End Using
|
||||
|
||||
'response.Close()
|
||||
|
||||
|
||||
|
||||
'Try
|
||||
' ' Setup session options
|
||||
' Dim sessionOptions As New SessionOptions
|
||||
' With sessionOptions
|
||||
' .Protocol = Protocol.Ftp
|
||||
' .HostName = "example.com"
|
||||
' .UserName = "user"
|
||||
' .Password = "mypassword"
|
||||
' End With
|
||||
|
||||
' Using session As New Session
|
||||
' ' Will continuously report progress of synchronization
|
||||
' AddHandler session.FileTransferred, AddressOf FileTransferred
|
||||
|
||||
' ' Connect
|
||||
' session.Open(sessionOptions)
|
||||
|
||||
' ' Synchronize files
|
||||
' Dim synchronizationResult As SynchronizationResult
|
||||
' synchronizationResult =
|
||||
' session.SynchronizeDirectories(
|
||||
' SynchronizationMode.Local, "d:\www", "/home/martin/public_html", False)
|
||||
|
||||
' ' Throw on any error
|
||||
' synchronizationResult.Check()
|
||||
' End Using
|
||||
|
||||
' Return 0
|
||||
'Catch e As Exception
|
||||
' Console.WriteLine("Error: {0}", e)
|
||||
' Return 1
|
||||
'End Try
|
||||
|
||||
|
||||
|
||||
'MsgBox(MDM_server & " - " & MDM_name & " - " & MDM_pwd & " - " & MDM_port)
|
||||
'Dim ConnectionInfo As New ConnectionInfo(MDM_server, MDM_port, MDM_name, New PasswordAuthenticationMethod(MDM_name, MDM_pwd))
|
||||
'Using client = New SftpClient(ConnectionInfo)
|
||||
' client.Connect()
|
||||
|
||||
' For Each f In client.ListDirectory(MDM_PFAD_out)
|
||||
' ' MsgBox(f.Name)
|
||||
' If Not f.Name.StartsWith(".") Then
|
||||
' 'Temp. DownloadPfad
|
||||
' Dim destFilenameTMP = VERARBEITUNGS_PFAD + "." & If(IO.File.Exists(VERARBEITUNGS_PFAD & "." & f.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & f.Name
|
||||
|
||||
' 'Datei herunterladen
|
||||
' Dim downloadFileStream As Stream = File.OpenWrite(destFilenameTMP)
|
||||
' client.DownloadFile(f.FullName, downloadFileStream)
|
||||
' If IO.File.Exists(destFilenameTMP) Then client.DeleteFile(f.FullName) 'Datei nach erfolgreichem Herunterladen vom Server löschen
|
||||
' downloadFileStream.Dispose()
|
||||
|
||||
' 'Gültiger Filename
|
||||
' Dim destFilename = VERARBEITUNGS_PFAD & If(IO.File.Exists(VERARBEITUNGS_PFAD & f.Name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & f.Name
|
||||
' IO.File.Move(destFilenameTMP, destFilename) 'Datei umbenennen
|
||||
|
||||
' Dim fi As FileInfo = New FileInfo(destFilename)
|
||||
' ListBox3.Items.Add(frmStartOptions.cut_file(fi.Name)) 'zur Liste hinzufügen
|
||||
' cnt += 1
|
||||
' End If
|
||||
' Next
|
||||
' client.Disconnect()
|
||||
'End Using
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
@@ -234,6 +118,7 @@ Public Class frmMDMNachrichtenVerarbeitung
|
||||
Return cnt
|
||||
End Function
|
||||
|
||||
|
||||
Sub DownloadFtpDirectory(url As String, credentials As NetworkCredential, localPath As String, ByRef cnt As Integer, deleteAfterDownload As Boolean)
|
||||
Dim listRequest As FtpWebRequest = WebRequest.Create(url)
|
||||
listRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails
|
||||
@@ -259,7 +144,7 @@ Public Class frmMDMNachrichtenVerarbeitung
|
||||
Dim localFilePath As String = Path.Combine(localPath, name)
|
||||
Dim fileUrl As String = url + name
|
||||
|
||||
If permissions(0) = "d" Then
|
||||
If permissions(0) = "d" Then 'Ordner
|
||||
If Not Directory.Exists(localFilePath) Then
|
||||
Directory.CreateDirectory(localFilePath)
|
||||
End If
|
||||
@@ -518,20 +403,27 @@ Public Class frmMDMNachrichtenVerarbeitung
|
||||
End Select
|
||||
|
||||
End If
|
||||
If fi.Extension.ToLower = ".pdf" Then
|
||||
found = False
|
||||
|
||||
If Not IO.Directory.Exists(ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
|
||||
End If
|
||||
|
||||
|
||||
If True Then
|
||||
If Not alreadyMoved Then
|
||||
If found Then
|
||||
If Not IO.Directory.Exists(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
If Not alreadyMoved Then
|
||||
If found Then
|
||||
If Not IO.Directory.Exists(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
Me.Refresh()
|
||||
|
||||
End If
|
||||
|
||||
Me.Refresh()
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
Reference in New Issue
Block a user