|
1 | | -/// Event Log is a log for every action performed by Pivot Subscriptions, covering five event types: creation, update, deletion, sent email subscriptions by Task, and immediately sent emails. |
2 | | -Class PivotSubscriptions.EventLog Extends %Persistent |
3 | | -{ |
4 | | - |
5 | | -/// Event Type covers: creation, update, deletion and sent email subscriptions |
6 | | -/* |
7 | | - * Only possible values are creation, update, deletion, send, and tableError |
8 | | - */ |
9 | | -Property EventType As %String (VALUELIST=",creation,update,deletion,send,tableError"); |
10 | | - |
11 | | -Property TimeStamp As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ]; |
12 | | - |
13 | | -Property UserName As %String(MAXLEN = 128) [ InitialExpression = {$username} ]; |
14 | | - |
15 | | -Property Pivot As %String(MAXLEN = 512); |
16 | | - |
17 | | -Property DayOfWeek As %String; |
18 | | - |
19 | | -Property Hour As %Integer(MINVAL=0, MAXVAL=23); |
20 | | - |
21 | | -Property Minute As %Integer (MINVAL=0, MAXVAL=59); |
22 | | - |
23 | | -Property Format As %String(VALUELIST = ",Excel,PDF"); |
24 | | - |
25 | | -Property Emails As %String; |
26 | | - |
27 | | -Property Name As %String; |
28 | | - |
29 | | -/// Takes in info about an Alert Task and logs the information to the TaskLog |
30 | | -ClassMethod LogEvent(pEvent, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName) As %Status |
31 | | -{ |
32 | | - Set tSC=$$$OK |
33 | | - |
34 | | - Set tEventLog=##class(PivotSubscriptions.EventLog).%New() |
35 | | - Set tEventLog.EventType=pEvent |
36 | | - Set tEventLog.TimeStamp=$zdt($h, 3, 1) |
37 | | - Set tEventLog.UserName=pUser |
38 | | - Set tEventLog.Pivot=pPivot |
39 | | - Set tEventLog.Name=pName |
40 | | - |
41 | | - Set tEventLog.DayOfWeek=pDayOfWeek |
42 | | - Set tEventLog.Hour=pHour |
43 | | - Set tEventLog.Minute=pMinute |
44 | | - |
45 | | - Set tEventLog.Format=pFormat |
46 | | - Set tEventLog.Emails=pEmails |
47 | | - |
48 | | - Set tSC=tEventLog.%Save() |
49 | | - |
50 | | - Quit tSC |
51 | | -} |
52 | | - |
53 | | -Storage Default |
54 | | -{ |
55 | | -<Data name="EventLogDefaultData"> |
56 | | -<Value name="1"> |
57 | | -<Value>%%CLASSNAME</Value> |
58 | | -</Value> |
59 | | -<Value name="2"> |
60 | | -<Value>EventType</Value> |
61 | | -</Value> |
62 | | -<Value name="3"> |
63 | | -<Value>TimeStamp</Value> |
64 | | -</Value> |
65 | | -<Value name="4"> |
66 | | -<Value>UserName</Value> |
67 | | -</Value> |
68 | | -<Value name="5"> |
69 | | -<Value>Pivot</Value> |
70 | | -</Value> |
71 | | -<Value name="6"> |
72 | | -<Value>SubscriptionId</Value> |
73 | | -</Value> |
74 | | -<Value name="7"> |
75 | | -<Value>DayOfWeek</Value> |
76 | | -</Value> |
77 | | -<Value name="8"> |
78 | | -<Value>Hour</Value> |
79 | | -</Value> |
80 | | -<Value name="9"> |
81 | | -<Value>Minute</Value> |
82 | | -</Value> |
83 | | -<Value name="10"> |
84 | | -<Value>Format</Value> |
85 | | -</Value> |
86 | | -<Value name="11"> |
87 | | -<Value>Emails</Value> |
88 | | -</Value> |
89 | | -<Value name="12"> |
90 | | -<Value>Name</Value> |
91 | | -</Value> |
92 | | -</Data> |
93 | | -<DataLocation>^PivotSubscriptions.EventLogD</DataLocation> |
94 | | -<DefaultData>EventLogDefaultData</DefaultData> |
95 | | -<IdLocation>^PivotSubscriptions.EventLogD</IdLocation> |
96 | | -<IndexLocation>^PivotSubscriptions.EventLogI</IndexLocation> |
97 | | -<StreamLocation>^PivotSubscriptions.EventLogS</StreamLocation> |
98 | | -<Type>%Storage.Persistent</Type> |
99 | | -} |
100 | | - |
101 | | -} |
| 1 | +/// Event Log is a log for every action performed by Pivot Subscriptions, covering five event types: creation, update, deletion, sent email subscriptions by Task, and immediately sent emails. |
| 2 | +Class PivotSubscriptions.EventLog Extends %Persistent |
| 3 | +{ |
| 4 | + |
| 5 | +/* |
| 6 | + * Only possible values are creation, update, deletion, send, and tableError |
| 7 | + */ |
| 8 | +/// Event Type covers: creation, update, deletion and sent email subscriptions |
| 9 | +Property EventType As %String(VALUELIST = ",create,update,delete,sendSubscription,sendError,tableError"); |
| 10 | + |
| 11 | +Property StartTime As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ]; |
| 12 | + |
| 13 | +Property EndTime As %TimeStamp; |
| 14 | + |
| 15 | +Property UserName As %String(MAXLEN = 128) [ InitialExpression = {$username} ]; |
| 16 | + |
| 17 | +Property Pivot As %String(MAXLEN = 512); |
| 18 | + |
| 19 | +Property DayOfWeek As %String; |
| 20 | + |
| 21 | +Property Hour As %Integer(MAXVAL = 23, MINVAL = 0); |
| 22 | + |
| 23 | +Property Minute As %Integer(MAXVAL = 59, MINVAL = 0); |
| 24 | + |
| 25 | +Property Format As %String(VALUELIST = ",Excel,PDF"); |
| 26 | + |
| 27 | +Property Emails As %String(MAXLEN = ""); |
| 28 | + |
| 29 | +Property Name As %String(MAXLEN = 100); |
| 30 | + |
| 31 | +Property Status As %Status; |
| 32 | + |
| 33 | +/// Takes in info about an Alert Task and logs the information to the TaskLog |
| 34 | +ClassMethod LogEvent(pType, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, ByRef pEvent) As %Status |
| 35 | +{ |
| 36 | + Set tSC=$$$OK |
| 37 | + |
| 38 | + Set tEventLog=##class(PivotSubscriptions.EventLog).%New() |
| 39 | + Set tEventLog.EventType=pType |
| 40 | + Set tEventLog.UserName=pUser |
| 41 | + Set tEventLog.Pivot=pPivot |
| 42 | + Set tEventLog.Name=pName |
| 43 | + |
| 44 | + Set tEventLog.DayOfWeek=pDayOfWeek |
| 45 | + Set tEventLog.Hour=pHour |
| 46 | + Set tEventLog.Minute=pMinute |
| 47 | + |
| 48 | + Set tEventLog.Format=pFormat |
| 49 | + Set tEventLog.Emails=pEmails |
| 50 | + |
| 51 | + If pType="tableError" { |
| 52 | + Set tEventLog.Status=$$$OK |
| 53 | + Set tEventLog.EndTime=$zdt($h,3,1) |
| 54 | + } |
| 55 | + |
| 56 | + Set tSC=tEventLog.%Save() |
| 57 | + Set pEvent=tEventLog |
| 58 | + |
| 59 | + Quit tSC |
| 60 | +} |
| 61 | + |
| 62 | +Method LogUpdate(pStatus) As %Status |
| 63 | +{ |
| 64 | + Set tSC=$$$OK |
| 65 | + |
| 66 | + Set ..EndTime=$zdt($h,3,1) |
| 67 | + Set ..Status=pStatus |
| 68 | + Set tSC=..%Save() |
| 69 | + |
| 70 | + Quit tSC |
| 71 | +} |
| 72 | + |
| 73 | +ClassMethod DayOfWeekDisplay(pDayOfWeek) As %String [ SqlProc ] |
| 74 | +{ |
| 75 | + Set pDayOfWeek=$Replace(pDayOfWeek,0,"Sunday") |
| 76 | + Set pDayOfWeek=$Replace(pDayOfWeek,1,"Monday") |
| 77 | + Set pDayOfWeek=$Replace(pDayOfWeek,2,"Tuesday") |
| 78 | + Set pDayOfWeek=$Replace(pDayOfWeek,3,"Wednesday") |
| 79 | + Set pDayOfWeek=$Replace(pDayOfWeek,4,"Thursday") |
| 80 | + Set pDayOfWeek=$Replace(pDayOfWeek,5,"Friday") |
| 81 | + Set pDayOfWeek=$Replace(pDayOfWeek,6,"Saturday") |
| 82 | + Quit pDayOfWeek |
| 83 | +} |
| 84 | + |
| 85 | +Query GetEvents() As %SQLQuery |
| 86 | +{ |
| 87 | + SELECT StartTime,EndTime,EventType,Name,Pivot,UserName,PivotSubscriptions.EventLog_DayOfWeekDisplay(DayOfWeek) As DayOfWeek,Format,"Hour","Minute",Emails,Status |
| 88 | + FROM PivotSubscriptions.EventLog |
| 89 | + ORDER BY ID DESC |
| 90 | +} |
| 91 | + |
| 92 | +Storage Default |
| 93 | +{ |
| 94 | +<Data name="EventLogDefaultData"> |
| 95 | +<Value name="1"> |
| 96 | +<Value>%%CLASSNAME</Value> |
| 97 | +</Value> |
| 98 | +<Value name="2"> |
| 99 | +<Value>EventType</Value> |
| 100 | +</Value> |
| 101 | +<Value name="3"> |
| 102 | +<Value>StartTime</Value> |
| 103 | +</Value> |
| 104 | +<Value name="4"> |
| 105 | +<Value>UserName</Value> |
| 106 | +</Value> |
| 107 | +<Value name="5"> |
| 108 | +<Value>Pivot</Value> |
| 109 | +</Value> |
| 110 | +<Value name="6"> |
| 111 | +<Value>SubscriptionId</Value> |
| 112 | +</Value> |
| 113 | +<Value name="7"> |
| 114 | +<Value>DayOfWeek</Value> |
| 115 | +</Value> |
| 116 | +<Value name="8"> |
| 117 | +<Value>Hour</Value> |
| 118 | +</Value> |
| 119 | +<Value name="9"> |
| 120 | +<Value>Minute</Value> |
| 121 | +</Value> |
| 122 | +<Value name="10"> |
| 123 | +<Value>Format</Value> |
| 124 | +</Value> |
| 125 | +<Value name="11"> |
| 126 | +<Value>Emails</Value> |
| 127 | +</Value> |
| 128 | +<Value name="12"> |
| 129 | +<Value>Name</Value> |
| 130 | +</Value> |
| 131 | +<Value name="13"> |
| 132 | +<Value>EndTime</Value> |
| 133 | +</Value> |
| 134 | +<Value name="14"> |
| 135 | +<Value>Status</Value> |
| 136 | +</Value> |
| 137 | +</Data> |
| 138 | +<DataLocation>^PivotSubscriptions.EventLogD</DataLocation> |
| 139 | +<DefaultData>EventLogDefaultData</DefaultData> |
| 140 | +<IdLocation>^PivotSubscriptions.EventLogD</IdLocation> |
| 141 | +<IndexLocation>^PivotSubscriptions.EventLogI</IndexLocation> |
| 142 | +<StreamLocation>^PivotSubscriptions.EventLogS</StreamLocation> |
| 143 | +<Type>%Storage.Persistent</Type> |
| 144 | +} |
| 145 | + |
| 146 | +} |
0 commit comments