diff --git a/Baget/Aplicacion.nuspec b/Baget/Aplicacion.nuspec index 17764a0..a6784ad 100644 --- a/Baget/Aplicacion.nuspec +++ b/Baget/Aplicacion.nuspec @@ -2,7 +2,7 @@ tsl5 - 3.0.7 + 3.0.8 Tecnosis Tecnosis false diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index ea6afbc..bd713d3 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -31,12 +31,13 @@ Imports System.Runtime.InteropServices ' mediante el asterisco ('*'), como se muestra a continuación: ' - - + + ' Modificaciones: ' =============== +' 09/07/2027 MANMOG Version 3.0.8 Se deshace corrección anterior ' 30/06/2027 MANMOG Version 3.0.7 Corrección CharConverter ' 26/06/2027 MANMOG Version 3.0.6 Se añade tsExcepcion ' 03/06/2027 MANMOG Version 3.0.5 Correccion en tsNotificacionesClient diff --git a/clFuncionesGenericas.vb b/clFuncionesGenericas.vb index e3256bf..a48a6c0 100644 --- a/clFuncionesGenericas.vb +++ b/clFuncionesGenericas.vb @@ -1,13 +1,12 @@ -Imports System.Data -Imports System.Data.OleDb +Imports System.Windows.Forms +Imports System.Data Imports System.Data.SqlClient +Imports MySql.Data.MySqlClient +Imports System.Data.OleDb +Imports System.IO 'Imports ComponentAce.Compression.ZipForge 'Imports ComponentAce.Compression.Archiver Imports System.Environment -Imports System.IO -Imports System.Text -Imports System.Windows.Forms -Imports MySql.Data.MySqlClient 'Imports UtilidadesTSL4net.clCharConv @@ -3757,62 +3756,74 @@ Public Class clFuncionesGenericas End Function - - - Public Shared Sub CharConverter(jcOrigen As String, jcDestino As String, Fichero_Origen As String, Optional Fichero_Destino As String = "") + Public Shared Sub CharConverter(ByVal jcOrigen As String, ByVal jcDestino As String, ByVal Fichero_Origen As String, Optional ByVal Fichero_Destino As String = "") Try - ' Seleccionamos las tablas de caracteres - Dim origen() As Char = GetCharTable(jcOrigen) - Dim destino() As Char = GetCharTable(jcDestino) - - If origen.Length <> destino.Length Then - Throw New Exception("Las tablas de conversión no tienen la misma longitud.") + Dim Temporal As String = Fichero_Origen & ".tmp" + Dim sBuffer As String + Dim i, pos, fr, fw As Integer + Dim Size As Long = FileLen(Fichero_Origen) + Dim cAux(), cOrigen(), cDestino() As Char + 'Inicializamos los juegos de caracteres origen y destino + Select Case jcOrigen.ToUpper + Case "WINDOWS" + cOrigen = WINDOWS + Case "ROMAN8" + cOrigen = ROMAN8 + Case "ROMAN8SA" + cOrigen = ROMAN8SA + Case Else + ' MsgBox("Juegos de caracteres origen erróneo o no soportado.") + ' Exit Sub + Throw New Exception("Juego de caracteres origen erróneo.") + End Select + Select Case jcDestino.ToUpper + Case "WINDOWS" + cDestino = WINDOWS + Case "ROMAN8" + cDestino = ROMAN8 + Case "ROMAN8SA" + cDestino = ROMAN8SA + Case Else + Throw New Exception("Juego de caracteres destino erróneo.") + 'MsgBox("Juegos de caracteres destino erróneo o no soportado.") + 'Exit Sub + End Select + 'Abrimos Origen y Destino + fr = FreeFile() + fw = fr + 1 + FileOpen(fr, Fichero_Origen, OpenMode.Input, OpenAccess.Read) + FileOpen(fw, Temporal, OpenMode.Output, OpenAccess.Write) + 'Guardamos el contenido del fichero en un Buffer + sBuffer = InputString(fr, Size) + 'Reemplazamos los caracteres especiales en Windows UTF8 por sus correspondientes en Roman8 + cAux = sBuffer + For i = 0 To NumChar - 1 + pos = 0 + Do + pos = InStr(pos + 1, sBuffer, cOrigen(i), CompareMethod.Binary) + If pos > 0 Then + cAux(pos - 1) = cDestino(i) + End If + Loop Until pos = 0 + Next + sBuffer = cAux + Print(fw, sBuffer) + 'Cerramos los ficheros + FileClose(fr, fw) + 'Si el destino no viene especificado es que tomaremos el origen como destino + 'y usaremos como destino para el proceso un fichero temporal + If Fichero_Destino = "" Then + File.Copy(Temporal, Fichero_Origen, True) + Else + File.Copy(Temporal, Fichero_Destino, True) End If - - ' Creamos diccionario de sustitución - Dim mapa As New Dictionary(Of Char, Char) - For i = 0 To origen.Length - 1 - mapa(origen(i)) = destino(i) - Next - - ' Leemos el fichero como texto (UTF-8 por defecto) - Dim texto As String = File.ReadAllText(Fichero_Origen, Encoding.UTF8) - - ' Convertimos carácter por carácter - Dim sb As New StringBuilder(texto.Length) - - For Each ch As Char In texto - If mapa.ContainsKey(ch) Then - sb.Append(mapa(ch)) - Else - sb.Append(ch) - End If - Next - - ' Determinar destino - Dim rutaDestino As String = If(Fichero_Destino = "", Fichero_Origen, Fichero_Destino) - - ' Guardar resultado - File.WriteAllText(rutaDestino, sb.ToString(), Encoding.UTF8) - + 'Borramos el fichero temporal + File.Delete(Temporal) Catch ex As Exception - Throw New Exception("Error en CharConverter: " & ex.Message) + 'MsgBox(ex.Message, , "Error") + Throw New Exception(ex.Message) End Try End Sub - - Private Shared Function GetCharTable(nombre As String) As Char() - Select Case nombre.ToUpper() - Case "WINDOWS" - Return WINDOWS - Case "ROMAN8" - Return ROMAN8 - Case "ROMAN8SA" - Return ROMAN8SA - Case Else - Throw New Exception("Juego de caracteres no soportado: " & nombre) - End Select - End Function - Public Shared Function LeeRegistrosSQLSQLServer(ByVal Conexion As SqlConnection, ByVal Clausula_SQL As String, Optional ByVal Sin_Errores As Boolean = True, Optional ByVal NombreDataset As String = "DATASET", Optional ByVal NombreTabla As String = "TABLA") As DataTable LeeRegistrosSQLSQLServer = Nothing Try