Imports DLLLicenseManager
Public Class ClassLicence
    Public Shared License_Date As Date
    Private Shared _lizenzManager As ClassLicenseManager
    Public Shared Sub Refresh_Licence()
        Try
            _lizenzManager = New ClassLicenseManager("#DigitalData35452!#", "")
            Dim sql As String = "SELECT LICENSEKEY FROM TBGI_CONFIGURATION WHERE GUID = 1"

            Dim lic As String = ClassDatabase.Execute_Scalar(sql, MyConnectionString)
            Dim licString = _lizenzManager.DecodeLicenseKey(lic)
            Dim split() = licString.ToString.Split("#")

            If lic <> "" Then
                LICENSE_COUNT = split(0)
            Else
                LICENSE_COUNT = 0
            End If
            License_Date = CDate(split(1))
            If CDate(split(1)) < CDate(Now.ToShortDateString) Then
                If USER_LANGUAGE = "de-DE" Then
                    MsgBox("Ihre Lizenz ist abgelaufen!" & vbNewLine & "Letztes Gültigkeitsdatum: " & split(1) & vbNewLine & "Bitte setzen Sie sich mit Digital Data in Verbindung", MsgBoxStyle.Exclamation)
                Else
                    MsgBox("Your license has expired!" & vbNewLine & "Last Valid Date: " & split(1) & vbNewLine & "Please contact Digital Data", MsgBoxStyle.Exclamation)
                End If
                START_INCOMPLETE = True
                LICENSE_EXPIRED = True
                LICENSE_COUNT = 0
            End If

            'tslblLicenses.Text = "Anzahl Lizenzen: " & licenseanzahl
            LICENSE_DOCTYPE_COUNT = split(2)
            Try
                LicenseHotKey = split(3)
            Catch ex As Exception
                LicenseHotKey = 0
            End Try
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Unexpected error in Licensemanager:")
            START_INCOMPLETE = True
        End Try
    End Sub

    Public Shared Function license_is_Valid()
        If LICENSE_EXPIRED Then
            If USER_LANGUAGE = "de-DE" Then
                MsgBox("Ihre Lizenz ist abgelaufen!" & vbNewLine & "Letztes Gültigkeitsdatum: " & License_Date & vbNewLine & "Bitte setzen Sie sich mit Digital Data in Verbindung", MsgBoxStyle.Exclamation)
            Else
                MsgBox("Your license has expired!" & vbNewLine & "Last Valid Date: " & License_Date & vbNewLine & "Please contact Digital Data", MsgBoxStyle.Exclamation)
            End If

            Return False
        Else : Return True

        End If
    End Function

End Class
