User Logged in Details as Report

Hi,

In Administration → Users → Online Time, When we select a user and click the “Online Time” it generates a report in which we can get the total hours logged in for a particular user.

In the same way i need to generate report,in which i can get 3 input criteria (user id, from date, to date)according to that the report should generated. And the fields i should get are

  1. user id , 2. total hours logged by the user , 3. total no of times the user logged in

Please Help.

Regards,

Rajee

HI Rajarajeshwari,

Try this…you will get an idea…

Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: RG

; Microsoft Dynamics AX Report: Users unloaded
; --------------------------------------------------------------------------------
VERSION 1

REPORT #Users
PROPERTIES
Name #Users
ENDPROPERTIES

METHODS
Version: 3
SOURCE #classDeclaration
#public class ReportRun extends ObjectRun
#{

UserId userId,user;

TransDate fromDate;

TransDate toDate;

UTCDateTime fDateTime,tDateTime;

DialogField dialogUser;

DialogField dialogFromDate;

DialogField dialogTodate;

#}
ENDSOURCE
SOURCE #fetch
#public boolean fetch()
#{

Query q;

QueryBuildDataSource qbds;

QueryBuildRange qbrUser,qbrDate;

QueryRun qr;

TimeZone tz;

q = new Query(this);

qbds = q.dataSourceTable(tablenum(SysUserLog));

qbrUser = qbds.addRange(fieldnum(SysuserLog,UserId));

qbrUser.value(userId);

qbrDate = qbds.addRange(fieldnum(SysUserLog,LogoutDateTime));

fDateTime = Global::datetobeginUtcDateTime(fromDate,tz);

tDateTime = Global::datetobeginUtcDateTime(toDate,tz);

qbrDate.value(SysQuery::range(fDateTime,tDateTime));

qr = new QueryRun(q);

while( qr.next() )

{

SysUserLog_1 = qr.get(tablenum(SysUserLog));

user = SysUserLog_1.UserId;

element.execute(1);

}

return true;

#}
ENDSOURCE
SOURCE #getFromDialog
#public boolean getFromDialog()
#{

;

userId = dialogUser.value();

fromDate = dialogFromDate.value();

toDate = dialogToDate.value();

return true;

#}

ENDSOURCE
SOURCE #dialog
#public Object dialog(Object _dialog)
#{

DialogRunbase dialog = _dialog;

;

dialogUser = dialog.addFieldValue(typeid(UserId),userid,“User”);

dialogFromDate = dialog.addFieldValue(typeId(TransDate),fromDate,“From Date”);

dialogToDate = dialog.addFieldValue(typeId(TransDate),toDate,“To Date”);

return dialog;

#}
ENDSOURCE
ENDMETHODS
QUERY #Query
PROPERTIES
Name #Query
Version #1
NextUniqueId #1001
ENDPROPERTIES

METHODS
Version: 3
SOURCE #classDeclaration
#public class QueryRun extends ObjectRun
#{
#}
ENDSOURCE
ENDMETHODS
BLOCKS
BLOCK #SysUserLog
PROPERTIES
Name #SysUserLog_1
Table #SysUserLog
UniqueId #1000
ENDPROPERTIES

FIELDLIST
PROPERTIES
ENDPROPERTIES

ENDFIELDLIST
SORTING
ENDSORTING
LINES
ENDLINES
BLOCKS
ENDBLOCKS
GROUPBY
ENDGROUPBY
ORDERBY
ENDORDERBY
ENDBLOCK
ENDBLOCKS
DEPENDENTS
ENDDEPENDENTS
COMPOSITEQUERIES
ENDCOMPOSITEQUERIES
ENDQUERY

DESIGNS
DESIGN
PROPERTIES
Name #ReportDesign1
ENDPROPERTIES

AUTOBODIES
PROPERTIES
ENDPROPERTIES

CONTROLBLOCK
PROPERTIES
Name #ProgrammableSection
ENDPROPERTIES

METHODS
Version: 3
SOURCE #getUserId
#display UserId getUserId()
#{

return user;

#}
ENDSOURCE
ENDMETHODS
STRFIELD
PROPERTIES
Name #getUserId
DataMethod #getUserId
ENDPROPERTIES

ENDSTRFIELD
ENDCONTROLBLOCK
ENDAUTOBODIES
ENDDESIGN
ENDDESIGNS
ENDREPORT

***Element: END

Naresh Kolli

Thanks Naresh,

But how can i calculate the "Total Logged in time & Total no of times the user had logged in "

Any ideas, Please share

-Rajee

HI Rajarajeshwari,

There is a methods “onlineTime” and “onlineTimeHours” in the table - SysUserLog level…you can use those methods in the report to display the total logged in time…And for every Login it creates a record so by records you can know the total times logged in…

Naresh Kolli