PISystem.GetSessions Method (Nullable(AFTime), Nullable(AFTime), AFSessionSortField, AFSortOrder, Int32, Int32)
- Last UpdatedNov 18, 2025
- 3 minute read
- PI System
- AF SDK 2024 R2
- Developer
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. - 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: AFSessionReturns an array of AFSession objects representing the connections satisfying the filter criteria.
Exceptions
| Exception | Condition |
|---|---|
| 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.