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
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TGSInspector_Period"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'Utility class to inspect Trial By Period License Model

Private m_lic As TGSLicense

Friend Property Let License(lic As TGSLicense)
'[INTERNAL]
  Set m_lic = lic
End Property


'============================== Public Properties =================================
Friend Property Get Period() As Long
'Trial Period in seconds
  Period = m_lic.getParamByName("periodInSeconds").Value
End Property

Friend Property Get IsClockRollbackDetectionEnabled() As Boolean
  IsClockRollbackDetectionEnabled = m_lic.getParamByName("rollbackTolerance").Value > 0
End Property

Friend Property Get RollbackTolerance() As Long
'Clock Rollback Tolerance, 0 if disabled
  RollbackTolerance = m_lic.getParamByName("rollbackTolerance").Value
End Property

Friend Property Get IsEntityEverAccessed() As Boolean
'Does the entity protected ever accessed at least once?
  IsEntityEverAccessed = m_lic.getParamByName("timeFirstAccess").HasValue
End Property

Friend Property Get TimeFirstAccess() As Date
'Local Date when the entity is accessed for the first time
  TimeFirstAccess = m_lic.getParamByName("timeFirstAccess").Value
End Property

Friend Property Get ExpireDate() As Date
'When to expire?
  If IsEntityEverAccessed Then
    ExpireDate = DateAdd("s", Period, TimeFirstAccess)
  Else
    'Never accessed before, so we do not know when to expire
    err.Raise vbObjectError + GSErr.VARIABLE_INVALID_VALUE, "Inspector_Period", "ExpireDate is not available!"
  End If
End Property

Friend Property Get TimeUsed() As Long
'How many seconds consumed since first access
  If IsEntityEverAccessed Then
    TimeUsed = DateDiff("s", TimeFirstAccess, Now)
    If TimeUsed > Period Then TimeUsed = Period
  Else
    'Never accessed before, so have full time left
    TimeUsed = 0
  End If
End Property


Friend Property Get TimeLeft() As Long
'How many seconds left before expire
  TimeLeft = Period - TimeUsed
End Property

'============================== Public Methods ====================================


Private Sub Class_Terminate()
  Set m_lic = Nothing
End Sub