示例#1
0
 public InformationException(StatusException status, string mensagens, Exception innerException = null) : base(status.GetDescription(), innerException)
 {
     Status    = status;
     Mensagens = new List <string> {
         mensagens
     };
 }
示例#2
0
        /// <summary>
        /// Connect to server.
        /// </summary>
        private int Connect()
        {
            if (m_Session == null)
            {
                m_Session = new Session(m_Application);
                m_Session.UseDnsNameAndPortFromDiscoveryUrl = true;

                // Attach to events
                m_Session.ConnectionStatusUpdate += new ServerConnectionStatusUpdateEventHandler(Session_ServerConnectionStatusUpdate);
            }

            // Check the content of the combobox.
            if (UrlCB.Text.Length == 0)
            {
                return(-1);
            }

            // Set wait cursor.
            Cursor = Cursors.WaitCursor;
            int result = 0;

            try
            {
                string endpointUrl;

                // Extract Url from combobox text.
                object item = UrlCB.SelectedItem;
                if ((item == null) || (item.GetType() == typeof(string)))
                {
                    // The URL has been entered as text.
                    endpointUrl = UrlCB.Text;

                    // Call connect with URL
                    m_Session.Connect(endpointUrl, SecuritySelection.None);
                }
                else
                {
                    // The endpoint was provided through discovery.
                    EndpointWrapper endpoint = (EndpointWrapper)item;

                    // Call connect with endpoint
                    m_Session.Connect(endpoint.Endpoint, null);
                }
            }
            catch (Exception e)
            {
                result = -1;

                // Update status label.
                StatusException se = e as StatusException;

                if (se != null)
                {
                    toolStripStatusLabel.Text = String.Concat("Connect failed. Error [", se.StatusCode.ToString(), "] ", e.Message);
                }
                else
                {
                    toolStripStatusLabel.Text = "Connect failed. Error: " + e.Message;
                }

                toolStripStatusLabel.Image = RabbitMQ_SendClient.Properties.Resources.error;
            }

            // Set default cursor.
            Cursor = Cursors.Default;
            return(result);
        }