Imports System.IO
Imports System.Threading
Imports System.Globalization
Imports DigitalData.Modules.Database
Imports DevExpress.LookAndFeel

Public Class frmConfig_Basic
    Dim formloaded = False
    Public Sub SetLanguage()
        Dim sz = Me.Size
        Dim pt = Me.Location
        Dim de = System.Globalization.CultureInfo.CurrentUICulture
        ''Neue Sprache festlegen und entfernen aller Controls
        'Thread.CurrentThread.CurrentUICulture = New CultureInfo(USER_LANGUAGE)
        'Me.Controls.Clear()
        'Me.Events.Dispose()
        InitializeComponent()

        'Wiederherstellen der Fensterposition
        Me.Size = sz
        Me.Location = pt
    End Sub

    Private Sub BtnConnect_Click(sender As Object, e As EventArgs) Handles BtnConnect.Click
        If Me.txtServer.Text = String.Empty Then
            MsgBox("Please specify SQL-Server Adress!", MsgBoxStyle.Information)
            txtServer.Focus()
            Exit Sub
        End If
        Try
            Dim constring As String
            If chkbxUserAut.Checked Then
                constring = "Data Source=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";Trusted_Connection=True;"
            Else
                constring = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";"
            End If


            Dim connection As New SqlClient.SqlConnection(constring) 'csb.ConnectionString)
            'während Verbindungsaufbau Sanduhr-Mauszeiger
            Cursor = Cursors.WaitCursor
            connection.Open()
            Cursor = Cursors.Default
            'DialogResult = Windows.Forms.DialogResult.OK
            Dim result As MsgBoxResult
            If USER_LANGUAGE = "de-DE" Then
                result = MessageBox.Show("Die Verbindung wurde erfolgreich aufgebaut!" & vbNewLine & "Möchten Sie diese Verbindung nun in der Anwendung speichern?", "Erfolgsmeldung:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            Else
                result = MessageBox.Show("Connection was created successfully!" & vbNewLine & "Do You want to save this connection now in the application?", "Success:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
            End If

            If result = MsgBoxResult.Yes Then
                'Set the construction string
                MyConnectionString = constring 'csb.ConnectionString

                If chkbxUserAut.Checked = False Then
                    'Das Passwort verschlüsseln
                    Dim wrapper As New ClassEncryption("!35452didalog=")
                    Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text)
                    Dim pw As String = cipherText
                    constring = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
                End If
                'SaveConfigValue("MyConnectionString", constring)
                CONFIG.Config.ConnectionString = constring
                CONFIG.Save()

                Me.txtActualConnection.Text = constring

                If DATABASE_ECM Is Nothing Then
                    DATABASE_ECM = New MSSQLServer(LOGCONFIG, MyConnectionString)
                End If

                Dim sql = "SELECT MAX(GUID) FROM TBDD_USER WHERE (LOWER(USERNAME) = LOWER('@user'))"
                sql = sql.Replace("@user", Environment.UserName)
                LOGGER.Info(">> Username: " & Environment.UserName)

                USER_ID = DATABASE_ECM.GetScalarValue(sql)
                If IsDBNull(USER_ID) Then
                    MsgBox("Attention: Your Username '" & Environment.UserName & "' is not configured for fileFLOW. this might result in unhandled exceptions!", MsgBoxStyle.Exclamation)
                    LOGGER.Info("User '" & Environment.UserName & "' not configured for fileFLOW! (DBNull - frmConfigBasic)")
                End If


                'Me.TBPM_KONFIGURATIONTableAdapter.Connection.ConnectionString = My.Settings.ConfigConnectionString
                'Me.TBPM_KONFIGURATIONTableAdapter.Fill(Me.DD_DMSLiteDataSet.TBPM_KONFIGURATION)
            End If
        Catch ex As Exception
            Cursor = Cursors.Default
            MsgBox("Error in Connection Build: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation)
        End Try
    End Sub

    Private Sub cmbDatenbank_MouseClick(sender As Object, e As MouseEventArgs) Handles cmbDatenbank.MouseClick
        Try
            If Me.txtServer.Text = String.Empty Then
                MsgBox("Please specify SQL-Server Adress!", MsgBoxStyle.Information)
                txtServer.Focus()
                Exit Sub
            End If
            Me.Cursor = Cursors.WaitCursor
            Dim csb As New SqlClient.SqlConnectionStringBuilder With {
                .DataSource = Me.txtServer.Text,
                .IntegratedSecurity = False,
                .UserID = Me.txtUser.Text,
                .Password = Me.txtPasswort.Text
            }

            Dim con As String
            If chkbxUserAut.Checked Then
                con = "Data Source=" & Me.txtServer.Text & ";Trusted_Connection=True;"
            Else
                con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";"
            End If
            Dim connection As New SqlClient.SqlConnection(con) 'csb.ConnectionString)
            connection.Open()
            Dim cmd As New SqlClient.SqlCommand("sp_databases", connection) With {
                .CommandType = CommandType.StoredProcedure
            }
            ' Ausführen und Ergebnis in einer ListBox anzeigen
            Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader
            If dr.HasRows Then
                Do While dr.Read
                    cmbDatenbank.Items.Add(dr("Database_Name"))
                Loop
                cmbDatenbank.DroppedDown = True
            End If
            connection.Close()
        Catch ex As Exception
            MsgBox("Error in Show Databases: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation)
        End Try
        Cursor = Cursors.Default
    End Sub

    Private Sub frmConfig_Basic_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        CheckBoxIndexResult.Checked = CONFIG.Config.ShowIndexResult
        CheckBoxPreviewDocs.Checked = CONFIG.Config.FilePreview
    End Sub

    Dim reload As Boolean = False
    Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
        Select Case TabControl1.SelectedIndex
            Case 1
                If ERROR_STATE = "NO DB-CONNECTION" Then
                    MsgBox("Configurations only editable after Application started completely!", MsgBoxStyle.Exclamation)
                    Me.TabControl1.SelectedIndex = 0
                    Exit Sub
                End If
                If USER_LANGUAGE = "de-DE" Then
                    cmbLanguage.SelectedIndex = 0
                Else
                    cmbLanguage.SelectedIndex = 1
                End If
                cmbDesign.Text = CONFIG.Config.MyFormsDesign

                'chkdelete_origin.Checked = CURR_DELETE_ORIGIN
            Case 2
                If ERROR_STATE = "NO DB-CONNECTION" Then
                    MsgBox("Configurations only editable after Application started completely!", MsgBoxStyle.Exclamation)
                    Me.TabControl1.SelectedIndex = 0
                    Exit Sub
                End If
                reload = True
                Dim folderwatch = DATABASE_ECM.GetScalarValue("SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & USER_ID)
                If folderwatch IsNot Nothing Then
                    CURRENT_FOLDERWATCH = folderwatch
                End If
                Me.txtFolderWatch.Text = CURRENT_FOLDERWATCH
                Dim SCAN_folderwatch = DATABASE_ECM.GetScalarValue("SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'SCAN' AND USER_ID = " & USER_ID)
                If SCAN_folderwatch IsNot Nothing Then
                    CURRENT_SCAN_FOLDERWATCH = SCAN_folderwatch
                End If
                Me.txtFolderWatch.Text = CURRENT_FOLDERWATCH
                Me.txtScanFolderWatch.Text = CURRENT_SCAN_FOLDERWATCH

                If FOLDER_WATCHER.FolderWatcher IsNot Nothing Then
                    If FOLDER_WATCHER.FolderWatcher.EnableRaisingEvents = True Then
                        If USER_LANGUAGE = "de-DE" Then
                            btnstartstop1.Text = "Überwachung stoppen"
                        Else
                            btnstartstop1.Text = "Stop hotfolder"
                        End If

                        btnstartstop1.Image = My.Resources.bell_delete
                    Else
                        If USER_LANGUAGE = "de-DE" Then
                            btnstartstop1.Text = "Überwachung starten"
                        Else
                            btnstartstop1.Text = "Start hotfolder"
                        End If

                        btnstartstop1.Image = My.Resources.bell_go
                    End If
                Else
                    If USER_LANGUAGE = "de-DE" Then
                        btnstartstop1.Text = "Überwachung starten"
                    Else
                        btnstartstop1.Text = "Start hotfolder"
                    End If


                    btnstartstop1.Image = My.Resources.bell_go
                End If

                If FOLDER_WATCHER.FolderWatcher_SCAN IsNot Nothing Then
                    If FOLDER_WATCHER.FolderWatcher_SCAN.EnableRaisingEvents = True Then
                        If USER_LANGUAGE = "de-DE" Then
                            btnstartstop2.Text = "Überwachung stoppen"
                        Else
                            btnstartstop2.Text = "Stop hotfolder"
                        End If

                        btnstartstop2.Image = My.Resources.bell_delete
                    Else
                        If USER_LANGUAGE = "de-DE" Then
                            btnstartstop2.Text = "Überwachung starten"
                        Else
                            btnstartstop2.Text = "Stop hotfolder"
                        End If

                        btnstartstop2.Image = My.Resources.bell_go
                    End If
                Else
                    If USER_LANGUAGE = "de-DE" Then
                        btnstartstop2.Text = "Überwachung starten"
                    Else
                        btnstartstop2.Text = "Stop hotfolder"
                    End If

                    btnstartstop2.Image = My.Resources.bell_go
                End If
                reload = False
                Me.DataGridView1.DataSource = DTEXCLUDE_FILES
        End Select
    End Sub

    Private Sub btnFW_Desktop_Click(sender As Object, e As EventArgs) Handles btnFW_Desktop.Click
        CURRENT_FOLDERWATCH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "fileFLOW")
        CheckFolder(CURRENT_FOLDERWATCH, "DEFAULT")
    End Sub
    Sub CheckFolder(mypath As String, FOLDER_TYPE As String)
        Try
            If mypath = "" Then
                DATABASE_ECM.ExecuteNonQuery("DELETE FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & USER_ID & " AND FOLDER_TYPE = '" & FOLDER_TYPE & "'")
                If FOLDER_TYPE = "SCAN" Then
                    CURRENT_SCAN_FOLDERWATCH = ""
                    CONFIG.Config.FolderWatchScanStarted = False
                    CONFIG.Save()
                Else
                    FW_started = False
                    'SaveConfigValue("FW_started", "False")
                    CONFIG.Config.FolderWatchStarted = False
                    CONFIG.Save()
                    CURRENT_FOLDERWATCH = ""
                End If

                Exit Sub
            End If
            Try
                If (Not System.IO.Directory.Exists(mypath)) Then
                    System.IO.Directory.CreateDirectory(mypath)
                End If
            Catch ex As Exception
                LOGGER.Info(" >> Unexpected error in CheckFolder: " & mypath)
                LOGGER.Error(ex)
                LOGGER.Info(" >> " & ex.Message)
                If USER_LANGUAGE = "de-DE" Then
                    MsgBox("Unexpected error in ECheckFolder: " & mypath & vbNewLine & "Bitte überprüfen Sie die Rechte!" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
                Else
                    MsgBox("Error in creating Hotfolder: " & mypath & vbNewLine & "Please check the rights!" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
                End If

                Exit Sub
            End Try

            Dim folderwatch = DATABASE_ECM.GetScalarValue("SELECT GUID FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & USER_ID & " AND FOLDER_TYPE = '" & FOLDER_TYPE & "'")
            Dim sql As String
            If folderwatch Is Nothing Then
                sql = "INSERT INTO TBGI_FOLDERWATCH_USER (USER_ID, FOLDER_PATH, FOLDER_TYPE, ADDED_WHO) VALUES (" & USER_ID & ",'" & mypath & "','" & FOLDER_TYPE & "','" & Environment.UserName & "')"
            Else
                sql = "UPDATE TBGI_FOLDERWATCH_USER SET FOLDER_PATH = '" & mypath & "', CHANGED_WHO = '" & Environment.UserName & "' where GUID = " & folderwatch
            End If
            If DATABASE_ECM.ExecuteNonQuery(sql) Then
                folderwatch = DATABASE_ECM.GetScalarValue("SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & USER_ID & " AND FOLDER_TYPE = '" & FOLDER_TYPE & "'")

                If FOLDER_TYPE = "SCAN" Then
                    CURRENT_SCAN_FOLDERWATCH = folderwatch
                    Me.txtScanFolderWatch.Text = CURRENT_SCAN_FOLDERWATCH
                Else
                    CURRENT_FOLDERWATCH = folderwatch
                    Me.txtFolderWatch.Text = CURRENT_FOLDERWATCH
                End If
            End If
            If FW_started = True And FOLDER_TYPE = "DEFAULT" Then
                FOLDER_WATCHER.Restart_FolderWatch()
            End If
            If CONFIG.Config.FolderWatchScanStarted = True And FOLDER_TYPE = "SCAN" Then
                FOLDER_WATCHER.Restart_FolderWatchSCAN()
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in CheckFolder:")
        End Try

    End Sub

    Private Sub btnFW_OwnFiles_Click(sender As Object, e As EventArgs) Handles btnFW_OwnFiles.Click
        CURRENT_FOLDERWATCH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "fileFLOW")
        CheckFolder(CURRENT_FOLDERWATCH, "DEFAULT")
    End Sub

    Private Sub btnstartstop1_Click(sender As Object, e As EventArgs) Handles btnstartstop1.Click
        If CURRENT_FOLDERWATCH <> "" Then
            CheckFW_State()
        End If

    End Sub
    Sub CheckFW_State()
        Select Case FOLDER_WATCHER.StartStop_FolderWatch()
            Case 1
                If USER_LANGUAGE = "de-DE" Then
                    btnstartstop1.Text = "Überwachung stoppen"
                Else
                    btnstartstop1.Text = "Stop Hotfolder"
                End If

                btnstartstop1.Image = My.Resources.bell_delete
            Case 0
                If USER_LANGUAGE = "de-DE" Then
                    btnstartstop1.Text = "Überwachung starten"
                Else
                    btnstartstop1.Text = "Stop Hotfolder"
                End If

                btnstartstop1.Image = My.Resources.bell_go
        End Select
    End Sub
    Sub CheckFWSCAN_State()
        Select Case FOLDER_WATCHER.StartStop_FolderWatchSCAN()
            Case 1
                If USER_LANGUAGE = "de-DE" Then
                    btnstartstop2.Text = "Überwachung stoppen"
                Else
                    btnstartstop2.Text = "Stop Hotfolder"
                End If
                btnstartstop2.Image = My.Resources.bell_delete
            Case 0
                If USER_LANGUAGE = "de-DE" Then
                    btnstartstop2.Text = "Überwachung starten"
                Else
                    btnstartstop2.Text = "Start Hotfolder"
                End If
                btnstartstop2.Image = My.Resources.bell_go
        End Select
    End Sub

    Private Sub btnsetFW_Folder_Click(sender As Object, e As EventArgs) Handles btnsetFW_Folder.Click
        Dim fbdialog As New FolderBrowserDialog
        If txtFolderWatch.Text <> "" Then
            fbdialog.SelectedPath = txtFolderWatch.Text
        End If
        If fbdialog.ShowDialog() = DialogResult.OK Then
            CheckFolder(fbdialog.SelectedPath, "DEFAULT")
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles chkLogErrorsOnly.CheckedChanged
        If formloaded = True Then
            Dim oDebug = chkLogErrorsOnly.Checked

            CONFIG.Config.LogDEBUG = oDebug
            CONFIG.Save()

            LOGGER.Info("Debug Log Enabled: [{0}]", oDebug)
            LOGGER.Debug("Debug Log Enabled: [{0}]", oDebug)

            LogErrorsOnly = oDebug
            LOGCONFIG.Debug = oDebug
        End If
    End Sub
    <STAThread()>
    Private Sub frmConfig_Basic_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Load_Basics()
        formloaded = True

    End Sub
    Sub Load_Basics()
        Try
            chkLogErrorsOnly.Checked = CONFIG.Config.LogDEBUG

            If Not MyConnectionString = String.Empty Then
                Dim csb As New SqlClient.SqlConnectionStringBuilder With {
                    .ConnectionString = MyConnectionString
                }
                Dim constr = MyConnectionString
                Try
                    If Not constr.Contains("Trusted_Connection") Then
                        Try
                            constr = constr.Replace(csb.Password, "XXXXX")
                        Catch ex As Exception
                            chkbxUserAut.Checked = False
                        End Try
                    Else
                        chkbxUserAut.Checked = True
                    End If
                Catch ex As Exception
                End Try


                Me.txtActualConnection.Text = constr
            End If

            If ERROR_STATE = "FAILED DBCONNECTION" Then
                Me.TabControl1.SelectedIndex = 0
            ElseIf ERROR_STATE = "NO DB-CONNECTION" Then
                Me.TabControl1.SelectedIndex = 0
            End If
        Catch ex As Exception
            MsgBox("Unexpected Error in Load_Basics:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try

    End Sub
    Private Sub btnopenlog_Click(sender As Object, e As EventArgs) Handles btnopenlog.Click
        Process.Start(LOGCONFIG.LogDirectory)
    End Sub
    Private Sub btnApplicationFolder_Click(sender As Object, e As EventArgs) Handles btnApplicationFolder.Click
        Process.Start(Application.UserAppDataPath())
    End Sub

    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxIndexResult.CheckedChanged
        CONFIG.Config.ShowIndexResult = CheckBoxIndexResult.Checked
        CONFIG.Save()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim fbdialog As New FolderBrowserDialog
        If txtScanFolderWatch.Text <> "" Then
            fbdialog.SelectedPath = txtScanFolderWatch.Text
        End If
        If fbdialog.ShowDialog() = DialogResult.OK Then
            CheckFolder(fbdialog.SelectedPath, "SCAN")
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles btnstartstop2.Click
        If CURRENT_SCAN_FOLDERWATCH <> "" Then
            CheckFWSCAN_State()
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxPreviewDocs.CheckedChanged
        CONFIG.Config.FilePreview = CheckBoxPreviewDocs.Checked
        CONFIG.Save()
    End Sub

    Private Sub txtScanFolderWatch_TextChanged(sender As Object, e As EventArgs) Handles txtScanFolderWatch.TextChanged
        If reload = True Then Exit Sub
        CheckFolder(txtScanFolderWatch.Text, "SCAN")
    End Sub

    Private Sub txtFolderWatch_TextChanged(sender As Object, e As EventArgs) Handles txtFolderWatch.TextChanged
        If reload = True Then Exit Sub
        CheckFolder(txtFolderWatch.Text, "DEFAULT")
    End Sub

    Private Sub btnSaveExclusionFiles_Click(sender As Object, e As EventArgs) Handles btnSaveExclusionFiles.Click
        DTEXCLUDE_FILES.AcceptChanges()
        DTEXCLUDE_FILES.WriteXml(PATH_FileExclusions)
        MsgBox("Changes saved.", MsgBoxStyle.Information)
    End Sub

    Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Button3.Click
        Dim result As MsgBoxResult
        If USER_LANGUAGE = "de-DE" Then
            result = MessageBox.Show("Wollen Sie die Applikationssprache nun auf '" & cmbLanguage.Text & "' ändern?", "Bestätigung erforderlich:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        Else
            result = MessageBox.Show("Would You like to change Your application language to '" & cmbLanguage.Text & "' ?", "Confirmation required:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        End If

        If result = MsgBoxResult.Yes Then
            formloaded = False
            Try
                Dim lang As String
                Select Case cmbLanguage.SelectedIndex
                    Case 0
                        lang = "de-DE"
                    Case 1
                        lang = "en-US"
                    Case 2
                        lang = "fr-FR"
                End Select

                Dim update As String = "UPDATE TBDD_USER SET [LANGUAGE] = '" & lang & "' WHERE GUID = " & USER_ID
                USER_LANGUAGE = lang

                If DATABASE_ECM.ExecuteNonQuery(update) = True Then
                    If USER_LANGUAGE = "de-DE" Then
                        MsgBox("Die Sprache wurde erfolgreich geändert!", MsgBoxStyle.Information)
                    Else
                        MsgBox("The language was changed successfully!", MsgBoxStyle.Information)

                    End If
                    LANGUAGE_CHANGED = True
                End If
            Catch ex As Exception

            End Try
            formloaded = True
            Load_Basics()

        End If
    End Sub
    Private Sub chkbxUserAut_CheckedChanged(sender As Object, e As EventArgs) Handles chkbxUserAut.CheckedChanged
        If chkbxUserAut.Checked Then
            Me.txtPasswort.Enabled = False
            Me.txtUser.Enabled = False
        Else
            Me.txtPasswort.Enabled = True
            Me.txtUser.Enabled = True
        End If
    End Sub

    Private Sub LinkLabel_SupportPortal_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel_SupportPortal.LinkClicked
        Try
            Me.LinkLabel_SupportPortal.LinkVisited = True

            Dim oSql As String = "SELECT CAT_STRING FROM TBDD_CATALOG WHERE CAT_TITLE = 'DDSUPPORT_PORTAL'"
            Dim oSupportLink As String = DATABASE_ECM.GetScalarValue(oSql)?.ToString()

            If Not String.IsNullOrEmpty(oSupportLink) Then
                Process.Start(oSupportLink)
            Else
                MsgBox("Support-Link nicht gefunden.", MsgBoxStyle.Information)
            End If

        Catch ex As Exception
            MsgBox("Fehler beim Öffnen des Support-Links: " & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub Label10_Click(sender As Object, e As EventArgs) Handles Label10.Click

    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        If cmbDesign.SelectedIndex <> -1 Then
            UserLookAndFeel.Default.SetSkinStyle(cmbDesign.Text)
            CONFIG.Config.MyFormsDesign = cmbDesign.Text
            CONFIG.Save()

        End If
    End Sub
End Class