本文整理汇总了C#中ProfileAuthenticationOption类的典型用法代码示例。如果您正苦于以下问题:C# ProfileAuthenticationOption类的具体用法?C# ProfileAuthenticationOption怎么用?C# ProfileAuthenticationOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProfileAuthenticationOption类属于命名空间,在下文中一共展示了ProfileAuthenticationOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
var connection = GetConnection();
var min = (double)userInactiveSinceDate.ToBinary();
const double max = double.MaxValue;
var key = string.Empty;
switch (authenticationOption)
{
case ProfileAuthenticationOption.All:
key = GetProfilesKey();
break;
case ProfileAuthenticationOption.Anonymous:
key = GetProfilesKeyAnonymous();
break;
case ProfileAuthenticationOption.Authenticated:
key = GetProfilesKeyAuthenticated();
break;
}
var inactiveUsersTask = connection.SortedSets.Range(_redisDb, key, min, max);
var inactiveUsers = connection.Wait(inactiveUsersTask);
var count = 0;
Parallel.ForEach(inactiveUsers, result =>
{
var profileResult = new string(Encoding.Unicode.GetChars(result.Key));
var parts = profileResult.Split(':');
var username = parts[0];
var isAuthenticated = Convert.ToBoolean(parts[1]);
if (DeleteProfile(username, isAuthenticated))
Interlocked.Increment(ref count);
});
return count;
}
示例2: DeleteInactiveProfiles
/// <summary>
/// When overridden in a derived class, deletes all user-profile data for profiles in which the last activity date
/// occurred before the specified date.
/// </summary>
/// <returns>
/// The number of profiles deleted from the data source.
/// </returns>
/// <param name="authenticationOption">
/// One of the <see cref="T:System.Web.Profile.ProfileAuthenticationOption"></see> values, specifying whether
/// anonymous, authenticated, or both types of profiles are deleted.
/// </param>
/// <param name="userInactiveSinceDate">
/// A <see cref="T:System.DateTime"></see> that identifies which user profiles are considered inactive. If the
/// <see
/// cref="P:System.Web.Profile.ProfileInfo.LastActivityDate">
/// </see>
/// value of a user profile occurs on or before this date and time, the profile is considered inactive.
/// </param>
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption,
DateTime userInactiveSinceDate)
{
SessionWrapper sessionWrapper = SessionManager.GetSessionWrapper();
try
{
switch (authenticationOption)
{
case ProfileAuthenticationOption.Anonymous:
return
MemberShipFactory.CreateProfileDao().DeleteAnonymous(
userInactiveSinceDate);
case ProfileAuthenticationOption.Authenticated:
return
MemberShipFactory.CreateProfileDao().DeleteAuthenticated(
userInactiveSinceDate);
default:
return MemberShipFactory.CreateProfileDao().Delete(userInactiveSinceDate);
}
}
finally
{
sessionWrapper.Close();
}
}
示例3: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption,
DateTime userInactiveSinceDate)
{
ProfileType? profileType = null;
if (authenticationOption == ProfileAuthenticationOption.Anonymous)
profileType = ProfileType.Anonymous;
else if (authenticationOption == ProfileAuthenticationOption.Authenticated)
profileType = ProfileType.Authenticated;
int profilesDeleted;
using (var transaction = new TransactionScope(_connName))
{
var profileStore = DSSEOProfile.Create(_connName);
IList<SEOProfile> users = profileStore.FindByFields(ApplicationName, null, userInactiveSinceDate,
profileType, PagingInfo.All);
profilesDeleted = users.Count;
foreach (var user in users)
{
profileStore.Delete(user.Id);
}
transaction.Commit();
}
return profilesDeleted;
}
示例4: DeleteInactiveProfiles
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
try {
SqlConnectionHolder holder = null;
try
{
holder = SqlConnectionHelper.GetConnection(_sqlConnectionString, true);
CheckSchemaVersion( holder.Connection );
//MySqlCommand cmd = new MySqlCommand("dbo.aspnet_Profile_DeleteInactiveProfiles", 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("@InactiveSinceDate", SqlDbType.DateTime, userInactiveSinceDate.ToUniversalTime()));
object o = MySqlStoredProcedures.aspnet_Profile_DeleteInactiveProfiles(ApplicationName,
(int)authenticationOption, userInactiveSinceDate, holder);
if (o == null || !(o is int))
return 0;
return (int) o;
}
finally {
if( holder != null )
{
holder.Close();
holder = null;
}
}
} catch {
throw;
}
}
示例5: DeleteInactiveProfiles
public int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
try
{
OleDbConnection conn = null;
OleDbCommand cmd = null;
try
{
conn = new OleDbConnection(SqlHelper.ConnString);
conn.Open();
cmd = new OleDbCommand(GenerateQuery(true, authenticationOption), conn);
cmd.CommandTimeout = CommandTimeout;
cmd.Parameters.Add(CreateInputParam("@InactiveSinceDate", OleDbType.VarChar, userInactiveSinceDate.ToUniversalTime()));
return cmd.ExecuteNonQuery();
}
finally
{
if (cmd != null)
{
cmd.Dispose();
}
if (conn != null)
{
conn.Close();
conn = null;
}
}
}
catch
{
throw;
}
}
示例6: FindInactiveProfilesByUserName
public override ProfileInfoCollection FindInactiveProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, DateTime userInactiveSinceDate, int pageIndex, int pageSize, out int totalRecords)
{
totalRecords = 0;
var users = Enumerable.Empty<User>();
ReturnResult returnResult;
switch (authenticationOption)
{
case ProfileAuthenticationOption.Anonymous:
returnResult =this.mongoGateway.GetInactiveAnonymSinceByUserName(this.ApplicationName, usernameToMatch,
userInactiveSinceDate, pageIndex, pageSize).Result;
users = returnResult.Users;
totalRecords =(int)returnResult.TotalRecords;
break;
case ProfileAuthenticationOption.Authenticated:
case ProfileAuthenticationOption.All:
returnResult = this.mongoGateway.GetInactiveSinceByUserName(this.ApplicationName, usernameToMatch, userInactiveSinceDate, pageIndex, pageSize).Result;
users = returnResult.Users;
totalRecords =(int)returnResult.TotalRecords;
break;
}
return ToProfileInfoCollection(users);
}
示例7: DeleteInactiveProfiles
/// <summary>
/// Deletes all user-profile data for profiles in which the last activity date occurred before the specified date.
/// </summary>
/// <param name="authenticationOption">One of the System.Web.Profile.ProfileAuthenticationOption values, specifying whether anonymous, authenticated, or both types of profiles are deleted.</param>
/// <param name="userInactiveSinceDate">A System.DateTime that identifies which user profiles are considered inactive. If the System.Web.Profile.ProfileInfo.LastActivityDate value of a user profile occurs on or before this date and time, the profile is considered inactive.</param>
/// <returns>The number of profiles deleted from the data source.</returns>
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
string[] userArray = new string[0];
dal.GetInactiveProfiles((int)authenticationOption, userInactiveSinceDate, ApplicationName).CopyTo(userArray, 0);
return DeleteProfiles(userArray);
}
示例8: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
OnDebug(this, name + ".DeleteInactiveProfiles()");
int output = 0;
try
{
IWcfProfileProvider remoteProvider = RemoteProvider();
output = remoteProvider.DeleteInactiveProfiles(authenticationOption, userInactiveSinceDate);
DisposeRemoteProvider(remoteProvider);
OnLog(this, name + ": Deleted " + output.ToString() + " profiles inactive since " + userInactiveSinceDate.ToString("u") + ".");
}
catch (Exception ex)
{
if (!OnError(this, ex))
{
throw;
}
output = 0;
}
return output;
}
示例9: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption,
DateTime userInactiveSinceDate)
{
ProfileType? profileType = null;
if (authenticationOption == ProfileAuthenticationOption.Anonymous)
profileType = ProfileType.Anonymous;
else if (authenticationOption == ProfileAuthenticationOption.Authenticated)
profileType = ProfileType.Authenticated;
int profilesDeleted = 0;
using (TransactionScope transaction = new TransactionScope(mConfiguration))
{
ProfileUserDataStore profileStore = new ProfileUserDataStore(transaction);
IList<ProfileUser> users = profileStore.FindByFields(ApplicationName, null, userInactiveSinceDate, profileType, PagingInfo.All);
profilesDeleted = users.Count;
foreach (ProfileUser user in users)
{
profileStore.Delete(user.Id);
}
transaction.Commit();
}
return profilesDeleted;
}
示例10: DeleteInactiveProfiles
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
try
{
AccessConnectionHolder holder = AccessConnectionHelper.GetConnection(_DatabaseFileName, true);
try
{
string inClause = @"SELECT UserId FROM aspnet_Users " +
@"WHERE ApplicationId = @AppId AND LastActivityDate <= @LastActivityDate " + GetClauseForAuthenticationOptions(authenticationOption);
string sqlQuery = @"DELETE FROM aspnet_Profile WHERE UserId IN (" + inClause + ")";
OleDbCommand cmd = new OleDbCommand(sqlQuery, holder.Connection);
cmd.Parameters.Add(new OleDbParameter("@AppId", GetApplicationId(holder)));
cmd.Parameters.Add(CreateDateTimeOleDbParameter("@LastActivityDate", userInactiveSinceDate));
return cmd.ExecuteNonQuery();
}
catch (Exception e)
{
throw AccessConnectionHelper.GetBetterException(e, holder);
}
finally
{
holder.Close();
}
}
catch
{
throw;
}
}
示例11: DeleteInactiveProfiles
/// <summary>
/// When overridden in a derived class, deletes all user-profile data for profiles in which the last activity date occurred before the specified date.
/// </summary>
/// <param name="authenticationOption">One of the <see cref="T:System.Web.Profile.ProfileAuthenticationOption"/> values, specifying whether anonymous, authenticated, or both types of profiles are deleted.</param>
/// <param name="userInactiveSinceDate">A <see cref="T:System.DateTime"/> that identifies which user profiles are considered inactive. If the <see cref="P:System.Web.Profile.ProfileInfo.LastActivityDate"/> value of a user profile occurs on or before this date and time, the profile is considered inactive.</param>
/// <returns>
/// The number of profiles deleted from the data source.
/// </returns>
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
SQLiteConnection cn = GetDBConnectionForProfile();
try
{
using (SQLiteCommand cmd = cn.CreateCommand())
{
cmd.CommandText = "DELETE FROM " + PROFILE_TB_NAME + " WHERE UserId IN (SELECT UserId FROM " + USER_TB_NAME
+ " WHERE ApplicationId = $ApplicationId AND LastActivityDate <= $LastActivityDate"
+ GetClauseForAuthenticationOptions(authenticationOption) + ")";
cmd.Parameters.AddWithValue("$ApplicationId", _applicationId);
cmd.Parameters.AddWithValue("$LastActivityDate", userInactiveSinceDate);
if (cn.State == ConnectionState.Closed)
cn.Open();
return cmd.ExecuteNonQuery();
}
}
finally
{
if (!IsTransactionInProgress())
cn.Dispose();
}
}
示例12: DeleteInactiveProfiles
////////////////////////////////////////////////////////
// Delete Inactive Profiles //
//----------------------------------------------------//
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
int appId = GetApplicationId(new SqliteConnection(_connectionString));
string inClause = "SELECT PKID FROM users WHERE ApplicationId ='" + appId + "' AND LastActivityDate <= '" + userInactiveSinceDate.ToString("yyyy:MM:dd hh:mm:ss") + "' " + GetClauseForAuthenticationOptions(authenticationOption);
string sqlQuery = "DELETE FROM aspnet_Profile WHERE PKID IN (" + inClause + ")";
SqliteConnection conn = new SqliteConnection(_connectionString);
int Result;
try
{
conn.Open();
SqliteCommand cmd = new SqliteCommand(sqlQuery, conn);
Result = cmd.ExecuteNonQuery();
return Result;
}
catch (Exception e)
{
if (WriteExceptionsToEventLog)
{
WriteToEventLog(e, "Delete Inactive Profiles");
throw new ProviderException(exceptionMessage);
}
else
{
throw e;
}
}
finally
{
conn.Close();
}
}
示例13: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate)
{
var userIds = "";
var anon = false;
switch (authenticationOption) {
case ProfileAuthenticationOption.Anonymous:
anon = true;
break;
case ProfileAuthenticationOption.Authenticated:
anon = false;
break;
default:
break;
}
try {
var profs = profiles.GetInactiveProfiles(ApplicationName, userInactiveSinceDate, anon);
if (profs != null) {
userIds = profs.Aggregate(userIds, (current, p) => current + (p.Id.ToString() + ","));
}
} catch (Exception ex) {
if (WriteExceptionsToEventLog)
WriteToEventLog(ex, "DeleteInactiveProfiles");
else
throw;
}
if (userIds.Length > 0)
userIds = userIds.Substring(0, userIds.Length - 1);
return DeleteProfilesbyId(userIds.Split(','));
}
示例14: DeleteInactiveProfiles
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption,DateTime userInactiveSinceDate)
{
var isAnonymous = authenticationOption == ProfileAuthenticationOption.Anonymous;
return UnitOfWork.Current.CreateRepository<Profile>().Delete(p =>
p.ApplicationName == ApplicationName
&& p.LastActivityDate == userInactiveSinceDate
&& p.IsAnonymous == isAnonymous);
}
示例15: GivenConfirmedUsersWhenGetNumberOfInactiveProfilesThenNotSupportedException
public void GivenConfirmedUsersWhenGetNumberOfInactiveProfilesThenNotSupportedException(ProfileAuthenticationOption option)
{
// arrange
var testClass = new BetterProfileProvider();
// act // assert
Assert.Throws<NotSupportedException>(
() => testClass.GetNumberOfInactiveProfiles(option, DateTime.MinValue));
}