/// <summary> /// 登陆 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void btnOk_Click(object sender, EventArgs e) { var username = txtUserName.Text; var password = txtPassword.Text; if (username.IsNullOrEmpty() || password.IsNullOrEmpty()) { IM("输入用户名和密码哦!"); return; } var vcdlg = new RequireVcDlg(_context); if (vcdlg.ShowDialog(this) != DialogResult.OK) { return; } var result = await _context.Session.LoginAsync(username, password, vcdlg.VerifyCode); if (result == null) { Close(); return; } EM("登录失败:" + result.Message); }
void Init() { this.btnSearch.Click += async(s, e) => { try { var info = await _context.UserService.GetUserInfo(txtUid.Text.Trim()); AppendLog(txtLog, info.ToString()); //var ctx = _context.Session.NetClient.Create<string>(HttpMethod.Get, ApiList.UserHomePage.FormatWith(txtUid.Text.Trim()), "https://www.mmbang.com/bang/1"); //await ctx.SendAsync(); //if (ctx.IsValid()) //{ // var doc = ctx.Result; // txtLog.Text = ctx.Result; //} } catch (Exception ex) { AppendLog(txtLog, ex.Message); } }; txtMsg.TextChanged += (s, e) => this.btnSend.Enabled = txtMsg.Text.Trim().Length > 4; btnSend.Click += async(s, e) => { try { var info = await _context.UserService.GetUserInfo(txtUid.Text.Trim()); var result = await _context.ActionService.SendMessage(info, txtMsg.Text); if (!result.success && result.verify_code_error > 0) //需要验证码 { var vcdlg = new RequireVcDlg(_context); if (vcdlg.ShowDialog(this) != DialogResult.OK) { return; } result = await _context.ActionService.SendMessage(info, txtMsg.Text, vcdlg.VerifyCode); } AppendLog(txtLog, result.success ? "发送成功(" + result.message + ")" : "发送失败:" + result.message); } catch (Exception ex) { AppendLog(txtLog, ex.Message); } }; }