Beispiel #1
0
        private void btn_Query_Click(object sender, EventArgs e)
        {
            lb_message.Text = string.Empty;
            if (string.IsNullOrEmpty(txt_VEID.Text.Trim()))
            {
                lb_message.Text = "请输入VEID";
                txt_VEID.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_APIKEY.Text.Trim()))
            {
                lb_message.Text = "请输入APIKEY";
                txt_APIKEY.Focus();
                return;
            }
            string requestAddress = $"https://api.64clouds.com/v1/getServiceInfo?veid={txt_VEID.Text.Trim()}&api_key={txt_APIKEY.Text.Trim()}";

            WebClient client = new WebClient();
            string    result = client.DownloadString(requestAddress);

            if (!string.IsNullOrEmpty(result))
            {
                KvmResponse model = JsonConvert.DeserializeObject <KvmResponse>(result);

                if (model != null)
                {
                    if (model.error == 0)
                    {
                        lb_PhysicalLocation.Text = model.node_location + "   " + model.node_alias;
                        lb_IPAddress.Text        = model.node_ip;
                        lb_RAM.Text            = model.BitToMB(model.plan_ram) + " MB";
                        lb_Bandwidthusage.Text = model.BitToGB(model.data_counter) + " / " + model.BitToGB(model.plan_monthly_data) + " GB";

                        progressBar1.Maximum = Convert.ToInt32(model.BitToGB(model.plan_monthly_data) * 100);
                        progressBar1.Value   = Convert.ToInt32(model.BitToGB(model.data_counter) * 100);

                        lb_OperatingSystem.Text = model.ReplaceLine(model.os);
                        lb_Hostname.Text        = model.ConvertToDateTime(model.data_next_reset).ToShortDateString();
                    }
                    else if (model.error == 700005)
                    {
                        MessageBox.Show("用户认证失败");
                    }
                    else
                    {
                        MessageBox.Show(model.message);
                    }
                }
                else
                {
                    MessageBox.Show("信息查询出错");
                }
            }
            else
            {
                MessageBox.Show("未查询到相关信息");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 重启VPS
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Restart_Click(object sender, EventArgs e)
        {
            lb_message.Text = string.Empty;
            if (string.IsNullOrEmpty(txt_VEID.Text.Trim()))
            {
                lb_message.Text = "请输入VEID";
                txt_VEID.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txt_APIKEY.Text.Trim()))
            {
                lb_message.Text = "请输入APIKEY";
                txt_APIKEY.Focus();
                return;
            }
            if (MessageBox.Show("你确定要重启VPS?\r\n重启过程您将如法使用服务器!!!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                string requestAddress = $"https://api.64clouds.com/v1/restart?veid={txt_VEID.Text.Trim()}&api_key={txt_APIKEY.Text.Trim()}";

                WebClient client = new WebClient();
                string    result = client.DownloadString(requestAddress);
                if (!string.IsNullOrEmpty(result))
                {
                    KvmResponse model = JsonConvert.DeserializeObject <KvmResponse>(result);

                    if (model != null)
                    {
                        if (model.error == 0)
                        {
                            lb_message.Text = "VPS服务器正在重启....";
                        }
                        else if (model.error == 700005)
                        {
                            MessageBox.Show("用户认证失败");
                        }
                        else
                        {
                            MessageBox.Show(model.message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("信息查询出错");
                    }
                }
                else
                {
                    MessageBox.Show("未查询到相关信息");
                }
            }
        }