Click or drag to resize
OSIsoft, LLC

AFSearchTIsMatch Method

Determines if the specified item matches the search query.

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.8.440
Syntax
public bool IsMatch(
	T item
)

Parameters

item
Type: T
The item to check against the search query.

Return Value

Type: Boolean
Returns if the specified item matches the search query. Otherwise is returned. If ThrowOnError is and an error is found in the query, then this method will return because the object does not match the query.

Implements

IAFSearchTIsMatch(T)
Exceptions
ExceptionCondition
FormatException This exception is thrown if the ThrowOnError property is and there is a format error in the search query.
NotSupportedException This exception is thrown if the ThrowOnError property is and one of the filters is not supported or the query is too complex to be evaluated by the server.
Remarks
This method will evaluate the search query and determine if the specified item matches the query filters for the search. The ThrowOnError property determines whether an exception is thrown if an error is found in the query.
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
10DateTime startTime = DateTime.Now;
11
12//Create a search to find all elements starting with "MyEvent" in their name
13//and an end date less than or equal to the current time plus 1 hour.
14AFEventFrameSearch search = new AFEventFrameSearch(myDB, "FindEventFrame", @"MyEvent* End:<=*+1h");
15AFEventFrame myEventFrame = new AFEventFrame(myDB, "MyEventFrame");
16myEventFrame.SetStartTime(startTime);
17myEventFrame.SetEndTime(startTime.AddHours(1));
18
19//IsMatch will evaluate to true if the new Element would match the 
20//query supplied in AFSearch above.  This avoids the need for having the SDK
21//do an actual RPC to the server as the match is evaluated on the client.
22bool match = search.IsMatch(myEventFrame);
23
24if (match)
25    Console.WriteLine("Event Frame {0} matched the supplied search query in the {1} search.", myEventFrame.Name, search.SearchName);
26else
27    Console.WriteLine("Event Frame {0} did not match the supplied search query in the {1} search.", myEventFrame.Name, search.SearchName);
Version Information

AFSDK

Supported in: 2.10.5
See Also
Enabling Operational Intelligence