Logout Event

0
I am looking to record the amount of time a user spends on the system each day (call center application). The system logs the last login datetime if I could use the/a logout event I could calculate the time between the to. Any ideas on how to build something like this? Thanks
asked
1 answers
0
  1. Record login time (using a MF as homepage, or just use the User.LastLogin)
  2. Loop the active sessions (2.5.3) regularly (using scheduled event) and set an last online attribuut on the active users.

For example:

    try {
        for(ISession session : Core.getActiveSessions()) {
            IMendixObject user = session.getUser().getMendixObject();
            if (user.getType().equals(YOURTYPE.getType())) {
                    user.setValue(getContext(), Member.MemberNames.LastOnline.toString(), new Date());
                    Core.commit(getContext(), user);
            }
        }
    } catch (Exception e) {
        Core.getLogger("Error").info("Error occured while trying to write LastOnline attribute: "+e.getMessage());
    }
    return true;

(note, the user.getType().equals might need to be an inheritance check depending on your situation)

Note that this approach might be up to 5 minutes + scheduled event interval minutes off. So if you need to know it exactly, you need another approach.

answered