PISystem.GetSessions Method (Nullable(AFTime), Nullable(AFTime), 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 = null, AFTime? endTime = null, AFSortOrder sortOrder = AFSortOrder.Descending, int startIndex = 0, int maxCount = 10000 )
Public Function GetSessions ( Optional startTime As AFTime? = Nothing, Optional endTime As AFTime? = Nothing, Optional sortOrder As AFSortOrder = AFSortOrder.Descending, Optional startIndex As Integer = 0, Optional maxCount As Integer = 10000 ) As AFSession() Dim instance As PISystem Dim startTime As AFTime? Dim endTime As AFTime? Dim sortOrder As AFSortOrder Dim startIndex As Integer Dim maxCount As Integer Dim returnValue As AFSession() returnValue = instance.GetSessions(startTime, endTime, sortOrder, startIndex, maxCount)
public: array<AFSession>^ GetSessions( Nullable<AFTime> startTime = nullptr, Nullable<AFTime> endTime = nullptr, AFSortOrder sortOrder = AFSortOrder::Descending, int startIndex = 0, int maxCount = 10000 )
member GetSessions : ?startTime : Nullable<AFTime> * ?endTime : Nullable<AFTime> * ?sortOrder : AFSortOrder * ?startIndex : int * ?maxCount : int (* Defaults: let _startTime = defaultArg startTime null let _endTime = defaultArg endTime null let _sortOrder = defaultArg sortOrder AFSortOrder.Descending let _startIndex = defaultArg startIndex 0 let _maxCount = defaultArg maxCount 10000 *) -> AFSession[]
Parameters
- startTime (Optional)
- Type: SystemNullableAFTime
The query looks for connections starting at or after the specified time. Specify to search all start times. - endTime (Optional)
- 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. - sortOrder (Optional)
- Type: OSIsoft.AFAFSortOrder
The query sorts connections using the specified order. Specify Descending to begin with the most recent connections. - startIndex (Optional)
- Type: SystemInt32
The starting index (zero based) of the sessions to return in the search. - maxCount (Optional)
- 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.