/// <summary> /// 触发BeforeLogin事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (this.BeforeLogin != null) { this.BeforeLogin(sender, e); } }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.LibraryServerUrl = this.dp2library.Url; bool bIsReader = false; e.UserName = this.dp2library.UserName; e.Password = this.dp2library.Password; bIsReader = false; // e.Parameters = "location=" + strLocation; if (bIsReader == true) { e.Parameters += ",type=reader"; } // e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); e.Parameters += ",client=dp2capo|" + "0.01"; // +Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // TODO: 可以出现对话框,但要注意跨线程的问题 // TODO: 当首次登录对话框没有输入密码的时候,这里就必须出现对话框询问密码了 e.Cancel = true; }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.ManagerUserName; e.Password = this.ManagerPassword; e.Parameters = "location=z39.50 server manager,type=worker,client=dp2ZServer|0.01"; /* * e.IsReader = false; * e.Location = "z39.50 server manager"; * */ if (String.IsNullOrEmpty(e.UserName) == true) { e.ErrorInfo = "没有指定管理用户名,无法自动登录"; e.Failed = true; return; } return; } e.ErrorInfo = "z39.50 service first try失败后,无法自动登录"; e.Failed = true; return; }
public void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.textBox_dp2UserName.Text; e.Password = this.textBox_dp2Password.Text; e.Parameters = "location=#upgrade,type=worker"; e.Parameters += ",client=upgradedt1000todp2|0.01"; if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // IWin32Window owner = null; if (sender is IWin32Window) owner = (IWin32Window)sender; else owner = this; e.UserName = this.textBox_dp2UserName.Text; e.Password = this.textBox_dp2Password.Text; e.SavePasswordShort = true; e.Parameters = "location=#upgrade,type=worker"; e.Parameters += ",client=upgradedt1000todp2|0.01"; e.SavePasswordLong = true; e.LibraryServerUrl = this.textBox_dp2AsUrl.Text; }
void channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.SupervisorUserName; e.Password = this.SupervisorPassword; e.Parameters = "location=#setup,type=worker,client=dp2OPAC|0.01"; // 2016/5/6 加上 0.01 部分 if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // IWin32Window owner = null; if (sender is IWin32Window) { owner = (IWin32Window)sender; } else { owner = this; } CirculationLoginDlg dlg = new CirculationLoginDlg(); GuiUtil.AutoSetDefaultFont(dlg); // dlg.Text = ""; dlg.ServerUrl = this.textBox_dp2LibraryUrl.Text; dlg.Comment = e.ErrorInfo; dlg.UserName = e.UserName; dlg.SavePasswordShort = false; dlg.SavePasswordLong = false; dlg.Password = e.Password; dlg.IsReader = false; dlg.OperLocation = "#setup"; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(owner); if (dlg.DialogResult == DialogResult.Cancel) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = dlg.SavePasswordShort; e.Parameters = "location=#setup,type=worker,client=dp2OPAC|0.01"; // 2016/5/6 加上 0.01 部分 e.SavePasswordLong = dlg.SavePasswordLong; e.LibraryServerUrl = dlg.ServerUrl; this.SupervisorUserName = e.UserName; this.SupervisorPassword = e.Password; }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.LibraryServerUrl = Program.MainForm.LibraryServerUrl; bool bIsReader = false; e.UserName = Program.MainForm.AppInfo.GetString( "default_account", "username", ""); e.Password = Program.MainForm.AppInfo.GetString( "default_account", "password", ""); e.Password = Program.MainForm.DecryptPasssword(e.Password); bIsReader = Program.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); Debug.Assert(Program.MainForm != null, ""); string strLocation = Program.MainForm.AppInfo.GetString( "default_account", "location", ""); e.Parameters = "location=" + strLocation; if (bIsReader == true) { e.Parameters += ",type=reader"; } // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = Program.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) { e.Parameters += ",expire=" + strExpire; } #endif e.Parameters += ",client=dp2circulation|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // TODO: 可以出现对话框,但要注意跨线程的问题 // TODO: 当首次登录对话框没有输入密码的时候,这里就必须出现对话框询问密码了 e.Cancel = true; }
/// <summary> /// 按需登录事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { e.LibraryServerUrl = this.GetPurlUrl(this.Setting.Url); e.UserName = this.Setting.UserName; e.Password = this.Setting.Password; e.Parameters = "type=worker,client=dp2mini|" + ClientInfo.ClientVersion;//Program.ClientVersion; return; /* * if (e.FirstTry == true) * { * e.LibraryServerUrl = this.GetPurlUrl(this.Setting.Url); * e.UserName = this.Setting.UserName; * e.Password = this.Setting.Password; * e.Parameters = "type=worker,client=dp2mini|" + ClientInfo.ClientVersion;//Program.ClientVersion; * return; * } * * * * if (!string.IsNullOrEmpty(e.ErrorInfo)) * { * MessageBox.Show(this, e.ErrorInfo); * * } * * * IWin32Window owner = null; * if (sender is IWin32Window) * owner = sender as IWin32Window; * else * owner = this; * * LoginForm dlg = null; * this.Invoke((Action)(() => * { * dlg = SetDefaultAccount( * e.LibraryServerUrl, * owner); * })); * if (dlg == null) * { * e.Cancel = true; * return; * } * * e.LibraryServerUrl= this.GetPurlUrl(dlg.LibraryUrl); * e.UserName = dlg.Username; * e.Password = dlg.Password; * e.Parameters = "type=worker,client=dp2mini|" + ClientInfo.ClientVersion;//Program.ClientVersion; */ }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (string.IsNullOrEmpty(this.dp2Username)) { e.Cancel = true; e.ErrorInfo = "尚未登录"; } e.LibraryServerUrl = this.dp2ServerUrl; e.UserName = this.dp2Username; e.Parameters = "type=worker,client=dp2analysis|0.01"; e.Password = this.dp2Password; }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } e.UserName = this.Dp2UserName; e.Password = this.Dp2Password; e.Parameters = "location=#opac,type=worker,client=dp2OPAC|" + OpacApplication.ClientVersion; e.LibraryServerUrl = this.App.WsUrl; }
private void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = Properties.Settings.Default.cfg_library_username; e.Password = Properties.Settings.Default.cfg_library_password; if (!string.IsNullOrEmpty(e.UserName)) { return; } } if (!string.IsNullOrEmpty(e.ErrorInfo)) { MessageBox.Show(this, e.ErrorInfo); } IWin32Window owner = null; if (sender is IWin32Window) { owner = sender as IWin32Window; } else { owner = this; } LoginForm dlg = null; this.Invoke((Action)(() => { dlg = SetDefaultAccount( e.LibraryServerUrl, owner); })); if (dlg == null) { e.Cancel = true; return; } e.UserName = dlg.Username; e.Password = dlg.Password; e.Parameters = "type=worker,client=dp2Mini|" + Program.ClientVersion; }
// 重新登录 // parameters: // return: // -1 出错 // 0 成功 public int ReLogin(out string strError) { #if USE_SESSION_CHANNEL // 尽量用已有的设施实现功能 BeforeLoginEventArgs e = new BeforeLoginEventArgs(); e.FirstTry = true; Channel_BeforeLogin(this, e); // return: // -1 error // 0 登录未成功 // 1 登录成功 // >1 有多个账户符合条件。 long lRet = this.Channel.Login(e.UserName, e.Password, e.Parameters, out strError); if (lRet == -1 || lRet == 0) { return(-1); } return(0); #else LibraryChannel channel = this.GetChannel(true); // this.GetChannel(true, this.m_strParameters); try { // return: // -1 error // 0 登录未成功 // 1 登录成功 // >1 有多个账户符合条件。 long lRet = channel.Login(channel.UserName, channel.Password, this.m_strParameters, out strError); if (lRet == -1 || lRet == 0) { return(-1); } _rights = channel.Rights; return(0); } finally { this.ReturnChannel(channel); } #endif }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } e.UserName = m_strUserName; e.Password = m_strPassword; e.Parameters = ""; e.Parameters += ",client=dp2library|" + LibraryApplication.Version; e.LibraryServerUrl = m_strUrl; }
/// <summary> /// 自动登录,提供密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } // 我这里赋上通道自己的账号,而不是使用全局变量。 // 因为从池中征用通道后,都给通道设了密码。账号密码是通道的属性。 LibraryChannel channel = sender as LibraryChannel; e.LibraryServerUrl = channel.Url; e.UserName = channel.UserName; e.Password = channel.Password; e.Parameters = "client=ilovelibrary|1.0"; //todo 写到这里合适吗 }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } e.UserName = m_strUserName; e.Password = m_strPassword; if (string.IsNullOrEmpty(m_strParameters) == false) { e.Parameters = m_strParameters; // 2014/12/23 SSO Login 会这么用 } else { if (StringUtil.HasHead(m_strPassword, "token:") == true) { Hashtable parameters = new Hashtable(); parameters["index"] = "-1"; if (this.m_bIsReader == true) { parameters["type"] = "reader"; } parameters["simulate"] = "yes"; parameters["location"] = "#opac_token@" + this.ClientIP; parameters["client"] = "dp2OPAC|" + OpacApplication.ClientVersion; e.Parameters = StringUtil.BuildParameterString(parameters, ',', '='); // e.Parameters = "location=#opac_token@" + this.ClientIP + ",index=-1,type=reader,simulate=yes,libraryCode="; e.Password = this.App.ManagerUserName + "," + this.App.ManagerPassword + "|||" + m_strPassword; // simulate登录的需要 } else { e.Parameters = "location=#opac@" + this.ClientIP + ",client=dp2OPAC|" + OpacApplication.ClientVersion; if (m_bIsReader == true) { e.Parameters += ",type=reader,libraryCode="; // TODO: 可以用一个参数设定馆代码限制范围 } } } e.LibraryServerUrl = App.WsUrl; }
public void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.textBox_dp2UserName.Text; e.Password = this.textBox_dp2Password.Text; e.Parameters = "location=#upgrade,type=worker"; e.Parameters += ",client=upgradedt1000todp2|0.01"; if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // IWin32Window owner = null; if (sender is IWin32Window) { owner = (IWin32Window)sender; } else { owner = this; } e.UserName = this.textBox_dp2UserName.Text; e.Password = this.textBox_dp2Password.Text; e.SavePasswordShort = true; e.Parameters = "location=#upgrade,type=worker"; e.Parameters += ",client=upgradedt1000todp2|0.01"; e.SavePasswordLong = true; e.LibraryServerUrl = this.textBox_dp2AsUrl.Text; }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { Debug.Assert(_currentAccount != null, ""); if (IsDot(_currentAccount.ServerUrl) == true) { e.LibraryServerUrl = this.MainForm.LibraryServerUrl; } else { e.LibraryServerUrl = _currentAccount.ServerUrl; } bool bIsReader = false; if (IsDot(_currentAccount.UserName) == true) { e.UserName = this.MainForm.AppInfo.GetString( "default_account", "username", ""); e.Password = this.MainForm.AppInfo.GetString( "default_account", "password", ""); e.Password = this.MainForm.DecryptPasssword(e.Password); bIsReader = this.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); } else { e.UserName = _currentAccount.UserName; e.Password = _currentAccount.Password; bIsReader = string.IsNullOrEmpty(_currentAccount.IsReader) == true ? false : DomUtil.IsBooleanTrue(_currentAccount.IsReader); } #if NO if (IsDot(_currentAccount.IsReader) == true) { bIsReader = this.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); } else { bIsReader = DomUtil.IsBooleanTrue(_currentAccount.IsReader); } #endif Debug.Assert(this.MainForm != null, ""); string strLocation = this.MainForm.AppInfo.GetString( "default_account", "location", ""); e.Parameters = "location=" + strLocation; if (bIsReader == true) { e.Parameters += ",type=reader"; } // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = this.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) { e.Parameters += ",expire=" + strExpire; } #endif e.Parameters += ",client=dp2circulation|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // TODO: 可以出现对话框,但要注意跨线程的问题 e.Cancel = true; }
/// <summary> /// 通讯通道登录前被触发 /// </summary> /// <param name="sender">调用者</param> /// <param name="e">事件参数</param> public virtual void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { this.MainForm.Channel_BeforeLogin(sender, e); // 2015/11/4 原来是 this }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this._userName; e.Password = this._password; e.Parameters = "location=z39.50 server, type=worker,client=dp2ZServer|0.01"; /* e.IsReader = false; e.Location = "z39.50 server"; * */ if (String.IsNullOrEmpty(e.UserName) == true) { e.ErrorInfo = "没有指定用户名,无法自动登录"; e.Failed = true; return; } return; } e.ErrorInfo = "first try失败后,无法自动登录"; e.Failed = true; return; }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.LibraryServerUrl = this.MainForm.LibraryServerUrl; bool bIsReader = false; e.UserName = this.MainForm.AppInfo.GetString( "default_account", "username", ""); e.Password = this.MainForm.AppInfo.GetString( "default_account", "password", ""); e.Password = this.MainForm.DecryptPasssword(e.Password); bIsReader = this.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); Debug.Assert(this.MainForm != null, ""); string strLocation = this.MainForm.AppInfo.GetString( "default_account", "location", ""); e.Parameters = "location=" + strLocation; if (bIsReader == true) e.Parameters += ",type=reader"; // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = this.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) e.Parameters += ",expire=" + strExpire; #endif e.Parameters += ",client=dp2circulation|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // TODO: 可以出现对话框,但要注意跨线程的问题 // TODO: 当首次登录对话框没有输入密码的时候,这里就必须出现对话框询问密码了 e.Cancel = true; }
void MyBeforeLogin(object sender, BeforeLoginEventArgs e) { // 只有当代理帐户有密码的时候,才进行第一次试探 if (e.FirstTry == true && string.IsNullOrEmpty(this.MainForm.FingerprintPassword) == false) { e.UserName = this.MainForm.FingerprintUserName; e.Password = this.MainForm.FingerprintPassword; bool bIsReader = false; // 工作人员方式 string strLocation = this.MainForm.AppInfo.GetString( "default_account", "location", ""); // 工作台号和缺省帐户一致 e.Parameters = "location=" + strLocation; if (bIsReader == true) e.Parameters += ",type=reader"; if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // IWin32Window owner = null; if (sender is IWin32Window) owner = (IWin32Window)sender; else owner = this; string strComment = "为初始化指纹缓存,需要用户 "+this.MainForm.FingerprintUserName+" 亲自进行登录"; CirculationLoginDlg dlg = SetFingerprintAccount( e.LibraryServerUrl, strComment, string.IsNullOrEmpty(e.ErrorInfo) == false ? e.ErrorInfo : strComment, e.LoginFailCondition, owner); if (dlg == null) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = dlg.SavePasswordShort; e.Parameters = "location=" + dlg.OperLocation; if (dlg.IsReader == true) e.Parameters += ",type=reader"; e.SavePasswordLong = dlg.SavePasswordLong; e.LibraryServerUrl = dlg.ServerUrl; }
private void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { throw new NotImplementedException(); }
void Channels_BeforeLogin(object sender, BeforeLoginEventArgs e) { LibraryChannel channel = (LibraryChannel)sender; dp2Server server = this.MainForm.Servers[channel.Url]; if (server == null) { e.ErrorInfo = "没有找到 URL 为 " + channel.Url + " 的服务器对象"; e.Failed = true; e.Cancel = true; return; } if (e.FirstTry == true) { e.UserName = server.DefaultUserName; e.Password = server.DefaultPassword; e.Parameters = "location=dp2Catalog,type=worker"; /* e.IsReader = false; e.Location = "dp2Catalog"; * */ // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = this.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) e.Parameters += ",expire=" + strExpire; #endif e.Parameters += ",client=dp2catalog|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // IWin32Window owner = this; ServerDlg dlg = SetDefaultAccount( e.LibraryServerUrl, null, e.ErrorInfo, owner); if (dlg == null) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = false; e.Parameters = "location=dp2Catalog,type=worker"; e.Parameters += ",client=dp2catalog|" + Program.ClientVersion; /* e.IsReader = false; e.Location = "dp2Catalog"; * */ e.SavePasswordLong = true; e.LibraryServerUrl = dlg.ServerUrl; }
// 重新登录 // parameters: // return: // -1 出错 // 0 成功 public int ReLogin(out string strError) { // 尽量用已有的设施实现功能 BeforeLoginEventArgs e = new BeforeLoginEventArgs(); e.FirstTry = true; Channel_BeforeLogin(this, e); // return: // -1 error // 0 登录未成功 // 1 登录成功 // >1 有多个账户符合条件。 long lRet = this.Channel.Login(e.UserName, e.Password, e.Parameters, out strError); if (lRet == -1 || lRet == 0) return -1; return 0; }
void Channels_BeforeLogin(object sender, BeforeLoginEventArgs e) { LibraryChannel channel = (LibraryChannel)sender; dp2Server server = this.MainForm.Servers[channel.Url]; if (server == null) { e.ErrorInfo = "没有找到 URL 为 " + channel.Url + " 的服务器对象"; e.Failed = true; e.Cancel = true; return; } if (e.FirstTry == true) { e.UserName = server.DefaultUserName; e.Password = server.DefaultPassword; e.Parameters = "location=dp2Catalog,type=worker"; /* * e.IsReader = false; * e.Location = "dp2Catalog"; * */ // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = this.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) { e.Parameters += ",expire=" + strExpire; } #endif e.Parameters += ",client=dp2catalog|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // IWin32Window owner = this; ServerDlg dlg = SetDefaultAccount( e.LibraryServerUrl, null, e.ErrorInfo, owner); if (dlg == null) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = false; e.Parameters = "location=dp2Catalog,type=worker"; e.Parameters += ",client=dp2catalog|" + Program.ClientVersion; /* * e.IsReader = false; * e.Location = "dp2Catalog"; * */ e.SavePasswordLong = true; e.LibraryServerUrl = dlg.ServerUrl; }
/* void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { this.MainForm.Channel_BeforeLogin(this, e); }*/ /// <summary> /// 重载的 Channel_BeforeLogin() /// </summary> /// <param name="sender">发送者</param> /// <param name="e">事件参数</param> public override void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (this.FingerPrintMode == false) base.Channel_BeforeLogin(this, e); else { if (string.IsNullOrEmpty(this.MainForm.FingerprintUserName) == false && this.MainForm.FingerprintUserName != this.MainForm.DefaultUserName) MyBeforeLogin(this, e); else base.Channel_BeforeLogin(this, e); } }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { Program.MainForm.Channel_BeforeLogin(sender, e); // 2015/11/8 }
void channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.SupervisorUserName; e.Password = this.SupervisorPassword; e.Parameters = "location=#setup,type=worker,client=dp2OPAC|0.01"; // 2016/5/6 加上 0.01 部分 if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // IWin32Window owner = null; if (sender is IWin32Window) owner = (IWin32Window)sender; else owner = this; CirculationLoginDlg dlg = new CirculationLoginDlg(); GuiUtil.AutoSetDefaultFont(dlg); // dlg.Text = ""; dlg.ServerUrl = this.textBox_dp2LibraryUrl.Text; dlg.Comment = e.ErrorInfo; dlg.UserName = e.UserName; dlg.SavePasswordShort = false; dlg.SavePasswordLong = false; dlg.Password = e.Password; dlg.IsReader = false; dlg.OperLocation = "#setup"; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(owner); if (dlg.DialogResult == DialogResult.Cancel) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = dlg.SavePasswordShort; e.Parameters = "location=#setup,type=worker,client=dp2OPAC|0.01"; // 2016/5/6 加上 0.01 部分 e.SavePasswordLong = dlg.SavePasswordLong; e.LibraryServerUrl = dlg.ServerUrl; this.SupervisorUserName = e.UserName; this.SupervisorPassword = e.Password; }
/// <summary> /// 自动登录,提供密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } // 我这里赋上通道自己的账号,而不是使用全局变量。 // 因为从池中征用通道后,都给通道设了密码。账号密码是通道的属性。 LibraryChannel channel = sender as LibraryChannel; e.LibraryServerUrl = channel.Url; e.UserName = channel.UserName; e.Password = channel.Password; }
void ChannelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } LibraryChannel channel = sender as LibraryChannel; if (StringUtil.HasHead(channel.Password, "token:") == true) { Hashtable parameters = new Hashtable(); if (channel.Param is string) { parameters = StringUtil.ParseParameters((string)channel.Param, ',', '='); } parameters["index"] = "-1"; #if NO if (parameters.ContainsKey("type") == false) parameters["type"] = "reader"; #endif parameters["simulate"] = "yes"; e.UserName = channel.UserName; e.Parameters = StringUtil.BuildParameterString(parameters, ',', '='); e.Password = this.ManagerUserName + "," + this.ManagerPassword + "|||" + channel.Password; // simulate登录的需要 } else { e.UserName = channel.UserName; e.Password = channel.Password; e.LibraryServerUrl = channel.Url; #if NO if (channel.Tag is string) e.Parameters = (string)channel.Tag; #endif if (channel.Param is string) e.Parameters = (string)channel.Param; } }
public void ChannelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } LibraryChannel channel = sender as LibraryChannel; // 2016/1/25 if (string.IsNullOrEmpty(channel.UserName) == true) throw new Exception("ChannelPool_BeforeLogin() channel.UserName is null"); if (channel.UserName == this.ManagerUserName) { e.UserName = channel.UserName; e.Password = channel.Password; e.LibraryServerUrl = channel.Url; e.Parameters = "client=dp2OPAC|" + OpacApplication.ClientVersion; #if NO if (channel.Param is string) e.Parameters = (string)channel.Param; #endif return; } if (StringUtil.HasHead(channel.Password, "token:") == true) { Hashtable parameters = new Hashtable(); if (channel.Param is string) { parameters = StringUtil.ParseParameters((string)channel.Param, ',', '='); } parameters["client"] = "dp2OPAC|" + OpacApplication.ClientVersion; parameters["index"] = "-1"; #if NO if (parameters.ContainsKey("type") == false) parameters["type"] = "reader"; #endif parameters["simulate"] = "yes"; e.UserName = channel.UserName; e.Parameters = StringUtil.BuildParameterString(parameters, ',', '='); e.Password = this.ManagerUserName + "," + this.ManagerPassword + "|||" + channel.Password; // simulate登录的需要 } else { e.UserName = channel.UserName; e.Password = channel.Password; e.LibraryServerUrl = channel.Url; #if NO if (channel.Tag is string) e.Parameters = (string)channel.Tag; #endif if (channel.Param is string) e.Parameters = (string)channel.Param; } }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { Debug.Assert(_currentAccount != null, ""); if (IsDot(_currentAccount.ServerUrl) == true) e.LibraryServerUrl = this.MainForm.LibraryServerUrl; else e.LibraryServerUrl = _currentAccount.ServerUrl; bool bIsReader = false; if (IsDot(_currentAccount.UserName) == true) { e.UserName = this.MainForm.AppInfo.GetString( "default_account", "username", ""); e.Password = this.MainForm.AppInfo.GetString( "default_account", "password", ""); e.Password = this.MainForm.DecryptPasssword(e.Password); bIsReader = this.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); } else { e.UserName = _currentAccount.UserName; e.Password = _currentAccount.Password; bIsReader = string.IsNullOrEmpty(_currentAccount.IsReader) == true ? false : DomUtil.IsBooleanTrue(_currentAccount.IsReader); } #if NO if (IsDot(_currentAccount.IsReader) == true) bIsReader = this.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); else bIsReader = DomUtil.IsBooleanTrue(_currentAccount.IsReader); #endif Debug.Assert(this.MainForm != null, ""); string strLocation = this.MainForm.AppInfo.GetString( "default_account", "location", ""); e.Parameters = "location=" + strLocation; if (bIsReader == true) e.Parameters += ",type=reader"; // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = this.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) e.Parameters += ",expire=" + strExpire; #endif if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // TODO: 可以出现对话框,但要注意跨线程的问题 e.Cancel = true; }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == false) { e.Cancel = true; return; } e.UserName = m_strUserName; e.Password = m_strPassword; if (string.IsNullOrEmpty(m_strParameters) == false) e.Parameters = m_strParameters; // 2014/12/23 SSO Login 会这么用 else { if (StringUtil.HasHead(m_strPassword, "token:") == true) { Hashtable parameters = new Hashtable(); parameters["index"] = "-1"; if (this.m_bIsReader == true) parameters["type"] = "reader"; parameters["simulate"] = "yes"; parameters["location"] = "#opac_token@" + this.ClientIP; parameters["client"] = "dp2OPAC|" + OpacApplication.ClientVersion; e.Parameters = StringUtil.BuildParameterString(parameters, ',', '='); // e.Parameters = "location=#opac_token@" + this.ClientIP + ",index=-1,type=reader,simulate=yes,libraryCode="; e.Password = this.App.ManagerUserName + "," + this.App.ManagerPassword + "|||" + m_strPassword; // simulate登录的需要 } else { e.Parameters = "location=#opac@" + this.ClientIP + ",client=dp2OPAC|" + OpacApplication.ClientVersion; if (m_bIsReader == true) e.Parameters += ",type=reader,libraryCode="; // TODO: 可以用一个参数设定馆代码限制范围 } } e.LibraryServerUrl = App.WsUrl; }
public void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.MainForm.AppInfo.GetString( "default_account", "username", ""); e.Password = this.MainForm.AppInfo.GetString( "default_account", "password", ""); e.Password = this.DecryptPasssword(e.Password); e.IsReader = this.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); e.Location = this.MainForm.AppInfo.GetString( "default_account", "location", ""); if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } // IWin32Window owner = null; if (sender is Form) owner = (Form)sender; else owner = this; CirculationLoginDlg dlg = SetDefaultAccount( e.CirculationServerUrl, null, e.ErrorInfo, owner); if (dlg == null) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = dlg.SavePasswordShort; e.IsReader = dlg.IsReader; e.Location = dlg.OperLocation; e.SavePasswordLong = dlg.SavePasswordLong; e.CirculationServerUrl = dlg.ServerUrl; }
// 重新登录 // parameters: // return: // -1 出错 // 0 成功 public int ReLogin(out string strError) { #if USE_SESSION_CHANNEL // 尽量用已有的设施实现功能 BeforeLoginEventArgs e = new BeforeLoginEventArgs(); e.FirstTry = true; Channel_BeforeLogin(this, e); // return: // -1 error // 0 登录未成功 // 1 登录成功 // >1 有多个账户符合条件。 long lRet = this.Channel.Login(e.UserName, e.Password, e.Parameters, out strError); if (lRet == -1 || lRet == 0) return -1; return 0; #else LibraryChannel channel = this.GetChannel(true); // this.GetChannel(true, this.m_strParameters); try { // return: // -1 error // 0 登录未成功 // 1 登录成功 // >1 有多个账户符合条件。 long lRet = channel.Login(channel.UserName, channel.Password, this.m_strParameters, out strError); if (lRet == -1 || lRet == 0) return -1; _rights = channel.Rights; return 0; } finally { this.ReturnChannel(channel); } #endif }
void Channels_BeforeLogin(object sender, BeforeLoginEventArgs e) { this.MainForm.Channel_BeforeLogin(sender, e); // 2015/11/8 }
void Channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { this.MainForm.Channel_BeforeLogin(this, e); }
void _channelPool_BeforeLogin(object sender, BeforeLoginEventArgs e) { bool bIsReader = false; if (e.FirstTry == true) { Debug.Assert(_currentAccount != null, ""); if (IsDot(_currentAccount.ServerUrl) == true) { e.LibraryServerUrl = Program.MainForm.LibraryServerUrl; } else { e.LibraryServerUrl = _currentAccount.ServerUrl; } if (IsDot(_currentAccount.UserName) == true) { e.UserName = Program.MainForm.AppInfo.GetString( "default_account", "username", ""); e.Password = Program.MainForm.AppInfo.GetString( "default_account", "password", ""); e.Password = Program.MainForm.DecryptPasssword(e.Password); bIsReader = Program.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); } else { e.UserName = _currentAccount.UserName; e.Password = _currentAccount.Password; bIsReader = string.IsNullOrEmpty(_currentAccount.IsReader) == true ? false : DomUtil.IsBooleanTrue(_currentAccount.IsReader); } #if NO if (IsDot(_currentAccount.IsReader) == true) { bIsReader = Program.MainForm.AppInfo.GetBoolean( "default_account", "isreader", false); } else { bIsReader = DomUtil.IsBooleanTrue(_currentAccount.IsReader); } #endif Debug.Assert(Program.MainForm != null, ""); string strLocation = Program.MainForm.AppInfo.GetString( "default_account", "location", ""); e.Parameters = "location=" + strLocation; if (bIsReader == true) { e.Parameters += ",type=reader"; } // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); #if SN // 从序列号中获得 expire= 参数值 string strExpire = Program.MainForm.GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) { e.Parameters += ",expire=" + strExpire; } #endif e.Parameters += ",client=dp2circulation|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // TODO: 可以出现对话框,但要注意跨线程的问题 DialogResult result = (DialogResult)Program.MainForm.Invoke((Func <DialogResult>)(() => { using (LoginDlg dlg = new LoginDlg()) { Hashtable table = StringUtil.ParseParameters(e.Parameters, ',', '='); string type = (string)table["type"]; bIsReader = type == "reader"; // TODO: Url 不让修改 dlg.UserName = bIsReader ? "~" + e.UserName : e.UserName; dlg.Comment = e.ErrorInfo; dlg.SavePassword = e.SavePasswordLong; dlg.ServerUrl = e.LibraryServerUrl; dlg.ShowDialog(Program.MainForm); if (dlg.DialogResult == DialogResult.OK) { if (dlg.UserName.StartsWith("~")) { e.UserName = dlg.UserName.Substring(1); bIsReader = true; } else { e.UserName = dlg.UserName; bIsReader = false; } e.Password = dlg.Password; e.SavePasswordLong = dlg.SavePassword; // 同步到当前账户 if (IsDot(_currentAccount.UserName) == false) { _currentAccount.UserName = e.UserName; _currentAccount.Password = e.Password; _currentAccount.IsReader = bIsReader ? "yes" : "no"; } // 长期保存密码,写回到 servers.xml 中 if (e.SavePasswordLong) { // 保存对账户的修改 var changed = SaveAccountInfo(this._servers_dom, _currentAccount); if (changed == true) { this.ServersDomChanged = true; } } table["type"] = bIsReader ? "reader" : "worker"; e.Parameters = StringUtil.BuildParameterString(table, ',', '='); } return(dlg.DialogResult); } })); if (result == DialogResult.Cancel) { e.Cancel = true; return; } }