/// <summary> /// 获取服务器列表 /// </summary> private void GetServerList() { string sUrl = domin + "/index.php/Appclt/getOpSerLst"; string result = HttpHelper.HttpPost(sUrl, string.Empty); JObject job = JObject.Parse(result); if (job["code"].ToString() == "200") { serverList = JsonConvert.DeserializeObject <List <ServerItem> >(Convert.ToString(job["entity"])); var showList = new List <ServerTextValue>(); foreach (var item in serverList) { showList.Add(new ServerTextValue() { value = item.serverid.ToString(), text = string.Format("{0} ({1}人在线) {2}M/秒", item.name, item.node_connector, item.traffic_rate) }); } this.ServerlistBox.DataSource = showList; } else { TipHelper.Alert(Convert.ToString(job["msg"])); } }
/// <summary> /// 登录操作 /// </summary> /// <param name="own_mob_no"></param> /// <param name="own_pwd"></param> /// <param name="vercode"></param> private void LoginOperate(string own_mob_no, string own_pwd, string vercode) { string sUrl = domin + "/index.php/Appclt/login"; string body = string.Format("own_mob_no={0}&own_pwd={1}&vercode={2}", own_mob_no, own_pwd, vercode); string result = HttpHelper.HttpPost(sUrl, body); JObject job = JObject.Parse(result); if (job["code"].ToString() == "200") { var user = JsonConvert.DeserializeObject <UserInfo>(Convert.ToString(job["entity"])); TimeSpan d3 = user.expire_in.Subtract(DateTime.Now); double seconds = d3.TotalSeconds; //缓存用户信息 CacheHelper.SetCache("UserInfo", user, seconds); //弹出窗体 NewConfigForm cf = new NewConfigForm(); cf.Show(); this.Hide();//隐藏登录窗体 } else { this.LoginBtn.Enabled = true;//启用按钮 TipHelper.Alert(Convert.ToString(job["msg"])); //登录失败更新验证码 GetImagesCode(); } }
/// <summary> /// 接入服务操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ServerBtn_Click(object sender, EventArgs e) { string sUrl = domin + "/index.php/Appclt/accessact"; var item = this.ServerlistBox.SelectedItem as ServerTextValue;//获取当前的选中的服务器 string body = "serverid=" + item.value; string result = HttpHelper.HttpPost(sUrl, body); JObject job = JObject.Parse(result); if (job["code"].ToString() == "200") { //创建服务 Server server = new Server(); RunServer(server); } else { TipHelper.Alert(Convert.ToString(job["msg"])); } }
/// <summary> /// 用户登录操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Login(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.UserName.Text)) { TipHelper.Alert("用户名不能为空!"); return; } if (string.IsNullOrWhiteSpace(this.UserPwd.Text)) { TipHelper.Alert("密码不能为空!"); return; } if (string.IsNullOrWhiteSpace(this.Code.Text)) { TipHelper.Alert("验证码不能为空!"); return; } this.LoginBtn.Enabled = false;//禁用按钮 LoginOperate(this.UserName.Text, this.UserPwd.Text, this.Code.Text); }