private void SetupContextMenu() { var items = lbItems.ContextMenu.Items; if (_sys.GetUnprocessedItemsCount(QueueType.Error) > 0) { miReturnAllErr.IsEnabled = true; miPurgeAllErr.IsEnabled = true; // Return All error messages var mi = miReturnAllErr; /* * mi.Click += async (sender, e) => { * try { * _loadingText = "Processing..."; * await _sys.MoveAllErrorMessagesToOriginQueue(null); * } catch( Exception ex ) { * _sys_ErrorOccured(this, new ErrorArgs("Failed to move messages to Orgin Queues", ex)); * } * }; */ mi.Items.Clear(); foreach (var q in _mgr.MonitorQueues.Where(q => q.Type == QueueType.Error)) { var m2 = new MenuItem() { Header = q.Name }; m2.Click += async(sender, e) => { _loadingText = "Processing..."; _sys.MoveAllErrorMessagesToOriginQueue(q.Name); }; mi.Items.Add(m2); } // Purge all error messages mi = miPurgeAllErr; mi.Items.Clear(); foreach (var q in _mgr.MonitorQueues.Where(q => q.Type == QueueType.Error)) { var m2 = new MenuItem() { Header = q.Name }; m2.Click += async(sender, e) => { _sys.PurgeErrorMessages(q.Name); }; mi.Items.Add(m2); } } else { miReturnAllErr.IsEnabled = false; miPurgeAllErr.IsEnabled = false; } miPurgeMsg.IsEnabled = _features.Any(f => f == ServiceBusFeature.PurgeMessage); if (miReturnAllErr.IsEnabled) { miPurgeAllErr.IsEnabled = _features.Any(f => f == ServiceBusFeature.PurgeAllMessages); } miReturnErrToOrgin.IsEnabled = _features.Any(f => f == ServiceBusFeature.MoveErrorMessageToOriginQueue); if (miReturnAllErr.IsEnabled) { miReturnAllErr.IsEnabled = _features.Any(f => f == ServiceBusFeature.MoveAllErrorMessagesToOriginQueue); } }