sandeep.narang

PI Notifications - To get all the active notifications.

Discussion created by sandeep.narang on May 16, 2012
Latest reply on May 16, 2012 by Mike Zboray

Hi Team

 

 

 

I am using following piece of code to get all the active notifications. Please let me know if this is the right approach for this implementation or any other alternative is available.

 
if (string.IsNullOrEmpty(notificationName.Trim()))
notificationName = "*";
//get all notification objects
AFNamedCollectionList objAFNotificationColl = AFNotification.FindNotifications(
this.Database,
notificationName,
AFSearchField.Name,
AFSortField.Name,
AFSortOrder.Ascending,
20000);
log.Info("NotificationCount : " + objAFNotificationColl.Count);
ANNotificationList notificationList = new ANNotificationList(objAFNotificationColl);
List listInstances = notificationList.GetInstances(new AFTime("-1h")); // get all history records

foreach (ANNotificationInstances notificationInstances in listInstances) //analize histiory records one by one
{
if (notificationInstances != null && notificationInstances.Instances != null && notificationInstances.Instances.Any(n => n.IsActive))
log.Info("Notification Name : " + notificationList.Notifications[notificationInstances.NotificationID].Name + " , status : " + true);
}

 

 

 

 

Also, this approach is taking lot of time while fetching the records. Please let us know any bwork around so that fetching time could be minimised.

 

 

 

Thanks and Regards

 

Sachin

Outcomes