// GCAT通道登录 旧的方式 public void gcat_channel_BeforeLogin(object sender, DigitalPlatform.GcatClient.BeforeLoginEventArgs e) { string strUserName = (string)this.DetailForm.MainForm.ParamTable["author_number_account_username"]; string strPassword = (string)this.DetailForm.MainForm.ParamTable["author_number_account_password"]; if (String.IsNullOrEmpty(strUserName) == true) { strUserName = "******"; strPassword = ""; } // 直接试探 if (!(e.UserName == strUserName && e.Failed == true) && strUserName != "") { e.UserName = strUserName; e.Password = strPassword; return; } LoginDlg dlg = new LoginDlg(); GuiUtil.SetControlFont(dlg, this.DetailForm.MainForm.Font); if (e.Failed == true) { dlg.textBox_comment.Text = "登录失败。加著者号码功能需要重新登录"; } else { dlg.textBox_comment.Text = "加著者号码功能需要登录"; } dlg.textBox_serverAddr.Text = e.GcatServerUrl; dlg.textBox_userName.Text = strUserName; dlg.textBox_password.Text = strPassword; dlg.checkBox_savePassword.Checked = true; dlg.textBox_serverAddr.Enabled = false; dlg.TopMost = true; // 2009/11/12 因为ShowDialog(null),为了防止对话框被放在非顶部 dlg.ShowDialog(null); if (dlg.DialogResult != DialogResult.OK) { e.Cancel = true; // 2009/11/12 如果缺这一句,会造成Cancel后仍然重新弹出登录对话框 return; } strUserName = dlg.textBox_userName.Text; strPassword = dlg.textBox_password.Text; e.UserName = strUserName; e.Password = strPassword; this.DetailForm.MainForm.ParamTable["author_number_account_username"] = strUserName; this.DetailForm.MainForm.ParamTable["author_number_account_password"] = strPassword; }
// 处理登录事宜 // 2007/6/29 int DoNotLogin(ref string strError) { if (this.BeforeLogin != null) { BeforeLoginEventArgs newargs = new BeforeLoginEventArgs(); newargs.GcatServerUrl = this.Url; REDOLOGIN: this.BeforeLogin(this, newargs); if (newargs.Cancel == true) { strError = "用户放弃"; return(-1); } if (newargs.UserName == "") { strError = "UserName不能为空"; return(-1); } int nRet = Login(newargs.UserName, newargs.Password, out strError); if (nRet != 1) { newargs.Failed = true; if (newargs.SavePassword == false) { newargs.Password = ""; } goto REDOLOGIN; } return(1); // 登录成功,可以重做API功能了 } return(-1); }
// 处理登录事宜 // 2007/6/29 int DoNotLogin(ref string strError) { if (this.BeforeLogin != null) { BeforeLoginEventArgs newargs = new BeforeLoginEventArgs(); newargs.GcatServerUrl = this.Url; REDOLOGIN: this.BeforeLogin(this, newargs); if (newargs.Cancel == true) { strError = "用户放弃"; return -1; } if (newargs.UserName == "") { strError = "UserName不能为空"; return -1; } int nRet = Login(newargs.UserName, newargs.Password, out strError); if (nRet != 1) { newargs.Failed = true; if (newargs.SavePassword == false) newargs.Password = ""; goto REDOLOGIN; } return 1; // 登录成功,可以重做API功能了 } return -1; }
// return: // -2 尚未登录 // -1 出错 // 0 成功 public int GetNumber(string strAuthor, bool bSelectPinyin, bool bSelectEntry, bool bOutputDebugInfo, out string strNumber, out string strDebugInfo, out string strError) { REDO: int nRet = ws.GetNumber(strAuthor, bSelectPinyin, bSelectEntry, bOutputDebugInfo, out strNumber, out strDebugInfo, out strError); if (nRet == -2) { if (this.BeforeLogin == null) return -2; BeforeLoginEventArgs newargs = new BeforeLoginEventArgs(); newargs.GcatServerUrl = this.Url; REDOLOGIN: this.BeforeLogin(this, newargs); if (newargs.Cancel == true) { strError = "用户放弃"; return -1; } if (newargs.UserName == "") { strError = "UserName不能为空"; return -1; } nRet = Login(newargs.UserName, newargs.Password, out strError); if (nRet != 1) { newargs.Failed = true; if (newargs.SavePassword == false) newargs.Password = ""; goto REDOLOGIN; /* if (nRet == 0) { return -1; } return nRet; */ } goto REDO; } return nRet; }
// return: // -2 尚未登录 // -1 出错 // 0 成功 public int GetNumber(string strAuthor, bool bSelectPinyin, bool bSelectEntry, bool bOutputDebugInfo, out string strNumber, out string strDebugInfo, out string strError) { REDO: int nRet = ws.GetNumber(strAuthor, bSelectPinyin, bSelectEntry, bOutputDebugInfo, out strNumber, out strDebugInfo, out strError); if (nRet == -2) { if (this.BeforeLogin == null) { return(-2); } BeforeLoginEventArgs newargs = new BeforeLoginEventArgs(); newargs.GcatServerUrl = this.Url; REDOLOGIN: this.BeforeLogin(this, newargs); if (newargs.Cancel == true) { strError = "用户放弃"; return(-1); } if (newargs.UserName == "") { strError = "UserName不能为空"; return(-1); } nRet = Login(newargs.UserName, newargs.Password, out strError); if (nRet != 1) { newargs.Failed = true; if (newargs.SavePassword == false) { newargs.Password = ""; } goto REDOLOGIN; /* * if (nRet == 0) * { * return -1; * } * return nRet; */ } goto REDO; } return(nRet); }