diff --git a/WindowsFormsApplication1/Form1.Designer.cs b/WindowsFormsApplication1/Form1.Designer.cs index 94e08fe..d5227e4 100644 --- a/WindowsFormsApplication1/Form1.Designer.cs +++ b/WindowsFormsApplication1/Form1.Designer.cs @@ -138,7 +138,7 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("SimSun", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.Location = new System.Drawing.Point(234, 22); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(129, 20); @@ -169,7 +169,7 @@ private void InitializeComponent() this.txtHostUrl.Name = "txtHostUrl"; this.txtHostUrl.Size = new System.Drawing.Size(151, 21); this.txtHostUrl.TabIndex = 10; - this.txtHostUrl.Text = "http://localhost:15672"; + this.txtHostUrl.Text = "localhost"; // // label2 // diff --git a/WindowsFormsApplication1/Form1.cs b/WindowsFormsApplication1/Form1.cs index 13228cc..402579b 100644 --- a/WindowsFormsApplication1/Form1.cs +++ b/WindowsFormsApplication1/Form1.cs @@ -15,28 +15,23 @@ namespace WindowsFormsApplication1 { public partial class Form1 : Form { - private const string M_HostName = "localhost"; - private string hosturl = "http://localhost:15672"; + private string hosturl; private string username; private string password; - private readonly string exchangesApi; - private readonly string queuesApi; - private readonly string bingdingsApi; + private string exchangesApi; + private string queuesApi; + private string bingdingsApi; private List userExchanges; private List queues; private List bindings; - private readonly ConnectionFactory factory; + private ConnectionFactory factory; private ExchangeEntity exchange; private QueueEntity queue; private BindingEntity binding; - + public Form1() { - InitializeComponent(); - exchangesApi = hosturl + "/api/exchanges"; - queuesApi = hosturl + "/api/queues"; - bingdingsApi = hosturl + "/api/bindings"; - factory = new ConnectionFactory { HostName = M_HostName }; + InitializeComponent(); InitRabbit(); } @@ -44,8 +39,15 @@ private void InitRabbit() { username = txtUsername.Text.Trim(); password = txtPwd.Text.Trim(); - hosturl = txtHostUrl.Text.Trim(); + var host = txtHostUrl.Text.Trim(); + hosturl = $"http://{host}:15672"; + + exchangesApi = hosturl + "/api/exchanges"; + queuesApi = hosturl + "/api/queues"; + bingdingsApi = hosturl + "/api/bindings"; + + factory = new ConnectionFactory { HostName = host }; cbExchangeType.SelectedIndex = 0; cbDurable.SelectedIndex = 0;