AnsweredAssumed Answered

Error when creating a ANNotification instance

Question asked by gortega on Jun 18, 2015
Latest reply on Jun 18, 2015 by dng

When trying to get the ANNotification  instance using the following code get the error below any ideas?
Thanks,
Gerardo

****************************************************************

private ANInstance GetNotificationInstance(Guid guid, string instanceId)
        {

            ANInstance anInstance = null;

            try
            {
                int id = int.Parse(instanceId);
                AFNotification afNotification = SearchForNotificationByGuid(guid);
                AFTime afStartTime = new AFTime("*-600d");
                AFTime afEndTime = new AFTime("*");
                AFTimeRange afTimeRange = new AFTimeRange(afStartTime, afEndTime);

               anInstance = ANNotification.GetInstance(afNotification, id, afTimeRange);

               
            }
            catch (Exception ex)
            {
                TraceLog.LogException(ex);
            }

            return anInstance;

        }

****************************************************************
Event Log error message
****************************************************************

Message:
Index was outside the bounds of the array.
StackTrace:
   at OSIsoft.AN.Notification.ANNotificationStateGroups.GetStatesWithDefaultPriority(String configString) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\Common\Notification\ANNotificationStateGroups.cs:line 77
   at OSIsoft.AN.Notification.ANNotificationStateGroup..ctor(AFAttribute attribute) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\Common\Notification\ANNotificationStateGroup.cs:line 34
   at OSIsoft.AN.ANConfigurationManager.GetNotificationGroups(PISystem system) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\Common\Library\ANConfigurationManager.cs:line 381
   at OSIsoft.AN.Notification.ANNotificationStateGroups.InitializeGroups() in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\Common\Notification\ANNotificationStateGroups.cs:line 427
   at OSIsoft.AN.Notification.ANNotificationStateGroups.GetGroups(PISystem system) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\Common\Notification\ANNotificationStateGroups.cs:line 62
   at OSIsoft.AN.Notification.ANNotificationState.CloneState(PISystem system, Int32 code) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\Common\Notification\ANNotificationState.cs:line 83
   at OSIsoft.AN.Notification.ANNotificationHistory.CreateInstancesFromStates(PIValues archiveStates) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\ANSDK\Notification\ANNotificationHistory.cs:line 1294
   at OSIsoft.AN.Notification.ANNotificationHistory.GetInstances(AFTime startTime, AFTime endTime, AFSearchMode searchMode, ANGetInstanceMode detailMode) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\ANSDK\Notification\ANNotificationHistory.cs:line 520
   at OSIsoft.AN.Notification.ANNotificationHistory.GetInstance(Int32 instanceID, AFTimeRange searchRange) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\ANSDK\Notification\ANNotificationHistory.cs:line 589
   at OSIsoft.AN.Notification.ANNotification.GetInstance(AFNotification notification, Int32 instanceID, AFTimeRange timeRange) in c:\Builds\152\PIANO\Notifications 1.2.1205 Nightly\Sources\1.2.1205\Library\ANSDK\Notification\ANNotification.cs:line 863
   at Sams.ContactEventService.NotificationAgent.GetNotificationInstance(Guid guid, String instanceId)
Source:
OSIsoft.PIAnalytics.Common
TargetSite:
System.Collections.Generic.Dictionary`2[System.String,OSIsoft.AN.Notification.ANPriority] GetStatesWithDefaultPriority(System.String)

****************************************************************

Outcomes