' 26/06/2026 Se controla todas las excepciones con tsl5.tsExcepcion y se añade HoraControl
This commit is contained in:
@@ -31,13 +31,12 @@ Imports System.Runtime.InteropServices
|
|||||||
' mediante el asterisco ('*'), como se muestra a continuación:
|
' mediante el asterisco ('*'), como se muestra a continuación:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("2.0.0.1")>
|
<Assembly: AssemblyVersion("3.0.0.0")>
|
||||||
<Assembly: AssemblyFileVersion("2.0.0.1")>
|
<Assembly: AssemblyFileVersion("3.0.0.0")>
|
||||||
|
|
||||||
|
|
||||||
' Cambios en la versión 2.0.0.1
|
' Cambios en la versión 3.0.0.0
|
||||||
'
|
' 26/06/2026 Se controla todas las excepciones con tsl5.tsExcepcion y se añade HoraControl
|
||||||
' 26/02/2025 Se elimina
|
|
||||||
|
|
||||||
|
|
||||||
' Cambios en la versión 2.0.0.0
|
' Cambios en la versión 2.0.0.0
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>tsFluentFTP</id>
|
<id>tsFluentFTP</id>
|
||||||
<version>1.0.0</version>
|
<version>3.0.0</version>
|
||||||
<authors>Tecnosis</authors>
|
<authors>Tecnosis</authors>
|
||||||
<owners>Tecnosis</owners>
|
<owners>Tecnosis</owners>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
|||||||
78
ftp.vb
78
ftp.vb
@@ -30,8 +30,9 @@ Public Class ftp
|
|||||||
If ftp.IsConnected = False Then ftp.Connect()
|
If ftp.IsConnected = False Then ftp.Connect()
|
||||||
Return ftp.GetModifiedTime(Fichero)
|
Return ftp.GetModifiedTime(Fichero)
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End Function
|
End Function
|
||||||
@@ -62,8 +63,9 @@ Public Class ftp
|
|||||||
If ftp.IsConnected = False Then ftp.Connect()
|
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")
|
If Not ftp.DownloadStream(st, Fichero, , Progreso) Then Throw New Exception("No se ha podido descargar el fichero")
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw New Exception(EX.Message, EX)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -133,10 +135,12 @@ Public Class ftp
|
|||||||
Else
|
Else
|
||||||
Await ftp.Disconnect
|
Await ftp.Disconnect
|
||||||
End If
|
End If
|
||||||
|
HoraControl = Now
|
||||||
Return t
|
Return t
|
||||||
|
|
||||||
' End Using
|
' End Using
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw New Exception(EX.Message, EX)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@@ -179,10 +183,11 @@ Public Class ftp
|
|||||||
Else
|
Else
|
||||||
Await ftp.Disconnect
|
Await ftp.Disconnect
|
||||||
End If
|
End If
|
||||||
|
HoraControl = Now
|
||||||
Return t
|
Return t
|
||||||
'End Using
|
'End Using
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw New Exception(EX.Message, EX)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Function
|
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)
|
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()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw New Exception(EX.Message, EX)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
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)
|
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
|
End If
|
||||||
If t = FtpStatus.Failed Then Throw New Exception("Error enviado fichero " & FicheroOrigen & " a " & FicheroDestino)
|
If t = FtpStatus.Failed Then Throw New Exception("Error enviado fichero " & FicheroOrigen & " a " & FicheroDestino)
|
||||||
Return t
|
Return t
|
||||||
|
HoraControl = Now
|
||||||
' End Using
|
' End Using
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw New Exception(EX.Message, EX)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
@@ -298,10 +305,10 @@ Public Class ftp
|
|||||||
Await ftp.Disconnect()
|
Await ftp.Disconnect()
|
||||||
If t = FtpStatus.Failed Then Throw New Exception("Error renombrando fichero " & FicheroOrigen & " a " & FicheroDestino)
|
If t = FtpStatus.Failed Then Throw New Exception("Error renombrando fichero " & FicheroOrigen & " a " & FicheroDestino)
|
||||||
Return t
|
Return t
|
||||||
|
HoraControl = Now
|
||||||
' End Using
|
' End Using
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
MsgBox(EX.Message)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
Throw New PKICOAS.TSException(EX.Message, EX, "FTP_ERROR.DESCONOCIDO", )
|
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@@ -334,8 +341,9 @@ Public Class ftp
|
|||||||
Dim t = ftp.UploadFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, False, Verificacion, Progreso)
|
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 & " ")
|
If t = FtpStatus.Failed Then Throw New Exception("Error enviando fichero " & FicheroOrigen & " a " & FicheroDestino & " ")
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw New Exception(EX.Message, EX)
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -367,8 +375,9 @@ Public Class ftp
|
|||||||
Dim t = ftp.UploadBytes(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, False, Progreso)
|
Dim t = ftp.UploadBytes(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite, False, Progreso)
|
||||||
If t = FtpStatus.Failed Then Throw New Exception("Error enviando fichero ")
|
If t = FtpStatus.Failed Then Throw New Exception("Error enviando fichero ")
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -403,8 +412,9 @@ Public Class ftp
|
|||||||
ftp.CreateDirectory(Directorio, True)
|
ftp.CreateDirectory(Directorio, True)
|
||||||
End If
|
End If
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -434,8 +444,9 @@ Public Class ftp
|
|||||||
If ftp.IsConnected = False Then ftp.Connect()
|
If ftp.IsConnected = False Then ftp.Connect()
|
||||||
ftp.DeleteFile(Fichero)
|
ftp.DeleteFile(Fichero)
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -466,8 +477,9 @@ Public Class ftp
|
|||||||
If Not ftp.Capabilities.Contains(FtpCapability.MDTM) Then ftp.Capabilities.Add(FtpCapability.MDTM)
|
If Not ftp.Capabilities.Contains(FtpCapability.MDTM) Then ftp.Capabilities.Add(FtpCapability.MDTM)
|
||||||
Return ftp.FileExists(Fichero)
|
Return ftp.FileExists(Fichero)
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
Catch EX As Exception
|
Catch EX As Exception
|
||||||
Throw
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@@ -500,10 +512,9 @@ Public Class ftp
|
|||||||
If Not ftp.Capabilities.Contains(FtpCapability.MDTM) Then ftp.Capabilities.Add(FtpCapability.MDTM)
|
If Not ftp.Capabilities.Contains(FtpCapability.MDTM) Then ftp.Capabilities.Add(FtpCapability.MDTM)
|
||||||
ftp.MoveFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite)
|
ftp.MoveFile(FicheroOrigen, FicheroDestino, FtpRemoteExists.Overwrite)
|
||||||
ftp.Disconnect()
|
ftp.Disconnect()
|
||||||
Catch EX As PKICOAS.TSException
|
HoraControl = Now
|
||||||
Throw EX
|
|
||||||
Catch EX As Exception
|
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 Try
|
||||||
End Sub
|
End Sub
|
||||||
'Public Shared Sub MueveFicheros(PatronFicheroOrigen As String, DirectorioDestino As String, ServidorFTP As ServidorFTP)
|
'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
|
' For Each F In lf
|
||||||
' ftp.Rename(F.FullName, DirectorioDestino & F.Name)
|
' ftp.Rename(F.FullName, DirectorioDestino & F.Name)
|
||||||
' Next
|
' Next
|
||||||
' Catch EX As PKICOAS.TSException
|
' Catch EX As tsl5.TsExcepcion
|
||||||
' Throw EX
|
' Throw EX
|
||||||
' Catch EX As Exception
|
' 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 Try
|
||||||
'End Sub
|
'End Sub
|
||||||
|
|
||||||
Public Shared Function ObtieneListaFicheros(Ruta As String, ServidorFTP As ServidorFTP) As FtpListItem()
|
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)
|
Try
|
||||||
If ServidorFTP.Pasivo Then
|
Dim ftp As New FtpClient(ServidorFTP.Servidor, ServidorFTP.Usuario, ServidorFTP.Contraseña, ServidorFTP.Puerto)
|
||||||
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV
|
If ServidorFTP.Pasivo Then
|
||||||
Else
|
ftp.Config.DataConnectionType = FtpDataConnectionType.PASV
|
||||||
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive
|
Else
|
||||||
End If
|
ftp.Config.DataConnectionType = FtpDataConnectionType.AutoActive
|
||||||
ftp.Config.RetryAttempts = ServidorFTP.Reintentos
|
End If
|
||||||
ftp.Config.ConnectTimeout = ServidorFTP.Timeout
|
ftp.Config.RetryAttempts = ServidorFTP.Reintentos
|
||||||
' ftp.Config.ListingCulture = Globalization.CultureInfo.CurrentCulture
|
ftp.Config.ConnectTimeout = ServidorFTP.Timeout
|
||||||
If ftp.IsConnected = False Then ftp.Connect()
|
' ftp.Config.ListingCulture = Globalization.CultureInfo.CurrentCulture
|
||||||
Dim lf = ftp.GetListing(Ruta)
|
If ftp.IsConnected = False Then ftp.Connect()
|
||||||
ftp.Disconnect()
|
Dim lf = ftp.GetListing(Ruta)
|
||||||
Return lf
|
ftp.Disconnect()
|
||||||
|
HoraControl = Now
|
||||||
|
Return lf
|
||||||
|
Catch EX As Exception
|
||||||
|
Throw New tsl5.tsExcepcion(EX.Message, EX, "FTP_ERROR")
|
||||||
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Shared Sub ValidarCertificado(control As FtpClient, e As FtpSslValidationEventArgs)
|
Private Shared Sub ValidarCertificado(control As FtpClient, e As FtpSslValidationEventArgs)
|
||||||
|
|||||||
@@ -50,9 +50,6 @@
|
|||||||
<OptionInfer>On</OptionInfer>
|
<OptionInfer>On</OptionInfer>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="PKICOAS">
|
|
||||||
<HintPath>..\..\Controles\Binarios\PKICOAS\PKICOAS.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
@@ -119,6 +116,9 @@
|
|||||||
<PackageReference Include="FluentFTP">
|
<PackageReference Include="FluentFTP">
|
||||||
<Version>53.0.2</Version>
|
<Version>53.0.2</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="tsl5">
|
||||||
|
<Version>3.0.6</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
Reference in New Issue
Block a user