Activities of "liangshiwei"

HI,

You can create a shared entityframeworkcore project used to share the database

Hi,

Okay, thanks.

Hi,

This is the design of the Aspnet Core Identity, I would like to suggest that don't change it if you don't have to

However, you can change it:

[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IdentityUserManager))]
public class MyUserManager : IdentityUserManager
{
    public MyUserManager(
        IdentityUserStore store,
        IIdentityRoleRepository roleRepository,
        IIdentityUserRepository userRepository,
        IOptions<IdentityOptions> optionsAccessor,
        IPasswordHasher<IdentityUser> passwordHasher,
        IEnumerable<IUserValidator<IdentityUser>> userValidators,
        IEnumerable<IPasswordValidator<IdentityUser>> passwordValidators,
        ILookupNormalizer keyNormalizer,
        IdentityErrorDescriber errors,
        IServiceProvider services,
        ILogger<IdentityUserManager> logger,
        ICancellationTokenProvider cancellationTokenProvider,
        IOrganizationUnitRepository organizationUnitRepository,
        ISettingProvider settingProvider) :
        base(store,
            roleRepository,
            userRepository,
            optionsAccessor,
            passwordHasher,
            userValidators,
            passwordValidators,
            keyNormalizer,
            errors,
            services,
            logger,
            cancellationTokenProvider,
            organizationUnitRepository,
            settingProvider)
    {
    }

    public override async Task<IdentityResult> AccessFailedAsync(IdentityUser user)
    {
        ThrowIfDisposed();
        var store = GetUserLockoutStore();
        if (user == null)
        {
            throw new ArgumentNullException(nameof(user));
        }

        // If this puts the user over the threshold for lockout, lock them out and reset the access failed count
        var count = await store.IncrementAccessFailedCountAsync(user, CancellationToken);
        if (count < Options.Lockout.MaxFailedAccessAttempts)
        {
            return await UpdateUserAsync(user);
        }
        Logger.LogWarning(12, "User is locked out.");
        await store.SetLockoutEndDateAsync(user, DateTime.Now.Add(Options.Lockout.DefaultLockoutTimeSpan),
            CancellationToken);
        await store.ResetAccessFailedCountAsync(user, CancellationToken);
        return await UpdateUserAsync(user);
    }

    public override async Task<bool> IsLockedOutAsync(IdentityUser user)
    {
        ThrowIfDisposed();
        var store = GetUserLockoutStore();
        if (user == null)
        {
            throw new ArgumentNullException(nameof(user));
        }
        if (!await store.GetLockoutEnabledAsync(user, CancellationToken))
        {
            return false;
        }
        var lockoutTime = await store.GetLockoutEndDateAsync(user, CancellationToken);
        return lockoutTime >= DateTime.Now;
    }

    private IUserLockoutStore<IdentityUser> GetUserLockoutStore()
    {
        var cast = Store as IUserLockoutStore<IdentityUser>;
        return cast;
    }
}

See: https://support.abp.io/QA/Questions/1628/AsyncBackgroundJobs#answer-9bd678d0-8939-94ff-3d01-39fdfeea6986

HI,

This is a temporary solution:

public class CancellationTokenOverride
{
    public CancellationToken CancellationToken { get; }

    public CancellationTokenOverride(CancellationToken cancellationToken)
    {
        CancellationToken = cancellationToken;
    }
}


[Dependency(ReplaceServices = true)]
public class MyCancellationTokenProvider : ICancellationTokenProvider, ITransientDependency
{

    public const string CancellationTokenOverrideContextKey = "Volo.Abp.Threading.CancellationToken.Override";

    public CancellationToken Token { get
    {
        if (OverrideValue != null)
        {
            return OverrideValue.CancellationToken;
        }
        return _httpContextAccessor.HttpContext?.RequestAborted ?? CancellationToken.None;
    }}

    private readonly IAmbientScopeProvider<CancellationTokenOverride> _cancellationTokenOverrideScopeProvider;
    private readonly IHttpContextAccessor _httpContextAccessor;
    protected CancellationTokenOverride OverrideValue => _cancellationTokenOverrideScopeProvider.GetValue(CancellationTokenOverrideContextKey);

    public MyCancellationTokenProvider(
        IAmbientScopeProvider<CancellationTokenOverride> cancellationTokenOverrideScopeProvider,
        IHttpContextAccessor httpContextAccessor)
    {
        _cancellationTokenOverrideScopeProvider = cancellationTokenOverrideScopeProvider;
        _httpContextAccessor = httpContextAccessor;
    }

    public IDisposable Use(CancellationToken cancellationToken)
    {
        return _cancellationTokenOverrideScopeProvider.BeginScope(CancellationTokenOverrideContextKey, new CancellationTokenOverride(cancellationToken));
    }
}
protected override async Task OnInitializedAsync()
{
    cts.CancelAfter(2000);//To test CancellationToken
    
    using (((MyCancellationTokenProvider) _cancellationTokenProvider).Use(cts.Token))
    {
       var pageResult = await CallsAppService.GetListAsync(new GetCallsInput { });
       Calls = pageResult.Items;
    }
}

Hi,

As I said, currently ABP does not support custom cancellationToken. because the request proxy interceptor always uses the ICancellationTokenProvider.

This PR will solve the issue, but 5.0.0 version, for now, you can implement it locally.

HI,

I can't reproduce the problem, Can you share some screenshots? thanks.

Answer

Use CurrentTenant.Change for per tenant : https://docs.abp.io/en/abp/latest/Multi-Tenancy#change-the-current-tenant

Answer

Resolved. You need to queue a job item: https://docs.abp.io/en/abp/latest/Background-Jobs#queue-a-job-item

Hi,

See: https://docs.abp.io/en/abp/latest/Timing

Configure<AbpClockOptions>(options =>
{
    options.Kind = DateTimeKind.Local;
});
Showing 4961 to 4970 of 5973 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11