Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

Product Family
Current publication

AFNotification.FindNotifications Method (AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32)

Table of Contents
HomeAF SDK Reference...NamespacesOSIsoft.AF.NotificationAFNotification ClassAFNotification MethodsFindNotifications Method AFNotification.FindNotifications Method (AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32)Current page
TABLE OF CONTENTS

AFNotification.FindNotifications Method (AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32)

AFNotification.FindNotifications Method (AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32)
Performs a non-paged text search within the AFDatabase to retrieve a collection of AFNotification objects which have a field that matches the specified query string.

Namespace:  OSIsoft.AF.Notification
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.0.1156

Syntax

public static AFNamedCollectionList<AFNotification> FindNotifications(
	AFDatabase database,
	string query,
	AFSearchField field,
	AFSortField sortField,
	AFSortOrder sortOrder,
	int maxCount
)
Public Shared Function FindNotifications ( 
	database As AFDatabase,
	query As String,
	field As AFSearchField,
	sortField As AFSortField,
	sortOrder As AFSortOrder,
	maxCount As Integer
) As AFNamedCollectionList(Of AFNotification)

Dim database As AFDatabase
Dim query As String
Dim field As AFSearchField
Dim sortField As AFSortField
Dim sortOrder As AFSortOrder
Dim maxCount As Integer
Dim returnValue As AFNamedCollectionList(Of AFNotification)

returnValue = AFNotification.FindNotifications(database, 
	query, field, sortField, sortOrder, 
	maxCount)
public:
static AFNamedCollectionList<AFNotification^>^ FindNotifications(
	AFDatabase^ database, 
	String^ query, 
	AFSearchField field, 
	AFSortField sortField, 
	AFSortOrder sortOrder, 
	int maxCount
)
static member FindNotifications : 
        database : AFDatabase * 
        query : string * 
        field : AFSearchField * 
        sortField : AFSortField * 
        sortOrder : AFSortOrder * 
        maxCount : int -> AFNamedCollectionList<AFNotification> 

Parameters

database
Type: OSIsoft.AF.AFDatabase
The AFDatabase to search for the requested objects.
query
Type: System.String
The query string used for finding objects.

The query string (or match pattern) can include regular characters and wildcard characters. Regular characters must match exactly the characters specified in the query string. Wildcard characters can be matched with arbitrary fragments of the query string. Wildcard characters can be escaped using the single backslash (\) character. Use a double backslash (\\) to match a single backslash. The syntax of the query string has the following rules:

  • If null or empty string, then everything will be matched.
  • If no wildcards, then an exact match on the query string is performed.
  • Wildcard * can be placed anywhere in the query string and matches zero or more characters.
  • Wildcard ? can be placed anywhere in the query string and matches exactly one character.
  • One character in a set of characters are matched by placing them within [ ]. For example, a[bc] would match 'ab' or 'ac', but it would not match 'ad' or 'abd'.
  • One character in a set of characters are not matched by placing them within [! ]. For example, a[!bc] would match 'ad', but it would not match 'ab', 'ac', or 'abd'.
  • A character in a range of characters from first to last are matched using the following syntax: [first - last]. For example, a[a-c] would match 'aa', 'ab', or 'ac', but it would not match 'ad' or 'abc'.

field
Type: OSIsoft.AF.AFSearchField
Specifies which of the object's properties are searched.
sortField
Type: OSIsoft.AF.AFSortField
The field or property of the object used to sort the returned collection.
sortOrder
Type: OSIsoft.AF.AFSortOrder
The order that the returned collection is sorted.
maxCount
Type: System.Int32
The maximum number of objects to be returned.

Return Value

Type: AFNamedCollectionList<AFNotification>
Returns the collection containing the first page of AFNotification objects which match the specified query string.

Remarks

An object matches the text search if the specified query is found in one of the object's properties specified by the field parameter.

Examples

// Loading a list of Notifications for display is a common task whose performance can be
// greatly improved by using bulk retrieval methods.Notifications typically reference several other top-level
// AF Objects, such as Analyses, Analysis Templates, Elements, Element Templates, and Element paths.
// This example uses several methods to illustrate how to load such a list.

// Get the Default Database
PISystems myPISystems = new PISystems();
AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase;
if (myDB == null)
    throw new InvalidOperationException("Database was not found.");

// Find notifications to load.  As with all top-level objects, the
// notifications returned are only partially loaded into memory.  
AFNamedCollectionList<AFNotification> notifications =
    AFNotification.FindNotifications(myDB, "", AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 100);

// The LoadNotifications call will fully load the notification into memory.
// The second parameter indicates whether the analysis should be loaded as well.
// For example, if you were going to display or edit analysis information, you would
// set this parameter to true.
AFNotification.LoadNotifications(notifications, false);

// Notifications target other AFObjects.  We can cause those to be loaded via this call.
// Note that typically, notifications target single AFElements, however, in the future,
// there may be other types of objects targeted.
IList<object> targets = AFNotification.LoadTargets(notifications, false);

// Now output the notifications.  There should be no more calls to the server at this point.
foreach (AFNotification notification in notifications)
{
    AFObject target = notification.Target as AFObject;
    if (target != null)
        Console.WriteLine("{0}: {1}", notification, target.GetPath());
    else
        Console.WriteLine("{0}: {1}", notification, notification.Target);
}
' Loading a list of Notifications for display is a common task whose performance can be
' greatly improved by using bulk retrieval methods.Notifications typically reference several other top-level
' AF Objects, such as Analyses, Analysis Templates, Elements, Element Templates, and Element paths.
' This example uses several methods to illustrate how to load such a list.

' Get the Default Database
Dim myPISystems As New PISystems()
Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases.DefaultDatabase
If myDB Is Nothing Then
    Throw New InvalidOperationException("Database was not found.")
End If

' Find notifications to load.  As with all top-level objects, the
' notifications returned are only partially loaded into memory.  
Dim notifications As AFNamedCollectionList(Of AFNotification) =
    AFNotification.FindNotifications(myDB, "", AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 100)

' The LoadNotifications call will fully load the notification into memory.
' The second parameter indicates whether the analysis should be loaded as well.
' For example, if you were going to display or edit analysis information, you would
' set this parameter to true.
AFNotification.LoadNotifications(notifications, False)

' Notifications target other AFObjects.  We can cause those to be loaded via this call.
' Note that typically, notifications target single AFElements, however, in the future,
' there may be other types of objects targeted.
Dim targets As IList(Of Object) = AFNotification.LoadTargets(notifications, False)

' Now output the notifications.  There should be no more calls to the server at this point.
For Each notification As AFNotification In notifications
    Dim target As AFObject = TryCast(notification.Target, AFObject)
    If target IsNot Nothing Then
        Console.WriteLine("{0}: {1}", notification, target.GetPath())
    Else
        Console.WriteLine("{0}: {1}", notification, notification.Target)
    End If
Next

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK


See Also

Was this topic helpful?