Asynchronous request to start watching the alert catalog.
Namespace: ININ.IceLib.Statistics.AlertsAssembly: ININ.IceLib.Statistics (in ININ.IceLib.Statistics.dll) Version: 0.0.0.0 (22.3.0.218)
Syntax
C# |
---|
public void StartWatchingAsync( AlertSetCategories categories, IEnumerable<AlertSet..::..Property> properties, AsyncCompletedEventHandler completedCallback, Object userState ) |
Visual Basic |
---|
Public Sub StartWatchingAsync ( _ categories As AlertSetCategories, _ properties As IEnumerable(Of AlertSet..::..Property), _ completedCallback As AsyncCompletedEventHandler, _ userState As Object _ ) |
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.
- completedCallback
- Type: System.ComponentModel..::..AsyncCompletedEventHandler
The completed callback.
- userState
- Type: System..::..Object
An optional object that contains state information for this request. This object is a way for the caller to store context information which will be provided to the AsyncCompleted event. If no context information is desired then nullNothingnullptra null reference (Nothing in Visual Basic) may be supplied.
Remarks
When completed, the completedCallback delegate is invoked on a thread appropriate to the application-model, such as the GUI thread in a UI application. The Error property of the AsyncCompletedEventArgs-derived object passed to the delegate will contain any exceptions thrown while executing the asynchronous task. See the synchronous version of this method for more detailed error information. For more information on async method calls, see How Async Calls Work.
Note |
---|
All event handlers should be added before calling StartWatching or StartWatchingAsync. |
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 |
---|
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
Exception | Condition |
---|---|
System..::..ArgumentNullException | A parameter is nullNothingnullptra null reference (Nothing in Visual Basic) or the requested categories are invalid. |
System..::..ArgumentException | The parameter array is empty. |
Version Information
Supported for IC Server version 2015 R1 and beyond.
For 4.0, supported for IC Server version 4.0 GA and beyond.
For 4.0, supported for IC Server version 4.0 GA and beyond.