protected override void OnDeleteMonitoredItemsComplete(ServerSystemContext context, IList<IMonitoredItem> monitoredItems)
{
ComDaClientManager system = (ComDaClientManager)this.SystemContext.SystemHandle;
ComDaClient client = system.SelectClient(context, false);
// sort monitored items by the locale id used to create them.
Dictionary<string, List<IMonitoredItem>> monitoredItemsByLocaleId = new Dictionary<string, List<IMonitoredItem>>();
for (int ii = 0; ii < monitoredItems.Count; ii++)
{
// look up the manager that was previously used to create the monitor item.
SubscribeRequestManager manager = null;
if (!m_monitoredItems.TryGetValue(monitoredItems[ii].Id, out manager))
{
manager = m_subscriptionManagers[client.Key];
}
// add monitored item to a list of items for the locale of the manager.
List<IMonitoredItem> subset = null;
if (!monitoredItemsByLocaleId.TryGetValue(manager.Key, out subset))
{
monitoredItemsByLocaleId[manager.Key] = subset = new List<IMonitoredItem>();
}
subset.Add(monitoredItems[ii]);
}
// delete the items.
foreach (KeyValuePair<string, List<IMonitoredItem>> entry in monitoredItemsByLocaleId)
{
SubscribeRequestManager manager = null;
if (m_subscriptionManagers.TryGetValue(entry.Key, out manager))
{
manager.DeleteItems(context, entry.Value);
}
}
}