⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagestats.vb

📁 Build words list automatic
💻 VB
字号:
Public Class PageStats
    Inherits DataAccessBase


    '--"Overloaded default constructor"
    '  Used by calling routine to create the object 
    '  and put it to work, all in one statement.
    '
    'Note that this is a Public Sub.  
    'The Web App Session Object is passed as a parameter
    'and if a new session is detected, the result is returned as Session("XSession") 
    'which is the new number of Sessions recorded.
    Public Sub VisitorStats(ByVal XSession As System.Web.SessionState.HttpSessionState, ByVal XPage As String _
    , ByVal UserHostName As String, ByVal UserHost As String, ByVal UserAgent As String)
        Dim nSession As Integer
        Dim UserName As String
        '
        If XSession("XSessionID") Is Nothing Then
            nSession = 0
        Else
            nSession = XSession("XSessionID")
        End If
        UserName = XSession("UserName")
        '
        Dim sSql As String
        Dim ds As New System.Data.DataSet
        'IF this a start of a Session THEN calculate next visitor number XSessionID
        If nSession = 0 Then
            sSql = "SELECT TOP 1 XSession FROM PageVisits ORDER BY XSession DESC;"
            ds = GetData("PageVisits", sSql)
            If ds.Tables("PageVisits").Rows.Count = 0 Then
                nSession = 1
            Else
                nSession = ds.Tables("PageVisits").Rows(0).Item(0) + 1
            End If
            XSession("XSessionID") = nSession
        End If
        'Note handling of an autonumber by not including it in the list of fields.
        'Also note sparing use of auto-values eg date could be auto
        'but I choose not to do that so I can more easily change databases later.
        '
        '030723 JPC
        UserName = Left(SqlEncode(UserName), 30)
        UserHostName = Left(SqlEncode(UserHostName), 80)
        UserHost = Left(UserHost, 20)
        UserAgent = Left(SqlEncode(UserAgent), 100)

        sSql = "INSERT INTO PageVisits " _
        & "(XDateTime, XSession, XPage, UserName, UserHostName, UserHost, UserAgent)" _
        & "VALUES('" & Format(Now, "yyyy-MM-dd HH:mm:ss") & "'," & nSession & ",'" & XPage & "'" _
        & ",'" & UserName & "','" & UserHostName & "','" & UserHost & "','" & UserAgent & "');"
        Call ExecuteNonQuery(sSql)

    End Sub 'New

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -