Wednesday, August 1, 2012

Who is On-Line? Active Users.

Dear Operation Managers and IT Administrators!

Knowing your hard work, I dedicated this post for you.

So how can we know, how many users are still on-line, sitting late in the office or working from home, preventing us from doing maintenance? Currently there is no way to see it at one glance. Which pushed me to create an inquiry.

First challenge we have here, a table where all this info stored is secured, meaning we cannot easily retrieve these data into a Generic Inquiry. So we have to create a database view first. Please refer to my earlier post on Adding View to Report on how exactly a view can be published into Acumatica data access class. I will just put below the text of the select statement:
CREATE view ActiveUsers as
select FirstName,LastName,CompanyID,
CAST(DAY(LastLoginDate) as varchar(2))+'/'+CAST(MONTH(LastLoginDate) as varchar(2))+'/'+CAST(YEAR(LastLoginDate) as varchar(4)) as LoginDate ,
CAST(CAST(LastLoginDate AS time(0)) as varchar(8)) as LoginTime 
from users where IsOnLine = 1 

Graph object should have the following code:

<Graph ClassName="ActiveUsers" Source="#CDATA" IsNew="True" FileType="NewDac"><CDATA name="Source"><![CDATA[using System;
using PX.Data;
namespace PX.Objects.SM
public class ActiveUsers: Cst_ActiveUsers, IBqlTable
{    #region FirstName
    [PXDBString(255, IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "First Name")]
    public string FirstName { get; set; }
    public class firstName : IBqlField{}
    #region LastName
    [PXDBString(255, IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "Last Name")]
    public string LastName { get; set; }
    public class lastName : IBqlField{}
    #region LoginDate
    [PXDBString(10, InputMask = "")]
    [PXUIField(DisplayName = "Login Date")]
    public string LoginDate { get; set; }
    public class loginDate : IBqlField{}
    #region LoginTime
    [PXDBString(8, InputMask = "")]
    [PXUIField(DisplayName = "Login Time")]
    public string LoginTime { get; set; }
    public class loginTime : IBqlField{}

With this view we can retrieve User's First and Last names, Date and Time of when they logged into the system. Once view is published, it is time to create a Generic Inquiry, using this DAC.

Let's call Inquiry - Active Users.
Under parameters I just specified - Filter, and data area - Users.
Its all non-mandatory. You can give any name based on your Inquiry specific.

Table name we can choose from a lookup screen, which should show us now under SM namespace object ActiveUsers. Alias is optional.

This GI will be dead simple. No relations, no sorting or parameters. Lets move straight to the last tab, Results Grid and select columns we need.

Nice feature we have here, Width. Please specify the width of the column, based on estimated Name length.
Save. And press button Add to Site Map. It will navigate us to the Site Map tree, where I added my GI to System Manager, Audit section.

Now lets try it out.

Looks good, seems I am the only one at this time...

Please note, Acumatica keeps track of time and date in GMT time zone, so if you need to calculate your local time, add/subtract accordingly.


No comments:

Post a Comment