public List <SinoMenuItem> GetAllMenus(string _postID) { SinoSZTicketInfo _currentUserInfo = CallContext.GetData("UserIdentity") as SinoSZTicketInfo; string _logonName = _currentUserInfo.Name; SinoUser _userinfo = LogonUserLib.GetUserInfo(_logonName); bool _find = false; foreach (SinoPost _sp in _userinfo.Posts) { if (_sp.PostID == _postID) { _find = true; break; } } if (_find) { return(MenuFactory.GetAllMenus(_postID)); } else { throw new Exception("用户不具有此岗位授权!"); } return(null); }
public SinoUser LoginSys(string _sysid, string _name, string _pass, string CheckType) { try { SinoUser _ret = AuthorizeFactory.LoginSys(_sysid, _name, _pass, CheckType); UserLogWriter.WriteLog(decimal.Parse(_ret.UserID), "系统登录", string.Format("用户{0}(登录名{1})使用CS客户端用登录系统成功!", _ret.UserName, _name), 1, _ret.IPAddress, _ret.HostName, _ret.SystemID); return(_ret); } catch (Exception e) { string _ipaddr = CallContext.GetData("ClientIP").ToString(); string _hostName = ""; try { _hostName = Dns.GetHostEntry(_ipaddr).HostName; } catch { _hostName = _ipaddr; } UserLogWriter.WriteLog(-1, "系统登录", string.Format("未知用户{0}(登录名{1})使用CS客户端用登录系统失败!失败信息:{2}", _name, _name, e.Message), 2, _ipaddr, _hostName, _sysid); return(null); } }
/// <summary> /// 通过用户ID取用户简单信息 /// </summary> /// <param name="_yhid"></param> /// <returns></returns> public static SinoUser GetSimpleUserInfoByYHID(string _yhid) { SinoUser _su = new SinoUser(); string _select1 = string.Format("SELECT a.yhm,a.dwid,a.xm,b.xdjb,b.aqjb,zhtj_zzjg2.GETDWDM_hgjs(a.dwid) dwdm,(select jgqc from qx2_zzjg c where c.zzjgid = a.dwid) DWMC FROM qx2_yhxx a ,qx_tjyhb b where a.yhid = b.yhid and a.yhid={0} ", _yhid); DataTable _yhdt = SqlHelper.Get_Data(_select1, "YHTABLE"); if (_yhdt.Rows.Count < 1) { //为未注册用户 //return GetNoRegistUser(_yhid); throw new Exception(string.Format("用户尚未在系统中注册!")); } DataRow _dr = _yhdt.Rows[0]; _su.LoginName = _dr["YHM"].ToString(); _su.Dwdm = _dr["DWDM"].ToString(); _su.DwID = _dr["DWID"].ToString(); _su.DwName = _dr["DWMC"].ToString(); _su.UserID = _yhid; _su.UserName = _dr["XM"].ToString(); _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString()); string _xdjb = _dr["XDJB"].ToString(); _su.QxszJB = _xdjb; return(_su); }
public SinoUser LoginSys(string SystemID, string UserName, string Password, string CheckType) { try { OraAuthorizeFactroy _of = new OraAuthorizeFactroy(); _su = _of.LoginSys(SystemID, UserName, Password, CheckType); //LogWriter(decimal.Parse(_su.UserID), "系统登录(执法办案平台CS客户端)", string.Format("用户{0}登录执法办案平台CS客户端成功!", UserName), // 1, _su.IPAddress, _su.HostName, SystemID); LogWriter.WriteSystemLog("登录成功!", "Info"); return(_su); } catch (Exception ex) { string _ipaddr = WCFClientInfo.IPAddr; string _hostName = ""; try { _hostName = Dns.GetHostEntry(_ipaddr).HostName; } catch { _hostName = _ipaddr; } //SystemLogWriter.WriteUserLog(-1, "系统登录(执法办案平台CS客户端)", string.Format("用户{0}登录执法办案平台CS客户端失败!", UserName), // 2, _ipaddr, _hostName, SystemID); return(null); } }
/// <summary> /// 获取超级管理员信息 /// </summary> /// <returns></returns> public static SinoUser GetAdminInfo() { SinoUser _su = new SinoUser(); _su.LoginName = "administrator"; _su.Dwdm = ""; _su.DwID = ""; _su.DwName = ""; _su.UserID = "0"; _su.UserName = "******"; _su.SecretLevel = 1000; _su.QxszJB = "直属海关级"; _su.Posts = new List <SinoPost>(); SinoPost _adminPost = new SinoPost(); _adminPost.PostID = "0"; _adminPost.PostName = "超级管理员"; _adminPost.PostDwID = ConfigFile.SytemDWRootID; _adminPost.Rights = new Dictionary <string, UserRightItem>(); StringBuilder _sb = new StringBuilder(); _sb.Append("SELECT dbo.GETDWDM_hgjs(@DWID) dwdm,dbo.GETDWMC(@DWID2) DWMC "); //_sb.Append("FROM DUAL "); SqlParameter[] _param = { new SqlParameter("@DWID", SqlDbType.Decimal), new SqlParameter("@DWID2", SqlDbType.Decimal), }; _param[0].Value = decimal.Parse(_adminPost.PostDwID); _param[1].Value = decimal.Parse(_adminPost.PostDwID); SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringProfile, CommandType.Text, _sb.ToString(), _param); while (dr.Read()) { _adminPost.PostDWDM = dr.IsDBNull(0) ? "" : dr.GetString(0); _adminPost.PostDWMC = dr.IsDBNull(1) ? "" : dr.GetString(1); } dr.Close(); //取权限 DataTable _dt = GetUserRightsByYHID(_su.UserID, ""); foreach (DataRow _row in _dt.Rows) { UserRightItem _rightItem = RightFunctions.CreateUserRightItem(_row); _adminPost.Rights.Add(_rightItem.Right.RightID, _rightItem); } _adminPost.SecretLevel = 1000; _su.Posts.Add(_adminPost); _su.DefaultPost = _adminPost; _su.CurrentPost = _adminPost; return(_su); }
public static SinoUser GetNoRegisterUserByUserID(decimal _yhid) { SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { try { StringBuilder _sb = new StringBuilder(); _sb.Append(" select yh.YHM,yh.YHID,yh.XM,jg.ZZJGID DWID,jg.ZZJGDM DWDM ,jg.JGQC DWMC from yw_qd_hbryxx hb "); _sb.Append(" join QX2_HGJG jg on hb.PARENT_GUID= jg.DWGUID "); _sb.Append(" join qx2_hgyh yh on hb.GUID=yh.YHGUID "); _sb.Append(" where yh.YHID=:YHID and ROWNUM=1 "); SqlCommand _cmd = new SqlCommand(_sb.ToString(), cn); _cmd.Parameters.Add(":YHID", _yhid); SqlDataReader dr = _cmd.ExecuteReader(); while (dr.Read()) { _su.LoginName = dr.IsDBNull(0) ? "" : dr.GetString(0); _su.IsSignOn = true; _su.Dwdm = dr.IsDBNull(4) ? "" : dr.GetString(4); _su.DwID = dr.IsDBNull(3) ? "" : dr.GetDecimal(3).ToString(); _su.DwName = dr.IsDBNull(5) ? "" : dr.GetString(5); _su.UserID = dr.IsDBNull(1) ? "" : dr.GetDecimal(1).ToString(); _su.UserName = dr.IsDBNull(2) ? "" : dr.GetString(2); _su.SecretLevel = 0; _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 } } catch (Exception ex) { SystemLogWriter.WriteLog(string.Format("通用YHID取非注册用户信息失败!YHID={0} 错误信息:{1}", _yhid, ex.Message), EventLogEntryType.Error); throw; } try { //取岗位信息 _su.Posts = new List <SinoPost>(); SinoPost _sp = new SinoPost("未注册用户岗位", "-1", _su.DwID, _su.DwName, _su.Dwdm, "未注册用户岗位", 0, true); _su.Posts.Add(_sp); _sp.Rights = C_GetGWInfo.GetRightsOfPost("-1", ""); _su.DefaultPost = _sp; _su.CurrentPost = _sp; } catch (Exception ex) { SystemLogWriter.WriteLog(string.Format("通用YHID取非注册用户岗位信息失败!YHID={0} 错误信息:{1}", _yhid, ex.Message), EventLogEntryType.Error); throw; } cn.Close(); } return(_su); }
static public SinoUser GetCurrentUser(string _ticket) { using (TokenService.TokenServiceClient _tsc = new TokenService.TokenServiceClient()) { byte[] _subytes = _tsc.GetCurrentUser(_ticket); Stream _str = new MemoryStream(_subytes); IFormatter formatter = new BinaryFormatter(); SinoUser _ret = (SinoUser)formatter.Deserialize(_str); return(_ret); } }
static public bool InsertTicket(string _ticket, SinoUser _su) { using (TokenService.TokenServiceClient _tsc = new TokenService.TokenServiceClient()) { IFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream(); formatter.Serialize(stream, _su); stream.Seek(0, SeekOrigin.Begin); byte[] blob = new byte[stream.Length]; stream.Read(blob, 0, blob.Length); stream.Close(); bool _ret = _tsc.InsertToken(_ticket, blob); return(_ret); } }
/// <summary> /// 通过缉私系统取用户信息 /// </summary> /// <param name="_name"></param> /// <returns></returns> public static SinoUser GetUserInfoByJSXT(string _name) { string _yhid; if (_name.ToLower() != "administrator") { _yhid = C_GetUserInfo.GetYHIDByName(_name, ""); } else { _yhid = "0"; } SinoUser _ret = C_GetUserInfo.GetUserInfoByYHID(_yhid); return(_ret); }
public static SinoUser GetNoRegisterUserByUserName(string _name) { SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { StringBuilder _sb = new StringBuilder(); _sb.Append(" select yh.YHM,yh.YHID,yh.XM,jg.ZZJGID DWID,jg.ZZJGDM DWDM ,jg.JGQC DWMC from yw_qd_hbryxx hb "); _sb.Append(" join QX2_HGJG jg on hb.PARENT_GUID= jg.DWGUID "); _sb.Append(" join qx2_hgyh yh on hb.GUID=yh.YHGUID "); _sb.Append(" where hb.YHM=:LOGONNAME and ROWNUM=1 "); SqlCommand _cmd = new SqlCommand(_sb.ToString(), cn); _cmd.Parameters.Add(":LOGONNAME", _name); SqlDataReader dr = _cmd.ExecuteReader(); while (dr.Read()) { _su.LoginName = _name; _su.IsSignOn = true; _su.Dwdm = dr.IsDBNull(4) ? "" : dr.GetString(4); _su.DwID = dr.IsDBNull(3) ? "" : dr.GetDecimal(3).ToString(); _su.DwName = dr.IsDBNull(5) ? "" : dr.GetString(5); _su.UserID = dr.IsDBNull(1) ? "" : dr.GetDecimal(1).ToString(); _su.UserName = dr.IsDBNull(2) ? "" : dr.GetString(2); _su.SecretLevel = 0; _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 } //取岗位信息 _su.Posts = new List <SinoPost>(); SinoPost _sp = new SinoPost("未注册用户岗位", "0", _su.DwID, _su.DwName, _su.Dwdm, "未注册用户岗位", 0, true); _su.Posts.Add(_sp); _sp.Rights = C_GetGWInfo.GetRightsOfPost("-1", ""); _su.DefaultPost = _sp; _su.CurrentPost = _sp; cn.Close(); } return(_su); }
public static SinoUser GetNoRegisterUserByUserName(string _name) { SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { SqlCommand _cmd = new SqlCommand(SQL_GetNoRegisterUserByUserName, cn); _cmd.Parameters.Add(":LOGONNAME", _name); using (SqlDataReader dr = _cmd.ExecuteReader()) { while (dr.Read()) { _su.LoginName = _name; _su.IsSignOn = true; _su.Dwdm = dr.IsDBNull(4) ? "" : dr.GetString(4); _su.DwID = dr.IsDBNull(3) ? "" : dr.GetDecimal(3).ToString(); _su.DwName = dr.IsDBNull(5) ? "" : dr.GetString(5); _su.UserID = dr.IsDBNull(1) ? "" : dr.GetDecimal(1).ToString(); _su.UserName = dr.IsDBNull(2) ? "" : dr.GetString(2); _su.SecretLevel = 0; _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 } //取岗位信息 _su.Posts = new List <SinoPost>(); SinoPost _sp = new SinoPost("未注册用户岗位", "0", _su.DwID, _su.DwName, _su.Dwdm, "未注册用户岗位", 0, true); _su.Posts.Add(_sp); _sp.Rights = C_GetGWInfo.GetRightsOfPost("-1", ""); _su.DefaultPost = _sp; _su.CurrentPost = _sp; } cn.Close(); } return(_su); }
/// <summary> /// 登录系统 /// </summary> /// <param name="_sysid"></param> /// <param name="_name"></param> /// <param name="_mwpass"></param> /// <returns></returns> public SinoUser LoginSys(string _sysid, string _name, string _mwpass, string _type) { //暂未实现 C_SignOnBase _SignOnControler = new C_SignOnBase(); string _pass = _mwpass; string _ipaddr = CallContext.GetData("ClientIP").ToString(); string _hostName = ""; try { _hostName = Dns.GetHostEntry(_ipaddr).HostName; } catch { _hostName = _ipaddr; } SinoUser _su = new SinoUser(); _su.LoginName = _name; _su.UserName = "******"; _su.DwName = "海关总署缉私局"; string _yhid = ""; if (_name.ToLower() != "administrator") { switch (ConfigFile.LoginType) { case "NONE": break; case "TESTPASS": _SignOnControler = new C_SignOnTestPass(); break; case "BASE": //采用综合系统验证功能 _SignOnControler = new C_SignOnFromJS(); break; case "OGUPERMISSION": //采用海关通用授权平台验证WEB验证的功能(不再使用) _SignOnControler = new C_SignOnOGUPermission(); break; case "HGAD": //采用域验证的方式 _SignOnControler = new C_SignOnHGAD(); break; case "QDHB": _SignOnControler = new C_SignOnQDHBService(); break; case "HBSERVICE": _SignOnControler = new C_SignOnHBSecurityService(); break; case "CUPPAPASSPORT": _SignOnControler = new C_SignOnCUPPAPassport(); break; default: _SignOnControler = new C_SignOnFromJS(); break; } } else { _SignOnControler = new C_SignOnAdmin(); } bool _signOn = _SignOnControler.Check(_name, _pass, _type); if (!_signOn) { throw new Exception("用户名/口令不正确!"); } //写入用户操作日志 //SystemLogWriter.WriteLog(string.Format("验证{0}的口令成功!", _name), EventLogEntryType.Information); if (_name.ToLower() != "administrator") { switch (ConfigFile.LoginType) { case "CUPPAPASSPORT": string _atype = C_SignOnCUPPAPassport.GetAuthType(_type); _yhid = C_GetUserInfo_Cuppa.GetYHIDByName(_name, _atype); break; default: _yhid = C_GetUserInfo.GetYHIDByName(_name, _pass); break; } } else { _yhid = "0"; } if (_yhid != "-1") { _su = C_GetUserInfo.GetUserInfoByYHID(_yhid); } else { _su = C_GetUserInfo.GetNoRegisterUserByUserName(_name); } //同步登录名信息用(处理三统一的问题) _su.LoginName = _name; //SystemLogWriter.WriteLog(string.Format("取{0}的用户信息成功!", _name), EventLogEntryType.Information); //写入用户操作日志 //SQLCommon.WriteUserLog(decimal.Parse(_yhid), "系统登录", string.Format("{1}使用用户名{0}登录成功!", _name, _su.UserName), 1, _ipaddr, _hostName); //CreateTicket(ref _su, _ipaddr); _su.EncryptedTicket = TicketLib.AddTicket(_name, _ipaddr); //SystemLogWriter.WriteLog(string.Format("生成{0}的验证票据成功!Address={1}", _name, _ipaddr), EventLogEntryType.Information); _su.IPAddress = _ipaddr; _su.SystemID = ConfigFile.SystemID; LogonUserLib.AddUserInfo(_su.LoginName, _su); //SystemLogWriter.WriteLog(string.Format("添加用户{0}到验证用户列表成功!", _name), EventLogEntryType.Information); return(_su); }
/// <summary> /// 通过用户ID取用户信息 /// </summary> /// <param name="_yhid"></param> /// <returns></returns> public static SinoUser GetUserInfoByYHID(string _yhid) { if (_yhid == "0") { return(C_GetUserInfo.GetAdminInfo()); } SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { //取用户信息 SqlCommand _cmd = new SqlCommand(SQL_GetUserInfoByYHID, cn); _cmd.Parameters.Add(":YHID", decimal.Parse(_yhid)); DataTable _yhdt = new DataTable("YHTABLE"); SqlDataAdapter _adapter = new SqlDataAdapter(_cmd); _adapter.Fill(_yhdt); if (_yhdt.Rows.Count < 1) { //为未注册用户 //throw new Exception(string.Format("用户尚未在系统中注册!")); return(C_GetUserInfo.GetNoRegisterUserByUserID(decimal.Parse(_yhid))); } DataRow _dr = _yhdt.Rows[0]; _su.LoginName = _dr["YHM"].ToString(); _su.Dwdm = _dr["DWDM"].ToString(); _su.DwID = _dr["DWID"].ToString(); _su.DwName = _dr["DWMC"].ToString(); _su.UserID = _yhid; _su.UserName = _dr["XM"].ToString(); _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString()); _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 //取岗位信息 _su.Posts = C_GetGWInfo.Get_PostsByYHID(_su.UserID); foreach (SinoPost _sp in _su.Posts) { _sp.Rights = C_GetGWInfo.GetRightsOfPost(_sp.PostID, ""); if (_sp.IsDefaultPost) { _su.DefaultPost = _sp; } } if (_su.DefaultPost == null) { if (_su.Posts.Count > 0) { _su.DefaultPost = (SinoPost)_su.Posts[0]; } else { _su.DefaultPost = new SinoPost(); } } _su.CurrentPost = _su.DefaultPost; cn.Close(); } return(_su); }
/// <summary> /// 通过用户登录名取用户信息 /// </summary> /// <param name="_userName">用户登录名称</param> /// <returns></returns> public static SinoUser GetUserInfoByLoginName(string _userName) { if (_userName == "Administrator") { return(C_GetUserInfo.GetAdminInfo()); } SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { //取用户信息 StringBuilder _sb = new StringBuilder(); _sb.Append("SELECT a.yhm,a.yhid,a.dwid,a.xm,b.xdjb,b.aqjb,zhtj_zzjg2.GETDWDM_hgjs(a.dwid) dwdm,"); _sb.Append("(select jgqc from qx2_zzjg c where c.zzjgid = a.dwid) DWMC FROM qx2_yhxx a ,qx_tjyhb b "); _sb.Append(" where a.yhid = b.yhid and a.yhm=:YHM "); SqlCommand _cmd = new SqlCommand(_sb.ToString(), cn); _cmd.Parameters.Add(":YHM", _userName); DataTable _yhdt = new DataTable("YHTABLE"); SqlDataAdapter _adapter = new SqlDataAdapter(_cmd); _adapter.Fill(_yhdt); if (_yhdt.Rows.Count < 1) { //为未注册用户 throw new Exception(string.Format("用户尚未在系统中注册!")); } DataRow _dr = _yhdt.Rows[0]; _su.LoginName = _dr["YHM"].ToString(); _su.Dwdm = _dr["DWDM"].ToString(); _su.DwID = _dr["DWID"].ToString(); _su.DwName = _dr["DWMC"].ToString(); _su.UserID = _dr["YHID"].ToString(); _su.UserName = _dr["XM"].ToString(); _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString()); _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 //取岗位信息 _su.Posts = C_GetGWInfo.Get_PostsByYHID(_su.UserID); foreach (SinoPost _sp in _su.Posts) { _sp.Rights = C_GetGWInfo.GetRightsOfPost(_sp.PostID, ""); if (_sp.IsDefaultPost) { _su.DefaultPost = _sp; } } if (_su.DefaultPost == null) { if (_su.Posts.Count > 0) { _su.DefaultPost = (SinoPost)_su.Posts[0]; } else { _su.DefaultPost = new SinoPost(); } } _su.CurrentPost = _su.DefaultPost; cn.Close(); } return(_su); }
/// <summary> /// 通过用户登录名取用户信息 /// </summary> /// <param name="_userName">用户登录名称</param> /// <returns></returns> public static SinoUser GetUserInfoByLoginName(string _userName) { if (_userName == "Administrator") { return(C_GetUserInfo.GetAdminInfo()); } SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { //取用户信息 SqlParameter[] _param = { new SqlParameter(":YHM", SqlDbType.VarChar) }; _param[0].Value = _userName; DataTable _yhdt = SqlHelper.FillDataTable(cn, CommandType.Text, SQL_GetUserInfoByLoginName, _param); if (_yhdt.Rows.Count < 1) { //为未注册用户 throw new Exception(string.Format("用户尚未在系统中注册!")); } DataRow _dr = _yhdt.Rows[0]; _su.LoginName = _dr["YHM"].ToString(); _su.Dwdm = _dr["DWDM"].ToString(); _su.DwID = _dr["DWID"].ToString(); _su.DwName = _dr["DWMC"].ToString(); _su.UserID = _dr["YHID"].ToString(); _su.UserName = _dr["XM"].ToString(); _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString()); _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 //取岗位信息 _su.Posts = C_GetGWInfo.Get_PostsByYHID(_su.UserID); foreach (SinoPost _sp in _su.Posts) { _sp.Rights = C_GetGWInfo.GetRightsOfPost(_sp.PostID, ""); if (_sp.IsDefaultPost) { _su.DefaultPost = _sp; } } if (_su.DefaultPost == null) { if (_su.Posts.Count > 0) { _su.DefaultPost = (SinoPost)_su.Posts[0]; } else { _su.DefaultPost = new SinoPost(); } } _su.CurrentPost = _su.DefaultPost; cn.Close(); } return(_su); }
/// <summary> /// 通过用户ID取用户信息 /// </summary> /// <param name="_yhid"></param> /// <returns></returns> public static SinoUser GetUserInfoByYHID(string _yhid) { if (_yhid == "0") { return(C_GetUserInfo.GetAdminInfo()); } SinoUser _su = new SinoUser(); using (SqlConnection cn = SqlHelper.OpenConnection()) { //取用户信息 DataTable _yhdt = new DataTable("YHTABLE"); try { StringBuilder _sb = new StringBuilder(); _sb.Append("SELECT a.yhm,a.dwid,a.xm,b.xdjb,b.aqjb,zhtj_zzjg2.GETDWDM_hgjs(a.dwid) dwdm,"); _sb.Append("(select jgqc from qx2_zzjg c where c.zzjgid = a.dwid) DWMC FROM qx2_yhxx a ,qx_tjyhb b "); _sb.Append(" where a.yhid = b.yhid and a.yhid=:YHID "); SqlCommand _cmd = new SqlCommand(_sb.ToString(), cn); _cmd.Parameters.Add(":YHID", decimal.Parse(_yhid)); SqlDataAdapter _adapter = new SqlDataAdapter(_cmd); _adapter.Fill(_yhdt); } catch (Exception ex) { SystemLogWriter.WriteLog(string.Format("通用YHID取用户信息失败!YHID={0} 错误信息:{1}", _yhid, ex.Message), EventLogEntryType.Error); throw; } if (_yhdt.Rows.Count < 1) { //为未注册用户 //throw new Exception(string.Format("用户尚未在系统中注册!")); return(C_GetUserInfo.GetNoRegisterUserByUserID(decimal.Parse(_yhid))); } try { DataRow _dr = _yhdt.Rows[0]; _su.LoginName = _dr["YHM"].ToString(); _su.Dwdm = _dr["DWDM"].ToString(); _su.DwID = _dr["DWID"].ToString(); _su.DwName = _dr["DWMC"].ToString(); _su.UserID = _yhid; _su.UserName = _dr["XM"].ToString(); _su.SecretLevel = _dr.IsNull("AQJB") ? 0 : int.Parse(_dr["AQJB"].ToString()); _su.QxszJB = ""; //级别限定已经无用,现在处理时是按照岗位所在的级别。 //取岗位信息 _su.Posts = C_GetGWInfo.Get_PostsByYHID(_su.UserID); foreach (SinoPost _sp in _su.Posts) { _sp.Rights = C_GetGWInfo.GetRightsOfPost(_sp.PostID, ""); if (_sp.IsDefaultPost) { _su.DefaultPost = _sp; } } if (_su.DefaultPost == null) { if (_su.Posts.Count > 0) { _su.DefaultPost = (SinoPost)_su.Posts[0]; } else { _su.DefaultPost = new SinoPost(); } } _su.CurrentPost = _su.DefaultPost; } catch (Exception ex) { SystemLogWriter.WriteLog(string.Format("通用YHID取用户的岗位信息失败!YHID={0} 错误信息:{1}", _yhid, ex.Message), EventLogEntryType.Error); throw; } cn.Close(); } return(_su); }
/// <summary> /// 登录系统 /// </summary> /// <param name="_sysid"></param> /// <param name="_name"></param> /// <param name="_mwpass"></param> /// <returns></returns> public SinoUser LoginSys(string _sysid, string _name, string _mwpass, string CheckType) { //暂未实现 C_SignOnBase _SignOnControler = new C_SignOnBase(); string _pass = _mwpass; string _ipaddr = WCFClientInfo.IPAddr; string _hostName = ""; try { _hostName = Dns.GetHostEntry(_ipaddr).HostName; } catch (Exception ex) { string _err = ex.Message; _hostName = _ipaddr; } SinoUser _su = new SinoUser(); _su.LoginName = _name; _su.UserName = "******"; _su.DwName = "海关总署缉私局"; string _yhid = ""; if (_name.ToLower() != "administrator") { switch (ConfigFile.LoginType) { case "NONE": break; case "TESTPASS": _SignOnControler = new C_SignOnTestPass(); break; case "BASE": //采用综合系统验证功能 _SignOnControler = new C_SignOnFromJS(); break; case "CUPPAPASSPORT": _SignOnControler = new C_SignOnCUPPAPassport(); break; default: _SignOnControler = new C_SignOnFromJS(); break; } } else { _SignOnControler = new C_SignOnAdmin(); } bool _signOn = _SignOnControler.Check(_name, _pass, CheckType); if (_signOn) { //写入用户操作日志 } else { //写入用户操作日志 throw new Exception("用户名/口令不正确!"); } if (_name.ToLower() != "administrator") { switch (ConfigFile.LoginType) { case "CUPPAPASSPORT": #if DEBUG _yhid = C_GetUserInfo.GetYHIDByName(_name, _pass); #else _yhid = C_GetUserInfo_Cuppa.GetYHIDByName(_name, CheckType); #endif break; default: _yhid = C_GetUserInfo.GetYHIDByName(_name, _pass); break; } } else { _yhid = "0"; } if (_yhid != "-1") { _su = C_GetUserInfo.GetUserInfoByYHID(_yhid); } else { _su = C_GetUserInfo.GetNoRegisterUserByUserName(_name); } //SystemLogWriter.WriteLog(string.Format("取{0}的用户信息成功!", _name), EventLogEntryType.Information); //写入用户操作日志 //SQLCommon.WriteUserLog(decimal.Parse(_yhid), "系统登录", string.Format("{1}使用用户名{0}登录成功!", _name, _su.UserName), 1, _ipaddr, _hostName); //CreateTicket(ref _su, _ipaddr); _su.EncryptedTicket = TicketLib.AddTicket(_yhid, _ipaddr); //SystemLogWriter.WriteLog(string.Format("生成{0}的验证票据成功!", _name), EventLogEntryType.Information); _su.IPAddress = _ipaddr; _su.SystemID = ConfigFile.SystemID; LogonUserLib.AddUserInfo(_su.UserID, _su); //SystemLogWriter.WriteLog(string.Format("添加用户{0}到验证用户列表成功!", _name), EventLogEntryType.Information); return(_su); }
public void Login() { try { string ls_name = textUser.EditValue.ToString().Trim(); string ls_pass = textPass.EditValue.ToString(); string ls_type = this.CE_AuthorType.EditValue.ToString(); #region 取数据接口 IAuthorize _authService = LoginConfig.GetAuthorizeInterface(); if (_authService == null) { throw new Exception("未找到服务器端登录服务!"); } #endregion SinoUser _su = _authService.LoginSys(ConfigFile.SystemID, ls_name, ls_pass, ls_type); if (_su != null) { SessionClass.CurrentLogonName = ls_name; SessionClass.CurrentLogonPass = ls_pass; SessionClass.CurrentSinoUser = _su; SessionClass.CurrentTicket = new SinoSZTicketInfo(_su.LoginName, _su.IPAddress, _su.EncryptedTicket); SessionClass.ServerConfigData = _authService.GetServerConfig(); DataRow[] _drs = _UserDs.User.Select(string.Format("Username='******'", ls_name)); if (_drs.Length == 0) { DataRow row = _UserDs.User.NewRow(); row["Username"] = ls_name; _UserDs.User.Rows.Add(row); _UserDs.WriteXml(_schemaFile, XmlWriteMode.IgnoreSchema); } _su.DwID = _su.CurrentPost.PostDwID; loginTimes = 0; System.ComponentModel.ISynchronizeInvoke synchronizer = this; MethodInvoker invoker = new MethodInvoker(LoginSuccess); synchronizer.Invoke(invoker, null); } else { XtraMessageBox.Show("用户名/口令不正确或过期!", "系统提示"); System.ComponentModel.ISynchronizeInvoke synchronizer = this; MethodInvoker invoker = new MethodInvoker(ResetForm); synchronizer.Invoke(invoker, null); } loginTimes++; if (loginTimes > 2) { System.ComponentModel.ISynchronizeInvoke synchronizer = this; MethodInvoker invoker = new MethodInvoker(CancelApplicaton); synchronizer.Invoke(invoker, null); } } catch (Exception e) { ShowMessageDelegate showProgress = new ShowMessageDelegate(ShowMessage); string _msg = string.Format("发生错误:{0}", e.Message); this.Invoke(showProgress, new object[] { _msg }); } }