AnsweredAssumed Answered

Efficient way to iterate through notifications

Question asked by DSmith1 on Nov 25, 2015
Latest reply on Nov 25, 2015 by Mike Zboray

I'm writing a small program that will iterate through the notifications on an AF database and check which are running.

 

I am used to just iterating through lists; but I'm trying to better follow OSI's AFSDK coding guidelines and bulk load.

See my code example below. I connect to a database, bulk load some of the notifications and then attempt different ways to track how many are running / not running.

 

 

 

// Connect to AF database


Console.WriteLine("Connected to AF database: " + targetDatabase);

// Collect the Fault Distance notifications and compare the total count to how many have an 'Enabled' status


AFNamedCollectionList<AFNotification> myNotifications = AFNotification.FindNotifications(targetAFDB, "*", 

AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 1000);

//AFNamedCollectionList<AFNotification> erroredNotifications = (AFNamedCollectionList<AFNotification>)myNotifications.Where(n=>n.GetStatus().ToString().Equals("Enabled"));


//nonRunningNotifications = erroredNotifications.Count;


foreach (AFNotification afNote in myNotifications)

if (!afNote.GetStatus().ToString().Equals("Enabled"))

//This unfortunately does nothing, what is this function for if it returns void?


AFNotification.GetStatus(myNotifications);

 

 

A couple of questions:

  1. (line 11) I failed at trying to use a predicate. Can someone help me sort out how I'd collect all notifications that are not running?
  2. (line 13) How do developers use AFNotification's GetStatus function? It returns an AFStatus object, but that's just a status that says "Enabled" or something like that. Do people traditionally just call its "ToString()" function to compare?
  3. (line 16) What is the point of the AFNotification.GetStatus() function? It takes in an AFNamedCollectionList of AFnotifications but its return type is void. Is it supposed to do something to my list of notifications?
  4. Where would I get the ANNotifications class? I've seen other users on here use it and I cannot see it in my .NET project. I heard it's part of ANSDK but I cannot find that

Outcomes