forked from ARSBlue/ToolBox-4-Iris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystemEventListener.cls
180 lines (159 loc) · 6 KB
/
SystemEventListener.cls
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/// This is a system event listener, it will inform you about all database, user, background process and external program call events.
/// NOTE: you do not need to explicit save the event listener, it is saved automatically on each set of a property!
///
/// ARSBlue ToolBox-4-Iris
/// Copyright © 2019 ARS Blue GmbH
/// http://www.ars-blue.at
Class arsblue.event.SystemEventListener Extends arsblue.event.EventListener
{
/// The database event flag (SYSTEM).
/// <ul>
/// <li>0...do not monitor database events (default).</li>
/// <li>1...monitor database startup events.</li>
/// <li>2...monitor database shutdown events.</li>
/// <li>3...monitor database startup and shutdown events.</li>
/// </ul>
Property TypeSystem As %Integer(MAXVAL = 3, MINVAL = 0) [ InitialExpression = 0 ];
/// The user event flag (LOGIN).
/// <ul>
/// <li>0...do not monitor user events (default).</li>
/// <li>1...monitor user login events.</li>
/// <li>2...monitor user logout events.</li>
/// <li>3...monitor user login and logout events.</li>
/// </ul>
Property TypeLogin As %Integer(MAXVAL = 3, MINVAL = 0) [ InitialExpression = 0 ];
/// The background process event flag (JOB).
/// <ul>
/// <li>0...do not monitor background process events (default).</li>
/// <li>1...monitor background process start events.</li>
/// <li>2...monitor background process end events.</li>
/// <li>3...monitor background process start and end events.</li>
/// </ul>
Property TypeJob As %Integer(MAXVAL = 3, MINVAL = 0) [ InitialExpression = 0 ];
/// The external program call event flag (CALLIN).
/// <ul>
/// <li>0...do not monitor external program call events (default).</li>
/// <li>1...monitor external program call start events.</li>
/// <li>2...monitor external program call end events.</li>
/// <li>3...monitor external program call start and end events.</li>
/// </ul>
Property TypeCallin As %Integer(MAXVAL = 3, MINVAL = 0) [ InitialExpression = 0 ];
/// The operating system command or program execution event flag (CALLIN).
/// <ul>
/// <li>0...do not monitor operating system command or program execution events (default).</li>
/// <li>1...monitor operating system command or program execution start events.</li>
/// <li>2...monitor operating system command or program execution end events.</li>
/// <li>3...monitor operating system command or program execution start and end events.</li>
/// </ul>
Property TypeCallout As %Integer(MAXVAL = 3, MINVAL = 0) [ InitialExpression = 0 ];
/// The database event index.
Index TypeSystem On TypeSystem [ Type = bitmap ];
/// The user event index.
Index TypeLogin On TypeLogin [ Type = bitmap ];
/// The background process index.
Index TypeJob On TypeJob [ Type = bitmap ];
/// The external program call index.
Index TypeCallin On TypeCallin [ Type = bitmap ];
/// The operating system command or program execution index.
Index TypeCallout On TypeCallout [ Type = bitmap ];
/// Set the event types.
/// If none of the valid type options will be set, the event listener will be marked as not running!
/// <ul>
/// <li>Types...the event typess: any combination of SYSTEM, LOGIN, JOB, CALLIN or CALLOUT in a comma separated string is allowed, invalid actions will be ignored.
/// You can also specify the monitoring option behind the action (e.g. "SYSTEM=0,LOGIN=1,JOB=2,CALLIN=3" do not monitor database and operating system command or program execution events
/// but monitors the login for user events, the start of background processes and start/stop of external program calls, defining "...,SYSTEM=3,..." or "...,SYSTEM,..." is the same).</li>
/// </ul>
/// Returns OK if successfully set the event types, any other status signals failure!
Method SetTypes(Types As %String = "") As %Status
{
set types=","_$ZCVT(Types,"U")_","
for type="SYSTEM","LOGIN","JOB","CALLIN","CALLOUT"
{
if ($F(types,","_type_"=1,"))
{
xecute ("set i%Type"_$ZCVT(type,"W")_"=1")
}
elseif ($F(types,","_type_"=2,"))
{
xecute ("set i%Type"_$ZCVT(type,"W")_"=2")
}
elseif ($F(types,","_type_",") || $F(types,","_type_"=3,"))
{
xecute ("set i%Type"_$ZCVT(type,"W")_"=3")
}
else
{
xecute ("set i%Type"_$ZCVT(type,"W")_"=0")
}
}
if ('(i%TypeSystem || i%TypeLogin || i%TypeJob || i%TypeCallin || i%TypeCallout))
{
set i%EventRun=0
}
quit ..%Save()
}
/// Get the event types.
Method GetTypes() As %String
{
set types=""
set types=types_$S(..TypeSystem:",SYSTEM="_..TypeSystem,1:"")
set types=types_$S(..TypeLogin:",LOGIN="_..TypeLogin,1:"")
set types=types_$S(..TypeJob:",JOB="_..TypeJob,1:"")
set types=types_$S(..TypeCallin:",CALLIN="_..TypeCallin,1:"")
set types=types_$S(..TypeCallout:",CALLOUT="_..TypeCallout,1:"")
quit $E(types,2,*)
}
/// Set the database event flag (SYSTEM).
Method TypeSystemSet(TypeSystem As %Integer) As %Status
{
set i%TypeSystem=TypeSystem
quit ..%Save()
}
/// Set the user event flag (LOGIN).
Method TypeLoginSet(TypeLogin As %Integer) As %Status
{
set i%TypeLogin=TypeLogin
quit ..%Save()
}
/// Set the background process event flag (JOB).
Method TypeJobSet(TypeJob As %Integer) As %Status
{
set i%TypeJob=TypeJob
quit ..%Save()
}
/// Set the external program call event flag (CALLIN).
Method TypeCallinSet(TypeCallin As %Integer) As %Status
{
set i%TypeCallin=TypeCallin
quit ..%Save()
}
/// Set the operating system command or program execution event flag (CALLIN).
Method TypeCalloutSet(TypeCallout As %Integer) As %Status
{
set i%TypeCallout=TypeCallout
quit ..%Save()
}
Storage Default
{
<Data name="SystemEventListenerDefaultData">
<Subscript>"SystemEventListener"</Subscript>
<Value name="1">
<Value>TypeSystem</Value>
</Value>
<Value name="2">
<Value>TypeLogin</Value>
</Value>
<Value name="3">
<Value>TypeJob</Value>
</Value>
<Value name="4">
<Value>TypeCallin</Value>
</Value>
<Value name="5">
<Value>TypeCallout</Value>
</Value>
</Data>
<DefaultData>SystemEventListenerDefaultData</DefaultData>
<Type>%Storage.Persistent</Type>
}
}