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); }
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); }
/// <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="_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); }