/// <summary> /// 取得指定用户的用户岗位 /// </summary> /// <param name="strUser"></param> /// <returns></returns> public string GetUserStation(string strUser) { string strRole = ""; try { EntityData entityRole = DAL.EntityDAO.OBSDAO.GetStationByUserCode(strUser); for (int i = 0; i < entityRole.CurrentTable.Rows.Count; i++) { if (strRole.Length > 1) { strRole += ","; } strRole += entityRole.CurrentTable.Rows[i]["StationCode"].ToString(); } } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, "取得用户角色失败"); } return(strRole); }
public static void LoadAvailableFunction() { try { FunctionStructureStrategyBuilder sb = new FunctionStructureStrategyBuilder(); sb.AddStrategy(new Strategy(FunctionStructureStrategyName.IsAvailable, "0")); QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("FunctionStructure", sb.BuildMainQueryString()); qa.Dispose(); foreach (DataRow dr in entity.CurrentTable.Rows) { string code = (string)dr["FunctionStructureCode"]; m_AvailableFunction.Add(code); } entity.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog("AvailableFunction", ex, ""); } }
private void LoadUserRight() { try { EntityData user = DAL.EntityDAO.SystemManageDAO.GetStandard_SystemUserByCode(this.m_UserCode); EntityData stations = DAL.EntityDAO.OBSDAO.GetStationByUserCode(this.m_UserCode); this.m_DataTableStation = stations.Tables["Station"]; foreach (DataRow drStation in stations.CurrentTable.Rows) { string stationCode = (string)drStation["StationCode"]; string roleCode = (string)drStation["RoleCode"]; string unitCode = (string)drStation["UnitCode"]; int iRoleLevel = (int)drStation["RoleLevel"]; if (iRoleLevel <= 1) { this.m_IsCompanyUser = true; } if (iRoleLevel == 0) { this.m_IsGroupUser = true; } // 从角色方面看有那些权限 EntityData role = DAL.EntityDAO.SystemManageDAO.GetStandard_RoleByCode(roleCode); foreach (DataRow drOperation in role.Tables["RoleOperation"].Rows) { string operationCode = (string)drOperation["OperationCode"]; if (!this.m_OperationArray.Contains(operationCode)) { this.m_OperationArray.Add(operationCode); } // string classCode = operationCode.Substring(0,4); // if ( ! this.m_ClassArray.Contains(classCode)) // this.m_ClassArray.Add( classCode); // // string moduleCode = operationCode.Substring(0,2); // if ( ! this.m_ModuleArray.Contains(moduleCode)) // this.m_ModuleArray.Add(moduleCode); } role.Dispose(); EntityData projects = null; if (iRoleLevel == 0) //集团级别 { this.m_IsGroupUser = true; /******************* 修改前 *************************/ //projects = DAL.EntityDAO.ProjectDAO.GetAllProject(); // 修改人clm 20050927 /******************* 修改后 *************************/ string companyUnitName = ""; string companyUnitFullCode = ""; string projectUnitName = ""; string projectUnitFullCode = ""; string companyUnitCode = BLL.SystemRule.GetUnitParentSpecailUnitCode(unitCode, "公司", ref companyUnitName, ref companyUnitFullCode); string projectUnitCode = BLL.SystemRule.GetUnitParentSpecailUnitCode(unitCode, "项目", ref projectUnitName, ref projectUnitFullCode); string targetUnitCode = (companyUnitFullCode.Length > projectUnitFullCode.Length) ? companyUnitCode : projectUnitCode; string targetUnitName = (companyUnitFullCode.Length > projectUnitFullCode.Length) ? companyUnitName : projectUnitName; projects = BLL.ProjectRule.GetProjectByUnit(targetUnitCode); /****************************************************/ AddRowToProject(projects); projects.Dispose(); EntityData companys = BLL.SystemRule.GetAllCompanyUnit(); AddRowToCompany(companys); companys.Dispose(); //集团级别时,用户能访问所有部门 EntityData units = DAL.EntityDAO.OBSDAO.GetAllUnit(); AddRowToUnit(units); units.Dispose(); } else if (iRoleLevel == 3) //部门级别 { this.m_IsCompanyUser = true; this.m_IsCompanyUser = true; string companyUnitName = ""; string companyUnitFullCode = ""; string projectUnitName = ""; string projectUnitFullCode = ""; string companyUnitCode = BLL.SystemRule.GetUnitParentSpecailUnitCode(unitCode, "公司", ref companyUnitName, ref companyUnitFullCode); string projectUnitCode = BLL.SystemRule.GetUnitParentSpecailUnitCode(unitCode, "项目", ref projectUnitName, ref projectUnitFullCode); string targetUnitCode = (companyUnitFullCode.Length > projectUnitFullCode.Length) ? companyUnitCode : projectUnitCode; string targetUnitName = (companyUnitFullCode.Length > projectUnitFullCode.Length) ? companyUnitName : projectUnitName; projects = BLL.ProjectRule.GetProjectByUnit(targetUnitCode); AddRowToProject(projects); projects.Dispose(); if (companyUnitCode == targetUnitCode) { AddRowToCompany(companyUnitCode, companyUnitName); } //部门级别时,用户能访问当前部门及其所有子部门 if (!this.m_IsGroupUser) { EntityData units = DAL.EntityDAO.OBSDAO.GetUnitAllChildAndSelf(unitCode); AddRowToUnit(units); units.Dispose(); } } else //个人 { /****************************************************** * string projectUnitName = ""; * string projectUnitFullCode = ""; * string projectUnitCode = BLL.SystemRule.GetUnitParentSpecailUnitCode(unitCode,"项目", ref projectUnitName, ref projectUnitFullCode); * projects = BLL.ProjectRule.GetProjectByUnit( projectUnitCode ); * AddRowToProject(projects); * projects.Dispose(); * /******************************************************/ //clm 修改 以上为修改前代码 projects = BLL.ProjectRule.GetProjectByUnit(unitCode); AddRowToProject(projects); projects.Dispose(); //部门级别时,用户能访问当前部门及其所有子部门 if (!this.m_IsGroupUser) { EntityData units = DAL.EntityDAO.OBSDAO.GetUnitAllChildAndSelf(unitCode); AddRowToUnit(units); units.Dispose(); } } } stations.Dispose(); user.Dispose(); // 从资源权限的角度看拥有的权限 string stationCodes = BuildStationCodeString(this.BuildStationCodes()); string s0 = String.Format(" ( AccessRange.AccessRangeType=0 and AccessRange.relationCode = '{0}' ) " , this.UserCode); string s1 = ""; if (stationCodes != "") { s1 = String.Format(" or ( AccessRange.AccessRangeType=1 and AccessRange.relationCode in ( {0} ) ) " , stationCodes); } string sss = String.Format("select distinct(operationCode) from accessrange where ( {0} {1} )" , new object[] { s0, s1 }); QueryAgent qa = new QueryAgent(); DataSet ds = qa.ExecSqlForDataSet(sss); foreach (DataRow drOp in ds.Tables[0].Rows) { if (!drOp.IsNull("OperationCode")) { string operationCode = (string)drOp["OperationCode"]; if (!this.m_OperationArray.Contains(operationCode)) { this.m_OperationArray.Add(operationCode); } // string classCode = operationCode.Substring(0,4); // if ( ! this.m_ClassArray.Contains(classCode)) // this.m_ClassArray.Add( classCode); // // string moduleCode = operationCode.Substring(0,2); // if ( ! this.m_ModuleArray.Contains(moduleCode)) // this.m_ModuleArray.Add(moduleCode); } } ds.Dispose(); qa.Dispose(); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); } }
private void Login(string userID, string pwd, bool IsNeedPwd) { try { UserStrategyBuilder sb = new UserStrategyBuilder(); //获取SQL查询语句; if (System.Configuration.ConfigurationSettings.AppSettings["UserNameLogin"] == "1") { sb.AddStrategy(new Strategy(UserStrategyName.UserIdorUserName, userID)); //将用户ID值加入到Strategy; if (IsNeedPwd) { sb.AddStrategy(new Strategy(UserStrategyName.PassWord, pwd)); } } else { sb.AddStrategy(new Strategy(UserStrategyName.UserID, userID)); } string sql = sb.BuildMainQueryString(); Rms.ORMap.QueryAgent qa = new QueryAgent(); //打开数据库; EntityData entity = qa.FillEntityData("SystemUser", sql); //读取数据数据; qa.Dispose(); string workNO = ""; bool OK = false; if (!entity.HasRecord()) { this.lblMessage.Text = "用户名或密码错误"; } else { string RealPwd = entity.GetString("Password"); if (pwd != RealPwd && IsNeedPwd) { this.lblMessage.Text = "用户名或密码错误"; } else { int status = entity.GetInt("Status"); // 0-正常,1 禁用 if (status == 1) { this.lblMessage.Text = "该用户已被禁用"; } else { string userCode = entity.GetString("UserCode"); User user = new User(userCode); //user.ResetUser("P1010"); Session["User"] = user; workNO = user.WorkNO; //是否缺省显示最后一次访问的项目 string UseLastProject = System.Configuration.ConfigurationSettings.AppSettings["UseLastProject"]; if (UseLastProject == "1") { // 取用户最后使用的项目,如果没有取用户能进入的项目, 和用户权限相结合 string projectCode = entity.GetString("LastProjectCode"); if (projectCode == "") { // 这里要修改, 取用户能进入的项目 EntityData projects = DAL.EntityDAO.ProjectDAO.GetAllProject(); if (projects.HasRecord()) { projectCode = projects.GetString("ProjectCode"); } projects.Dispose(); } Session["ProjectCode"] = projectCode; if (projectCode != "") { ((ProjectInfo)Session["project"]).Reset(projectCode); } } OK = true; /********************** 在线用户统计 ***************************/ Application.Lock(); Hashtable UserTable = (Hashtable)Application["UserTable"]; if (!UserTable.Contains(user.UserCode + "," + Session.SessionID)) { UserTable.Add(user.UserCode + "," + Session.SessionID, user.UserName); Application["UserTable"] = UserTable; } //单一用户登录控制 if (BLL.ConvertRule.ToString(Application["SingleUserLogin"]) == "1") { Hashtable KilledUserTable = (Hashtable)Application["KilledUserTable"]; PageBase.KillUser(user, UserTable, KilledUserTable, Session); } Application.UnLock(); /***************************************************************/ } } } entity.Dispose(); if (OK) { //记录最后操作时间 Session["LastOperTime"] = DateTime.Now; string strOaPath = System.Configuration.ConfigurationSettings.AppSettings["OAUrl"]; Response.Write(@"<Script language=""javascript"" src=""./Rms.js""></Script>"); Response.Write(Rms.Web.JavaScript.ScriptStart); Response.Write("window.opener=null;"); string usercode = ((User)Session["User"]).UserCode; Response.Write(@" var win = OpenFullWindow('frame.htm','房产项目管理系统" + (usercode == "0"?(DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()):usercode) + "'); "); Response.Write(@" if ( win != this ) { win.opener = null;window.open('', '_parent', ''); window.close(); }"); Response.Write(Rms.Web.JavaScript.ScriptEnd); } } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, "用户登录失败"); Response.Write(Rms.Web.JavaScript.Alert(true, "用户登录失败:" + ex.Message)); } }
private bool Login(string userID, string pwd, bool IsNeedPwd) { try { bool OK = false; UserStrategyBuilder sb = new UserStrategyBuilder(); sb.AddStrategy(new Strategy(UserStrategyName.UserID, userID)); string sql = sb.BuildMainQueryString(); Rms.ORMap.QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("SystemUser", sql); qa.Dispose(); string workNO = ""; if (!entity.HasRecord()) { } else { string RealPwd = entity.GetString("Password"); if (RealPwd != pwd) { OK = false; } else { int status = entity.GetInt("Status"); // 0-正常,1 禁用 if (status == 0) { string userCode = entity.GetString("UserCode"); User user = new User(userCode); // user.ResetUser("P1010"); Session["User"] = user; ViewState["UserName"] = userID; ViewState["Password"] = pwd; workNO = user.WorkNO; OK = true; /********************** 在线用户统计 ***************************/ Application.Lock(); Hashtable UserTable = (Hashtable)Application["UserTable"]; if (!UserTable.Contains(user.UserCode + "," + Session.SessionID)) { UserTable.Add(user.UserCode + "," + Session.SessionID, user.UserName); Application["UserTable"] = UserTable; } //单一用户登录控制 if (BLL.ConvertRule.ToString(Application["SingleUserLogin"]) == "1") { Hashtable KilledUserTable = (Hashtable)Application["KilledUserTable"]; PageBase.KillUser(user, UserTable, KilledUserTable, Session); } Application.UnLock(); /***************************************************************/ } } } entity.Dispose(); if (OK) { //记录最后操作时间 Session["LastOperTime"] = DateTime.Now; } return(OK); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, "用户登录失败"); Response.Write(Rms.Web.JavaScript.Alert(true, "用户登录失败:" + ex.Message)); return(false); } }