Imports DigitalData.Modules.Database

Public Class ClassParamRefresh
    Public Shared Sub Refresh_Params(DT_CHECKUSER As DataTable)
        If DT_CHECKUSER.Rows.Count = 1 Then
            USERCOUNT_LOGGED_IN = DT_CHECKUSER.Rows(0).Item("USERCOUNT_LOGGED_IN")
            Try
                WORKING_MODE = DT_CHECKUSER.Rows(0).Item("WORKING_MODE")
            Catch ex As Exception
                WORKING_MODE = ""
            End Try

            Dim oSplitWorkMode As String() = WORKING_MODE.Split("#")

            ' Use For Each loop over words and display them.
            Dim oMode As String
            For Each oMode In oSplitWorkMode
                LOGGER.Debug($"oWorkingMode Parameter: {oMode}")
                If oMode.StartsWith("IDB_CONID!") Then
                    Dim oConnectionId = oMode.Replace("GLOBIX.IDB_CONID!", "")
                    Dim oConString = DATABASE_ECM.Get_ConnectionStringforID(oConnectionId)

                    CONNECTION_STRING_IDB = oConString
                    DATABASE_IDB = New MSSQLServer(LOGCONFIG, CONNECTION_STRING_IDB)

                    Dim oSQL = $"SELECT * FROM TBIDB_ATTRIBUTE"
                    Dim oDT As DataTable = DATABASE_IDB.GetDatatable(oSQL)

                    If Not IsNothing(oDT) Then
                        If oDT.Rows.Count > 0 Then
                            IDB_ACTIVE = True
                        Else
                            LOGGER.Warn($"Got an IDB-ConnID [{oConnectionId}] but check DTAttribute.Row.Count is [{oDT.Rows.Count}]!!")
                        End If
                    Else
                        LOGGER.Warn($"Got an IDB-ConnID [{oConnectionId}] but check DT Attribute is Nothing!!")
                    End If
                ElseIf oMode.StartsWith("IDB.LOG_INDEX") Then
                    IDB_LOG_INDEX = oMode.Replace("IDB.LOG_INDEX!", "")
                Else
                    LOGGER.Info($"Wrong oMode: {oMode}")
                End If
            Next

        End If
    End Sub
End Class
