//========================================================================= // FunctionName : Query /// <summary> /// 检索方法 /// </summary> /// <param name="appData">应用数据实体</param> /// <returns>返回数据实体对象</returns> //========================================================================= public T_PM_UserInfoApplicationData Query(T_PM_UserInfoApplicationData appData) { T_PM_UserInfoBusinessEntity instanceT_PM_UserInfoBusinessEntity = (T_PM_UserInfoBusinessEntity)CreateBusinessEntityInstance(typeof(T_PM_UserInfoBusinessEntity)); instanceT_PM_UserInfoBusinessEntity.AppData = appData; if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.PK) { instanceT_PM_UserInfoBusinessEntity.SelectByKey(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ID) { instanceT_PM_UserInfoBusinessEntity.SelectByObjectID(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ALL) { instanceT_PM_UserInfoBusinessEntity.SelectByAnyCondition(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else { instanceT_PM_UserInfoBusinessEntity.SelectByAnyCondition(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } return(instanceT_PM_UserInfoBusinessEntity.AppData); }
//========================================================================= // FunctionName : AutoGenerateUserID /// <summary> /// 自动生成UserID编号方法 /// </summary> /// <returns>返回UserID新编号</returns> //========================================================================= public string AutoGenerateUserID(T_PM_UserInfoApplicationData appData) { int intNumberLength = 5; string strPrefix = ("U").ToString(); strPrefix = strPrefix.ToLower() == "null" ? "" : strPrefix; T_PM_UserInfoBusinessEntity instanceT_PM_UserInfoBusinessEntity = (T_PM_UserInfoBusinessEntity)CreateBusinessEntityInstance(typeof(T_PM_UserInfoBusinessEntity)); string strMaxValue; StringBuilder sbNewID = new StringBuilder(string.Empty); sbNewID.Append(strPrefix); strMaxValue = instanceT_PM_UserInfoBusinessEntity.GetMaxValue(strPrefix, intNumberLength).ToString(); if (strMaxValue != String.Empty) { if (strMaxValue.Length == strPrefix.Length + intNumberLength) { int intMaxValue = Convert.ToInt32(strMaxValue.Substring(strPrefix.Length, intNumberLength)) + 1; sbNewID.Append(FillZeroToString(intMaxValue.ToString(), intNumberLength)); } else { sbNewID.Append(FillZeroToString("1", intNumberLength)); } } else { sbNewID.Append(FillZeroToString("1", intNumberLength)); } return(sbNewID.ToString()); }
protected void btnSendChangePasswordEmail_Click(object sender, EventArgs e) { bool boolReturn = true; ValidateData validateData = new ValidateData(); T_PM_UserInfoApplicationLogic userInfoApplicationLogic = new T_PM_UserInfoApplicationLogic(); validateData = ValidateUserLoginName(UserLoginName.Text, false, false); if (validateData.Result) { UserLoginName.BackColor = System.Drawing.Color.Empty; if (!validateData.IsNull) { if (UserLoginName.Text.IsValidEmail()) { T_PM_UserInfoApplicationData existAppData = new T_PM_UserInfoApplicationData(); existAppData.UserLoginName = UserLoginName.Text.HtmlDecodeWithTrim(); existAppData.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.ALL; existAppData.PageSize = 1; existAppData.CurrentPage = 1; existAppData = userInfoApplicationLogic.Query(existAppData); if (existAppData.RecordCount == 0) { validateData.Message = "登录用户名不存在,请检查后再次提交。"; UserLoginName.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = false; } else { appData = T_PM_UserInfoBusinessEntity.GetDataByObjectID(((Guid)existAppData.ResultSet.Tables[0].Rows[0]["ObjectID"]).ToString()); if (appData != null) { appData.vcode = Guid.NewGuid().ToString(); appData.OPCode = ApplicationDataBase.OPType.ID; userInfoApplicationLogic.Modify(appData); // 发送Email SendChangePasswordMail(appData.UserLoginName, appData.UserNickName, DomainUrl, appData.vcode); MessageContent += "修改密码链接已发送到您的邮箱,请检查邮箱并进行密码修改。"; btnSendChangePasswordEmail.Enabled = false; Page.CloseWindow(true); } } } else { validateData.Message = "登录用户名格式错误。"; UserLoginName.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = false; } } } else { UserLoginName.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } }
//========================================================================= // FunctionName : Count /// <summary> /// 统计记录数方法 /// </summary> /// <param name="appData">应用数据实体</param> /// <returns>返回数据实体对象</returns> //========================================================================= public T_PM_UserInfoApplicationData Count(T_PM_UserInfoApplicationData appData) { T_PM_UserInfoBusinessEntity instanceT_PM_UserInfoBusinessEntity = (T_PM_UserInfoBusinessEntity)CreateBusinessEntityInstance(typeof(T_PM_UserInfoBusinessEntity)); instanceT_PM_UserInfoBusinessEntity.AppData = appData; instanceT_PM_UserInfoBusinessEntity.CountByAnyCondition(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; return(instanceT_PM_UserInfoBusinessEntity.AppData); }
//========================================================================= // FunctionName : Modify /// <summary> /// 更新方法 /// </summary> /// <param name="appData">应用数据实体</param> /// <returns>返回数据实体对象</returns> //========================================================================= public T_PM_UserInfoApplicationData Modify(T_PM_UserInfoApplicationData appData) { T_PM_UserInfoBusinessEntity instanceT_PM_UserInfoBusinessEntity = (T_PM_UserInfoBusinessEntity)CreateBusinessEntityInstance(typeof(T_PM_UserInfoBusinessEntity)); instanceT_PM_UserInfoBusinessEntity.AppData = appData; if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.PK) { if (instanceT_PM_UserInfoBusinessEntity.IsExistByKey() == true) { instanceT_PM_UserInfoBusinessEntity.UpdateByKey(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else { instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure; } } else if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ID) { if (instanceT_PM_UserInfoBusinessEntity.IsExistByObjectID() == true) { instanceT_PM_UserInfoBusinessEntity.UpdateByObjectID(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else { instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure; } } else if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.BATCH) { instanceT_PM_UserInfoBusinessEntity.UpdateByObjectIDBatch(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else if (instanceT_PM_UserInfoBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ALL) { instanceT_PM_UserInfoBusinessEntity.UpdateByAnyCondition(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else { if (instanceT_PM_UserInfoBusinessEntity.IsExistByObjectID() == true) { instanceT_PM_UserInfoBusinessEntity.UpdateByObjectID(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else { instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure; } } return(instanceT_PM_UserInfoBusinessEntity.AppData); }
protected bool ValidateUserIsLogined() { if (DataValidateManager.ValidateIsNull(Session[ConstantsManager.SESSION_USER_ID]) == false && DataValidateManager.ValidateIsNull(Session[ConstantsManager.SESSION_USER_GROUP_ID]) == false && DataValidateManager.ValidateIsNull(Session[ConstantsManager.SESSION_USER_NICK_NAME]) == false // && DataValidateManager.ValidateIsNull(Session[ConstantsManager.SESSION_SSDW_ID]) == false && DataValidateManager.ValidateIsNull(Session[ConstantsManager.SESSION_USER_LOGIN_NAME]) == false) { currentUserInfo = T_PM_UserInfoBusinessEntity.GetDataByKey(new T_PM_UserInfoApplicationData() { UserID = (string)Session[ConstantsManager.SESSION_USER_ID], }); return(true); } if (!string.IsNullOrWhiteSpace(Request.QueryString["lcode"])) { currentUserInfo = T_PM_UserInfoBusinessEntity.GetDataByKey(new T_PM_UserInfoApplicationData() { UserID = (string)(new T_PM_UserInfoBusinessEntity()).GetValueByFixCondition("lcode", (string)Request.QueryString["lcode"], "UserID"), }); Session[ConstantsManager.SESSION_USER_ID] = currentUserInfo.UserID; Session[ConstantsManager.SESSION_USER_GROUP_ID] = currentUserInfo.UserGroupID; Session[ConstantsManager.SESSION_USER_LOGIN_NAME] = currentUserInfo.UserLoginName; Session[ConstantsManager.SESSION_SSDW_ID] = currentUserInfo.SubjectID; Session[ConstantsManager.SESSION_USER_NICK_NAME] = currentUserInfo.UserNickName; return(true); } if (DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_USER_ID]) == false && DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_USER_GROUP_ID]) == false && DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_USER_NICK_NAME]) == false // && DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_SSDW_ID]) == false && DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME]) == false) { Session[ConstantsManager.SESSION_USER_ID] = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_USER_ID].Value.ToString()); Session[ConstantsManager.SESSION_USER_GROUP_ID] = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_USER_GROUP_ID].Value.ToString()); Session[ConstantsManager.SESSION_USER_LOGIN_NAME] = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME].Value.ToString()); Session[ConstantsManager.SESSION_SSDW_ID] = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_SSDW_ID].Value.ToString()); Session[ConstantsManager.SESSION_USER_NICK_NAME] = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_USER_NICK_NAME].Value.ToString()); currentUserInfo = T_PM_UserInfoBusinessEntity.GetDataByKey(new T_PM_UserInfoApplicationData() { UserID = (string)Session[ConstantsManager.SESSION_USER_ID], }); //记录日志开始 string strLogContent = MessageManager.GetMessageInfo(MessageManager.LOG_MSGID_0001, new string[] { currentUserInfo.UserLoginName }); LogLibrary.LogWrite("A01", strLogContent, null, null, null); //记录日志结束 return(true); } currentUserInfo = null; return(false); }
protected void Page_Load(object sender, EventArgs e) { if (!DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_SAVE_LOGIN_STATUS]) && !DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME]) && !DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_PASSWORD])) { txtUserLoginName.Text = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME].Value); txtPassword.Text = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_PASSWORD].Value); chkSaveLoginStatus.Checked = true; ValidateUserLogin(); } imgIdentifyCode.ImageUrl = ConstantsManager.WEBSITE_VIRTUAL_ROOT_DIR + "/Page/IdentifyCode.aspx"; if (!IsPostBack) { var vcode = Request.QueryString["vcode"]; if (vcode.IsHtmlNullOrWiteSpace() || !DataValidateManager.ValidateUniqueIdentifierFormat(vcode)) { if (!DataValidateManager.ValidateIsNull(Request.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME])) { txtUserLoginName.Text = Server.UrlDecode(Request.Cookies[ConstantsManager.COOKIE_USER_LOGIN_NAME].Value); } } else { T_PM_UserInfoApplicationLogic userInfoApplicationLogic = new T_PM_UserInfoApplicationLogic(); T_PM_UserInfoApplicationData appData = new T_PM_UserInfoApplicationData(); appData.vcode = vcode; appData.CurrentPage = 1; appData.PageSize = 1; appData.OPCode = ApplicationDataBase.OPType.ALL; userInfoApplicationLogic.Query(appData); if (appData.RecordCount > 0) { appData = T_PM_UserInfoBusinessEntity.GetDataByObjectID(((Guid)appData.ResultSet.Tables[0].Rows[0]["ObjectID"]).ToString()); appData.UserStatus = "02"; appData.vcode = null; appData.OPCode = ApplicationDataBase.OPType.ID; userInfoApplicationLogic.Modify(appData); txtUserLoginName.Text = appData.UserLoginName; MessageLabel.Text = "邮箱通过验证,请登录开始使用系统。"; } else { MessageLabel.Text = "邮箱验证信息有误。"; } } } txtIdentifyCode.Attributes.Add("onfocus", "document.getElementById('txtIdentifyCode').value = GetCookie('IdentifyCode');"); }
//========================================================================= // FunctionName : Add /// <summary> /// 添加方法 /// </summary> /// <param name="appData">应用数据实体</param> /// <returns>返回数据实体对象</returns> //========================================================================= public T_PM_UserInfoApplicationData Add(T_PM_UserInfoApplicationData appData) { T_PM_UserInfoBusinessEntity instanceT_PM_UserInfoBusinessEntity = (T_PM_UserInfoBusinessEntity)CreateBusinessEntityInstance(typeof(T_PM_UserInfoBusinessEntity)); instanceT_PM_UserInfoBusinessEntity.AppData = appData; if (instanceT_PM_UserInfoBusinessEntity.IsExistByKey() == false) { instanceT_PM_UserInfoBusinessEntity.Insert(); instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed; } else { instanceT_PM_UserInfoBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure; } return(instanceT_PM_UserInfoBusinessEntity.AppData); }
protected void btnChangePassword_Click(object sender, EventArgs e) { bool boolReturn = true; ValidateData validateData = new ValidateData(); appData = T_PM_UserInfoBusinessEntity.GetDataByObjectID(ObjectID.Text); if (Password.Text == PasswordConfirm.Text) { validateData = ValidatePassword(Password.Text, false, false); if (validateData.Result == true) { if (validateData.IsNull == false) { appData.Password = RICH.Common.SecurityManager.MD5(Convert.ToString(validateData.Value.ToString()), 32); Password_Note.InnerHtml = @"<font color=""gray"">输入正确。</font>"; } Password.BackColor = System.Drawing.Color.Empty; } else { Password.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } } else { Password.BackColor = System.Drawing.Color.YellowGreen; PasswordConfirm.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">两次输入不一致,请重新输入。</font>"; boolReturn = false; } if (boolReturn) { T_PM_UserInfoApplicationLogic userInfoApplicationLogic = new T_PM_UserInfoApplicationLogic(); appData.vcode = null; appData.OPCode = ApplicationDataBase.OPType.ID; userInfoApplicationLogic.Modify(appData); Response.Redirect("login.aspx"); } }
//========================================================================= // FunctionName : GetValueByFixCondition /// <summary> /// 取指定条件的指定值方法 /// </summary> /// <returns>返回值</returns> //========================================================================= public object GetValueByFixCondition(string strConditionField, object strConditionValue, string strValueField) { T_PM_UserInfoBusinessEntity instanceT_PM_UserInfoBusinessEntity = (T_PM_UserInfoBusinessEntity)CreateBusinessEntityInstance(typeof(T_PM_UserInfoBusinessEntity)); return(instanceT_PM_UserInfoBusinessEntity.GetValueByFixCondition(strConditionField, strConditionValue, strValueField)); }