Click or drag to resize
OSIsoft, LLC

AFEventFrameSearch Class

This class is an implementation of the abstract AFSearch class the supports searching for AFEventFrame objects.

Inheritance Hierarchy

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.0.8608
Syntax
public sealed class AFEventFrameSearch : AFSearch, 
	IAFSearch<AFEventFrame>

The AFEventFrameSearch type exposes the following members.

Constructors
  NameDescription
Public methodAFEventFrameSearch(AFDatabase, String, IListAFSearchToken)
Creates an instance of an AFEventFrameSearch to search for AFEventFrame objects using the specified list of search tokens.
Public methodAFEventFrameSearch(AFDatabase, String, String)
Creates an instance of an AFEventFrameSearch to search for AFEventFrame objects using the specified search query string.
Public methodAFEventFrameSearch(AFDatabase, String, AFEventFrameSearchMode, AFTime, String)
Creates an instance of an AFEventFrameSearch to search for AFEventFrame objects using the specified AFEventFrameSearchMode, time and optional search query string.
Public methodAFEventFrameSearch(AFDatabase, String, AFSearchMode, AFTime, AFTime, String)
Creates an instance of an AFEventFrameSearch to search for AFEventFrame objects using the specified AFSearchMode, times and optional search query string.
Top
Properties
  NameDescription
Public propertyCacheInterval
The search's cached automatic refresh interval.
(Inherited from AFSearch.)
Public propertyCacheTimeout
The timeout to clean up the cached search in the server if it has not been used.
(Inherited from AFSearch.)
Public propertyDatabase
The AFDatabase to be searched by the query.
(Inherited from AFSearch.)
Public propertyIdentity
This read-only property specifies the identity of the objects returned from the search.
(Inherited from AFSearch.)
Public propertyPISystem
The PISystem to be searched by the query.
(Inherited from AFSearch.)
Public propertySearchName
The name of the search object.
(Inherited from AFSearch.)
Public propertyThrowOnError
Specifies it an exception will be thrown for missing objects or invalid data in the query.
(Inherited from AFSearch.)
Public propertyTokens
The tokens that represent this search object.
(Inherited from AFSearch.)
Top
Methods
  NameDescription
