void RmsChannels_AskAccountInfo(object sender, AskAccountInfoEventArgs e) { e.Owner = null; /// e.UserName = this.Dp2UserName; e.Password = this.Dp2Password; e.Result = 1; }
void channels_AskAccountInfo(object sender, AskAccountInfoEventArgs e) { e.Owner = this; LoginDlg dlg = new LoginDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.textBox_serverAddr.Text = this.textBox_kernelUrl.Text; dlg.textBox_serverAddr.ReadOnly = true; dlg.textBox_comment.Text = e.Comment; dlg.textBox_userName.Text = this.ManagerUserName; dlg.textBox_password.Text = this.ManagerPassword; dlg.checkBox_savePassword.Checked = this.SavePassword; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { e.Result = 0; return; } this.ManagerPassword = dlg.textBox_userName.Text; if (dlg.checkBox_savePassword.Checked == true) { this.ManagerPassword = dlg.textBox_password.Text; } else { this.ManagerPassword = ""; } e.UserName = dlg.textBox_userName.Text; e.Password = dlg.textBox_password.Text; e.Result = 1; }
void channels_AskAccountInfo(object sender, AskAccountInfoEventArgs e) { e.Owner = this; LoginDlg dlg = new LoginDlg(); dlg.textBox_serverAddr.Text = this.textBox_dp2LibraryUrl.Text; dlg.textBox_serverAddr.ReadOnly = true; dlg.textBox_comment.Text = e.Comment; dlg.textBox_userName.Text = this.ManagerUserName; dlg.textBox_password.Text = this.ManagerPassword; dlg.checkBox_savePassword.Checked = this.SavePassword; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { e.Result = 0; return; } this.ManagerPassword = dlg.textBox_userName.Text; if (dlg.checkBox_savePassword.Checked == true) this.ManagerPassword = dlg.textBox_password.Text; else this.ManagerPassword = ""; e.UserName = dlg.textBox_userName.Text; e.Password = dlg.textBox_password.Text; e.Result = 1; }
// 登录。如果必要,出现对话框 // parameters: // strPath 资源路径。不包含URL部分。 // bAutoLogin 是否不出现对话框先自动登录一次。 // return: // -1 error // 0 login failed,出错信息在strError中 // 1 login succeed public int UiLogin( string strComment, string strPath, LoginStyle loginStyle, out string strError) { strError = ""; string strUserName; string strPassword; IWin32Window owner = null; REDOINPUT: // 获得缺省帐户信息 // return: // 2 already login succeed // 1 dialog return OK // 0 dialog return Cancel // -1 other error /* int nRet = this.Container.procAskAccountInfo( this.Container, strComment, this.Url, strPath, loginStyle, out owner, out strUserName, out strPassword); */ AskAccountInfoEventArgs e = new AskAccountInfoEventArgs(); e.Channels = this.Container; e.Comment = strComment; e.Url = this.Url; e.Path = strPath; e.LoginStyle = loginStyle; e.Channel = this; // 2013/2/14 this.Container.OnAskAccountInfo(this, e); owner = e.Owner; strUserName = e.UserName; strPassword = e.Password; if (e.Result == -1) { if (e.ErrorInfo == "") strError = "procAskAccountInfo() error"; else strError = e.ErrorInfo; return -1; } if (e.Result == 2) return 1; if (e.Result == 1) { // 登录 // return: // -1 出错。错误信息在strError中 // 0 登录失败。错误信息也在strError // 1 登录成功 int nRet = this.Login(strUserName, strPassword, out strError); if (nRet == -1) return -1; if (nRet == 0) { if (this.Container.GUI == true) MessageBox.Show(owner, strError); else { return -1; } goto REDOINPUT; } // this.m_nRedoCount = 0; return 1; // 登录成功,可以重做API功能了 } if (e.Result == 0) { strError = "放弃登录"; return -1; } strError = "UiLogin() 不应该走到这里"; return -1; }