public static ValidationFormat GetRegularExpressionByStateId(int StateId) { int validationRuleId = StateHelper.GetStateById(StateId).ValidationRuleId.Value; ValidationRule validationRule = LicenseValidationHelper.GetValidationRuleById(validationRuleId); ValidationFormat validationFormat = new ValidationFormat(); validationFormat.RegularExpression = validationRule.RegularExpression; validationFormat.IsSSN = validationRule.IsSSN; validationFormat.IsUserLoggedIn = false; validationFormat.SSN = string.Empty; validationFormat.ErrorMessage = validationRule.Description; if (SessionWrapper.LoggedUser != null) { validationFormat.IsUserLoggedIn = true; User user = UserHelper.GetUserById(SessionWrapper.LoggedUser.UserId); if (validationFormat.IsSSN) { if (!string.IsNullOrEmpty(user.IdentificationValue)) { validationFormat.SSN = EncryptionHelper.Decryptdata(user.IdentificationValue); } } if (validationRule.IsLastCharcter) { validationFormat.RegularExpression = validationFormat.RegularExpression.Replace("[a-zA-Z]", user.LastName[0].ToString()); } } return(validationFormat); }
private void SetUserLicenseInfo() { UserLicenseInfo userLicenseInfo = UserLicenseInfoHelper.GetUserLicenseInfoByUserId(SessionWrapper.LoggedUser.UserId); if (userLicenseInfo != null) { txtNumber.Text = userLicenseInfo.LicenseNumber; txtName.Text = userLicenseInfo.LicenseName; // txtAgency.Text = userLicenseInfo.LicensingAgency; ddlStateLicense.Index = userLicenseInfo.StateId; ValidationRule validationRule = LicenseValidationHelper.GetValidationRuleById(StateHelper.GetStateById(userLicenseInfo.StateId).ValidationRuleId.Value); string regExp = validationRule.RegularExpression; regExp = regExp.Replace(@"\", @"\\"); User user = UserHelper.GetUserById(SessionWrapper.LoggedUser.UserId); if (validationRule.IsLastCharcter) { string lastCharacter = user.LastName[0].ToString(); regExp = regExp.Replace("[a-zA-Z]", lastCharacter); } string SSN = string.Empty; if (validationRule.IsSSN) { SSN = user.IdentificationValue.Replace("-", string.Empty); } hdnIsLoggedIn.Value = "True"; hdnIsSSN.Value = validationRule.IsSSN.ToString(); hdnRegularExp.Value = validationRule.RegularExpression; hdnSSN.Value = SSN; hdnErrorMessage.Value = validationRule.Description; ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "LicenseWrapper('" + regExp + "' ,'" + validationRule.IsSSN + "','" + true + "','" + SSN + "');", true); } }