-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM_clsLogSession.def
95 lines (78 loc) · 2.83 KB
/
M_clsLogSession.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'---------------------------------------------------------------------------------------
' Module : clsLogSession
' Author : K.Gundermann
' Date : 19.01.2012
' Purpose : Information about the current session which may be used by LogSavers
'---------------------------------------------------------------------------------------
Option Compare Database
Option Explicit
Private c_SessionID As Long
Private c_HostName As String
Private c_OSVersion As String
Private c_OSUserName As String
Private c_AccessUserName As String
Private c_ApplicationUserName As String
Private c_SessionStartTime As Date
Private c_LoginTime As Date
Public Event Login()
Public Event Logout()
Public Property Get SessionID() As Long
SessionID = c_SessionID
End Property
Public Property Get HostName() As String
HostName = c_HostName
End Property
Public Property Get OSVersion() As String
OSVersion = c_OSVersion
End Property
Public Property Get OSUserName() As String
OSUserName = c_OSUserName
End Property
Public Property Get AccessUserName() As String
AccessUserName = c_AccessUserName
End Property
Public Property Get ApplicationUserName() As String
ApplicationUserName = c_ApplicationUserName
End Property
Public Property Get SessionStartTime() As Date
SessionStartTime = c_SessionStartTime
End Property
Public Property Get LoginTime() As Date
LoginTime = c_LoginTime
End Property
' -----------------------------------------------------------------
Public Sub Login(ByVal Username As String)
c_LoginTime = Now
c_ApplicationUserName = Username
RaiseEvent Login
End Sub
Public Sub Logout()
c_LoginTime = 0
c_ApplicationUserName = vbNullString
RaiseEvent Logout
End Sub
' -----------------------------------------------------------------
Public Function ToString() As String
ToString = "" _
& "Computername: " & Me.HostName & vbCrLf _
& "OSVersion: " & Me.OSVersion & vbCrLf _
& "OSUserName: " & Me.OSUserName & vbCrLf _
& "AccessUserName: " & Me.AccessUserName & vbCrLf _
& "ApplicationUserName: " & Me.ApplicationUserName & vbCrLf _
& "SessionStartTime: " & Me.SessionStartTime & vbCrLf _
& "LoginTime: " & Me.LoginTime & vbCrLf _
& vbCrLf
End Function
Private Sub Class_Initialize()
c_SessionID = timeGetTime
c_SessionStartTime = Now
c_HostName = OS.System.GetComputerNameEx(ComputerNameDnsFullyQualified)
c_OSVersion = "Windows" ' OS.Version.WinVersionText
c_OSUserName = "Unknown" ' OS.System.UserName
c_AccessUserName = Application.CurrentUser
c_ApplicationUserName = "" ' Username within your Application
End Sub