From 976da9a153569db8915daf0104c708dedf1b80a3 Mon Sep 17 00:00:00 2001 From: pitzm Date: Thu, 9 Jan 2025 10:13:48 +0100 Subject: [PATCH] =?UTF-8?q?Modules.Config:=20Abfrage=20von=20Lizenzen=20ze?= =?UTF-8?q?ntral=20=C3=BCber=20eine=20Funktion,=20die=20auch=20die=20Versi?= =?UTF-8?q?on=20ber=C3=BCcksichtigt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Config.vbproj | 4 ++++ Config/ConfigDbFunct.vb | 52 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Config/ConfigDbFunct.vb diff --git a/Config/Config.vbproj b/Config/Config.vbproj index b23ef41e..eb3d6e82 100644 --- a/Config/Config.vbproj +++ b/Config/Config.vbproj @@ -47,6 +47,9 @@ ..\Base\bin\Debug\DigitalData.Modules.Base.dll + + ..\Database\bin\Debug\DigitalData.Modules.Database.dll + ..\packages\NLog.5.0.5\lib\net46\NLog.dll @@ -78,6 +81,7 @@ + diff --git a/Config/ConfigDbFunct.vb b/Config/ConfigDbFunct.vb new file mode 100644 index 00000000..b0216ead --- /dev/null +++ b/Config/ConfigDbFunct.vb @@ -0,0 +1,52 @@ +Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.Database + + +Public Class ConfigDbFunct + + ''' + ''' Ermittelt die aktuelle Lizenz für das gewünschte Produkt + ''' aus der DB-Tabelle TBDD_3RD_PARTY_MODULES + ''' + ''' + ''' An instance of LogConfig + ''' Initial connectionstring for connecting to DD_ECM database. + ''' LicenseKey, if found, otherwise String.Empty + Public Shared Function GetProductLicense(pProductName As String, pVersion As String, pLogConfig As LogConfig, pConnectionString As String) As String + + Dim oLogger As Logger = pLogConfig.GetLogger() + + If (String.IsNullOrEmpty(pProductName)) Then + oLogger.Error("Parameter pProductName is null or empty") + Return String.Empty + End If + + If (String.IsNullOrEmpty(pVersion)) Then + oLogger.Error("Parameter pVersion is null or empty") + Return String.Empty + End If + + If (String.IsNullOrEmpty(pConnectionString)) Then + oLogger.Error("Parameter pConnectionString is null or empty") + Return String.Empty + End If + + Try + Dim oDecryptedConnectionString As String = MSSQLServer.DecryptConnectionString(pConnectionString) + Dim oDatabase As MSSQLServer = New MSSQLServer(pLogConfig, oDecryptedConnectionString) + + Dim oSql As String = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = '" + pProductName + "' AND ACTIVE = 1 AND VERSION = '" + pVersion + "'" + Dim oLicenseString As String = oDatabase.GetScalarValue(oSql) + + Return oLicenseString + + Catch ex As Exception + oLogger.Error("Exception occured in ConfigDbFunct.GetProductLicense()") + oLogger.Error(ex) + End Try + + Return String.Empty + + End Function + +End Class