Synchronous request to start watching alert filters.

Namespace: ININ.IceLib.Statistics.Alerts
Assembly: ININ.IceLib.Statistics (in ININ.IceLib.Statistics.dll) Version: 0.0.0.0 (22.3.0.218)

Syntax

C#
public void StartWatching(
	AlertSetCategories categories,
	IEnumerable<AlertSet..::..Property> properties
)
Visual Basic
Public Sub StartWatching ( _
	categories As AlertSetCategories, _
	properties As IEnumerable(Of AlertSet..::..Property) _
)

Parameters

categories
Type: ININ.IceLib.Statistics.Alerts..::..AlertSetCategories
The category or categories to watch.
properties
Type: System.Collections.Generic..::..IEnumerable<(Of <(<'AlertSet..::..Property>)>)>
The AlertSet properties to watch.

Remarks

Note
If categories is All or categories has the AdminAccess flag, the user must have the Alert Administrator right set in Interaction Administrator.
Note
Using the All or AdminAccess will pull all Alerts from the system and in conjunction with listening to all Alerts can be harmful to performance.
Note
All event handlers should be added before calling StartWatching or StartWatchingAsync.
Note
For more information on watches see How Watches Work.

Examples

This example illustrates what should be avoided when using All or AdminAccess.
CopyC#
    Session session = new Session();
    session.Connect(...);
    StatisticsManager statisticsManager = StatisticsManager.GetInstance(session);
    AlertCatalog alertCatalog = new AlertCatalog(statisticsManager);
    AlertListener alertListener = new AlertListener(statisticsManager);

    AlertSet.Property[] properties = new[]
                                               {
                                                   AlertSet.Property.AccessMode,
                                                    AlertSet.Property.AlertDefinitions,
                                                    AlertSet.Property.Created,
                                                    AlertSet.Property.Description,
                                                    AlertSet.Property.DisplayString,
                                                    AlertSet.Property.Id,
                                                    AlertSet.Property.Modified,
                                                    AlertSet.Property.ModifiedBy,
                                                    AlertSet.Property.Owner,
                                                    AlertSet.Property.OwnerDisplayName,
                                                    AlertSet.Property.SubscribedByOther,
                                                    AlertSet.Property.SubscribedByUser,
                                                    AlertSet.Property.AlertSetSubscribers
                                                };

    alertCatalog.StartWatching(AlertSetCategories.All, properties);

    alertListener.AlertReceived += AlertListenerAlertReceived;
    alertListener.AlertChanged += AlertListenerAlertChanged;

    // This will return all AlertSets from the server when using <see cref="F:ININ.IceLib.Statistics.Alerts.AlertSetCategories.All" /> or <see cref="F:ININ.IceLib.Statistics.Alerts.AlertSetCategories.AdminAccess" />.
    var watchedAlertSets = alertCatalog.GetWatchedAlertSets();

    // Build AlertFilterKeys
    List<AlertFilterKey> filterKeys = new List<AlertFilterKey>();

    foreach (AlertSet alertSet in watchedAlertSets)
    {                                
        filterKeys.AddRange(BuildAlertFilterKey(alertSet));
    }

    // If AlertSetCategories.All or AlertSetCategories.AdminAccess was used this will start a watch on every unique AlertDefinition in each AlertSet.
    // **This is where performance could be impacted.**
    alertListener.StartWatching(
            filterKeys.ToArray(),
               AlertListenerFilter.Action | AlertListenerFilter.Condition | AlertListenerFilter.Severity);
}

private IEnumerable<AlertFilterKey> BuildAlertFilterKey(AlertSet alertSet)
{
    List<AlertFilterKey> alertFilterKeys = new List<AlertFilterKey>();
    List<string> uniqueTargets = new List<string>();

    foreach (AlertDefinition alertDefinition in alertSet.AlertDefinitions)
    {
        foreach (AlertRule alertRule in alertDefinition.AlertRules)
        {
            foreach (AlertAction alertAction in alertRule.AlertActions)
               {
                   if (!uniqueTargets.Contains(alertAction.TargetId))
                   {
                      uniqueTargets.Add(alertAction.TargetId);
                       alertFilterKeys.Add(new AlertFilterKey(alertSet, alertAction.TargetId));
                   }
               }
           }
    }

    return alertFilterKeys;
}

Exceptions

ExceptionCondition
System..::..InvalidOperationExceptionThe watch is already watching.
System..::..ArgumentNullExceptionA parameter is nullNothingnullptra null reference (Nothing in Visual Basic) or the requested categories are invalid.
System..::..ArgumentExceptionThe parameter array is empty.
ININ.IceLib.Connection..::..RequestTimeoutExceptionThe request timed out while waiting for a response.
ININ.IceLib.Connection..::..SessionDisconnectedExceptionThe Session does not have a valid connection.
System..::..ObjectDisposedExceptionThe Session has been disposed.

Version Information

Supported for IC Server version 2015 R1 and beyond.
For 4.0, supported for IC Server version 4.0 GA and beyond.

See Also