void DeleteBuffers(ServiceBusTreeNode treeNode) { if (treeNode.ServiceBusNode != null) { if (treeNode.ServiceBusNode.Policy != null) { if (treeNode.ServiceBusNode.Policy is MessageBufferPolicy) { string nodeAddress = treeNode.ServiceBusNode.Address; nodeAddress = nodeAddress.Replace(@"sb://", @"https://"); TransportClientEndpointBehavior credential = Graphs[ServiceNamespace.ToLower()].Credential; Uri address = new Uri(nodeAddress); try { MessageBufferClient.GetMessageBuffer(credential, address).DeleteMessageBuffer(); } catch {} } } } foreach (TreeNode node in treeNode.Nodes) { DeleteBuffers(node as ServiceBusTreeNode); } }
void OnDragDrop(object sender, DragEventArgs args) { Cursor.Current = Cursors.Default; Debug.Assert(m_DraggedNode != null); ServiceBusTreeNode targetNode = GetTargetNode(args); if (targetNode.ServiceBusNode == null) { return; } if (targetNode.ServiceBusNode.Policy != null)//A router or a buffer { if (targetNode.ServiceBusNode.Policy is RouterPolicy) { Trace.WriteLine("Droped at: " + targetNode.Text); string draggedAddress = m_DraggedNode.ServiceBusNode.Address; draggedAddress = draggedAddress.Replace(@"https://", @"sb://"); draggedAddress = draggedAddress.Replace(@"http://", @"sb://"); string targetAddress = targetNode.ServiceBusNode.Address; targetAddress = targetAddress.Replace(@"https://", @"sb://"); targetAddress = targetAddress.Replace(@"http://", @"sb://"); TransportClientEndpointBehavior credential = Graphs[ServiceNamespace.ToLower()].Credential; Uri draggedUri = new Uri(draggedAddress); Uri targetUri = new Uri(targetAddress); try { RouterClient targetClient = RouterManagementClient.GetRouter(credential, targetUri); if (m_DraggedNode.ServiceBusNode.Policy is RouterPolicy) { RouterClient draggedClient = RouterManagementClient.GetRouter(credential, draggedUri); draggedClient.SubscribeToRouter(targetClient, TimeSpan.MaxValue); } else { MessageBufferClient draggedClient = MessageBufferClient.GetMessageBuffer(credential, draggedUri); /* TODO Restore on next release * draggedClient.SubscribeToRouter(targetClient,TimeSpan.MaxValue); */ } OnExplore(this, EventArgs.Empty); m_ServiceBusTree.SelectedNode = targetNode; m_ServiceBusTree.Select(); } catch (Exception exception) { MessageBox.Show("Unable to subscribe: " + exception.Message, "Service Bus Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } m_DraggedNode = null; }
private void InitializeCommands(NavigationalEntry <ItemCommand <ClientViewModel> > rootEntry) { var navigationalEntries = new Dictionary <string, NavigationalEntry <ItemCommand <ClientViewModel> > >(); foreach (var commandDescription in _commandDescriptions) { var serviceNamespace = ServiceNamespace.Parse(commandDescription.Namespace); var menuEntry = rootEntry; foreach (var relativeSegment in serviceNamespace.GetRelativeSegments()) { var lastEntry = menuEntry; if (navigationalEntries.TryGetValue(relativeSegment, out menuEntry)) { continue; } menuEntry = new NavigationalEntry <ItemCommand <ClientViewModel> >(true) { Header = ServiceNamespace.TranslateSegment(relativeSegment) }; navigationalEntries.Add(relativeSegment, menuEntry); lastEntry.Add(menuEntry); } menuEntry.Add(new ItemCommand <ClientViewModel> { Header = commandDescription.Name, Icon = commandDescription.Icon, Command = new DelegateCommand <ClientViewModel>(x => ExecuteCommand(new List <ClientViewModel> { x }, commandDescription)), MultipleCommand = new DelegateCommand <IList <ClientViewModel> >(x => ExecuteCommand(x, commandDescription)) }); } }