Click or drag to resize
OSIsoft, LLC

AFSearchSummaryAsync Method (String, AFSummaryTypes, CancellationToken)

Summarizes the result of this search asynchronously.

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.8.440
Syntax
public Task<AFSummaryResult> SummaryAsync(
	string field,
	AFSummaryTypes summaryTypes,
	CancellationToken cancellationToken
)

Parameters

field
Type: SystemString
The field that should be summarized.
summaryTypes
Type: OSIsoft.AF.DataAFSummaryTypes
The summaries that should be performed on the field.
cancellationToken
Type: System.ThreadingCancellationToken
A token to control cancellation of the aggregation request.

Return Value

Type: TaskAFSummaryResult
A result containing the requested summaries or an error if the summaries could not be performed.
Remarks

Note Notes to Callers
This call might use a background task to complete some of its work. See the Threading Overview for some matters to consider when execution transitions to another thread.

Examples
// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
if (myPISystem == null)
    throw new InvalidOperationException("Default PISystem was not found.");
AFDatabase myDB = myPISystem.Databases[dbName];
if (myDB == null)
    throw new InvalidOperationException("Database was not found.");

// Create a search to find all the event frames created from the 'Event'
// template in the last year.
using (AFEventFrameSearch eventSearch = new AFEventFrameSearch(myDB, "EventFrameSearch", @"Template:'Event' Start:>'t-1y'"))
{
    eventSearch.CacheTimeout = TimeSpan.FromMinutes(10);
    // Summarize the Minimum, Average, and Maximum duration for items meeting the search criteria
    AFSummaryResult summaryResult = await eventSearch.SummaryAsync("Duration", AFSummaryTypes.Minimum | AFSummaryTypes.Maximum | AFSummaryTypes.Average, CancellationToken.None);
    Console.WriteLine("Minimum: {0}, Average: {1}, Maximum: {2}",
        summaryResult.SummaryResults[AFSummaryTypes.Minimum],
        summaryResult.SummaryResults[AFSummaryTypes.Average],
        summaryResult.SummaryResults[AFSummaryTypes.Maximum]);
}
Version Information

AFSDK

Supported in: 2.10.5, 2.10, 2.9.5, 2.9
See Also
Enabling Operational Intelligence