' 26/06/2026 Se controla todas las excepciones con tsl5.tsExcepcion y se añade HoraControl
This commit is contained in:
78
ftp.vb
78
ftp.vb
@@ -30,8 +30,9 @@ Public Class ftp
|
||||
If ftp.IsConnected = False Then ftp.Connect()
|
||||
Return ftp.GetModifiedTime(Fichero)
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
Return Nothing
|
||||
End Function
|
||||
@@ -62,8 +63,9 @@ Public Class ftp
|
||||
If ftp.IsConnected = False Then ftp.Connect()
|
||||
If Not ftp.DownloadStream(st, Fichero, , Progreso) Then Throw New Exception("No se ha podido descargar el fichero")
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw New Exception(EX.Message, EX)
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -133,10 +135,12 @@ Public Class ftp
|
||||
Else
|
||||
Await ftp.Disconnect
|
||||
End If
|
||||
HoraControl = Now
|
||||
Return t
|
||||
|
||||
' End Using
|
||||
Catch EX As Exception
|
||||
Throw New Exception(EX.Message, EX)
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -179,10 +183,11 @@ Public Class ftp
|
||||
Else
|
||||
Await ftp.Disconnect
|
||||
End If
|
||||
HoraControl = Now
|
||||
Return t
|
||||
'End Using
|
||||
Catch EX As Exception
|
||||
Throw New Exception(EX.Message, EX)
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -215,8 +220,9 @@ Public Class ftp
|
||||
If ftp.DownloadFile(FicheroLocal, FicheroRemoto, FtpLocalExists.Overwrite, Verificacion, Progreso) = FtpStatus.Failed Then Throw New Exception("No se ha podido descargar el fichero " & FicheroRemoto & " en " & FicheroLocal)
|
||||
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw New Exception(EX.Message, EX)
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
Public Shared Async Function EnviaFicheroAsync(FicheroOrigen As String, FicheroDestino As String, ServidorFTP As ServidorFTP, Optional Progreso As IProgress(Of FtpProgress) = Nothing, Optional Verificacion As FtpVerify = FtpVerify.None, Optional ct As Threading.CancellationTokenSource = Nothing) As Tasks.Task(Of FtpStatus)
|
||||
@@ -258,9 +264,10 @@ Public Class ftp
|
||||
End If
|
||||
If t = FtpStatus.Failed Then Throw New Exception("Error enviado fichero " & FicheroOrigen & " a " & FicheroDestino)
|
||||
Return t
|
||||
HoraControl = Now
|
||||
' End Using
|
||||
Catch EX As Exception
|
||||
Throw New Exception(EX.Message, EX)
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
|
||||
End Function
|
||||
@@ -298,10 +305,10 @@ Public Class ftp
|
||||
Await ftp.Disconnect()
|
||||
If t = FtpStatus.Failed Then Throw New Exception("Error renombrando fichero " & FicheroOrigen & " a " & FicheroDestino)
|
||||
Return t
|
||||
HoraControl = Now
|
||||
' End Using
|
||||
Catch EX As Exception
|
||||
MsgBox(EX.Message)
|
||||
Throw New PKICOAS.TSException(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", )
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -334,8 +341,9 @@ Public Class ftp
|
||||
Dim t = ftp.UploadFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, False, Verificacion, Progreso)
|
||||
If t = FtpStatus.Failed Then Throw New Exception("Error enviando fichero " & FicheroOrigen & " a " & FicheroDestino & " ")
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw New Exception(EX.Message, EX)
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -367,8 +375,9 @@ Public Class ftp
|
||||
Dim t = ftp.UploadBytes(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, False, Progreso)
|
||||
If t = FtpStatus.Failed Then Throw New Exception("Error enviando fichero ")
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -403,8 +412,9 @@ Public Class ftp
|
||||
ftp.CreateDirectory(Directorio, True)
|
||||
End If
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -434,8 +444,9 @@ Public Class ftp
|
||||
If ftp.IsConnected = False Then ftp.Connect()
|
||||
ftp.DeleteFile(Fichero)
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -466,8 +477,9 @@ Public Class ftp
|
||||
If Not ftp.Capabilities.Contains(FtpCapability.MDTM) Then ftp.Capabilities.Add(FtpCapability.MDTM)
|
||||
Return ftp.FileExists(Fichero)
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -500,10 +512,9 @@ Public Class ftp
|
||||
If Not ftp.Capabilities.Contains(FtpCapability.MDTM) Then ftp.Capabilities.Add(FtpCapability.MDTM)
|
||||
ftp.MoveFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite)
|
||||
ftp.Disconnect()
|
||||
Catch EX As PKICOAS.TSException
|
||||
Throw EX
|
||||
HoraControl = Now
|
||||
Catch EX As Exception
|
||||
Throw New PKICOAS.TSException(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", )
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Sub
|
||||
'Public Shared Sub MueveFicheros(PatronFicheroOrigen As String, DirectorioDestino As String, ServidorFTP As ServidorFTP)
|
||||
@@ -528,27 +539,32 @@ Public Class ftp
|
||||
' For Each F In lf
|
||||
' ftp.Rename(F.FullName, DirectorioDestino & F.Name)
|
||||
' Next
|
||||
' Catch EX As PKICOAS.TSException
|
||||
' Catch EX As tsl5.TsExcepcion
|
||||
' Throw EX
|
||||
' Catch EX As Exception
|
||||
' Throw New PKICOAS.TSException(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", )
|
||||
' Throw New tsl5.TsExcepcion(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", )
|
||||
' End Try
|
||||
'End Sub
|
||||
|
||||
Public Shared Function ObtieneListaFicheros(Ruta As String, ServidorFTP As ServidorFTP) As FtpListItem()
|
||||
Dim ftp As New FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto)
|
||||
If ServidorFTP.Pasivo Then
|
||||
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV
|
||||
Else
|
||||
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive
|
||||
End If
|
||||
ftp.Config.RetryAttempts = ServidorFTP.Reintentos
|
||||
ftp.Config.ConnectTimeout = ServidorFTP.Timeout
|
||||
' ftp.Config.ListingCulture = Globalization.CultureInfo.CurrentCulture
|
||||
If ftp.IsConnected = False Then ftp.Connect()
|
||||
Dim lf = ftp.GetListing(Ruta)
|
||||
ftp.Disconnect()
|
||||
Return lf
|
||||
Try
|
||||
Dim ftp As New FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto)
|
||||
If ServidorFTP.Pasivo Then
|
||||
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV
|
||||
Else
|
||||
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive
|
||||
End If
|
||||
ftp.Config.RetryAttempts = ServidorFTP.Reintentos
|
||||
ftp.Config.ConnectTimeout = ServidorFTP.Timeout
|
||||
' ftp.Config.ListingCulture = Globalization.CultureInfo.CurrentCulture
|
||||
If ftp.IsConnected = False Then ftp.Connect()
|
||||
Dim lf = ftp.GetListing(Ruta)
|
||||
ftp.Disconnect()
|
||||
HoraControl = Now
|
||||
Return lf
|
||||
Catch EX As Exception
|
||||
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Shared Sub ValidarCertificado(control As FtpClient, e As FtpSslValidationEventArgs)
|
||||
|
||||
Reference in New Issue
Block a user