-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventLogNS.cls.xml
835 lines (768 loc) · 33.2 KB
/
EventLogNS.cls.xml
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="EnsPortal.EventLogNS">
<Description>
This is the Event Log page of the ZEN Ensemble application.
With namespace support</Description>
<IncludeCode>Ensemble</IncludeCode>
<Super>EnsPortal.EventLog</Super>
<System>4</System>
<TimeCreated>60310,50851.071342</TimeCreated>
<Parameter name="BaseSQL">
<Type>%String</Type>
<Default>SELECT Type,ID,TimeLogged,SessionId,Job,ConfigName,Text,TraceCat,SourceClass,SourceMethod,$ZNSPACE As Namespace FROM Ens_Util.Log</Default>
</Parameter>
<XData name="resultsPane">
<Description>
This pane displays event log activity table. User may click on a row and details are displayed to the side.</Description>
<XMLNamespace>http://www.intersystems.com/zen</XMLNamespace>
<Data><![CDATA[
<pane>
<vgroup valign="top">
<!--<spacer height="5"/>-->
<tablePane id="table"
cellSpacing="2"
dataSource="columns"
tableName="Ens_Util.Log"
useSnapshot="false"
showZebra="true"
valueColumn="ID"
maxRows="1000"
useKeys="true"
showQuery="false"
onselectrow="zenPage.selectItem(zenThis);"
nowrap="true"
onmouseoverClass="tpMouseOver"
enableToggleSelect="true"
onupdate="setTimeout('zenPage.onAfterSearch();',50);"
initialExecute="false"
OnCreateResultSet="CheckConditions"
unlockSession="true"
>
<!-- provide header values for all columns so they can be localized -->
<column header="Type" colName="Type" style="text-align:left;" width="65" OnDrawCell="DrawLocalType"
title="Alert, Assert, Error, Info, Trace, or Warning"/>
<column header="ID" colName="ID" style="text-align:left;" width="90"
title="Log Event ID"/>
<column header="Namespace" colName="Namespace" style="text-align:left;" width="90"
title="Namespace"/>
<column header="Time Logged" colName="TimeLogged999" id="idTimeLogged999" width="180" colExpression="{fn RIGHT(%EXTERNAL(TimeLogged),999)}"
title="Time the event was noted in the log" hidden="true" />
<column header="Time Logged" colName="TimeLogged12" id="idTimeLogged12" width="180" colExpression="{fn RIGHT(%EXTERNAL(TimeLogged),12)}"
title="Time the event was noted in the log" />
<column header="Session" colName="SessionId" width="90"
title="Identifier for the session in which the event occurred"
link=" "
OnDrawCell="DrawSessionCell" />
<column header="Job" colName="Job" width="90"
title="System job in which the event occurred"
OnDrawCell="DrawMethodCell" />
<column header="Source" colName="ConfigName" width="200"
title="Ensemble configuration name of the item that triggered the event"
OnDrawCell="DrawMethodCell" />
<column header="Text" colName="Text" width="1200"
title="Descriptive text logged with the event"
OnDrawCell="DrawTextCell" />
<column colName="TraceCat" hidden="true"/>
<column colName="SourceClass" hidden="true"/>
<column colName="SourceMethod" hidden="true"/>
<!-- we will not be switching colors by user preference; we will always use zebra plus 1-column color coding -->
<condition id="condAlert" colName="Type" predicate="EQ" value="Alert" targetCol="Type" cellStyle="background: yellow; color: darkred; font-weight: bold;" />
<condition id="condError" colName="Type" predicate="EQ" value="Error" targetCol="Type" cellStyle="background: pink; color: darkred; font-weight: bold;" />
<condition id="condWarning" colName="Type" predicate="EQ" value="Warning" targetCol="Type" cellStyle="background: orange; color: darkred; font-weight: bold;" />
<condition id="condAssert" colName="Type" predicate="EQ" value="Assert" targetCol="Type" cellStyle="background: silver; color: darkred; font-weight: bold;" />
<condition id="condTrace" colName="Type" predicate="EQ" value="Trace" targetCol="Type" cellStyle="background: lightblue; color: darkblue; font-weight: bold;" />
<!-- it does not work to have a condition Type EQ Info and also have Method EQ Start/StopProduction so no condition on Type EQ Info -->
<condition id="condStart" colName="SourceMethod" predicate="EQ" value="StartProduction" targetCol="Type" cellStyle="background: lightgreen; color: darkgreen; font-weight: bold;" />
<condition id="condStop" colName="SourceMethod" predicate="EQ" value="StopProduction" targetCol="Type" cellStyle="background: lightgreen; color: darkgreen; font-weight: bold;" />
</tablePane>
<!-- set default auto refresh to "None" -->
<timer id="timer" ontimeout="zenPage.timeout(zenThis);" timeout="0"/>
</vgroup>
</pane>
]]></Data>
</XData>
<XData name="searchPane">
<Description>
This pane displays the search criteria. We provide defaults and user can change them.
User's values are saved and used as future defaults for this user.
Clicking a drop down list item will refresh the table immediately.
Text fields you are required to click [Enter] or the "Search" button.</Description>
<XMLNamespace>http://www.intersystems.com/zen</XMLNamespace>
<Data><![CDATA[
<pane xmlns="http://www.intersystems.com/zen" >
<vgroup id="mainPanel" enclosingClass="menuPanel" valign="top">
<form name="searchForm" id="searchForm" layout="vertical" cellStyle="padding: 2px 10px; font-size:0.8em;">
<expando name="expNS" id="expNS" caption="Select Namespaces" expanded="false"
childIndent="16px" containerStyle="padding:10px 10px 0px 10px;" >
<hgroup valign="top">
<vgroup>
<multiSelectSet id="nslist"
enclosingStyle="overflow-y: scroll; height: 300px; z-index:1000; position:absolute; background: #ddd; width: 200px;"
/>
</vgroup>
</hgroup>
</expando>
<expando name="expQuick" id="expQuick" caption="Quick Search" expanded="true"
childIndent="16px" containerStyle="padding:10px 10px 0px 10px;" >
<hgroup valign="top">
<vgroup>
<select label="Auto-Refresh" name="chkRefresh" id="chkRefresh"
displayList="None,30 Seconds,60 Seconds,2 Minutes,5 Minutes" valueList="None,30000,60000,120000,300000" value="None" showEmpty="false"
onclick="zenPage.changeRefresh();"/>
<select label="Sort Order" name="SortOrder" id="SortOrder"
displayList="Newest First,Oldest First" valueList="Newest First,Oldest First" value="Newest First" showEmpty="false"
onchange="zenPage.doSearch();"/>
<select label="Time Format" name="TimeFormat" id="TimeFormat"
displayList="Complete,Time Only" valueList="999,12" value="999" showEmpty="false"
onchange="zenPage.doSearch();"/>
<spacer width="10" />
</vgroup>
<spacer width="10" />
<vgroup valign="top">
<label name="pageTotal" id="pageTotal" label="Page" value="#(%page.currentPage)#" enclosingStyle="font-size:0.8em;padding-bottom:5px;padding-top:2px;"
title="Current page of the display table, based on Page Size and the current search criteria."/>
<select label="Page Size" name="MaxRows" id="MaxRows"
displayList="10,20,30,50,100,200,500,1000,2000" valueList="10,20,30,50,100,200,500,1000,2000" value="#(%page.pageSize)#" showEmpty="false"
onchange="zenPage.doSearch();"/>
</vgroup>
</hgroup>
</expando>
<expando name="expInclude" id="expInclude" caption="Event Types" expanded="true"
childIndent="16px" containerStyle="padding:10px 10px 0px 10px;" >
<hgroup>
<vgroup cellStyle="font-size:0.8em">
<checkbox name="Error" id="Error" caption="Error" value="1" onclick="zenPage.doSearch();"/>
<checkbox name="Alert" id="Alert" caption="Alert" value="1" onclick="zenPage.doSearch();"/>
<checkbox name="Info" id="Info" caption="Info" value="1" onclick="zenPage.doSearch();"/>
</vgroup>
<spacer width="10" />
<vgroup cellStyle="font-size:0.8em">
<checkbox name="Warning" id="Warning" caption="Warning" value="1" onclick="zenPage.doSearch();"/>
<checkbox name="Trace" id="Trace" caption="Trace" value="1" onclick="zenPage.doSearch();"/>
<checkbox name="Assert" id="Assert" caption="Assert" value="1" onclick="zenPage.doSearch();" />
</vgroup>
</hgroup>
</expando>
<expando name="expDetails" id="expDetails" caption="Search Events By..." expanded="true"
childIndent="16px" containerStyle="padding:10px 10px 0px 10px;" >
<vgroup valign="top">
<hgroup valign="top">
<dateText name="StartTime" id="StartTime" label="Start Time" size="18" showTime="true" containerStyle="padding:0px 3px 0px 0px;"
title="Entering a date/time value in this field will restrict the search results to times after or equal to the given value" />
<spacer width="10" />
<text name="StartId" id="StartId" label="Start ID" size="9"
title="Entering an ID value in this field will restrict the search results to Event Log IDs greater than or equal to the given value" />
</hgroup>
<hgroup valign="top">
<dateText name="EndTime" id="EndTime" label="End Time" size="18" showTime="true" containerStyle="padding:0px 3px 0px 0px;"
title="Entering a date/time value in this field will restrict the search results to times before or equal to the given value" />
<spacer width="10" />
<text name="EndId" id="EndId" label="End ID" size="9"
title="Entering an ID value in this field will restrict the search results to Event Log IDs less than or equal to the given value" />
</hgroup>
<hgroup valign="top">
<pane paneName="configNameControl" />
<spacer width="10" />
</hgroup>
<hgroup valign="top">
<text name="SourceClass" id="SourceClass" label="Source Class" size="21"
title="Entering a class name in this field will restrict the search results to log events generated in the given class. The SQL wildcard '%' may be used." />
<spacer width="10" />
<text name="SessionId" id="SessionId" label="Session ID" size="9"
title="Entering an ID value in this field will restrict the search results to log events generated in the given session" />
</hgroup>
<hgroup valign="top">
<text name="SourceMethod" id="SourceMethod" label="Source Method" size="21"
title="Entering a method name in this field will restrict the search results to log events generated in the given method. The SQL wildcard '%' may be used." />
<spacer width="10" />
<text name="Job" id="Job" label="Job" size="9"
title="Entering a Job ID value in this field will restrict the search results to log events generated in the given job or process" />
</hgroup>
</vgroup>
<text name="Text" id="Text" label="Text" size="37" maxlength="50"
title="Entering a text string value in this field will restrict the search results to log events whose text content contains the given string" />
</expando>
<expando name="expPurge" id="expPurge" caption="Purge Event Log" expanded="false"
childIndent="16px" containerStyle="padding:10px 10px 0px 10px;" >
<hgroup valign="top">
<vgroup>
<label name="logTotal" id="logTotal" label="Current Count" value="#(%page.GetCount())#" ondblclick="zenPage.countReset();" enclosingStyle="font-size:0.8em;padding-bottom:3px;"
title="Total number of Event Log entries. To update, double-click the field." />
<label label="Do Not Purge Most Recent" labelStyle="white-space:normal;"
title="Set a value to avoid purging the most recent Event Log entries."/>
<hgroup>
<text name="keepDays" id="keepDays" size="3" maxlength="4" value="7"/>
<spacer width="4px" />
<label label="Days"/>
</hgroup>
<spacer height="5px" />
<button id="startPurgeButton" controlClass="commandButton" caption="Purge" onclick="zenPage.startPurge();"
title="Start purging Event Log entries." />
</vgroup>
</hgroup>
</expando>
</form>
</vgroup>
</pane>
]]></Data>
</XData>
<Method name="CheckConditions">
<Description><![CDATA[
Callback that is executed when creating the resultset for the main table.
Returns <query>MultiTypeNS</query> class query]]></Description>
<FormalSpec>*pSC:%Status,pInfo:%ZEN.Auxiliary.QueryInfo</FormalSpec>
<ReturnType>%ResultSet</ReturnType>
<Implementation><![CDATA[
#If ##class(%Dictionary.CompiledParameter).%ExistsId("EnsPortal.EventLogNS||CANCANCELSEARCH")
Do:..#CANCANCELSEARCH ..PrepareCancel()
#EndIf
Set pSC = $$$OK
Set tRS = ""
Set tSearchCriteria = ..GetSearchCriteria()
Set tDefaults = $P(tSearchCriteria,"^",3)
Set tConfigName = $S(""'=..matchSource:..matchSource, 1:$P(tDefaults,",",1))
Set tStartTime = $P(tDefaults,",",8)
Set tEndTime = $P(tDefaults,",",9)
Set tEventTypes = $P(tSearchCriteria,"^",4)
Set tTypeCount = 0
Set tEventNames = $LB("Assert","Error","Warning","Info","Trace","Alert")
Set tTypes = ""
For i=1:1:6 {
Set tInclude = $P(tEventTypes,",",i)
If $S(tInclude="true":1,tInclude="false":0,1:tInclude) {
Set tTypeCount = tTypeCount + 1
Set tTypes = tTypes _ $LB($LG(tEventNames,i))
}
}
#; Get inclusive StartID and EndID values
Set tStartID = $P(tSearchCriteria,",",6)
Set tEndID = $P(tSearchCriteria,",",7)
If (tStartID && tEndID) && (tEndID < tStartID) {
Set tTempID = tStartID
Set tStartID = tEndID
Set tEndID = tTempID
}
Set tMinID = $S(tStartID: tStartID-1, 1: "")
Set tMaxID = $S(tEndID: tEndID+1, 1: "")
Do ..AdjustMinMax(.tMinID,.tMaxID)
Set tConditions = ##class(%ZEN.proxyObject).%New()
Set:tMinID tConditions.MinID = tMinID
Set:tMaxID tConditions.MaxID = tMaxID
// Pick up any other restrictions
Set tConditions.ConfigName = tConfigName
Set tConditions.SourceClass = $P(tDefaults,",",2)
Set tConditions.SourceMethod = $P(tDefaults,",",3)
Set tConditions.Text = $P(tDefaults,",",4)
Set tConditions.Job = $P(tDefaults,",",5)
Set tConditions.SessionID = $P(tDefaults,",",10)
Set tConditions.NamespaceList = $P(tSearchCriteria,"^",8)
Set tConditions.StartTime = tStartTime
Set tConditions.EndTime = tEndTime
Set tDescending = $S($P(tSearchCriteria,"^",1) = "Newest First": 1, 1: 0)
Set tRS = ##class(%Library.ResultSet).%New("EnsPortal.EventLogNS:MultiType")
Set pSC = tRS.Execute($LTS(tTypes),tDescending,,tConditions)
If $$$ISERR(pSC) Quit ""
Set pInfo.queryText = "EnsPortal.EventLogNS:MultiType class query"
Set pInfo.queryExecuted = 1
Set tMaxRows = $P(tSearchCriteria,"^",5)
If (tMaxRows = "") Set tMaxRows = 500
Set pInfo.rows = tMaxRows
Quit tRS
]]></Implementation>
</Method>
<Method name="SaveDefaults">
<Description>
Save user's last search criteria into global for page default</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>SortOrder,TimeFormat,Defaults,EventType,MaxRows,States,AutoRefresh,NamespaceList=$Namespace</FormalSpec>
<ZenMethod>1</ZenMethod>
<Implementation><![CDATA[
For p = 1:1:$L(EventType,",") Set pv = $P(EventType,",",p),$P(EventType,",",p) = $S(pv="true":1,pv="false":0,1:pv)
For p = 1:1:$L(States,",") Set pv = $P(States,",",p),$P(States,",",p) = $S(pv="true":1,pv="false":0,1:pv)
Set AutoRefresh = $S(AutoRefresh="true":1,AutoRefresh="false":0,1:AutoRefresh)
Do ..SetDefaultString(SortOrder_"^"_TimeFormat_"^"_Defaults_"^"_EventType_"^"_MaxRows_"^"_States_"^"_AutoRefresh _"^"_ NamespaceList)
]]></Implementation>
</Method>
<Method name="GetSearchCriteria">
<CodeMode>expression</CodeMode>
<Private>1</Private>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[$get(^CacheTemp.EnsPortal($Username,"EventLogNS","SearchCriteria"),"Newest First^999^^1,1,1,1,1,1^500^0,0,0,0,0^1^"_$Namespace)
]]></Implementation>
</Method>
<Method name="SetDefaultString">
<ClassMethod>1</ClassMethod>
<FormalSpec>pDefaults:%String=""</FormalSpec>
<Private>1</Private>
<Implementation><![CDATA[
If pDefaults = "" {
Kill ^CacheTemp.EnsPortal($username,"EventLogNS","SearchCriteria")
}
Else {
Set ^CacheTemp.EnsPortal($username,"EventLogNS","SearchCriteria") = pDefaults
}
]]></Implementation>
</Method>
<Method name="GetAndUseDefaults">
<Description><![CDATA[
Method called from <method>%OnAfterCreatePage</method> to get defaults and build up the initial display]]></Description>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
If ..matchSource '= "" {
Do ..SetDefaultString("")
}
#; Get the last saved default values and use them as defaults.
Set SearchCriteria = ..GetSearchCriteria()
Set SortOrder = $P(SearchCriteria,"^",1)
Set TimeFormat = $P(SearchCriteria,"^",2)
Set TimeFormat = $case(TimeFormat, 999: 999, : 12)
Set Defaults = $P(SearchCriteria,"^",3)
Set EventType = $P(SearchCriteria,"^",4)
Set MaxRows = $P(SearchCriteria,"^",5)
Set expandoState = $P(SearchCriteria,"^",6)
Set AutoRefresh = $P(SearchCriteria,"^",7)
#; Load defaults for Details
Set ..%GetComponentById("SortOrder").value = SortOrder
Set ..%GetComponentById("TimeFormat").value = TimeFormat
Set ..%GetComponentById("MaxRows").value = MaxRows
Set ..%GetComponentById("ConfigName").value = $S(""'=..matchSource:..matchSource, 1:$P(Defaults,",",1))
Set ..%GetComponentById("SourceClass").value = $P(Defaults,",",2)
Set ..%GetComponentById("SourceMethod").value = $P(Defaults,",",3)
Set ..%GetComponentById("Text").value = $P(Defaults,",",4)
Set ..%GetComponentById("Job").value = $P(Defaults,",",5)
Set ..%GetComponentById("StartId").value = ..startId // the default is blank
Set ..%GetComponentById("EndId").value = ..endId // the default is blank
Set ..%GetComponentById("StartTime").value = $P(Defaults,",",8)
Set ..%GetComponentById("EndTime").value = $P(Defaults,",",9)
Set ..%GetComponentById("SessionId").value = $P(Defaults,",",10)
#; Load defaults for Event Type
Set ..%GetComponentById("Assert").value = $P(EventType,",",1)
Set ..%GetComponentById("Error").value = $P(EventType,",",2)
Set ..%GetComponentById("Warning").value = $P(EventType,",",3)
Set ..%GetComponentById("Info").value = $P(EventType,",",4)
Set ..%GetComponentById("Trace").value = $P(EventType,",",5)
Set ..%GetComponentById("Alert").value = $P(EventType,",",6)
#; Load Expando states
Set ..%GetComponentById("expQuick").expanded = $P(expandoState,",",1)
Set ..%GetComponentById("expInclude").expanded = $P(expandoState,",",2)
Set ..%GetComponentById("expDetails").expanded = $P(expandoState,",",3) || (""=$P(Defaults,",",1) && (""'=..matchSource))
Set ..%GetComponentById("expPurge").expanded = $P(expandoState,",",4)
#; Load auto-refresh setting
Set ..%GetComponentById("chkRefresh").value = AutoRefresh
#; set up the table
Set table = ..%GetComponentById("table")
#; Where clause
Set table.whereClause = ..GetWhereClause(Defaults,EventType)
#; Order by clause
Set table.orderByClause = "%ID"
If SortOrder = "Newest First" {
Set table.orderByClause = "%ID desc"
}
#; Load time preference
Set ..%GetComponentById("idTimeLogged12").hidden = (TimeFormat = 999)
Set ..%GetComponentById("idTimeLogged999").hidden = (TimeFormat = 12)
#; Max Rows (Page Size)
If (MaxRows > 10000) { Set MaxRows = 500 }
If (MaxRows < 0) { Set MaxRows = 1 }
Set table.maxRows = MaxRows
#; Namespaces
Set tNamespaceList = $LTS(..GetEnsembleNamespaces())
Set ..%GetComponentById("nslist").valueList = tNamespaceList
]]></Implementation>
</Method>
<Method name="ConstructWhereCause">
<Description>
Construct WHERE part of an SQL statement. </Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,pTypes,pConditions:%ZEN.proxyObject=""]]></FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
Set tWhereConditions = ..ConstructWhereConditions(.qHandle, pTypes, pConditions)
If (tWhereConditions '= ""){
Set tWhereCause = " WHERE " _ tWhereConditions
} Else {
Set tWhereCause = ""
}
Quit tWhereCause
]]></Implementation>
</Method>
<Method name="ConstructWhereConditions">
<Description><![CDATA[
Construct WHERE <Condition(s)> part of an SQL statement. Returns empty string if there is no conditions.]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,pTypes,pConditions:%ZEN.proxyObject=""]]></FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
Set qHandle("mainArgs") = 0
Set tConditions = ""
If $IsObject(pConditions) {
If (pConditions.MinID '= "") {
Set tConditions = tConditions _ $LB("ID > ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.MinID
}
If (pConditions.MaxID '= "") {
Set tConditions = tConditions _ $LB("ID < ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.MaxID
}
If (pConditions.Job '= "") {
Set tConditions = tConditions _ $LB("Job = ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.Job
}
If (pConditions.SessionID '= "") {
Set tConditions = tConditions _ $LB("SessionId = ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.SessionID
}
If (pConditions.SourceClass '= "") {
Set tConditions = tConditions _ $LB("SourceClass LIKE ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.SourceClass
}
If (pConditions.SourceMethod '= "") {
Set tConditions = tConditions _ $LB("SourceMethod LIKE ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs",qHandle("mainArgs")) = pConditions.SourceMethod
}
If (pConditions.Text '= "") {
Set tConditions = tConditions _ $LB("Text [ ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.Text
}
If (pConditions.StartTime '= "") {
Set tConditions = tConditions _ $LB("TimeLogged >= ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs",qHandle("mainArgs")) = pConditions.StartTime
}
If (pConditions.EndTime '= "") {
Set tConditions = tConditions _ $LB("TimeLogged <= ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.EndTime
}
If (pConditions.ConfigName '= "") {
Set tConditions = tConditions _ $LB("ConfigName LIKE ?")
Set qHandle("mainArgs") = qHandle("mainArgs") + 1
Set qHandle("mainArgs", qHandle("mainArgs")) = pConditions.ConfigName
}
}
Set tTypeCount = $L(pTypes,",")
If ((pTypes '= "") && (tTypeCount>0)) {
Set tTypesSQL=""
For i= 1:1:tTypeCount {
Set tType = $P(pTypes,",",i)
If (tType '= "") && '##class(Ens.DataType.LogType).IsValid(tType) {
Set tTypesSQL =tTypesSQL _ $LB("'" _ tType _ "'")
}
}
Set tTypesSQL = $LTS(tTypesSQL,", ")
Set tConditions = tConditions _ $LB("Type IN (" _ tTypesSQL _ ")")
}
Quit $LTS(tConditions," AND ")
]]></Implementation>
</Method>
<Method name="ConstructOrgerByCause">
<Description>
Construct ORDER BY part of an SQL statement. </Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pDescending:%Boolean=1</FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
Set tOrder = $S(pDescending: "DESC", 1: "ASC")
Quit " ORDER BY ID " _ tOrder
]]></Implementation>
</Method>
<Query name="MultiType">
<Type>%Query</Type>
<FormalSpec>pTypes:%String="",pDescending:%Boolean=0,pSelectMode:%Integer=2,pConditions:%ZEN.proxyObject=""</FormalSpec>
<Parameter name="CONTAINID" value="2"/>
<Parameter name="ROWSPEC" value="Type:Ens.DataType.LogType,ID:%String,TimeLogged:%String,SessionId:%String,Job:%String,ConfigName:%String,Text:%String,TraceCat:%String,SourceClass:%String,SourceMethod:%String,TimeLogged999:%String,TimeLogged12:%String,Namespace:%String"/>
</Query>
<Method name="MultiTypeExecute">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,pTypes:%String="",pDescending:%Boolean=1,pSelectMode:%Integer=2,pConditions:%ZEN.proxyObject=""]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Set tStatus = $$$OK
Try {
If (($IsObject(pConditions)) && (pConditions.NamespaceList '= "")) {
Set qHandle("NamespaceList") = pConditions.NamespaceList
Set qHandle("OriginalNamespace") = $Namespace
Set qHandle("NamespaceCount") = $L(qHandle("NamespaceList"),",")
Set qHandle("CurrentNamespaceNumber") = 1
Set qHandle("CurrentNamespace") = $P(qHandle("NamespaceList"),",",qHandle("CurrentNamespaceNumber"))
} Else {
Set qHandle("NamespaceList") = $Namespace
Set qHandle("OriginalNamespace") = $Namespace
Set qHandle("NamespaceCount") = 1
Set qHandle("CurrentNamespaceNumber") = 1
Set qHandle("CurrentNamespace") = $Namespace
}
Zn qHandle("CurrentNamespace")
Set tMainStatement = ##class(%SQL.Statement).%New()
Set tMainStatement.%SelectMode = pSelectMode
Set tSQL = ..#BaseSQL _ ..ConstructWhereCause(.qHandle, pTypes, pConditions) _ ..ConstructOrgerByCause(pDescending)
Set qHandle("SQL") = tSQL
Set tStatus = tMainStatement.%Prepare(tSQL)
If $$$ISERR(tStatus) Quit
Merge tMainArgs = qHandle("mainArgs")
Set tRS = tMainStatement.%Execute(tMainArgs...)
Set qHandle("mainStmt") = tMainStatement
Set qHandle("tRS") = tRS // %sqlcq class extending %SQL.ISelectResult
}
Catch {
Set tStatus = $$$EnsSystemError
}
Quit tStatus
]]></Implementation>
</Method>
<Method name="MultiTypeFetch">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary,&Row:%List,&AtEnd:%Integer=0]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Set tStatus = $$$OK
Try {
Set Row = ""
While (Row = "") {
If qHandle("tRS").%Next() { // We are iterating over resultset
Set tDataRS = qHandle("tRS")
Set Row = $LB(tDataRS.Type,tDataRS.ID,tDataRS.TimeLogged,tDataRS.SessionId,tDataRS.Job,tDataRS.ConfigName,tDataRS.Text,tDataRS.TraceCat,tDataRS.SourceClass,tDataRS.SourceMethod,tDataRS.TimeLogged,$P(tDataRS.TimeLogged," ",2),tDataRS.Namespace)
} Else { // We have reached the end of current resultset
If qHandle("CurrentNamespaceNumber") < qHandle("NamespaceCount") { // Check, if there are yet namespaces left to execute our query in
Set qHandle("CurrentNamespaceNumber") = qHandle("CurrentNamespaceNumber") + 1
Set qHandle("CurrentNamespace") = $P(qHandle("NamespaceList"),",",qHandle("CurrentNamespaceNumber"))
Zn qHandle("CurrentNamespace")
Set tStatus = qHandle("mainStmt").%Prepare(qHandle("SQL"))
If $$$ISERR(tStatus) Quit
Merge tMainArgs = qHandle("mainArgs")
Set tRS = qHandle("mainStmt").%Execute(tMainArgs...)
Set qHandle("tRS") = tRS
} Else { // We iterated over all required namespaces
Set AtEnd = 1
Quit
}
}
}
}
Catch {
Set tStatus = $$$EnsSystemError
}
Quit tStatus
]]></Implementation>
</Method>
<Method name="MultiTypeClose">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&qHandle:%Binary]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Zn qHandle("OriginalNamespace")
Kill qHandle
Quit $$$OK
]]></Implementation>
</Method>
<Method name="GetEnsembleNamespaces">
<Description>
Returns info about availible Ensemble-enabled Namespaces</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
Set tOriginalNamespace = $Namespace
Set tStatus = ##class(%CSP.Portal.Utils).%GetNamespaceList(.tNSList)
If $$$ISERR(tStatus) Quit tStatus
Set tNamespace = $O(tNSList(""))
Set tEnsNSList = ""
While tNamespace '= "" {
Set tEnabled = $LG(tNSList(tNamespace),1)
Zn tNamespace
If tEnabled && ##class(%EnsembleMgr).IsEnsembleNamespace() {
Set tEnsNSList = tEnsNSList _ $LB(tNamespace)
}
Set tNamespace = $O(tNSList(tNamespace))
}
Zn tOriginalNamespace
Quit tEnsNSList
]]></Implementation>
</Method>
<Method name="AdjustMinMax">
<Description>
Ensure that we check the table's sql to see whether there is any paging based on a condition on "ID"
This is OK (for now) because the main StartID and EndID restrictions use conditions on "%ID"</Description>
<FormalSpec><![CDATA[&pMinID:%Integer,&pMaxID:%Integer]]></FormalSpec>
<Implementation><![CDATA[
Set tTable = ..%GetComponentById("table")
If $IsObject(tTable) && (tTable.sql '= "") {
Set tModifiers = $P(tTable.sql," FROM Ens_Util.Log",2)
If (tModifiers '= "") && (tModifiers [ " WHERE ") {
Set tWhere = $P($P(tModifiers," ORDER BY ID",1),"WHERE ",2)
If (tWhere '= "") {
For i=1:1:$L(tWhere," AND ") {
#; remove trailing whitespace so the value is at end
Set tCondition = $Zstrip($P(tWhere," AND ",i),">W")
Set tProp = $P(tCondition," ",1)
If (tProp = "ID") {
Set tOp = $P($P(tCondition,tProp_" ",2)," ",1)
Set tVal = $P(tCondition," ",$L(tCondition," "))
If (tOp = "<") {
Set pMaxID = $S(tVal="": pMaxID, pMaxID="": tVal, pMaxID<tVal: pMaxID, 1: tVal)
}
ElseIf (tOp = ">") {
Set pMinID = $S(tVal="": pMinID, pMinID="": tVal, pMinID>tVal: pMinID, 1: tVal)
}
}
}
}
}
}
]]></Implementation>
</Method>
<Method name="DrawEventDetails">
<Description>
Server-side callback to provide data for the details table</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pSeed:%String</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
Set tId = $P(pSeed,",",1)
Set tEventNamespace = $P(pSeed,",",2)
Set tCurrentNamespace = $Namespace
Zn:(tEventNamespace'=tCurrentNamespace) tEventNamespace
Set tStatus = ##class(EnsPortal.Utils).DrawEventInfo(tId,1,1)
Zn:(tEventNamespace'=tCurrentNamespace) tCurrentNamespace
Quit tStatus
]]></Implementation>
</Method>
<Method name="GetDefaultApp">
<Description><![CDATA[
Returns default web application name (where ZEN classes are) of a <b>pNamespace</b>]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>pNamespace:%String</FormalSpec>
<ReturnType>%String</ReturnType>
<ZenMethod>1</ZenMethod>
<Implementation><![CDATA[ Quit $System.CSP.GetDefaultApp(pNamespace)
]]></Implementation>
</Method>
<Method name="onSearchHandler">
<Description>
User clicked the Search button, user changed a Quick Search or Event Type criterion,
or we have completed a non-zero Purge.</Description>
<Language>javascript</Language>
<ClientMethod>1</ClientMethod>
<Implementation><![CDATA[
zen("pageTotal").setValue(1);
var table = this.getResultsTable();
var where = "";
var SortOrder = zen("SortOrder").getValue();
// modify Select TimeExecuted based on Time Format
var TimeFormat = zen('TimeFormat').getValue();
zen('idTimeLogged12').setProperty('hidden',TimeFormat == '999');
zen('idTimeLogged999').setProperty('hidden',TimeFormat == '12');
// whereClause, orderByClause, and groupByClause
var ConfigName = zen("ConfigName").value;
var SourceClass = zen("SourceClass").value;
var SourceMethod = zen("SourceMethod").value;
var Text = zen("Text").value;
var Job = zen("Job").value;
var StartId = zen("StartId").value;
var EndId = zen("EndId").value;
var StartTime = zen("StartTime").value;
var EndTime = zen("EndTime").value;
var SessionId = zen("SessionId").value;
var Assert = zen("Assert").value;
var Error = zen("Error").value;
var Warning = zen("Warning").value;
var Info = zen("Info").value;
var Trace = zen("Trace").value;
var Alert = zen("Alert").value;
var Defaults = ConfigName+","+SourceClass+","+SourceMethod+","+Text+","+Job+","+StartId+","+EndId+","+StartTime+","+EndTime+","+SessionId;
var EventType = Assert+","+Error+","+Warning+","+Info+","+Trace+","+Alert;
// call server method to build the where clause
var where = zenPage.GetWhereClause(Defaults,EventType);
table.whereClause = where;
table.orderByClause = "%ID";
if (SortOrder == "Newest First") table.orderByClause = "%ID desc";
rows = zen('MaxRows');
var MaxRows = parseInt(rows.value);
if (MaxRows > 10000) MaxRows = 100;
if (MaxRows < 0) MaxRows = 1;
// Get the current expando state and save it
var States = zenPage.expandoState();
// Get the Auto-Refresh choice and save it
var auto = zen("chkRefresh");
var AutoRefresh = auto.getValue();
// Save last selections to global as default for page
zenPage.SaveDefaults(SortOrder,TimeFormat,Defaults,EventType,MaxRows,States,AutoRefresh,zen('nslist').getValue());
]]></Implementation>
</Method>
<Method name="onSelectItem">
<Description>
toggle detailTable for a selected row.</Description>
<Language>javascript</Language>
<ClientMethod>1</ClientMethod>
<Implementation><![CDATA[
if (this.selectedId > 0) {
var detail = zen("dynaGrid"); // get the detail display
if (!this._oldRows) { // if needed, establish oldRows array to remember content
this._oldRows = new Object();
}
if (this._oldRows[this.selectedId]) { // reuse the content for this row
detail.setContent(this._oldRows[this.selectedId]);
} else { // get new content from server
detail.setContent(""); // clear out any lingering content from before
var table = zen('table');
detail.seed = this.selectedId + ',' + table.getRenderedRowData(table.selectedIndex).Namespace;
detail.refreshContents(true);
this._oldRows[this.selectedId] = detail.getEnclosingDiv().innerHTML;
}
detail.setHidden(false);
}
]]></Implementation>
</Method>
<Method name="showTrace">
<Description>
User clicked a link for Trace. Display the Visual Trace page in a popup,
so user can click the arrows to go from session to session without losing his/her place in the Event Log.</Description>
<FormalSpec>session,stopEvent,evt</FormalSpec>
<Language>javascript</Language>
<ClientMethod>1</ClientMethod>
<Implementation><![CDATA[
if (stopEvent) {
if (zenIsIE) {
if (!evt) {
evt = window.event;
}
if (evt) {
evt.cancelBubble = true;
}
}
else if (evt) {
evt.stopPropagation();
}
}
if (session != '') {
if (!this.canViewTrace) {
alert(this.msgNotPermitted);
return false;
}
var table = zen('table');
var ns = table.getRenderedRowData(table.selectedIndex).Namespace;
var URI = zenPage.GetDefaultApp(ns) + '/' + this.tracePage +'?SESSIONID='+encodeURIComponent(session);
window.open(URI);
}
]]></Implementation>
</Method>
<Method name="onloadHandler">
<Description>
This client event, if present, is fired when the page is loaded.</Description>
<Language>javascript</Language>
<ClientMethod>1</ClientMethod>
<Implementation><![CDATA[
zen('StartTime').setProperty('defaultTime', '00:00:00');
zen('EndTime').setProperty('defaultTime', '23:59:59');;
this.invokeSuper('onloadHandler',[]);
]]></Implementation>
</Method>
</Class>
</Export>