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