/// <summary> /// Gets the Profile properties for the User /// </summary> /// <param name="portalId">The Id of the portal.</param> /// <param name="objProfile">The profile.</param> /// <history> /// [cnurse] 03/29/2006 Created /// </history> private void GetProfileProperties(int portalId, IDataReader dr, UserProfile objProfile) { int definitionId; ProfilePropertyDefinition profProperty; ProfilePropertyDefinitionCollection properties; properties = ProfileController.GetPropertyDefinitionsByPortal( portalId ); //Iterate through the Profile properties try { while( dr.Read() ) { definitionId = Convert.ToInt32( dr["PropertyDefinitionId"] ); profProperty = properties.GetById( definitionId ); if( profProperty != null ) { profProperty.PropertyValue = Convert.ToString( dr["PropertyValue"] ); profProperty.Visibility = (UserVisibilityMode)dr["Visibility"]; } } } finally { if( dr != null ) { dr.Close(); } } //Add the properties to the profile foreach( ProfilePropertyDefinition tempLoopVar_profProperty in properties ) { profProperty = tempLoopVar_profProperty; objProfile.ProfileProperties.Add( profProperty ); } }
private static UserInfo FillUserAndProfile(int portalId, IDataReader dr) { UserInfo user = null; bool bContinue = (String.Equals(dr.GetName(0), "UserID", StringComparison.InvariantCultureIgnoreCase)); //Ensure the data reader returned is valid if (bContinue) { user = new UserInfo { PortalID = Null.SetNullInteger(dr["PortalID"]), IsSuperUser = Null.SetNullBoolean(dr["IsSuperUser"]), IsDeleted = Null.SetNullBoolean(dr["IsDeleted"]), UserID = Null.SetNullInteger(dr["UserID"]), DisplayName = Null.SetNullString(dr["DisplayName"]), Username = Null.SetNullString(dr["Username"]), Email = Null.SetNullString(dr["Email"]), AffiliateID = Null.SetNullInteger(dr["AffiliateID"]) }; user.AffiliateID = Null.SetNullInteger(Null.SetNull(dr["AffiliateID"], user.AffiliateID)); UserController.GetUserMembership(user); user.Membership.UpdatePassword = Null.SetNullBoolean(dr["UpdatePassword"]); if (!user.IsSuperUser) { user.Membership.Approved = Null.SetNullBoolean(dr["Authorised"]); } if (user.PortalID == Null.NullInteger) { user.PortalID = portalId; } var userProfile = new UserProfile(user); userProfile.InitialiseProfile(portalId); for (int i = 0; i < dr.FieldCount; i++) { switch (dr.GetName(i)) { case "PortalID": case "IsSuperUser": case "IsDeleted": case "UserID": case "DisplayName": case "Username": case "Email": case "AffiliateID": case "UpdatePassword": case "Authorised": case "CreateDate": case "LastActivityDate": case "LastLockoutDate": case "LastLoginDate": case "LastPasswordChangedDate": case "IsLockedOut": case "PasswordQuestion": case "IsApproved": case "PasswordResetToken": case "PasswordResetExpiration": break; default: //Probably a profile property string name = dr.GetName(i); userProfile.SetProfileProperty(name, Null.SetNullString(dr[name])); break; } } user.Profile = userProfile; } return user; }
public void DateTimePropertyAcccess_GetProperty_Adjusts_For_TimeZone(string propertyName, string timeZoneId) { //Arrange var dtPropertyAccess = new DateTimePropertyAccess(); var userTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); var timeZoneProfileProperty = new ProfilePropertyDefinition(Constants.PORTAL_Zero) { PropertyName = "PreferredTimeZone", PropertyValue = timeZoneId }; var userProfile = new UserProfile(); userProfile.ProfileProperties.Add(timeZoneProfileProperty); var accessingUser = new UserInfo { Profile = userProfile }; var culture = CultureInfo.InvariantCulture; string expected = String.Empty; switch (propertyName) { case "current": expected = TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString("D", culture); break; case "now": expected = TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString("g", culture); break; case "system": expected = DateTime.Now.ToString("g", culture); break; case "utc": expected = DateTime.Now.ToUniversalTime().ToString("g", culture); break; } //Act bool propertyNotFound = false; string propertyValue = dtPropertyAccess.GetProperty(propertyName, "", culture, accessingUser, Scope.DefaultSettings, ref propertyNotFound); //Assert Assert.AreEqual(expected, propertyValue); }
/// ----------------------------------------------------------------------------- /// <summary> /// Validates the Profile properties for the User (determines if all required properties /// have been set) /// </summary> /// <param name="portalId">The Id of the portal.</param> /// <param name="objProfile">The profile.</param> /// ----------------------------------------------------------------------------- public static bool ValidateProfile(int portalId, UserProfile objProfile) { bool isValid = true; var imageType = new ListController().GetListEntryInfo("DataType", "Image"); foreach (ProfilePropertyDefinition propertyDefinition in objProfile.ProfileProperties) { if (propertyDefinition.Required && string.IsNullOrEmpty(propertyDefinition.PropertyValue) && propertyDefinition.DataType != imageType.EntryID) { isValid = false; break; } } return isValid; }
/// ----------------------------------------------------------------------------- /// <summary> /// Validates the Profile properties for the User (determines if all required properties /// have been set) /// </summary> /// <param name="portalId">The Id of the portal.</param> /// <param name="objProfile">The profile.</param> /// ----------------------------------------------------------------------------- public static bool ValidateProfile(int portalId, UserProfile objProfile) { bool isValid = true; foreach (ProfilePropertyDefinition propertyDefinition in objProfile.ProfileProperties) { if (propertyDefinition.Required && string.IsNullOrEmpty(propertyDefinition.PropertyValue)) { isValid = false; break; } } return isValid; }
/// <summary> /// Validates the Profile properties for the User (determines if all required properties /// have been set) /// </summary> /// <param name="portalId">The Id of the portal.</param> /// <param name="objProfile">The profile.</param> public static bool ValidateProfile(int portalId, UserProfile objProfile) { bool isValid = true; foreach (ProfilePropertyDefinition propertyDefinition in objProfile.ProfileProperties) { if (propertyDefinition.Required && propertyDefinition.PropertyValue == Null.NullString) { isValid = false; goto endOfForLoop; } } endOfForLoop: return isValid; }
/// <summary> /// GetUserProfile retrieves the UserProfile information from the Data Store /// </summary> /// <remarks> /// </remarks> /// <param name="user">The user whose Profile information we are retrieving.</param> /// <history> /// [cnurse] 03/29/2006 Created /// </history> public override void GetUserProfile(ref UserInfo user) { int portalId; if( user.IsSuperUser ) { portalId = Common.Globals.glbSuperUserAppName; } else { portalId = user.PortalID; } IDataReader dr = dataProvider.GetUserProfile( user.UserID ); UserProfile objUserProfile = new UserProfile(); GetProfileProperties( portalId, dr, objUserProfile ); //Clear IsDirty Flag objUserProfile.ClearIsDirty(); user.Profile = objUserProfile; }
public UserInfo() { _UserID = -1; _PortalID = -1; _IsSuperUser = false; _AffiliateID = -1; _Membership = new UserMembership(); _Profile = new UserProfile(); }