Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

PISystem.GetSessions Method (Nullable(AFTime), Nullable(AFTime), AFSessionSortField, AFSortOrder, Int32, Int32)

PISystem.GetSessions Method (Nullable(AFTime), Nullable(AFTime), AFSessionSortField, AFSortOrder, Int32, Int32)

  • Last UpdatedNov 18, 2025
  • 3 minute read
PISystem.GetSessions Method (Nullable(AFTime), Nullable(AFTime), AFSessionSortField, AFSortOrder, Int32, Int32)
Retrieves session data for the specified filter criteria.

Namespace:  OSIsoft.AF
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public AFSession[] GetSessions(
	AFTime? startTime,
	AFTime? endTime,
	AFSessionSortField sortField,
	AFSortOrder sortOrder,
	int startIndex,
	int maxCount
)
Public Function GetSessions ( 
	startTime As AFTime?,
	endTime As AFTime?,
	sortField As AFSessionSortField,
	sortOrder As AFSortOrder,
	startIndex As Integer,
	maxCount As Integer
) As AFSession()

Dim instance As PISystem
Dim startTime As AFTime?
Dim endTime As AFTime?
Dim sortField As AFSessionSortField
Dim sortOrder As AFSortOrder
Dim startIndex As Integer
Dim maxCount As Integer
Dim returnValue As AFSession()

returnValue = instance.GetSessions(startTime, 
	endTime, sortField, sortOrder, startIndex, 
	maxCount)
public:
array<AFSession>^ GetSessions(
	Nullable<AFTime> startTime, 
	Nullable<AFTime> endTime, 
	AFSessionSortField sortField, 
	AFSortOrder sortOrder, 
	int startIndex, 
	int maxCount
)
member GetSessions : 
        startTime : Nullable<AFTime> * 
        endTime : Nullable<AFTime> * 
        sortField : AFSessionSortField * 
        sortOrder : AFSortOrder * 
        startIndex : int * 
        maxCount : int -> AFSession[] 

Parameters

startTime
Type: SystemNullableAFTime
The query looks for connections starting at or after the specified time. Specify to search all start times.
endTime
Type: SystemNullableAFTime
The query looks for connections ending at or before the specified time. Specify to search all end times. Specify MaxValue to search only sessions which are still open.
sortField
Type: OSIsoft.AFAFSessionSortField
The query sorts connections using the specified field.
Note Note
If the target PISystem is older than 2.10.5 then connections are always sorted by StartTime.
sortOrder
Type: OSIsoft.AFAFSortOrder
The query sorts connections using the specified order. Specify Descending to begin with the most recent connections.
startIndex
Type: SystemInt32
The starting index (zero based) of the sessions to return in the search.
maxCount
Type: SystemInt32
Maximum number of sessions to return in the search.

Return Value

Type: AFSession
Returns an array of AFSession objects representing the connections satisfying the filter criteria.

Exceptions

ExceptionCondition
SecurityException A security exception is thrown if the user does not have Admin permission.

Remarks

The returned session data can be used to determine information about clients that are connected to the server. This information can be used to identify active clients. Then from the client machine you can use the GetClientRpcMetrics method to determine what calls the clients are making to the server.

Session information is not replicated in PI AF Collective environments. In these setups, make sure you connect to the member you want to retrieve session info from.

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5

See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in