示例#1
0
        void DeleteRouters(ServiceBusTreeNode treeNode)
        {
            if (treeNode.ServiceBusNode != null)
            {
                if (treeNode.ServiceBusNode.Policy != null)
                {
                    if (treeNode.ServiceBusNode.Policy is RouterPolicy)
                    {
                        string nodeAddress = treeNode.ServiceBusNode.Address;
                        nodeAddress = nodeAddress.Replace(@"https://", @"sb://");
                        nodeAddress = nodeAddress.Replace(@"http://", @"sb://");

                        TransportClientEndpointBehavior credential = Graphs[ServiceNamespace.ToLower()].Credential;
                        Uri address = new Uri(nodeAddress);
                        try
                        {
                            RouterManagementClient.DeleteRouter(credential, address);
                        }
                        catch
                        {}
                    }
                }
            }
            foreach (TreeNode node in treeNode.Nodes)
            {
                DeleteRouters(node as ServiceBusTreeNode);
            }
        }
示例#2
0
        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;
        }
        RouterPolicy GetRouterPolicy(string address)
        {
            address = address.Replace(@"https://", @"sb://");
            address = address.Replace(@"http://", @"sb://");

            Uri routerAddress = new Uri(address);

            return(RouterManagementClient.GetRouterPolicy(Credential, routerAddress));
        }
 void ApplyPolicy(RouterPolicy policy)
 {
     try
     {
         RouterClient client = RouterManagementClient.GetRouter(Credential, RealAddress);
         client.DeleteRouter();
         RouterManagementClient.CreateRouter(Credential, RealAddress, policy);
         RestoreSubscribedTo();
         Explore();
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error applying change: " + exception.Message, "Service Bus Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        void RestoreSubscribedTo()
        {
            if (Node.SubscribedTo == null)
            {
                return;
            }

            RouterPolicy policy = Node.Policy as RouterPolicy;
            RouterClient client = RouterManagementClient.GetRouter(Credential, RealAddress);

            foreach (ServiceBusNode router in Node.SubscribedTo)
            {
                Uri          address      = GetRealAddress(router.Address);
                RouterClient parentRouter = RouterManagementClient.GetRouter(Credential, address);
                TimeSpan     TimeSpan     = DateTime.UtcNow - policy.ExpirationInstant;
                client.SubscribeToRouter(parentRouter, TimeSpan);
            }
        }
        void OnDelete(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete the router?", "Service Bus Explorer", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (result == DialogResult.No)
            {
                return;
            }

            try
            {
                RouterClient client = RouterManagementClient.GetRouter(Credential, RealAddress);
                client.DeleteRouter();
                Explore();
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error deleting router: " + exception.Message, "Service Bus Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#7
0
        void OnCreate(object sender, EventArgs e)
        {
            Debug.Assert(m_AddressTextBox.Text != BaseAddress);

            RouterPolicy policy = new RouterPolicy();

            if (m_AllRadioButton.Checked)
            {
                policy.MessageDistribution = MessageDistributionPolicy.AllSubscribers;
            }
            else
            {
                policy.MessageDistribution = MessageDistributionPolicy.OneSubscriber;
            }

            if (m_MaxSubscribersTextBox.Text != "")
            {
                policy.MaxSubscribers = Convert.ToInt32(m_MaxSubscribersTextBox.Text);
            }
            if (m_PushRetriesTextBox.Text != "")
            {
                policy.PushDeliveryRetries = Convert.ToInt32(m_PushRetriesTextBox.Text);
            }

            policy.ExpirationInstant = m_ExpirationTimePicker.Value;

            if (m_BufferLengthTextBox.Text != "")
            {
                policy.MaxBufferLength = Convert.ToInt32(m_BufferLengthTextBox.Text);
            }

            switch (m_OverflowComboBox.Text)
            {
            case "Reject":
            {
                policy.OverflowPolicy = OverflowPolicy.RejectIncomingMessage;
                break;
            }

                /* TODO Restore on next release
                 *
                 * case "Discard Incoming":
                 * {
                 * policy.Overflow = OverflowPolicy.DiscardIncomingMessage;
                 * break;
                 * }
                 * case "Discard Existing":
                 * {
                 * policy.Overflow = OverflowPolicy.DiscardExistingMessage;
                 * break;
                 * }
                 */
            }
            if (m_AddressTextBox.Text.EndsWith(@"/") == false)
            {
                m_AddressTextBox.Text += @"/";
            }
            try
            {
                Client = RouterManagementClient.CreateRouter(Credential, new Uri(m_AddressTextBox.Text), policy);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Unable to create router: " + exception.Message, "Service Bus Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Close();
        }