Imports System
Imports System.ComponentModel

Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering

Imports DevExpress.ExpressApp
Imports DevExpress.Persistent.Base
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Persistent.Validation

<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
Public Class QueryStatistics
    Inherits BaseObject

    Private _ObjectName As String
    Private _ObjectKey As Guid
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _TimeStart As Date
    Private _TimeStop As Date
    Private _TimeEllapsed As System.TimeSpan
    Private _RecordNumber As Long = 0
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
        End If
    End Sub

    <Size(255)> _
    Property ObjectName As String
        Get
            Return _ObjectName
        End Get
        Set(value As String)
            SetPropertyValue("ObjectName", _ObjectName, value)
        End Set
    End Property
    Property ObjectKey As Guid
        Get
            Return _ObjectKey
        End Get
        Set(value As Guid)
            SetPropertyValue("ObjectKey", _ObjectKey, value)
        End Set
    End Property
    <NonCloneable> _
    Property UserCreated As User
        Get
            Return _UserCreated
        End Get
        Set(value As User)
            SetPropertyValue("UserCreated", _UserCreated, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(value As Date)
            SetPropertyValue("ObjectCreated", _ObjectCreated, value)
        End Set
    End Property
    Property TimeStart As Date
        Get
            Return _TimeStart
        End Get
        Set(value As Date)
            SetPropertyValue("TimeStart", _TimeStart, value)
        End Set
    End Property
    Property TimeStop As Date
        Get
            Return _TimeStop
        End Get
        Set(value As Date)
            SetPropertyValue("TimeStop", _TimeStop, value)
        End Set
    End Property
    Property TimeEllapsed As System.TimeSpan
        Get
            Return _TimeEllapsed
        End Get
        Set(value As System.TimeSpan)
            SetPropertyValue("TimeEllapsed", _TimeEllapsed, value)
        End Set
    End Property
    Property RecordNumber As Long
        Get
            Return _RecordNumber
        End Get
        Set(value As Long)
            SetPropertyValue("RecordNumber", _RecordNumber, value)
        End Set
    End Property
End Class