Public methodCode exampleAggregate
Performs all requested aggregates on the objects that match the search criteria.
(Inherited from AFSearch.)
Public methodCode exampleAggregateAsync
Performs all requested aggregates on the objects that match the search criteria asynchronously.
(Inherited from AFSearch.)
Public methodCode exampleBinnedSummaryTBin
Generates a summary broken down by the specified bins for items matching the search criteria.
(Inherited from AFSearch.)
Public methodCode exampleBinnedSummaryAsyncTBin
Generates a summary broken down by the specified bins for items matching the search criteria asynchronously.
(Inherited from AFSearch.)
Public methodClose
Closes the search that is cached in the server.
(Inherited from AFSearch.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleFindEventFrames
This method will return the AFEventFrame objects that match the search tokens.
Public methodCode exampleFindObjectFields(String, Int32, Int32)
This method will return the values as an IList for the specified fields for each of the objects that match the search tokens.
(Inherited from AFSearch.)
Public methodCode exampleFindObjectFieldsTObject(Int32, Int32)
This method will return the values for the fields defined by the user-defined type for each of the objects that match the search tokens.
(Inherited from AFSearch.)
Public methodCode exampleFindObjectFieldsTObject(String, FuncIListObject, TObject, Int32, Int32)
This method will return the values as an object for the specified fields for each of the objects that match the search tokens using the supplied factory delegate.
(Inherited from AFSearch.)
Public methodCode exampleFindObjectIds
This method will return a list of the ID for each object that matches the search tokens.
(Inherited from AFSearch.)
Public methodCode exampleFrequencyDistribution
Generates a frequency distribution for the specified items.
(Inherited from AFSearch.)
Public methodCode exampleFrequencyDistributionAsync
Generates a frequency distribution for the specified items asynchronously.
(Inherited from AFSearch.)
Public methodGetCachedEventFrames
Gets the active matches for this search when there is an active subscriber.
Public methodStatic memberGetFilters
Get the full list of valid filters for an AFEventFrame search query for all servers.
Public methodStatic memberGetFilters(PISystem)
Get the list of valid filters for an AFEventFrame search query for the specified server.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetObjectFields
Get the list of valid object fields that can used for the FindObjectFields(String, Int32, Int32) search of an AFEventFrame search query for the specified server.
Public methodGetTotalCount
Returns the total count of the items that could be returned from the search query.
(Inherited from AFSearch.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodCode exampleGroupedSummary
Generates summaries broken down by group for items matching the search criteria.
(Inherited from AFSearch.)
Public methodCode exampleGroupedSummaryAsync
Generates summaries broken down by group for items matching the search criteria asynchronously.
(Inherited from AFSearch.)
Public methodCode exampleHistogramTBin
Generates a histogram using the specified weighting for items matching this search.
(Inherited from AFSearch.)
Public methodCode exampleHistogramAsyncTBin
Generates a histogram using the specified weighting for items matching this search asynchronously.
(Inherited from AFSearch.)
Public methodCode exampleIsMatch
Determines if the specified AFEventFrame matches the search query.
Public methodStatic memberParseQuery
Parses the specified search query into search tokens which can be used to search for AFEventFrame objects.
Public methodRefresh
Refreshes the search that is cached in the server.
(Inherited from AFSearch.)
Public methodSubscribe(IObserverAFSearchUpdateEventAFEventFrame)
Subscribes an observer to matches for this event frame search.
Public methodSubscribe(IObserverAFSearchUpdateEventAFEventFrame, Boolean, Int32)
Subscribes an observer to matches for this event frame search.
Public methodCode exampleSummary(String, AFSummaryTypes)
Summarizes the result of this search.
(Inherited from AFSearch.)
Public methodSummary(String, AFSummaryTypes, String)
Summarizes the result of this search with the specified weighting.
(Inherited from AFSearch.)
Public methodCode exampleSummaryAsync(String, AFSummaryTypes, CancellationToken)
Summarizes the result of this search asynchronously.
(Inherited from AFSearch.)
Public methodSummaryAsync(String, AFSummaryTypes, String, CancellationToken)
Summarizes the result of this search with the specified weighting asynchronously.
(Inherited from AFSearch.)
Public methodToString
Returns a String that represents the current object.
(Inherited from AFSearch.)
Public methodTryFindSearchToken
Find the AFSearchToken associated with the specified AFSearchFilter.
(Inherited from AFSearch.)
Public methodTryFindSearchTokens
Find the AFSearchToken list associated with the specified AFSearchFilter.
(Inherited from AFSearch.)
Top
Remarks

This class provides support for query based searches for AFEventFrame objects. The QuerySearch feature can be checked to determine if this query search is supported.

A query string is parsed into search tokens which are used to specify the query filters for the search.

To optimize getting items from several pages of search results, a search can be cached by setting the CacheTimeout to a non-zero value. If you will only be getting items from the first page, then it is best to leave the cache disabled. The cache is disabled by default. Call the Refresh method to refresh the results of a cached search. Use the Close method to close a cached search when finished using it to free the memory used by the cached results in the server. Since the search implements the IDisposable interface, you can call the cached search in a using statement to automatically call the Close method when it leaves scope.

Note Notes to Callers
When a query is too complex for a server, then you will get a NotSupportedException.

Examples
 1// Get the Database
 2PISystems myPISystems = new PISystems();
 3PISystem myPISystem = myPISystems.DefaultPISystem;
 4if (myPISystem == null)
 5    throw new InvalidOperationException("Default PISystem was not found.");
 6AFDatabase myDB = myPISystem.Databases[dbName];
 7if (myDB == null)
 8    throw new InvalidOperationException("Database was not found.");
 9
10// Create a search to find all the event frames created from the 'Event'
11// template, with a start time greater than or equal to three days ago,
12// and its 'Level' attribute value is greater than or equal 45.
13// Note: Time strings must be in a format supported by AFTime.Parse which
14//       will use current culture and then fall back to invariant culture.
15int count;
16using (var search = new AFEventFrameSearch(myDB, "FindEvents", @"Template:'Event' Start:>='*-3d' |Level:>=45.0"))
17{
18    search.CacheTimeout = TimeSpan.FromMinutes(10);
19
20    // When the event frames are returned from a find operation, they are only
21    // partially loaded into memory, typically enough to display their 
22    // inherent properties, such as Name, Description, Template, etc.  
23    // When a piece of information is accessed in the event frame that requires more 
24    // information, an RPC to the server is made to fully load the event frame.  
25    // By having the search do a full load, all information is loaded in bulk and
26    // we can reduce the number of RPCs made to retrieve this information.
27    count = search.GetTotalCount();
28    Console.WriteLine("Found {0} EventFrames.", count);
29    foreach (AFEventFrame item in search.FindEventFrames(fullLoad: true))
30    {
31        // Now we can use the event frames without having to make any additional RPCs
32        // In the example below, accessing the Attributes collection would have 
33        // caused an additional RPC per element found.
34        // Now we can use the event frames without having to make any additional RPCs
35        // In the example below, accessing the Attributes collection would have 
36        // caused an additional RPC per event frame found.
37        Console.WriteLine("  EventFrame {0} has {1} Attributes", item.Name, item.Attributes.Count);
38    }
39}
Version Information

AFSDK

Supported in: 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5
See Also
Enabling Operational Intelligence