Public Class ClassParamRefresh
    Public Shared Sub Refresh_Params(DT_CHECKUSER As DataTable)
        Dim oStopwatch As New RefreshHelper.SW("Refresh_Params")
        FORCE_LAYOUT_OVERVIEW = False
        SHOW_CHARTS = True
        USER_DEBUG_LOG = False


        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
            Try
                ADDITIONAL_TITLE = DT_CHECKUSER.Rows(0).Item("ADDITIONAL_TITLE")
                If ADDITIONAL_TITLE = String.Empty Then
                    ADDITIONAL_TITLE = My.Application.Info.ProductName
                End If
            Catch ex As Exception
                ADDITIONAL_TITLE = My.Application.Info.ProductName
            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 = "PM.FORCE_LAYOUT_OVERVIEW" Then
                    FORCE_LAYOUT_OVERVIEW = True
                ElseIf oMode = "PM.NO_MASS_VALIDATOR" Then
                    SHOW_MASS_VALIDATOR = False
                ElseIf oMode = "PM.NO_CHARTS" Then
                    SHOW_CHARTS = False
                ElseIf oMode = "PM.DEBUG_LOG" Then
                    USER_DEBUG_LOG = True
                    LOGCONFIG.Debug = True
                ElseIf oMode = "PM.IDBWITHWMFS" Then
                    IDB_USES_WMFILESTORE = True
                ElseIf oMode = "PM.NO_BASICCONF" Then
                    BASIC_CONF_VISIBLE = False
                ElseIf oMode.StartsWith("PM.IDB_CONID!") Then
                    Dim CON_ID = oMode.Replace("PM.IDB_CONID!", "")
                    Dim oConString = ClassDatabase.Get_ConnectionString(CON_ID)
                    CONNECTION_STRING_IDB = oConString
                    If ClassDatabase.Init(CONNECTION_STRING_IDB) = False Then
                        IDB_ACTIVE = False
                    Else
                        IDB_ACTIVE = True
                        LOGGER.Info($"Got an IDB-Connection [{CON_ID}]!")
                    End If
                ElseIf oMode.StartsWith("PM.IDB_APP_SERV_CONID!") Then
                    Dim CON_ID = oMode.Replace("PM.IDB_APP_SERV_CONID!", "")
                    Dim oConString = ClassDatabase.Get_ConnectionString(CON_ID)
                    CONNECTION_STRING_IDB_APP_SERVER = oConString
                    If ClassDatabase.Init(CONNECTION_STRING_IDB_APP_SERVER) = True Then
                        LOGGER.Info($"Got an IDB APP-Server-Connection [{CON_ID}]!")
                    End If
                ElseIf oMode = "PM.MONITORING" Then
                    MONITORING_ACTIVE = True
                ElseIf oMode = "PM.GHOSTMODE" Then
                    GHOSTMODE_ACTIVE = True
                ElseIf oMode.StartsWith("PM.COLORSCHEME") Then
                    Dim oColorScheme = oMode.Replace("PM.COLORSCHEME=", "")
                    RIBBON_COLOR_SCHEME = oColorScheme.ToUpper
                ElseIf oMode.StartsWith("PM.NO_DETAIL_PROFILES") Then
                    NO_DETAIL_PROFILES = True
                ElseIf oMode = "PM.NO_POPUP" Then
                    POPUP_REMINDER_ACTIVE = False
                ElseIf oMode.StartsWith("PM.CONV_IDENTIFICATION") Then
                    Dim oIdent = oMode.Replace("PM.CONV_IDENTIFICATION=", "")
                    CONV_IDENTIFICATION = oIdent
                ElseIf oMode.StartsWith("PM.INACTIVITY_DURATION") Then
                    Dim oInactivityDuration = oMode.Replace("PM.INACTIVITY_DURATION=", "")
                    Try
                        INACTIVITY_DURATION = CInt(oInactivityDuration)
                    Catch ex As Exception
                        INACTIVITY_DURATION = 0

                    End Try
                ElseIf oMode.StartsWith("PM.COL_LAST_EDITED") Then
                    Dim oLEDITEDCOL = oMode.Replace("PM.COL_LAST_EDITED=", "")
                    Try
                        LAST_EDITED_COLUMN = oLEDITEDCOL
                        LOGGER.Debug($"LAST_EDITED_COLUMN: {oLEDITEDCOL}")
                    Catch ex As Exception
                        LAST_EDITED_COLUMN = ""

                    End Try
                ElseIf oMode.StartsWith("PM.COL_LAST_ADDED") Then
                    Dim oLEDITEDCOL = oMode.Replace("PM.COL_LAST_ADDED=", "")
                    Try
                        LAST_ADDED_COLUMN = oLEDITEDCOL
                        LOGGER.Debug($"LAST_ADDED_COLUMN: {oLEDITEDCOL}")
                    Catch ex As Exception
                        LAST_ADDED_COLUMN = ""

                    End Try
                ElseIf oMode.StartsWith("PM.USE_APPSERVER") Then
                    Dim oUSE_APPSERVER = oMode.Replace("PM.USE_APPSERVER=", "")
                    Try
                        USE_APPSERVER = CBool(oUSE_APPSERVER)
                    Catch ex As Exception
                        USE_APPSERVER = False

                    End Try
                ElseIf oMode.StartsWith("PM.SEARCH1") Then
                    Dim oSearch1 = oMode.Replace("PM.SEARCH1=", "")
                    Try
                        SEARCH1 = oSearch1
                    Catch ex As Exception
                        SEARCH1 = ""

                    End Try
                ElseIf oMode.StartsWith("PM.SEARCH2") Then
                    Dim oSearch2 = oMode.Replace("PM.SEARCH2=", "")
                    Try
                        SEARCH2 = oSearch2
                    Catch ex As Exception
                        SEARCH2 = ""

                    End Try
                Else
                    LOGGER.Info($"Wrong oMode: {oMode}")
                End If
            Next
            If IDB_ACTIVE Then
                If CONNECTION_STRING_APP_SERVER <> String.Empty Then
                    If USE_APPSERVER = True Then
                        CONNECTION_STRING_IDB_READ = CONNECTION_STRING_APP_SERVER
                    Else
                        CONNECTION_STRING_IDB_READ = CONNECTION_STRING_IDB
                    End If

                Else
                    CONNECTION_STRING_IDB_READ = CONNECTION_STRING_IDB
                End If
                CONNECTION_STRING_IDB_WRITE = CONNECTION_STRING_IDB
            End If
        End If
        oStopwatch.Done()
    End Sub
End Class
