Remove class helper and replace with Language Module

This commit is contained in:
Jonathan Jenne 2021-09-23 12:10:02 +02:00
parent d31ba427e2
commit 27294faa13
3 changed files with 5 additions and 71 deletions

View File

@ -1,65 +0,0 @@
Imports System.Text
Imports System.Text.RegularExpressions
Public Class ClassHelper
Public Shared Function encode_utf8(ByVal str As String) As String
Try
'supply True as the construction parameter to indicate
'that you wanted the class to emit BOM (Byte Order Mark)
'NOTE: this BOM value is the indicator of a UTF-8 string
Dim utf8Encoding As New System.Text.UTF8Encoding(True)
Dim encodedString() As Byte
encodedString = utf8Encoding.GetBytes(str)
LOGGER.Info(String.Format(" >> String {0} was encoded via utf8 to {1}", str, utf8Encoding.GetString(encodedString)))
Return utf8Encoding.GetString(encodedString)
Catch ex As Exception
LOGGER.Info("Unexpected error in encode_utf8: " & ex.Message)
LOGGER.Error(ex)
Return Nothing
End Try
End Function
Public Shared Function StringAsUtf8Bytes(ByVal strData As String) As Byte()
Try
Dim bytes() As Byte
' get unicode string as bytes
bytes = Encoding.UTF8.GetBytes(strData)
' return byte data
Return bytes
Catch ex As Exception
LOGGER.Info("Unexpected error in StringAsUtf8Bytes: " & ex.Message)
LOGGER.Error(ex)
Return Nothing
End Try
End Function
Public Shared Function CheckSpecialSigns(ByVal str As String)
Try
Dim pattern As String = "[!""#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\s]"
Dim matches As MatchCollection = Regex.Matches(str, pattern)
Return matches.Count
Catch ex As Exception
LOGGER.Info("Unexpected error in CheckSpecialSigns: " & ex.Message)
LOGGER.Error(ex)
Return 0
End Try
End Function
Public Shared Sub Refresh_RegexTable()
CURRENT_DT_REGEX = DATABASE_ECM.GetDatatable("SELECT * FROM TBGI_FUNCTION_REGEX")
End Sub
''' <summary>
''' Überprüft einen Wert auf verschiedene Arten von "Null" und gibt einen Standard-Wert zurück, wenn der Wert "Null" ist.
''' </summary>
''' <param name="value">Der zu überprüfende Wert</param>
''' <param name="defaultValue">Der Standard Wert</param>
''' <returns>value oder wenn dieser "Null" ist, defaultValue</returns>
Public Shared Function NotNull(Of T)(ByVal value As T, ByVal defaultValue As T) As T
If IsNothing(value) OrElse String.IsNullOrEmpty(value.ToString) OrElse IsDBNull(value) Then
Return defaultValue
Else
Return value
End If
End Function
End Class

View File

@ -264,7 +264,6 @@
<Compile Include="ClassEncryption.vb" />
<Compile Include="ClassFilehandle.vb" />
<Compile Include="ClassFolderWatcher.vb" />
<Compile Include="ClassHelper.vb" />
<Compile Include="ClassIDBData.vb" />
<Compile Include="ClassIndexFunctions.vb" />
<Compile Include="ClassInit.vb" />

View File

@ -2113,17 +2113,17 @@ Public Class frmIndex
' 1. Schritt: Einfach-Indexe und Platzhalter ersetzen
For Each oAutoIndexRow As DataRow In oDatatable
_Logger.Info("Working on AutomaticIndex: " & oAutoIndexRow.Item("INDEXNAME") & "...")
Dim oSqlResult As String = ClassHelper.NotNull(oAutoIndexRow.Item("SQL_RESULT"), "")
Dim oSqlActive As Boolean = ClassHelper.NotNull(oAutoIndexRow.Item("SQL_ACTIVE"), False)
Dim oSqlConnectionId As Integer = ClassHelper.NotNull(oAutoIndexRow.Item("CONNECTION_ID"), -1)
Dim oSqlProvider As String = ClassHelper.NotNull(oAutoIndexRow.Item("SQL_PROVIDER"), "")
Dim oSqlResult As String = Utils.NotNull(oAutoIndexRow.Item("SQL_RESULT"), "")
Dim oSqlActive As Boolean = Utils.NotNull(oAutoIndexRow.Item("SQL_ACTIVE"), False)
Dim oSqlConnectionId As Integer = Utils.NotNull(oAutoIndexRow.Item("CONNECTION_ID"), -1)
Dim oSqlProvider As String = Utils.NotNull(oAutoIndexRow.Item("SQL_PROVIDER"), "")
Dim oEndResult As New List(Of String)
' Wenn kein SQL Befehl vorhanden oder aktiv ist,
' versuchen wir, die Spalte VALUE zu ersetzen
If oSqlResult = String.Empty Or oSqlActive = 0 Then
Dim oPlaceholderResult As String
Dim oValue As String = ClassHelper.NotNull(oAutoIndexRow.Item("VALUE"), "")
Dim oValue As String = Utils.NotNull(oAutoIndexRow.Item("VALUE"), "")
oPlaceholderResult = GetPlaceholderValue(oValue, CURRENT_WORKFILE, USER_SHORTNAME)