cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to use timer to get active session

leokeinsfeld
13-Aquamarine

How to use timer to get active session

Hi everyone,

 

I'm beginner with Thingworx and I'm using:

 

Thingworx 8.5 with Postgre

 

I'd like to know how can I to create a timer to get active session.

 

For example:

 

I wanna motinor for how long time an user is logged.

 

Is possible create a timer to do it?

 

Regards,

 

Leonardo.

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @leokeinsfeld,

Take a look at the following article:

 

Events Provided by the SecurityMonitor Thing on ThingWorx 

 

Unfortunately, this feature is not provided OOTB. However, you can create your own Data Table to store this data:

 

  • The Data Shape fields can be determined by you (i.e. username, loggedInTime, loggedOutTime, sessionTime...)
  • Create a subscription to the Logout event found on the SecurityMonitor Thing
  • The Logout subscription will use the CurrentSessionInfo Resource to run the GetCurrentUserExtensionProperties service, and return an infotable with the current user information, including a lastConnection field in datetime format
  • Populate the Data Table with all the obtained information
    • loggedInTime -> infotable.lastConnection (from GetCurrentUserExtensionProperties)
    • loggedOutTime -> currentTime (see article below)
    • username -> infotable.name (from GetCurrentUserExtensionProperties)
    • sessionTime -> use dateDifference function found in code snippets, DateFunctions

 

How to get current date and time using JavaScript source code in ThingWorx 

 

This should allow you to keep track of all sessions in ThingWorx. You can play around with the services and events to create your own subscriptions that fit your use case and populate the Data Table.

 

Regards,

Emmanuel

 

 

View solution in original post

3 REPLIES 3

Hi @leokeinsfeld,

 

Here are some links that may be helpful in addressing your request:

 

Events Provided by the SecurityMonitor Thing on ThingWorx

Simple User Login / Logout Audit Logger for ThingWorx

 

Please let me know if you have further questions.

 

Regards,

Emmanuel

leokeinsfeld
13-Aquamarine
(To:emscur)

Hi @emscur 

 

I have seen this topics but I was not able to use it to resolve my problem.

 

I need to find one way to monitor how long time the users are logged in Thingworx Platform.

 

I would like to show this value in minutes.

Hello @leokeinsfeld,

Take a look at the following article:

 

Events Provided by the SecurityMonitor Thing on ThingWorx 

 

Unfortunately, this feature is not provided OOTB. However, you can create your own Data Table to store this data:

 

  • The Data Shape fields can be determined by you (i.e. username, loggedInTime, loggedOutTime, sessionTime...)
  • Create a subscription to the Logout event found on the SecurityMonitor Thing
  • The Logout subscription will use the CurrentSessionInfo Resource to run the GetCurrentUserExtensionProperties service, and return an infotable with the current user information, including a lastConnection field in datetime format
  • Populate the Data Table with all the obtained information
    • loggedInTime -> infotable.lastConnection (from GetCurrentUserExtensionProperties)
    • loggedOutTime -> currentTime (see article below)
    • username -> infotable.name (from GetCurrentUserExtensionProperties)
    • sessionTime -> use dateDifference function found in code snippets, DateFunctions

 

How to get current date and time using JavaScript source code in ThingWorx 

 

This should allow you to keep track of all sessions in ThingWorx. You can play around with the services and events to create your own subscriptions that fit your use case and populate the Data Table.

 

Regards,

Emmanuel

 

 

Top Tags