6.9.1, Angular, .NET Framework
I'm trying to implement notifications similar to NewTenantRegisteredAsync(...) of AppNotifier.cs to inform host users about entities being created by tenant users. But none of the notifications ever seem to show up. So I tried with NewTenantRegisteredAsync(...) as my implementation is very similar and I only got one notification out of 4 test runs ... Also, the one notification that I received took a couple of minutes to show up ... In database there also is only the one notification.
Other notifications seem to work fine (e.g. WelcomeToTheApplicationAsync(..) and GdprDataPrepared(...)).
7 Answer(s)
-
0
show what you've done. some important key points are
- https://github.com/aspnetzero/aspnet-zero-core/blob/baef4039e577e344d00f8e8b1bc59f2383307fb6/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Core/Notifications/AppNotifier.cs#L45
- https://github.com/aspnetzero/aspnet-zero-core/blob/baef4039e577e344d00f8e8b1bc59f2383307fb6/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/wwwroot/Common/Scripts/appUserNotificationHelper.js#L26
- https://github.com/aspnetzero/aspnet-zero-core/blob/29212eb9058eeef8380e83ac1d216a747d3d06d6/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Application/MultiTenancy/TenantRegistrationAppService.cs#L114
- https://github.com/aspnetzero/aspnet-zero-core/blob/baef4039e577e344d00f8e8b1bc59f2383307fb6/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/wwwroot/Common/Scripts/appUserNotificationHelper.js
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @alper!
I didn't change any of the code for notifications that ship with ASPNETZERO.
I just implemented some classes:
ProjectNameNotificationNames(similar toAppNotificationNames)ProjectNameNotificationProvider(similar toAppNotificationProvider; added to notification providers inProjectNameCoreModule.cs)IProjectNameNotifier(similar toIAppNotifier)ProjectNameNotifier(similar toAppNotifier)
I already triple-checked them for typos and similar mistakes.
Anyway, I'm more confused about why I don't receive a new notification for each
NewTenantRegisteredAsync(...)... To me it seems like a problem with NotificationPublisher.PublishAsync(...).Maybe there is something unexpected happening when there is neither any
tenantIdsnor anyuserIdspassed on toPublishAsync()? LikeAbpSession.TenantIdmight have a value other thannullbut notifications cannot be sent or received since tenant users don't have permission to do so (refering topermissionDependecyinNotificationProvider)? Just guessing as I don't know how to test this.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
-
0
Hi @ismcagdas! Yes, notification settings are correct.
I think I found what was causing the problem with not receiving further notifications for
NewTenantRegisteredAsync(...): After registering a new tenant I used the browser's back-button to go back to registering the next new tenant - in this case no further notification is sent (note that the newly registered tenant is selected automatically after registration). But if I just delete the/account/register-tenant-result-part from the browser's address-bar to get back to login page and start a fresh registration from there (first switch from new tenant back to host) everything works as expected. So, I think the fact that after a successful registration, the new tenant was selected automatically for login was causing the problem (asAbpSession.TenantIdfor sure was something other thannull). I guess, this is not something that would happen in reality - so, there is no issue here (and sorry for stealing your time).Next, I will try to make my custom notifications work - but I might start a new questions if I still face problems!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I'm reopening this because I now know why my custom notifications don't work - and the reason is similar to what I explained in my comment above.
The situation is the following: If a tenant user creates or edits an entity, a notification will be sent to host users and the entity will be temporarely locked to be reviewed by a host user with a sepecific permission. Since I want any host user (given the specific permission) to be able to receive the notification, I don't pass any
tenantIdsoruserIdstoNotificationPublisher.PublishAsync(...). But this doesn't lead to the correct result because if notenantIdsand nouserIdsare passed on, then thetenantIdswill be set to an array containingAbpSession.TenantIdwhich is the current tenant as we can see here. This means I cannot trigger a notification by a tenant user and send it to all host users. At least not this way.Is there any easy solution to what I want to achieve? Right now I can only think of retrieving all host users and add them to
userIds- any better ideas?Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
you can send the message to online clients https://aspnetboilerplate.com/Pages/Documents/SignalR-Integration#online-clients
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Thank you for your reply @alper!
I chose to do it by making use of UserManager:
[UnitOfWork] private async Task<UserIdentifier[]> GetHostUserIds() { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant)) { var hostUsers = await _userManager.Users.Where(e => e.TenantId == null).ToListAsync(); var hostUserIds = new UserIdentifier[hostUsers.Count]; for (var i = 0; i < hostUsers.Count; i++) { hostUserIds[i] = hostUsers[i].ToUserIdentifier(); } return hostUserIds; } }Works nicely!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)
