Getting Event Type Within Handler

Getting Event Type Within Handler

Anonymous
Not applicable
341 Views
2 Replies
Message 1 of 3

Getting Event Type Within Handler

Anonymous
Not applicable

Hi,

 

I was wondering if there was any way to get information about the event from within the handler assigned to it.

 

I have the same handler running on different triggers, each requiring a slightly different execution depending on the event type.

 

I know I can wrap this in a dedicated handler and parameterize a call to the rule from within this, but is there otherwise no way to get information about the event itself?

 

Thanks

0 Likes
Accepted solutions (1)
342 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

I strongly recommend you to use separate rule for each event handler. In the background you can call one external rule with specific arguments.

 

But to your question. It is possible but it can be little bit obscure and behavior can change in future without any information because it is not part of public iLogic API.

This code snippet show how to access underlying .NET call stack and print the called methods to the iLogic log. You need to analyze this callstack and determine which event runs this rule

 

 

Imports System.Diagnostics

'Get Call stack
Dim stackTrace As New StackTrace() 	

' Get method calls (frames)
Dim stackFrames As StackFrame() = stackTrace.GetFrames() 	

For Each stackFrame As StackFrame In stackFrames
	'Write method name
	Logger.Debug(StackFrame.GetMethod().Name)				
Next

 

 

My results for 

Part Geometry Changed eventBefore Save Document event
INFO| 19: >>---------------------------
DEBUG|Main
DEBUG|ExecRuleInAssembly
DEBUG|ExecRuleEval
DEBUG|EvalRule
DEBUG|EvalRule
DEBUG|RuleRun
DEBUG|VisitRule
DEBUG|RunListOfRules
DEBUG|RunInternalRules
DEBUG|OnSurfaceBodyChanged
DEBUG|InvokeMethod
DEBUG|UnsafeInvokeInternal
DEBUG|Invoke
INFO| 20: >>---------------------------
DEBUG|Main
DEBUG|ExecRuleInAssembly
DEBUG|ExecRuleEval
DEBUG|EvalRule
DEBUG|EvalRule
DEBUG|RuleRun
DEBUG|VisitRule
DEBUG|RunListOfRules
DEBUG|RunInternalRules
DEBUG|mobjApplicationEvents_OnSaveDocument
DEBUG|InvokeMethod
DEBUG|UnsafeInvokeInternal
DEBUG|Invoke

 

Message 3 of 3

Anonymous
Not applicable

But the problem is, if I try to programmatically remove a rule, I have to remove either the generic handler or create unique handlers to remove, for each rule in which I need to know the event type.

0 Likes