public void Add (ProfileInfo profileInfo) { if (readOnly) throw new NotSupportedException (); list.Add (profileInfo); }
public void Add(ProfileInfo profileInfo) { if (_ReadOnly) throw new NotSupportedException(); if (profileInfo == null || profileInfo.UserName == null) throw new ArgumentNullException( "profileInfo" ); _Hashtable.Add(profileInfo.UserName, _CurPos); _ArrayList.Add(profileInfo); _CurPos++; }
public void Add(ProfileInfo profileInfo) { if (this._ReadOnly) { throw new NotSupportedException(); } if ((profileInfo == null) || (profileInfo.UserName == null)) { throw new ArgumentNullException("profileInfo"); } this._Hashtable.Add(profileInfo.UserName, this._CurPos); this._ArrayList.Add(profileInfo); this._CurPos++; }
private ProfileInfo GetProfileInfoFromReader(IDataReader reader) { string username = reader.GetString(0); DateTime lastActivityDate = new DateTime(); if (reader.GetValue(1) != DBNull.Value) { lastActivityDate = reader.GetDateTime(1); } DateTime lastUpdatedDate = new DateTime(); if (reader.GetValue(2) != DBNull.Value) { lastUpdatedDate = reader.GetDateTime(2); } bool isAnonymous = reader.GetBoolean(3); ProfileInfo profileInfo = new ProfileInfo(username, isAnonymous, lastActivityDate, lastUpdatedDate, 0); return profileInfo; }
private static ProfileInfo ToProfileInfo(ProfileValue profileValue) { SessionWrapper sessionWrapper = SessionManager.GetSessionWrapper(); try { var reuslt = new ProfileInfo(profileValue.LoginId, profileValue.IsAnonymous, profileValue.LastActivityDate.Value, profileValue.LastActivityDate.Value, 0); return reuslt; } finally { sessionWrapper.Close(); } }
private ProfileInfo GetProfileInfoFromProfile(Profile p) { var user = users.Get(p.Users_Id); if (user == null) throw new ProviderException("The userid not found in memebership tables.GetProfileInfoFromProfile(p)"); // ProfileInfo.Size not currently implemented. var pi = new ProfileInfo(user.Username, p.IsAnonymous, p.LastActivityDate, p.LastUpdatedDate, 0); return pi; }
// GetProfileInfo // Retrieves a count of profiles and creates a // ProfileInfoCollection from the profile data in the // database. Called by GetAllProfiles, GetAllInactiveProfiles, // FindProfilesByUserName, FindInactiveProfilesByUserName, // and GetNumberOfInactiveProfiles. // Specifying a pageIndex of 0 retrieves a count of the results only. private ProfileInfoCollection GetProfileInfo( ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime? userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) { totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); // Count profiles only. if (pageSize == 0) return profiles; int counter = 0; int startIndex = pageSize * (pageIndex - 1); int endIndex = startIndex + pageSize - 1; bool? isAnonymous = null; if (authenticationOption == ProfileAuthenticationOption.Anonymous) isAnonymous = true; else if (authenticationOption == ProfileAuthenticationOption.Authenticated) isAnonymous = false; foreach (CustomProfile profile in Accessor.GetProfile( isAnonymous, usernameToMatch, userInactiveSinceDate, _applicationName, out totalRecords)) { if (counter >= startIndex) { ProfileInfo p = new ProfileInfo( profile.UserName, profile.IsAnonymous ?? true, profile.LastActivityDate ?? DateTime.MinValue, profile.LastUpdatedDate ?? DateTime.MinValue, 0); profiles.Add(p); } if (counter >= endIndex) break; counter++; } return profiles; }
/// <summary> /// Gets the profile info from reader. /// </summary> /// <param name="profile">The profile.</param> /// <returns></returns> private ProfileInfo GetProfileInfoFromReader(BsonDocument profile) { string username = profile["Username"].AsString; DateTime lastActivityDate = new DateTime(); if (profile["LastActivityDate"] != BsonNull.Value) lastActivityDate = profile["LastActivityDate"].ToUniversalTime(); DateTime lastUpdatedDate = new DateTime(); if (profile["LastUpdatedDate"] != BsonNull.Value) lastUpdatedDate = profile["LastUpdatedDate"].ToUniversalTime(); bool isAnonymous = profile["IsAnonymous"].AsBoolean; ProfileInfo p = new ProfileInfo(username, isAnonymous, lastActivityDate, lastUpdatedDate, 0); return p; }
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { // TODO: Take paging into account // TODO: Take auth option into account totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); SelectRequest request = new SelectRequest().WithSelectExpression("select * from " + domain); SelectResponse response = client.Select(request); if (response.SelectResult.Item.Count > 0) { foreach (Item _item in response.SelectResult.Item) { ProfileInfo profile = null; List<Attribute> attributes = _item.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = _item.Name; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } bool Anon = bool.Parse(item.Get("Anon").Replace("", "false")); DateTime LastActivity = DateTime.Parse(item.Get("LastActivity")); DateTime LastUpdated = DateTime.Parse(item.Get("LastUpdated")); profile = new ProfileInfo(item.Id, Anon, LastActivity, LastUpdated, 0); profiles.Add(profile); } } totalRecords = profiles.Count; return profiles; }
public void Add(ProfileInfo profileInfo) { }
private ProfileInfo GetProfileInfoFromProfile(Profiles p) { Users usr = null; using (ISession session = SessionFactory.OpenSession()) { usr = session.CreateCriteria(typeof(Users)) .Add(NHibernate.Criterion.Restrictions.Eq("Id", p.Users_Id)) .Add(NHibernate.Criterion.Restrictions.Eq("ApplicationName", ApplicationName)) .UniqueResult<Users>(); } if (usr == null) throw new ProviderException("The userid not found in memebership tables.GetProfileInfoFromProfile(p)"); // ProfileInfo.Size not currently implemented. ProfileInfo pi = new ProfileInfo(usr.Username, p.IsAnonymous, p.LastActivityDate, p.LastUpdatedDate, 0); return pi; }
private ProfileInfoCollection ProfileUsersToProfileInfoCollection(IList<ProfileUser> users) { ProfileInfoCollection profilesCollection = new ProfileInfoCollection(); foreach (ProfileUser user in users) { bool isAnonymous; if (user.ProfileType == ProfileType.Anonymous) isAnonymous = true; else isAnonymous = false; ProfileInfo profileInfo = new ProfileInfo(user.Name, isAnonymous, user.LastActivityDate, user.LastPropertyChangedDate, -1); profilesCollection.Add(profileInfo); } return profilesCollection; }
/// <summary> /// When overridden in a derived class, retrieves user profile data for all profiles /// in the data source. /// </summary> /// <param name="authenticationOption">One of the System.Web.Profile.ProfileAuthenticationOption values, specifying /// whether anonymous, authenticated, or both types of profiles are returned.</param> /// <param name="pageIndex">The index of the page of results to return.</param> /// <param name="pageSize">The size of the page of results to return.</param> /// <param name="totalRecords">When this method returns, contains the total number of profiles.</param> /// <returns>A System.Web.Profile.ProfileInfoCollection containing user-profile information /// for all profiles in the data source.</returns> public System.Web.Profile.ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection profileInfoCol = new ProfileInfoCollection(); Nequeo.DataAccess.CloudInteraction.Data.Extension.Profile profile = new Nequeo.DataAccess.CloudInteraction.Data.Extension.Profile(); // Get all the profiles for the match. long profilesMatched = 0; int skipNumber = (pageIndex * pageSize); // Get the current set on data. IQueryable <Data.Profile> profileData = null; // Select the authentication option switch (authenticationOption) { case ProfileAuthenticationOption.Anonymous: profileData = profile.Select.QueryableProvider(). Where(u => (u.ApplicationName == ApplicationName) && (u.IsAnonymous == true)). OrderBy(u => u.Username). Take(pageSize). Skip(skipNumber); profilesMatched = profile.Select.GetRecordCount(u => (u.ApplicationName == ApplicationName) && (u.IsAnonymous == true)); totalRecords = Int32.Parse(profilesMatched.ToString()); break; case ProfileAuthenticationOption.Authenticated: profileData = profile.Select.QueryableProvider(). Where(u => (u.ApplicationName == ApplicationName) && (u.IsAnonymous == false)). OrderBy(u => u.Username). Take(pageSize). Skip(skipNumber); profilesMatched = profile.Select.GetRecordCount(u => (u.ApplicationName == ApplicationName) && (u.IsAnonymous == false)); totalRecords = Int32.Parse(profilesMatched.ToString()); break; default: // Get all the profiles for the match. profilesMatched = profile.Select.GetRecordCount( u => (u.ApplicationName == ApplicationName)); // Get the total number of uses. totalRecords = Int32.Parse(profilesMatched.ToString()); // Get the current set on data. profileData = profile.Select.QueryableProvider(). Where(u => (u.ApplicationName == ApplicationName)). OrderBy(u => u.Username). Take(pageSize). Skip(skipNumber); break; } // For each profile found. if (profileData != null) { foreach (Data.Profile item in profileData) { // Create the membership user. System.Web.Profile.ProfileInfo profileUser = new System.Web.Profile.ProfileInfo( item.Username, item.IsAnonymous.Value, item.LastActivityDate.Value, item.LastUpdatedDate.Value, 0); // Add the profile to the collection. profileInfoCol.Add(profileUser); } } // Return the collection of profile users. return(profileInfoCol); }
public void CopyTo (ProfileInfo[ ] array, int index) { list.CopyTo (array, index); }
private ProfileInfo GetProfileInfoFromProfile(Profiles p) { Users usr = null; usr = _userService.GetUserByIdApplicationName(p.UserId, ApplicationName); if (usr == null) throw new ProviderException("The userid not found in memebership tables.GetProfileInfoFromProfile(p)"); // ProfileInfo.Size not currently implemented. var pi = new ProfileInfo(usr.Username, p.IsAnonymous, p.LastActivityDate, p.LastUpdatedDate, 0); return pi; }
/// <summary> /// Returns a user's profile /// Currently assumes a single user will match the token. /// </summary> /// <param name="authenticationOption"></param> /// <param name="usernameToMatch"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRecords"></param> /// <returns></returns> public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { // TODO: Take paging into account // TODO: Take auth option into account totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(domain).WithItemName(usernameToMatch); GetAttributesResponse response = client.GetAttributes(request); if (response.GetAttributesResult.Attribute.Count > 0) { ProfileInfo profile = null; List<Attribute> attributes = response.GetAttributesResult.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = usernameToMatch; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } bool Anon = bool.Parse(item.Get("Anon").Replace("", "false")); DateTime LastActivity = DateTime.Parse(item.Get("LastActivity")); DateTime LastUpdated = DateTime.Parse(item.Get("LastUpdated")); profile = new ProfileInfo(item.Id, Anon, LastActivity, LastUpdated, 0); profiles.Add(profile); } totalRecords = profiles.Count; return profiles; }
public void CopyTo(ProfileInfo[] array, int index) { }
public static ProfileInfo[] ToArray(this ProfileInfoCollection collection) { var profiles = new ProfileInfo[collection.Count]; collection.CopyTo(profiles, 0); return profiles; }
public void CopyTo(ProfileInfo [] array, int index) { DoCompact(); _ArrayList.CopyTo(array, index); }
//GetProfileInfo //Retrieves a count of profiles and creates a //ProfileInfoCollection from the profile data in the //database. Called by GetAllProfiles, GetAllInactiveProfiles, //FindProfilesByUserName, FindInactiveProfilesByUserName, //and GetNumberOfInactiveProfiles. //Specifying a pageIndex of 0 retrieves a count of the results only. private static ProfileInfoCollection GetProfileInfo(ProfileAuthenticationOption authenticationOption, string usernameToMatch, object userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection profiles = new ProfileInfoCollection(); totalRecords = 0; // Count profiles only. if (pageSize == 0) return profiles; int counter = 0; int startIndex = pageSize * (pageIndex - 1); int endIndex = startIndex + pageSize - 1; DateTime dt = new DateTime(1900, 1, 1); if (userInactiveSinceDate != null) dt = (DateTime)userInactiveSinceDate; foreach (CustomProfileInfo profile in dal.GetProfileInfo((int)authenticationOption, usernameToMatch, dt, applicationName, out totalRecords)) { if (counter >= startIndex) { ProfileInfo p = new ProfileInfo(profile.UserName, profile.IsAnonymous, profile.LastActivityDate, profile.LastUpdatedDate, 0); profiles.Add(p); } if (counter >= endIndex) { break; } counter++; } return profiles; }
/// <summary> /// The get all profiles. /// </summary> /// <param name="authenticationOption"> /// The authentication option. /// </param> /// <param name="pageIndex"> /// The page index. /// </param> /// <param name="pageSize"> /// The page size. /// </param> /// <param name="totalRecords"> /// The total records. /// </param> /// <returns> /// The System.Web.Profile.ProfileInfoCollection. /// </returns> public override ProfileInfoCollection GetAllProfiles( ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection collection = new ProfileInfoCollection(); XmlNodeList profiles = this.doc.SelectNodes("/Profiles/Profile"); if (profiles != null) { totalRecords = profiles.Count; int startIndex = pageIndex * pageSize; int endIndex = startIndex + pageSize - 1; if (totalRecords < (startIndex + 1)) { return collection; } if (endIndex > totalRecords - 1) { endIndex = totalRecords - 1; } for (int curIndex = startIndex; curIndex <= endIndex; curIndex++) { XmlNode profile = profiles[curIndex]; string userName = profile.Attributes["UserName"].Value; DateTime actDate = DateTime.MinValue; DateTime.TryParseExact( profile.Attributes["LastActivity"].Value, this.dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out actDate); DateTime updDate = DateTime.MinValue; DateTime.TryParseExact( profile.Attributes["LastUpdated"].Value, this.dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out updDate); ProfileInfo info = new ProfileInfo(userName, true, actDate, updDate, profile.InnerXml.Length); collection.Add(info); } } totalRecords = collection.Count; return collection; }
private ProfileInfoCollection GetProfiles( ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) { List<string> whereClauses = new List<string>(); using (MySqlConnection c = new MySqlConnection(connectionString)) { c.Open(); MySqlCommand cmd = new MySqlCommand( @"SELECT p.*, u.name, u.isAnonymous, u.lastActivityDate, LENGTH(p.stringdata) + LENGTH(p.binarydata) AS profilesize FROM my_aspnet_profiles p JOIN my_aspnet_users u ON u.id = p.userId WHERE u.applicationId = @appId", c); cmd.Parameters.AddWithValue("@appId", app.FetchId(c)); if (usernameToMatch != null) { cmd.CommandText += " AND u.name LIKE @userName"; cmd.Parameters.AddWithValue("@userName", usernameToMatch); } if (userInactiveSinceDate != DateTime.MinValue) { cmd.CommandText += " AND u.lastActivityDate < @lastActivityDate"; cmd.Parameters.AddWithValue("@lastActivityDate", userInactiveSinceDate); } if (authenticationOption == ProfileAuthenticationOption.Anonymous) cmd.CommandText += " AND u.isAnonymous = 1"; else if (authenticationOption == ProfileAuthenticationOption.Authenticated) cmd.CommandText += " AND u.isAnonymous = 0"; cmd.CommandText += String.Format(" LIMIT {0},{1}", pageIndex * pageSize, pageSize); ProfileInfoCollection pic = new ProfileInfoCollection(); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { ProfileInfo pi = new ProfileInfo( reader.GetString("name"), reader.GetBoolean("isAnonymous"), reader.GetDateTime("lastActivityDate"), reader.GetDateTime("lastUpdatedDate"), reader.GetInt32("profilesize")); pic.Add(pi); } } cmd.CommandText = "SELECT FOUND_ROWS()"; totalRecords = Convert.ToInt32(cmd.ExecuteScalar()); return pic; } }
// // GetProfileInfoFromReader // Takes the current row from the OdbcDataReader // and populates a ProfileInfo object from the values. // private ProfileInfo GetProfileInfoFromReader(OdbcDataReader reader) { string username = reader.GetString(0); DateTime lastActivityDate = new DateTime(); if (reader.GetValue(1) != DBNull.Value) lastActivityDate = reader.GetDateTime(1); DateTime lastUpdatedDate = new DateTime(); if (reader.GetValue(2) != DBNull.Value) lastUpdatedDate = reader.GetDateTime(2); bool isAnonymous = reader.GetBoolean(3); // ProfileInfo.Size not currently implemented. ProfileInfo p = new ProfileInfo(username, isAnonymous, lastActivityDate, lastUpdatedDate, 0); return p; }
ProfileInfo ReadProfileInfo (DbDataReader reader) { ProfileInfo pi = null; try { string username = reader.GetString (0); bool anonymous = reader.GetBoolean (1); DateTime lastUpdate = reader.GetDateTime (2); DateTime lastActivity = reader.GetDateTime (3); int size = reader.GetInt32 (4); pi = new ProfileInfo (username, anonymous, lastActivity, lastUpdate, size); } catch { } return pi; }
private static ProfileInfo CreateProfileInfoFromDictionary(IDictionary<string, byte[]> dict) { var profileInfo = new ProfileInfo(new string(Encoding.Unicode.GetChars(dict["Username"])), !BitConverter.ToBoolean(dict["IsAuthenticated"], 0), DateTime.FromBinary(BitConverter.ToInt64(dict["LastActivityDate"], 0)), DateTime.FromBinary(BitConverter.ToInt64(dict["LastUpdatedDate"], 0)), 0); return profileInfo; }