Specific Client Login Information

There’s no client where the transaction group runs. You could use runScript to call a project script that calls system.util.getSessionInfo() to find the client details you want, and return that as a string to be logged.

I see your point on the transaction groups. I will give the scripting a shot and see if it fits my needs. Thanks

Isn’t this what the audit log is for? :confused:

I’m not exactly sure. Basically, what I’m trying to do is I have 2 clients designed as production report screens. My company runs 2 cnc routers from which I have screens that they use to show them the program schedule, their current efficiency, the programs they have already run, how many plywood sheets they’ve processed ,etc. We only have one shift working right now, but by the end of the year we want 3 shifts. This would mean 3 different people will use the same screen and router each day. I have a transaction group that logs the cycle time, feed rate override setting, program number, and time stamp each time a program is complete. Now I want to add a column to the db table that also shows who was logged in at that time. I’m learning ignition pretty fast, but I’ve only used it a couple of months. Thanks

First question, when you say user name of a client, are you talking about the user name of the person that logs into Ignition client or you’re talking about the Windows username of the person that is using that client?
If we are talking Ignition user then that’s simple, you can use the AUDIT file @JordanCClark suggested and it will show you when a ACTOR (user) login or logout and also a few other useful things.

If you are talking about a OS username then that won’t be showed in the AUDIT file, the closest thing is the device ID (computer name) but if everyone is using the same computer that won’t help you. It would be better to just use a client tag to capture the user that is on the client ([System]Client/User/OSUsername) and put it in a transaction group and capture it as it changes.

Ah! Gotcha. In that case, Phil's suggestion would work best. In fact, he wrote a little snippet a while back that may help you out:

And, you get to see him in Technicolor!

1 Like

Huh. I forgot about that snippet. (-:

That’s good, but what’s the syntax for returning only one username, the current one?

I want it to return username where project is Router1 and isDesigner is false

Try this:

','.join([x['username'] for x in system.util.getSessionInfo() if(x['project'] == 'Router1' and not x['isDesigner'])])

Hooray! nice work, seems to work perfect. Now I can change ‘Router1’ to any project if I need to see who is logged in. Thanks JordanCCLark and pturmel much appreciated

@pturmel @JordanCClark

Hi all. I’m using this method in a value change tag event script to record usernames whenever setpoints are modified since [System]Client/User/Username returns a null/empty string. However since my application will have more than one user logged in at a time I notice that ','.join([x['username'] for x in system.util.getSessionInfo() if not x['isDesigner']) would return all the usernames logged in at the time in a tuple. Is there a way to isolate the specific client username that triggered the setpoint change?

Thanks.

You'll have to turn on the audit subsystem and query its log.

1 Like

Thanks. I’ll give that a shot.

@pturmel

What would be the best way to compare the EVENT_TIMESTAMP to? The following is what I have in my tag event script, when comparing to t_stamp I get an error however if i use now I get an empty string back.

now = system.date.now()
t_stamp = system.date.format(now, 'YYYY-MM-dd HH:mm:ss')

user = system.db.runScalarPrepQuery("SELECT ACTOR FROM AUDIT_EVENTS WHERE ACTION = 'tag write' AND EVENT_TIMESTAMP = ?", [t_stamp], DB)

Thanks!

I would use a SQL Query ordered by t_stamp descending, with a LIMIT 1 clause, looking just for tag write to the tag in question. t_stamp would not be in the where clause.

1 Like

That worked perfectly. Thank you for all your help!

Hi @dkhayes117 may I know that how do this ? I need that features so much. Thanks in advance.

This script is what I use in an expression tag to determine the user at a specific computer using the hostname. I have 5 stations that use the same project at 2 different plants. The x['address'] part is the client’s hostname.

runScript("','.join([x['username'] for x in system.util.getSessionInfo(project = 'RouterStation') if(not x['isDesigner'] and 'p4Router1' in x['address'] )])",3000)
2 Likes

I always thought runScript was only used to call functions, really cool that you can do list comprehension one-liners in them, that’s very useful.