public bool Login(string userID, string pwd) { 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"); RmsPM.Web.User user = new RmsPM.Web.User(userCode); // user.ResetUser("P1010"); Session["User"] = user; workNO = user.WorkNO; OK = true; /***************************************************************/ } } } entity.Dispose(); if (OK) { //记录最后操作时间 Session["LastOperTime"] = DateTime.Now; } return(OK); } catch (Exception ex) { RmsPM.Web.ApplicationLog.WriteLog(this.ToString(), ex, "用户登录失败"); return(false); } }
public static EntityData GetUserByStation(string stationCode) { EntityData data2; try { UserStrategyBuilder builder = new UserStrategyBuilder(); builder.AddStrategy(new Strategy(UserStrategyName.StationCode, stationCode)); string queryString = builder.BuildMainQueryString() + builder.GetDefaultOrder(); QueryAgent agent = new QueryAgent(); EntityData data = agent.FillEntityData("SystemUser", queryString); agent.Dispose(); data2 = data; } catch (Exception exception) { throw exception; } return(data2); }
public static DataView GetUserMessage(string projectCode) { DataView view2; try { UserStrategyBuilder builder = new UserStrategyBuilder(); if (projectCode != "") { builder.AddStrategy(new Strategy(UserStrategyName.ProjectCode, projectCode)); } string queryString = builder.BuildMainQueryString(); QueryAgent agent = new QueryAgent(); DataView dv = agent.ExecSqlForDataSet(queryString).Tables[0].DefaultView; agent.Dispose(); view2 = AddToUserMessage(dv); } catch (Exception exception) { throw exception; } return(view2); }
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)); } }
public string CreateCase(String ProcudeID, string ApplicationCode, string ApplicationTitle, string XmlData, string Username, String ToTask, string ToUser) { try { ProcudeID = System.Web.HttpUtility.UrlDecode(ProcudeID); ApplicationTitle = System.Web.HttpUtility.UrlDecode(ApplicationTitle); XmlData = System.Web.HttpContext.Current.Server.HtmlDecode(System.Web.HttpUtility.UrlDecode(XmlData)).Replace("<br>", "\n"); Username = System.Web.HttpUtility.UrlDecode(Username); ToTask = System.Web.HttpUtility.UrlDecode(ToTask); ToUser = System.Web.HttpUtility.UrlDecode(ToUser); string ProjectName = ""; RmsPM.BLL.ConvertRule cConvertRule = new RmsPM.BLL.ConvertRule(); System.Xml.XmlNode xmlnode = cConvertRule.GetXmlDate(XmlData.ToLower()); if (xmlnode.SelectSingleNode("projectname") != null) { ProjectName = xmlnode.SelectSingleNode("projectname").InnerText.Trim(); } string SystemUserCode = ""; string SystemUnitCode = ""; string Transactor = ""; string TransactUnit = ""; this.FlowName = ProcudeID; UserStrategyBuilder sb = new UserStrategyBuilder(); sb.AddStrategy(new Strategy(UserStrategyName.UserID, Username)); string sql = sb.BuildMainQueryString(); Rms.ORMap.QueryAgent qa = new QueryAgent(); EntityData entity = qa.FillEntityData("SystemUser", sql); qa.Dispose(); if (entity.HasRecord()) { SystemUserCode = entity.GetString("UserCode"); } if (SystemUserCode == "") { return("UserNotFound"); } string ProjectCode = ""; if (ProjectName != "") { ProjectCode = RmsPM.BLL.ProjectRule.GetProjectCodeByName(ProjectName.Trim()); } string actCode = ""; string ProcedureCode = RmsPM.BLL.WorkFlowRule.GetProcedureCodeByName(ProcudeID, ProjectCode); WorkCase workCase = Rms.WorkFlow.WorkCaseManager.StartNewWorkCase(ApplicationCode, ProcedureCode, SystemUserCode, SystemUnitCode, ref actCode, Transactor, TransactUnit); System.Collections.IDictionaryEnumerator ie = workCase.GetActEnumerator(); while (ie.MoveNext()) { Act act = (Act)ie.Value; if (act.Copy != 1) { act.IsSleep = 1; } } DataSet ds = Rms.WorkFlow.WorkCaseManager.SaveWorkCaseData(workCase); RmsPM.BLL.WorkFlowApplicationRule.SaveWorkCaseEx(ds, workCase.CaseCode); this.CaseCode = workCase.CaseCode; this.ActCode = actCode; this.SaveCasePropertyValue("主题", ApplicationTitle, ProcedureCode); this.SaveCasePropertyValue("申请人", SystemUserCode, ProcedureCode); this.SaveCasePropertyValue("项目代码", ProjectCode, ProcedureCode); this.SaveCasePropertyValue("项目部门", RmsPM.BLL.ProjectRule.GetUnitByProject(ProjectCode), ProcedureCode); this.SaveCasePropertyValue("业务类别", "", ProcedureCode); this.SaveCasePropertyValue("业务部门", "", ProcedureCode); this.SaveCasePropertyValue("业务数据", XmlData, ProcedureCode); this.SaveCasePropertyValue("表单部门", "", ProcedureCode); this.SaveCasePropertyValue("手送资料", "", ProcedureCode); string NumberString = RmsPM.BLL.WorkFlowRule.GetProcedureNumberByName(this.FlowName) + DateTime.Now.Year.ToString().Substring(2, 2); int FlowNumberLenth = (RmsPM.BLL.SystemRule.GetProjectConfigValue("FlowNumberLength") == "") ? 4 : int.Parse(RmsPM.BLL.SystemRule.GetProjectConfigValue("FlowNumberLength")); NumberString += RmsPM.DAL.EntityDAO.SystemManageDAO.GetNewSysCode(NumberString).Substring(6 - FlowNumberLenth, FlowNumberLenth); this.SaveCasePropertyValue("流水号", NumberString, ProcedureCode); ///////////////////////////////////////////////////////////////////// if (actCode != "") { return("success"); } else { return("faild"); } } catch (System.Exception ec) { return(ec.Message); } }
protected void Page_Load(object sender, System.EventArgs e) { string Value = Request.QueryString["Value"] + ""; string UserCode = ""; string UserName = ""; string SortID = ""; string Hint = ""; string IsExists = ""; if (Value != "") { //按工号查 EntityData entity = DAL.EntityDAO.SystemManageDAO.GetSystemUserBySortID(Value); entity.Dispose(); //按登录名查 if (!entity.HasRecord()) { entity = DAL.EntityDAO.SystemManageDAO.GetSystemUserByUserID(Value); entity.Dispose(); } //按姓名查 if (!entity.HasRecord()) { entity = DAL.EntityDAO.SystemManageDAO.GetSystemUserByUserName(Value); entity.Dispose(); } //按姓名模糊查 if (!entity.HasRecord()) { UserStrategyBuilder sb = new UserStrategyBuilder(); sb.AddStrategy(new Strategy(UserStrategyName.UserName, "%" + Value + "%")); string sql = sb.BuildMainQueryString(); sql = sql + sb.GetDefaultOrder(); QueryAgent qa = new QueryAgent(); qa.SetTopNumber(1); entity = qa.FillEntityData("SystemUser", sql); qa.Dispose(); } if (entity.HasRecord()) { UserCode = entity.GetString("UserCode"); UserName = entity.GetString("UserName"); SortID = entity.GetString("SortID"); IsExists = "1"; } else { Hint = "用户不存在 !"; } } string sResult = "<Result>" + "<UserCode>" + UserCode + "</UserCode>" + "<UserName>" + UserName + "</UserName>" + "<SortID>" + SortID + "</SortID>" + "<Hint>" + Hint + "</Hint>" + "<IsExists>" + IsExists + "</IsExists>" + "</Result>"; Response.Write(sResult); Response.End(); }
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); } }