/// <summary> /// When overridden in a derived class, deletes profile properties and information /// for the supplied list of profiles. /// </summary> /// <param name="profiles">A System.Web.Profile.ProfileInfoCollection of information about profiles /// that are to be deleted.</param> /// <returns>The number of profiles deleted from the data source.</returns> public int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { int deleteCount = 0; // For each profile found delete the profile. foreach (ProfileInfo p in profiles) { // Get the profile for the current user name. Nequeo.DataAccess.CloudInteraction.Data.Profile profile = GetSpecificProfile(p.UserName); // If a profile exits. if (profile != null) { // Delete all profile values and profiles. if (DeleteProfileValue(profile.ProfileID)) { if (DeleteProfile(p.UserName)) { deleteCount++; } } } } // The number of profiles deleted. return(deleteCount); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { return DeleteProfiles(profiles .Cast<ProfileInfo>() .Select(profile => profile.UserName) .ToArray()); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, ProviderResources.Parameter_collection_empty, new object[] { "profiles" }), "profiles"); } int num = 0; using (MembershipContext context = ModelHelper.CreateMembershipContext(this.ConnectionString)) { foreach (ProfileInfo info in profiles) { ProfileEntity entity = QueryHelper.GetProfile(context, this.ApplicationName, info.UserName); if (entity != null) { num++; context.Profiles.Remove(entity); } } context.SaveChanges(); } return num; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { foreach (var prof in profiles) { NHibernateHelper.Delete(prof); } return profiles.Count; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { List<string> userNames = new List<string>(); foreach (ProfileInfo profile in profiles) { userNames.Add(profile.UserName); } return this.DeleteProfiles(userNames.Distinct<string>().ToArray<string>()); }
/// <summary> /// Deletes profile properties and information for the supplied list of profiles. /// </summary> /// <param name="profiles">A System.Web.Profile.ProfileInfoCollection of information about profiles that are to be deleted.</param> /// <returns>The number of profiles deleted from the data source.</returns> public override int DeleteProfiles(ProfileInfoCollection profiles) { int deleteCount = 0; foreach (ProfileInfo p in profiles) if (DeleteProfile(p.UserName)) deleteCount++; return deleteCount; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { string[] usernames = new string[profiles.Count]; int i = 0; foreach(ProfileInfo profile in profiles) { usernames[i++] = profile.UserName; } return DeleteProfiles(usernames); }
/// <summary> /// Erzeugt eine leere Auflistung für Benutzerprofile. /// </summary> /// <param name="totalRecords">Meldet die gesamte Anzahl von Einträgen.</param> /// <returns>Eine neue, leere Auflistung.</returns> private ProfileInfoCollection CreateEmptyCollection( out int totalRecords ) { // Create collection var result = new ProfileInfoCollection(); // None totalRecords = 0; // Finish return result; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw TraceException("DeleteProfiles", new ArgumentNullException("profiles")); } if (profiles.Count == 0) { return 0; } return DeleteProfiles(profiles.Cast<ProfileInfo>().Select(p => p.UserName).ToArray()); }
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection profiles = new ProfileInfoCollection(); UserList users = Bridge.GetUserContainer(false); if (users != null) { totalRecords = users.Children.Count; foreach(User u in users.GetChildren(new Collections.CountFilter(pageIndex * pageSize, pageSize))) profiles.Add(CreateProfile(u)); } totalRecords = 0; return profiles; }
/// <summary> /// Delete profiles based upon the user names in the collection of profiles. /// </summary> /// <param name="profiles">Collection of profiles.</param> /// <returns>Number of profiles deleted.</returns> public override int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { string[] userNames = new string[profiles.Count]; int index = 0; foreach (ProfileInfo profileInfo in profiles) { userNames[index] = profileInfo.UserName; index += 1; } return(DeleteProfiles(userNames)); }
public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection profiles = new ProfileInfoCollection(); User u = Bridge.GetUser(usernameToMatch); if (u != null) { totalRecords = 1; if(pageIndex == 0 && pageSize > 0) profiles.Add(CreateProfile(u)); } totalRecords = 0; return profiles; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { var deleteCount = 0; try { deleteCount = profiles.Cast<ProfileInfo>().Count(p => DeleteProfile(p.UserName)); } catch (Exception ex) { if (WriteExceptionsToEventLog) { WriteToEventLog(ex, "DeleteProfiles(ProfileInfoCollection)"); throw new ProviderException(exceptionMessage); } throw; } return deleteCount; }
/// <summary> /// When overridden in a derived class, deletes profile properties and information for the supplied list of profiles. /// </summary> /// <returns>The number of profiles deleted from the data source.</returns> /// <param name="profiles">A <see cref="T:System.Web.Profile.ProfileInfoCollection" /> of information about profiles that are to be deleted.</param> public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException("profiles"); } string[] usernames = profiles.Cast<ProfileInfo>().Select(p => p.UserName).ToArray(); return DeleteProfiles(usernames); }
public static int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException(System.Web.SR.GetString("Parameter_collection_empty", new object[] { "profiles" }), "profiles"); } foreach (ProfileInfo info in profiles) { SecUtility.CheckParameter(ref info.UserName, true, true, true, 0, "UserName"); } return(Provider.DeleteProfiles(profiles)); }
public static int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException(System.Web.SR.GetString("Parameter_collection_empty", new object[] { "profiles" }), "profiles"); } foreach (ProfileInfo info in profiles) { SecUtility.CheckParameter(ref info.UserName, true, true, true, 0, "UserName"); } return Provider.DeleteProfiles(profiles); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { Condition.Requires(profiles, "profiles").IsNotNull(); int i; using (var db = this.ConnectToDatabase()) { DeleteUserInRoles(db, profiles); DeleteOAuthMembership(db, profiles); DeleteMembership(db, profiles); i = profiles.Cast<ProfileInfo>() .Sum(profile => db.Execute(this.sqlQueryBuilder.DeleteProfile, profile.UserName)); } return i; }
internal static int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { List <string> listUserName = new List <string>(); listUserName.Add(profiles["UserName"].ToString()); try { businessProxy.DeleteProfiles(listUserName.ToArray()); return(1); } catch (Exception ex) { Logger.Error(ex); return(0); } }
private void RetrieveDates() { if (_DatesRetrieved || ProfileManager.Provider == null) { return; } int totalRecords; ProfileInfoCollection coll = ProfileManager.Provider.FindProfilesByUserName(ProfileAuthenticationOption.All, _UserName, 0, 1, out totalRecords); foreach (ProfileInfo p in coll) { _LastActivityDate = p.LastActivityDate.ToUniversalTime(); _LastUpdatedDate = p.LastUpdatedDate.ToUniversalTime(); _DatesRetrieved = true; return; } }
public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection infos = new ProfileInfoCollection(); try { User u = NHibernateProviderEntityHelper.GetUser(usernameToMatch); Profile prof = NHibernateProviderEntityHelper.GetProfile(usernameToMatch); infos.Add(new ProfileInfo(u.Name, this.isAnonymous(), u.LastActivityDate, prof.LastActivityDate, prof.PropertyNames.Length + prof.PropertyValuesBinary.Length + prof.PropertyValuesString.Length)); totalRecords = 1; } catch (Exception ex) { throw ExceptionUtil.NewProviderException(this, "FindInactiveProfilesByUserName", ex); } return infos; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException(System.Web.SR.GetString("Parameter_collection_empty", new object[] { "profiles" }), "profiles"); } string[] usernames = new string[profiles.Count]; int num = 0; foreach (ProfileInfo info in profiles) { usernames[num++] = info.UserName; } return this.DeleteProfiles(usernames); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { XElement perfilesXml = new XElement("Perfiles"); foreach (ProfileInfo profileInfo in profiles) { perfilesXml.Add(new XElement("Perfil", new XAttribute("Login", profileInfo.UserName))); } SqlDatabase sqlDatabase = new SqlDatabase(_connectionString); DbCommand dbCommand = sqlDatabase.GetStoredProcCommand("adm.NlayerSP_EliminarPerfil"); sqlDatabase.AddInParameter(dbCommand, "Aplicacion", DbType.String, _applicationName); sqlDatabase.AddInParameter(dbCommand, "Perfiles", DbType.Xml, perfilesXml.ToString()); sqlDatabase.ExecuteNonQuery(dbCommand); return profiles.Count; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException(System.Web.SR.GetString("Parameter_collection_empty", new object[] { "profiles" }), "profiles"); } string[] usernames = new string[profiles.Count]; int num = 0; foreach (ProfileInfo info in profiles) { usernames[num++] = info.UserName; } return(this.DeleteProfiles(usernames)); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles.Count < 1) { ExceptionReporter.ThrowArgument("PROFILE", "PROFILESEMPTY"); } string[] usernames = new string[profiles.Count]; int index = 0; foreach (ProfileInfo profile in profiles) { usernames[index++] = profile.UserName; } return DeleteProfiles(usernames); }
////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// public static int DeleteProfiles(ProfileInfoCollection profiles) { if( profiles == null ) { throw new ArgumentNullException( "profiles" ); } if ( profiles.Count < 1 ) { throw new ArgumentException( SR.GetString(SR.Parameter_collection_empty, "profiles" ), "profiles" ); } foreach (ProfileInfo pi in profiles) { string username = pi.UserName; SecUtility.CheckParameter(ref username, true, true, true, 0, "UserName"); } return Provider.DeleteProfiles(profiles); }
public override int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count == 0) { return(0); } string[] usernames = new string[profiles.Count]; int i = 0; foreach (ProfileInfo info in profiles) { usernames[i++] = info.UserName; } return(DeleteProfiles(usernames)); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException("The collection parameter 'profiles' should not be empty.", "profiles"); } string[] usernames = new string[profiles.Count]; int iter = 0; foreach (ProfileInfo profile in profiles) { usernames[iter++] = profile.UserName; } return DeleteProfiles(usernames); }
public override int DeleteProfiles (ProfileInfoCollection profiles) { if (profiles == null) throw new ArgumentNullException ("prfoles"); if (profiles.Count == 0) throw new ArgumentException ("prfoles"); string [] usernames = new string [profiles.Count]; int i = 0; foreach (ProfileInfo pi in profiles) { if (pi.UserName == null) throw new ArgumentNullException ("element in profiles collection is null"); if (pi.UserName.Length == 0 || pi.UserName.Length > 256 || pi.UserName.IndexOf (',') != -1) throw new ArgumentException ("element in profiles collection in illegal format"); usernames [i++] = pi.UserName; } return DeleteProfilesInternal (usernames); }
ProfileInfoCollection BuildProfileInfoCollection(DbDataReader reader, out int totalRecords) { ProfileInfoCollection pic = new ProfileInfoCollection(); while (reader.Read()) { ProfileInfo pi = ReadProfileInfo(reader); if (pi != null) { pic.Add(pi); } } totalRecords = 0; if (reader.NextResult()) { if (reader.Read()) { totalRecords = reader.GetInt32(0); } } return(pic); }
////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// public static int DeleteProfiles(ProfileInfoCollection profiles) { if (profiles == null) { throw new ArgumentNullException("profiles"); } if (profiles.Count < 1) { throw new ArgumentException( SR.GetString(SR.Parameter_collection_empty, "profiles"), "profiles"); } foreach (ProfileInfo pi in profiles) { string username = pi.UserName; SecUtility.CheckParameter(ref username, true, true, true, 0, "UserName"); } return(Provider.DeleteProfiles(profiles)); }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Private methods ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private ProfileInfoCollection GetProfilesForQuery(SqlParameter [] args, ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { if (pageIndex < 0) { throw new ArgumentException(SR.GetString(SR.PageIndex_bad), "pageIndex"); } if (pageSize < 1) { throw new ArgumentException(SR.GetString(SR.PageSize_bad), "pageSize"); } long upperBound = (long)pageIndex * pageSize + pageSize - 1; if (upperBound > Int32.MaxValue) { throw new ArgumentException(SR.GetString(SR.PageIndex_PageSize_bad), "pageIndex and pageSize"); } try { SqlConnectionHolder holder = null; SqlDataReader reader = null; try { holder = SqlConnectionHelper.GetConnection(_sqlConnectionString, true); CheckSchemaVersion(holder.Connection); SqlCommand cmd = new SqlCommand("dbo.aspnet_Profile_GetProfiles", holder.Connection); cmd.CommandTimeout = CommandTimeout; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(CreateInputParam("@ApplicationName", SqlDbType.NVarChar, ApplicationName)); cmd.Parameters.Add(CreateInputParam("@ProfileAuthOptions", SqlDbType.Int, (int)authenticationOption)); cmd.Parameters.Add(CreateInputParam("@PageIndex", SqlDbType.Int, pageIndex)); cmd.Parameters.Add(CreateInputParam("@PageSize", SqlDbType.Int, pageSize)); foreach (SqlParameter arg in args) { cmd.Parameters.Add(arg); } reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess); ProfileInfoCollection profiles = new ProfileInfoCollection(); while (reader.Read()) { string username; DateTime dtLastActivity, dtLastUpdated; bool isAnon; username = reader.GetString(0); isAnon = reader.GetBoolean(1); dtLastActivity = DateTime.SpecifyKind(reader.GetDateTime(2), DateTimeKind.Utc); dtLastUpdated = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc); int size = reader.GetInt32(4); profiles.Add(new ProfileInfo(username, isAnon, dtLastActivity, dtLastUpdated, size)); } totalRecords = profiles.Count; if (reader.NextResult()) { if (reader.Read()) { totalRecords = reader.GetInt32(0); } } return(profiles); } finally { if (reader != null) { reader.Close(); } if (holder != null) { holder.Close(); holder = null; } } } catch { throw; } }
private ProfileInfoCollection GetProfilesForQuery(SqlParameter[] args, ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection infos2; if (pageIndex < 0) { throw new ArgumentException(System.Web.SR.GetString("PageIndex_bad"), "pageIndex"); } if (pageSize < 1) { throw new ArgumentException(System.Web.SR.GetString("PageSize_bad"), "pageSize"); } long num = ((pageIndex * pageSize) + pageSize) - 1L; if (num > 0x7fffffffL) { throw new ArgumentException(System.Web.SR.GetString("PageIndex_PageSize_bad"), "pageIndex and pageSize"); } try { SqlConnectionHolder connection = null; SqlDataReader reader = null; try { connection = SqlConnectionHelper.GetConnection(this._sqlConnectionString, true); this.CheckSchemaVersion(connection.Connection); SqlCommand command = new SqlCommand("dbo.aspnet_Profile_GetProfiles", connection.Connection) { CommandTimeout = this.CommandTimeout, CommandType = CommandType.StoredProcedure }; command.Parameters.Add(this.CreateInputParam("@ApplicationName", SqlDbType.NVarChar, this.ApplicationName)); command.Parameters.Add(this.CreateInputParam("@ProfileAuthOptions", SqlDbType.Int, (int) authenticationOption)); command.Parameters.Add(this.CreateInputParam("@PageIndex", SqlDbType.Int, pageIndex)); command.Parameters.Add(this.CreateInputParam("@PageSize", SqlDbType.Int, pageSize)); foreach (SqlParameter parameter in args) { command.Parameters.Add(parameter); } reader = command.ExecuteReader(CommandBehavior.SequentialAccess); ProfileInfoCollection infos = new ProfileInfoCollection(); while (reader.Read()) { string username = reader.GetString(0); bool boolean = reader.GetBoolean(1); DateTime lastActivityDate = DateTime.SpecifyKind(reader.GetDateTime(2), DateTimeKind.Utc); DateTime lastUpdatedDate = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc); int size = reader.GetInt32(4); infos.Add(new ProfileInfo(username, boolean, lastActivityDate, lastUpdatedDate, size)); } totalRecords = infos.Count; if (reader.NextResult() && reader.Read()) { totalRecords = reader.GetInt32(0); } infos2 = infos; } finally { if (reader != null) { reader.Close(); } if (connection != null) { connection.Close(); connection = null; } } } catch { throw; } return infos2; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { throw new NotImplementedException(); }
private ProfileInfoCollection GetProfilesForQuery(SqlParameter[] args, ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection infos2; if (pageIndex < 0) { throw new ArgumentException(System.Web.SR.GetString("PageIndex_bad"), "pageIndex"); } if (pageSize < 1) { throw new ArgumentException(System.Web.SR.GetString("PageSize_bad"), "pageSize"); } long num = ((pageIndex * pageSize) + pageSize) - 1L; if (num > 0x7fffffffL) { throw new ArgumentException(System.Web.SR.GetString("PageIndex_PageSize_bad"), "pageIndex and pageSize"); } try { SqlConnectionHolder connection = null; SqlDataReader reader = null; try { connection = SqlConnectionHelper.GetConnection(this._sqlConnectionString, true); this.CheckSchemaVersion(connection.Connection); SqlCommand command = new SqlCommand("dbo.aspnet_Profile_GetProfiles", connection.Connection) { CommandTimeout = this.CommandTimeout, CommandType = CommandType.StoredProcedure }; command.Parameters.Add(this.CreateInputParam("@ApplicationName", SqlDbType.NVarChar, this.ApplicationName)); command.Parameters.Add(this.CreateInputParam("@ProfileAuthOptions", SqlDbType.Int, (int)authenticationOption)); command.Parameters.Add(this.CreateInputParam("@PageIndex", SqlDbType.Int, pageIndex)); command.Parameters.Add(this.CreateInputParam("@PageSize", SqlDbType.Int, pageSize)); foreach (SqlParameter parameter in args) { command.Parameters.Add(parameter); } reader = command.ExecuteReader(CommandBehavior.SequentialAccess); ProfileInfoCollection infos = new ProfileInfoCollection(); while (reader.Read()) { string username = reader.GetString(0); bool boolean = reader.GetBoolean(1); DateTime lastActivityDate = DateTime.SpecifyKind(reader.GetDateTime(2), DateTimeKind.Utc); DateTime lastUpdatedDate = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc); int size = reader.GetInt32(4); infos.Add(new ProfileInfo(username, boolean, lastActivityDate, lastUpdatedDate, size)); } totalRecords = infos.Count; if (reader.NextResult() && reader.Read()) { totalRecords = reader.GetInt32(0); } infos2 = infos; } finally { if (reader != null) { reader.Close(); } if (connection != null) { connection.Close(); connection = null; } } } catch { throw; } return(infos2); }
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; } }
/// <summary> /// *Note Currently not supported -- Delete profiles based upon the user names in the collection of profiles. /// </summary> public override int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { string[] userNames = new string[profiles.Count]; return(DeleteProfiles(userNames)); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { throw new Exception("DeleteProfiles2: The method or operation is not implemented."); }
public static int DeleteProfiles(ProfileInfoCollection profiles) { return(Provider.DeleteProfiles(profiles)); }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // Private methods ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// private ProfileInfoCollection GetProfilesForQuery(SqlParameter[] insertArgs, int pageIndex, int pageSize, StringBuilder insertQuery, out int totalRecords) { if (pageIndex < 0) throw new ArgumentException("pageIndex"); if (pageSize < 1) throw new ArgumentException("pageSize"); long lowerBound = (long)pageIndex * pageSize; long upperBound = lowerBound + pageSize - 1; if (upperBound > Int32.MaxValue) { throw new ArgumentException("pageIndex and pageSize"); } SqlConnection conn = null; SqlDataReader reader = null; SqlCommand cmd = null; try { conn = new SqlConnection(_sqlConnectionString); conn.Open(); StringBuilder cmdStr = new StringBuilder(200); // Create a temp table TO store the select results cmd = new SqlCommand("CREATE TABLE #PageIndexForProfileUsers(IndexId int IDENTITY (0, 1) NOT NULL, UserId uniqueidentifier)", conn); cmd.CommandTimeout = CommandTimeout; cmd.ExecuteNonQuery(); cmd.Dispose(); insertQuery.Append(" ORDER BY UserName"); cmd = new SqlCommand(insertQuery.ToString(), conn); cmd.CommandTimeout = CommandTimeout; if (insertArgs != null) { foreach (SqlParameter arg in insertArgs) cmd.Parameters.Add(arg); } cmd.ExecuteNonQuery(); cmd.Dispose(); cmdStr = new StringBuilder(200); cmdStr.Append("SELECT u.UserName, u.IsAnonymous, u.LastActivityDate, p.LastUpdatedDate FROM vw_aspnet_Users u, ").Append(_table); cmdStr.Append(" p, #PageIndexForProfileUsers i WHERE u.UserId = p.UserId AND p.UserId = i.UserId AND i.IndexId >= "); cmdStr.Append(lowerBound).Append(" AND i.IndexId <= ").Append(upperBound); cmd = new SqlCommand(cmdStr.ToString(), conn); cmd.CommandTimeout = CommandTimeout; reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess); ProfileInfoCollection profiles = new ProfileInfoCollection(); while (reader.Read()) { string username; DateTime dtLastActivity, dtLastUpdated = DateTime.UtcNow; bool isAnon; username = reader.GetString(0); isAnon = reader.GetBoolean(1); dtLastActivity = DateTime.SpecifyKind(reader.GetDateTime(2), DateTimeKind.Utc); dtLastUpdated = DateTime.SpecifyKind(reader.GetDateTime(3), DateTimeKind.Utc); profiles.Add(new ProfileInfo(username, isAnon, dtLastActivity, dtLastUpdated, 0)); } totalRecords = profiles.Count; if (reader != null) { reader.Close(); reader = null; } cmd.Dispose(); // Cleanup, REVIEW: should move to finally? cmd = new SqlCommand("DROP TABLE #PageIndexForProfileUsers", conn); cmd.ExecuteNonQuery(); return profiles; } catch (Exception ex) { throw ex; } finally { if (reader != null) reader.Close(); if (cmd != null) cmd.Dispose(); if (conn != null) { conn.Close(); conn = null; } } }
/// <summary> /// When overridden in a derived class, deletes profile properties /// and information for the supplied list of profiles. /// </summary> /// <param name="profiles">A /// <see cref="T:System.Web.Profile.ProfileInfoCollection"/> of /// information about profiles that are to be deleted.</param> /// <returns> /// The number of profiles deleted from the data source. /// </returns> public override int DeleteProfiles(ProfileInfoCollection profiles) { string[] s = new string[profiles.Count]; int i = 0; foreach (ProfileInfo p in profiles) s[i++] = p.UserName; return DeleteProfiles(s); }
public int DeleteProfiles(System.Web.Profile.ProfileInfoCollection profiles) { return(profileProvider.DeleteProfiles(profiles)); }
public static int DeleteProfiles(ProfileInfoCollection profiles) { return(default(int)); }
ProfileInfoCollection BuildProfileInfoCollection (DbDataReader reader, out int totalRecords) { ProfileInfoCollection pic = new ProfileInfoCollection (); while (reader.Read ()) { ProfileInfo pi = ReadProfileInfo (reader); if (pi != null) pic.Add (pi); } totalRecords = 0; if (reader.NextResult ()) { if (reader.Read ()) totalRecords = reader.GetInt32 (0); } return pic; }
public override int DeleteProfiles(ProfileInfoCollection profiles) { return(default(int)); }
public override int DeleteProfiles(ProfileInfoCollection profiles) { //foreach (ProfileInfo prof in profiles) //{ // User user = _userService.GetUser(prof.UserName); // Profile profile = (Profile)_profileService.GetByUserId(user.Id); //FindByNamedQuery<Profile>("Profile.ByUserId", user.Id, NHibernateUtil.Int32)[0]; // _profileService.DeleteProfile(profile); //} return profiles.Count; }
//bool isAnonymous() //{ // HttpContext current = HttpContext.Current; // if (current != null) // { // if (current.Request.IsAuthenticated) // { // return false; // } // } // return true; //} public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection infos = new ProfileInfoCollection(); //try //{ // User u = _userService.GetUser(usernameToMatch); // Profile prof = _profileService.GetProfile(u); // infos.Add(new ProfileInfo(u.Name, this.isAnonymous(), u.LastActivityDate, prof.LastActivityDate, prof.PropertyNames.Length + prof.PropertyValuesBinary.Length + prof.PropertyValuesString.Length)); // totalRecords = 1; totalRecords = 0; //} //catch (Exception ex) //{ // throw ExceptionUtil.NewProviderException(this, "FindInactiveProfilesByUserName", ex); //} return infos; }
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { ProfileInfoCollection infos = new ProfileInfoCollection(); //IList<Profile> profiles = _profileService.GetAllProfiles(pageIndex, pageSize);//.FindPageByNamedQuery<Profile>("Profile.GetAllProfiles", pageIndex, pageSize); //totalRecords = profiles.Count; //foreach (Profile prof in profiles) //{ // int userID = prof.UserId; // User u = _userService.Get(userID); // infos.Add(new ProfileInfo(u.Name, this.isAnonymous(), u.LastActivityDate, prof.LastActivityDate, prof.PropertyNames.Length + prof.PropertyValuesBinary.Length + prof.PropertyValuesString.Length)); //} totalRecords = 0; return infos; }
public abstract int DeleteProfiles(ProfileInfoCollection profiles);