Author Topic: Audit help  (Read 1093 times)

Phrog30

  • Guest
Audit help
« on: July 21, 2017, 09:15:58 PM »
I'm creating an audit system which logs several things to a DB.  I would like to grab the component name as well as form name the component is on.  Example, when a basicbutton is pressed I will log the user, datetime, and the button name and the form the button is on.  I have figured out everything but the form name.  The issue is the audit event is in the controls solution (basicbutton code) so when I try to find the form with the component is comes back as nothing.  Is it possible to cross solutions and find a form searching a control?  It's easy to go from AdvancedHMI solution to AdvancedHMIControls solution, but not the other way around.  Any guidance is much appreciated.

James

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Audit help
« Reply #1 on: July 21, 2017, 09:58:55 PM »
Would something like this do it:

Code: [Select]
       Dim pf As Control
        '* Keep going up the tree until we find the top level parent
        pf = Parent
        While (pf IsNot Nothing) AndAlso (Not (TypeOf (pf) Is Form))
            If pf.Parent IsNot Nothing Then
                pf = pf.Parent
            Else
                Exit While
            End If
        End While

        MsgBox(DirectCast(pf, Form).Name)

Phrog30

  • Guest
Re: Audit help
« Reply #2 on: July 21, 2017, 10:23:25 PM »
Yes sir, that works like a champ.  Thanks...

Phrog30

  • Guest
Re: Audit help
« Reply #3 on: July 22, 2017, 01:44:33 PM »
I dare the end user to say, "No, we didn't hit that button!!".... :)


Phrog30

  • Guest
Re: Audit help
« Reply #4 on: July 22, 2017, 09:53:09 PM »
Is there anyway that when an event occurs in the controls solution that I could somehow trigger an event in the advancedhmi solution?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Audit help
« Reply #5 on: July 23, 2017, 09:32:51 AM »
Is there anyway that when an event occurs in the controls solution that I could somehow trigger an event in the advancedhmi solution?
Do you mean an existing event, such as the Click event of a BasicButton, or an event that doesn't exist, such as a value changing of a custom property.

Phrog30

  • Guest
Re: Audit help
« Reply #6 on: July 23, 2017, 02:03:12 PM »
Either, but as an example if on a click event how could I "send" this across to the HMI solution and then pick this up. Its easy from HMI to controls, but not the other way.