Base solution for your next web application

Activities of "cmthomps"

Thanks @aaron. You're right.... That leads me to my next question. As part of this, I've created my own module that represents the ABP SignalRRealTimeNotifier called SmcSignalRRealTimeNotifier. In there, I've defined a my own AbpCommonHub called SmcAbpCommonHub. The code in the module is exactly the same as what is in ABP (Abp.AspNetCore.SignalR/AspNetCore/SignalR/).

When I use the AbpCommonHub in the Mvc startup.cs, the redis notifications do not work. When I override the SignalRRealTimeNotifier dependency with my own SmcSignalRRealTimeNotifier and use the SmcAbpCommonHub, the redis notifications start working. Can you think of a reason why that is?

I made no changes to the client side of things. In the Web.Mvc project, I changed a couple of things:

  1. In the Startup.cs ConfigureServices method, I changed
            var signalrBuilder = services.AddSignalR();

To

                var signalrBuilder = services.AddSignalR();
                signalrBuilder.AddStackExchangeRedis(_appConfiguration["SignalR:ConnectionString"], options => {
                        options.Configuration.ChannelPrefix = "smczero";
                        });
                }
  1. In the Configure method, I changed
            app.UseSignalR(routes =>
            {
                routes.MapHub<AbpCommonHub>("/signalr");
                routes.MapHub<ChatHub>("/signalr-chat");
            });

To

            app.UseSignalR(routes =>
            {
                routes.MapHub<SmcAbpCommonHub>("/signalr");
                routes.MapHub<ChatHub>("/signalr-chat");
            });

The last thing I did was register the register the SmcSignalRRealTimeNotifier as IRealTimeNotifier in my Web.Core project which is where the new module code lives.

Here's a question for you. Have you tried to reproduce the issue I'm having on your machine with Redis and the StackExchangeRedis nuget package? When I run a straight, out of the box download of AspNetZero with no changes other than adding the StackExchangeRedis nuget package and adding the call to AddStackExchangeRedis in Startup.cs, the notifications do not work. Don't know what else to tell you.

Thanks @ismcagdas. I have a private github repository that I just shared with you. It contains an AspNetZero demo project that uses Redis for both Chat and Notifications. I've done some minimal testing. But it appears to work on Kubernetes running multiple pods behind a load balancer. Not sure if it's something that can be incorporated into the base product. For us, having the ability to run behind a load balancer is very important.

Thanks @ismcagdas - Honestly, I have a workaround that seems to be working for us. The last time I checked, notifications do not work when using the StackExchange Redis Backplane but I have tried the v6.9.

Craig

I want to check a permission in the Login method of the AccountController. I'm checking a permission using PermissionChecker.IsGrantedAsync after GetLoginResultAsync, but it always comes back false. I'm assuming that the permissions get created sometime later. Is there away that I that I can accomplish that?

Thanks, Craig

Any help?

Thanks - I'm using the permission checker right after the call to GetLoginAsync method. The result is always false. Wondering if the permissions get cached somehow later in the process. Not sure.

            var loginResult = await GetLoginResultAsync(loginModel.UsernameOrEmailAddress, loginModel.Password, GetTenancyNameOrNull());

            var hasPermissions = await PermissionChecker.IsGrantedAsync(AppPermissions.Permission1);

Using the the userManager to check the permissions works (it returns true for the user that just logged in if that user has the permission). I'm not sure why the permission checker does not.

            var loginResult = await GetLoginResultAsync(loginModel.UsernameOrEmailAddress, loginModel.Password, GetTenancyNameOrNull());

            var hasPermissions = await _userManager.IsGrantedAsync(loginResult.User.Id, AppPermissions.Permission1);

As @ismcagdas suggested, you can implement your own AuditStore. What we did was create an admin setting that we could use to log only errors or log all events This is what our implementation looks like:


    public class SmcAuditStore : AuditingStore
    {

        public ILogger<AuditingStore> Logger { get; set; }

        private readonly IRepository<AuditLog, long> _auditLogRepository;
        private readonly ISettingManager _settingManager;

        public SmcAuditStore(IRepository<AuditLog, long> auditLogRepository, ISettingManager settingManager) : base(auditLogRepository)
        {
            _auditLogRepository = auditLogRepository;
            _settingManager = settingManager;
        }

        public override async Task SaveAsync(AuditInfo auditInfo)
        {
            AuditLog auditLog = new AuditLog();

            bool logErrorsOnly = await _settingManager.GetSettingValueAsync<bool>(AppSettings.Logging.LogOnErrorsOnly);

            var exceptionMessage = auditInfo.Exception != null ? auditInfo.Exception.ToString() : null;

            if ((logErrorsOnly && exceptionMessage != null) || !logErrorsOnly)
            {

                auditLog = await _auditLogRepository.InsertAsync(AuditLog.CreateFromAuditInfo(auditInfo));
            }


        }

    }

You can replace the default auditstore by replacing it in the Core Module PreInitialize:

Configuration.ReplaceService<IAuditingStore, SmcAuditStore>();
Showing 71 to 80 of 88 entries