protected void btnLogin_Click(object sender, EventArgs e) { this.lbError.Text = string.Empty; RequestMeasure requestMeasure = new RequestMeasure("btnLogin_Click"); CallContext resultContext = AdminClientRef.Login(this.tbxUserName.Text, this.tbxPassword.Text); LogDebug(requestMeasure.ToString()); if (resultContext.ResultCode == ETEMEnums.ResultEnum.Success) { this.userProps = new UserProps(); ETEMModel.Models.User currentUser = AdminClientRef.GetUserByUserID(resultContext.EntityID); if (currentUser != null) { this.userProps = MakeLoginByUserID(resultContext.EntityID); LogDebug("Потребител " + this.userProps.UserName + " влезе в системата"); Response.Redirect(Welcome.formResource.PagePath); } else { this.lbError.Text = ETEMModel.Helpers.BaseHelper.GetCaptionString("Съществува проблем с базата данни"); } } else { this.lbError.Text = resultContext.Message; } }
public UserProps MakeLoginByUserID(string UserID) { UserProps userProps = new UserProps(); ETEMModel.Models.User currentUser = AdminClientRef.GetUserByUserID(UserID); if (currentUser != null) { userProps.Roles = AdminClientRef.GetAllRolesByUser(currentUser.idUser.ToString(), null, null); for (int i = 0; i < userProps.Roles.Count; i++) { List <int> currentRolePermmitedActionsIds = AdminClientRef. GetAllPermittedActionsByRole(userProps.Roles[i].idRole.ToString(), null, null) .Select(r => r.idPermittedAction).ToList(); for (int j = 0; j < currentRolePermmitedActionsIds.Count; j++) { bool isDuplicate = userProps.ListUserPermittedActionsID.Any(p => p == currentRolePermmitedActionsIds[j]); if (!isDuplicate) { userProps.ListUserPermittedActionsID.Add(currentRolePermmitedActionsIds[j]); } } } //userProps.ListUserPermittedActionsID = AdminClientRef.getallp userProps.IdUser = currentUser.idUser.ToString(); userProps.UserName = currentUser.UserName; Person person = this.AdminClientRef.GetPersonByPersonID(currentUser.idPerson.ToString()); userProps.PersonNamePlusTitle = person.FullNamePlusTitle; userProps.PersonNameNoTitle = person.FullName; userProps.PersonNameAndFamily = person.FullNameTwo; userProps.PersonTwoNamePlusTitle = person.TwoNamesPlusTitle; userProps.PersonID = person.idPerson.ToString(); userProps.SessionID = this.Session.SessionID; userProps.IPAddress = Request.UserHostAddress; userProps.LoginDateTime = DateTime.Now; this.Session.Timeout = Convert.ToInt32(BasicPage.GetValueFromWebConfig("SessionTimeOut")); userProps.idStudent = Constants.INVALID_ID; userProps.IsCheckDomain = currentUser.idCheckDomain == GetKeyValueByIntCode("YES_NO", "Yes").idKeyValue; userProps.IsKilled = false; this.Session.Add(ETEMModel.Helpers.Constants.SESSION_USER_PROPERTIES, userProps); this.Session.Timeout = Int32.Parse(GetSettingByCode(ETEMEnums.AppSettings.WebSessionTimeOut).SettingValue); Dictionary <string, HttpSessionState> sessionData = (Dictionary <string, HttpSessionState>)Application[Constants.APPLICATION_ALL_SESSIONS]; if (sessionData.Keys.Contains(HttpContext.Current.Session.SessionID)) { sessionData.Remove(HttpContext.Current.Session.SessionID); sessionData.Add(HttpContext.Current.Session.SessionID, HttpContext.Current.Session); } } return(userProps); }
protected void btnSendNewPasswordMail_OnClick(object sender, EventArgs e) { #region Basic checkings if (this.tbxForgottenUsername.Text == "") { AddErrorMessage(lbResultContext, "Полето 'Потребителско име' е задължително"); return; } if (this.tbxForgottenEGN.Text == "") { AddErrorMessage(lbResultContext, "Полето 'ЕГН/ЛНЧ/ИДН' е задължително"); return; } if (this.tbxForgottenEmail.Text == "") { AddErrorMessage(lbResultContext, "Полето 'Email' е задължително"); return; } #endregion #region dbChecks ETEMModel.Models.User user = AdminClientRef.GetUserByUsername(this.tbxForgottenUsername.Text); if (user == null) { AddErrorMessage(lbResultContext, "Не съществува потребител с това потребителско име"); return; } Person person = AdminClientRef.GetPersonByPersonID(user.idPerson.ToString()); string egn = GetEgnOrIdnOrLnch(person); if (egn != this.tbxForgottenEGN.Text) { AddErrorMessage(lbResultContext, "Данните в полето 'ЕГН/ЛНЧ/ИДН' не съвпадат с тези от потребителя"); return; } if (person.EMail != this.tbxForgottenEmail.Text) { AddErrorMessage(lbResultContext, "Данните в полето 'Email' не съвпадат с тези от потребителя"); return; } #endregion CallContext = AdminClientRef.ChangeUserForgottenPasswordPassword(user, person, CallContext); CheckIfResultIsSuccess(lbResultContext); this.lbResultContext.Text = CallContext.Message; }
public override void UserControlLoad() { if (this.ownerPage == null) { throw new UMSException("Current Page is null or is not inheritor of BasicPage."); } InitLoadControls(); SetEmptyValues(); if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING) { this.CurrentEntityMasterID = this.hdnRowMasterKey.Value; } this.currentEntity = this.ownerPage.AdminClientRef.GetUserByUserID(this.CurrentEntityMasterID); if (this.currentEntity != null) { this.tbxUserName.Text = this.currentEntity.UserName; this.tbxPassword.Attributes.Add("value", BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.Password))); this.tbxPassword.Text = ETEMModel.Helpers.BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.Password)); Person person = this.ownerPage.AdminClientRef.GetPersonByPersonID(this.currentEntity.idPerson.ToString()); if (person != null) { this.tbxAutoCompletePersonName.Text = person.FullName; this.tbxAutoCompletePersonName.SelectedValue = person.idPerson.ToString(); this.tbxEGN.Text = person.EGN; this.tbxIdentityNumber.Text = person.IdentityNumber; this.tbxMail.Text = person.EMail; } BaseHelper.CheckAndSetSelectedValue(this.ddlStatus.DropDownListCTRL, this.currentEntity.idStatus, false); BaseHelper.CheckAndSetSelectedValue(this.ddlCheckDomain.DropDownListCTRL, this.currentEntity.idCheckDomain, false); if (this.currentEntity.idAltPerson.HasValue) { Person altPerson = this.ownerPage.AdminClientRef.GetPersonByPersonID(this.currentEntity.idAltPerson.Value.ToString()); if (altPerson != null) { this.tbxAutoCompleteAltPersonName.Text = altPerson.FullName; this.tbxAutoCompleteAltPersonName.SelectedValue = altPerson.idPerson.ToString(); } } this.tbxAltPassword.Attributes.Add("value", BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.AltPassword))); this.tbxAltPassword.Text = ETEMModel.Helpers.BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.AltPassword)); this.tbxDescription.Text = this.currentEntity.Description; this.hdnRowMasterKey.Value = this.currentEntity.idUser.ToString(); ClearResultContext(); } else { SetEmptyValues(); } }
public override Tuple<CallContext, string> UserControlSave() { bool isNewEntity = true; if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING) { this.currentEntity = new User(); } else { this.currentEntity = this.ownerPage.AdminClientRef.GetUserByUserID(this.hdnRowMasterKey.Value); if (this.currentEntity == null) { string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("UserMain_Data")); this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error; this.ownerPage.CallContext.Message = falseResult; return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("UserMain_Data")); } isNewEntity = false; } this.currentEntity.UserName = this.tbxUserName.Text.Trim(); this.currentEntity.Password = ETEMModel.Helpers.BaseHelper.Encrypt(this.tbxPassword.Text.Trim()); this.currentEntity.idPerson = this.tbxAutoCompletePersonName.SelectedValueIntOrInvalidID; this.currentEntity.idStatus = this.ddlStatus.SelectedValueINT; this.currentEntity.idCheckDomain = this.ddlCheckDomain.SelectedValueINT; this.currentEntity.idAltPerson = this.tbxAutoCompleteAltPersonName.SelectedValueINT; this.currentEntity.AltPassword = ETEMModel.Helpers.BaseHelper.Encrypt(this.tbxAltPassword.Text.Trim()); this.currentEntity.Description = this.tbxDescription.Text; this.ownerPage.CallContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser; this.ownerPage.CallContext = this.ownerPage.AdminClientRef.UserSave(this.currentEntity, this.ownerPage.CallContext); this.lbResultContext.Text = this.ownerPage.CallContext.Message; if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success) { this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID; this.tbxPassword.Attributes.Add("value", BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.Password))); this.tbxPassword.Text = ETEMModel.Helpers.BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.Password)); this.tbxAltPassword.Attributes.Add("value", BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.AltPassword))); this.tbxAltPassword.Text = ETEMModel.Helpers.BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.AltPassword)); Person person = this.ownerPage.AdminClientRef.GetPersonByPersonID(this.currentEntity.idPerson.ToString()); if (isNewEntity && person != null) { this.tbxEGN.Text = person.EGN; this.tbxIdentityNumber.Text = person.IdentityNumber; } } CheckIfResultIsSuccess(); return new Tuple<CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("UserMain_Data")); }
public override Tuple <CallContext, string> UserControlSave() { bool isNewEntity = true; if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING) { this.currentEntity = new User(); } else { this.currentEntity = this.ownerPage.AdminClientRef.GetUserByUserID(this.hdnRowMasterKey.Value); if (this.currentEntity == null) { string falseResult = string.Format(BaseHelper.GetCaptionString("Entity_is_not_update_in_tab"), BaseHelper.GetCaptionString("UserMain_Data")); this.ownerPage.CallContext.ResultCode = ETEMEnums.ResultEnum.Error; this.ownerPage.CallContext.Message = falseResult; return(new Tuple <CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("UserMain_Data"))); } isNewEntity = false; } this.currentEntity.UserName = this.tbxUserName.Text.Trim(); this.currentEntity.Password = ETEMModel.Helpers.BaseHelper.Encrypt(this.tbxPassword.Text.Trim()); this.currentEntity.idPerson = this.tbxAutoCompletePersonName.SelectedValueIntOrInvalidID; this.currentEntity.idStatus = this.ddlStatus.SelectedValueINT; this.currentEntity.idCheckDomain = this.ddlCheckDomain.SelectedValueINT; this.currentEntity.idAltPerson = this.tbxAutoCompleteAltPersonName.SelectedValueINT; this.currentEntity.AltPassword = ETEMModel.Helpers.BaseHelper.Encrypt(this.tbxAltPassword.Text.Trim()); this.currentEntity.Description = this.tbxDescription.Text; this.ownerPage.CallContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser; this.ownerPage.CallContext = this.ownerPage.AdminClientRef.UserSave(this.currentEntity, this.ownerPage.CallContext); this.lbResultContext.Text = this.ownerPage.CallContext.Message; if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success) { this.hdnRowMasterKey.Value = this.ownerPage.CallContext.EntityID; this.tbxPassword.Attributes.Add("value", BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.Password))); this.tbxPassword.Text = ETEMModel.Helpers.BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.Password)); this.tbxAltPassword.Attributes.Add("value", BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.AltPassword))); this.tbxAltPassword.Text = ETEMModel.Helpers.BaseHelper.Decrypt(System.Web.HttpUtility.UrlDecode(this.currentEntity.AltPassword)); Person person = this.ownerPage.AdminClientRef.GetPersonByPersonID(this.currentEntity.idPerson.ToString()); if (isNewEntity && person != null) { this.tbxEGN.Text = person.EGN; this.tbxIdentityNumber.Text = person.IdentityNumber; } } CheckIfResultIsSuccess(); return(new Tuple <CallContext, string>(this.ownerPage.CallContext, BaseHelper.GetCaptionString("UserMain_Data"))); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="idUser">Initial value of the idUser property.</param> /// <param name="idPerson">Initial value of the idPerson property.</param> /// <param name="idStatus">Initial value of the idStatus property.</param> public static User CreateUser(global::System.Int32 idUser, global::System.Int32 idPerson, global::System.Int32 idStatus) { User user = new User(); user.idUser = idUser; user.idPerson = idPerson; user.idStatus = idStatus; return user; }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }