If _FTP_正在下载 = True Then
Return True
End If
_FTP_正在下载 = True
' 下载所有扩展列附件(图片、文件)
Dim FTP As New FTPClient
FTP.Host = _FTP_Abbr_Host
FTP.Password = _FTP_Abbr_Pass
FTP.Account = _FTP_Abbr_Acco
FTP.Port = _FTP_Abbr_Port
FTP.RootDir = _FTP_Abbr_Root
FTP.Connect
If FTP.Connect = False Then
If Forms("登录日志").Opened = True AndAlso Forms("登录日志").Controls.Contains("DT_List") = True Then
Dim MESS As WinForm.ListBox = Forms("登录日志").Controls("DT_List")
MESS.ComboList = MESS.ComboList & "|" & "FTP连接失败!" & Date.Now()
End If
_FTP_正在下载 = False
Return False
Else
If Forms("登录日志").Opened = True AndAlso Forms("登录日志").Controls.Contains("DT_List") = True Then
Dim MESS As WinForm.ListBox = Forms("登录日志").Controls("DT_List")
MESS.ComboList = MESS.ComboList & "|" & "FTP目录" & FTP.RootDir & "|" & "FTP启动" & Date.Now()
End If
End If
Dim 成功 As Integer = 0
Dim 失败 As Integer = 0
Dim 跳过 As Integer = 0
Dim 执行 As Integer = 0
Dim 丢失 As Integer = 0
Dim 条件 As String = " And _New_Acc = '" & _登录人 & "'"
If Functions.Execute("Acc_Into", "{系统管理组}|{报表打印组}") = True Then
条件 = ""
End if
For Each DT As DataTable In DataTables
For Each DC As DataCol In DT.DataCols
If DC.ExtendType = ExtendTypeEnum.Images OrElse DC.ExtendType = ExtendTypeEnum.File OrElse DC.ExtendType = ExtendTypeEnum.FileS Then
Dim drs As List(Of DataRow) = DT.SQLSelect(DC.Name & " Is Not Null " & 条件)
For Each dr As DataRow In drs
Dim Files As String = DR(DC.NAME)
Dim Values() As String
Values = Files.Split(vbCrLf)
For Index As Integer = 0 To Values.Length - 1
If _FTP_下载终止 = True Then
Return True
End If
执行 = 执行 + 1
Dim NetFile As String = Values(Index)
If NetFile = "" Then
Continue For ' 下一个循环
End If
' 排除那些文件
' If NetFile.Contains("png") OrElse NetFile.Contains("pg") OrElse NetFile.Contains("ls") Then
' Continue For ' 下一个循环
' End If
Dim LocFile As String = ProjectPath & "\RemoteFiles\" & NetFile.Replace("/", "\")
LocFile = LocFile.Replace("\\", "\")
If FTP.Connect = False Then ' FTP连接失败时
StatusBar.Message3 = "FTP连接失败!" & Date.Now()
_FTP_正在下载 = False
Return False
End If
Try
If ftp.FileExists(NetFile) = False Then '如果存在则下载
丢失 = 丢失 + 1
Continue For ' 下一个循环
End If
Catch ex As Exception
If Forms("登录日志").Opened = True AndAlso Forms("登录日志").Controls.Contains("DT_List") = True Then
Dim MESS As WinForm.ListBox = Forms("登录日志").Controls("DT_List")
MESS.ComboList = MESS.ComboList & "|" & "FTP远程检查异常:" & DT.Name & " " & DC.Name
MESS.ComboList = MESS.ComboList & "|" & NetFile
MESS.ComboList = MESS.ComboList & "|" & "√" & 成功 & "×" & 失败 & "☆" & 丢失 & "⌒" & 跳过 & "/" & 执行
End If
'Continue For ' 下一个循环
End Try
Try
If FileSys.FileExists(LocFile) Then
Dim NetSize As Integer
NetSize = ftp.GetFileSize(NetFile)
Dim Locifo As New FileInfo(LocFile)
Dim LocSize As Integer = Locifo.Length
'Output.Show(NetSize & " " & LocSize)
If NetSize = LocSize Then
跳过 = 跳过 + 1
Continue For ' 下一个循环
End If
End If
Catch ex As Exception
If Forms("登录日志").Opened = True AndAlso Forms("登录日志").Controls.Contains("DT_List") = True Then
Dim MESS As WinForm.ListBox = Forms("登录日志").Controls("DT_List")
MESS.ComboList = MESS.ComboList & "|" & "FTP文件比较异常:" & DT.Name & " " & DC.Name
MESS.ComboList = MESS.ComboList & "|" & NetFile
End If
'Continue For ' 下一个循环
End Try
If FTP.Connect = False Then ' FTP连接失败时
StatusBar.Message3 = "FTP连接失败!" & Date.Now()
_FTP_正在下载 = False
Return False
End If
If FTP.Connect = True Then
Try
If ftp.Download(NetFile, LocFile) Then
成功 = 成功 + 1
Else
失败 = 失败 + 1
End If
Catch ex As Exception
If Forms("登录日志").Opened = True AndAlso Forms("登录日志").Controls.Contains("DT_List") = True Then
Dim MESS As WinForm.ListBox = Forms("登录日志").Controls("DT_List")
MESS.ComboList = MESS.ComboList & "|" & "FTP下载异常:" & DT.Name & " " & DC.Name
MESS.ComboList = MESS.ComboList & "|" & NetFile
End If
End Try
End If
If _FTP_下载终止 = True Then
Return True
End If
Next
Next
StatusBar.Message3 = "√" & 成功 & "×" & 失败 & "☆" & 丢失 & "⌒" & 跳过 & "/" & 执行 & " " & DT.Name & " " & DC.Name
End If
Next
Next
StatusBar.Message3 = "√" & 成功 & "×" & 失败 & "☆" & 丢失 & "⌒" & 跳过 & "|" & 执行
If Forms("登录日志").Opened = True AndAlso Forms("登录日志").Controls.Contains("DT_List") = True Then
Dim MESS As WinForm.ListBox = Forms("登录日志").Controls("DT_List")
MESS.ComboList = MESS.ComboList & "|" & StatusBar.Message3
MESS.ComboList = MESS.ComboList & "|" & "FTP完成下载"
End If
_FTP_完成下载 = True
_FTP_正在下载 = False
Return True