Imports DigitalData.Modules.Database
Imports FirebirdSql.Data.FirebirdClient

''' <summary>
''' TODO: BRAUCHEN WIR DAS ÜBERHAUPT?
''' </summary>
Public Class Request
    Public Name As String
    Public Username As String
    Public RequestId As String
    Public Connection As FbConnection
    Public Database As Firebird
    Public Debug As Boolean

    Public Sub New(Name As String, Username As String, Database As Firebird, Debug As Boolean)
        Me.Username = Username
        Me.Name = Name
        Me.RequestId = Guid.NewGuid().ToString()
        Me.Connection = Database.GetConnection()
        Me.Database = Database
        Me.Debug = Debug

        'Dim oSql = $"INSERT INTO TBEDM_REQUEST_USER (REQUEST_GUID, USER_NAME) VALUES ('{RequestId}', '{Username}')"
        'Database.ExecuteNonQueryWithConnection(oSql, Connection)
    End Sub

    Public Sub LogDebug(Message As String)
        'If Debug Then
        '    Dim oSqlCommand = $"INSERT INTO TBEDM_REQUEST_LOG (REQUEST_GUID, LOG_MSG, DEBUG) VALUES ('{RequestId}','{Message}', True)"
        '    Database.ExecuteNonQueryWithConnection(oSqlCommand, Connection)
        'End If
    End Sub

    Public Sub LogError(Message As String)
        'Dim oSqlCommand = $"INSERT INTO TBEDM_REQUEST_LOG (REQUEST_GUID, LOG_MSG, ERROR) VALUES ('{RequestId}','{Message}', True)"
        'Database.ExecuteNonQueryWithConnection(oSqlCommand, Connection)
    End Sub

    Public Overrides Function ToString() As String
        Return $"<Name={Name},RequestId={RequestId}>"
    End Function
End Class