You are right @maliming! Didn't see it myself, not even in code (overlooked many times...) - how were you able to tell from log message? Experience? Thanks a lot!
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!
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 tenantIds
or userIds
to NotificationPublisher.PublishAsync(...)
. But this doesn't lead to the correct result because if no tenantIds
and no userIds
are passed on, then the tenantIds
will be set to an array containing AbpSession.TenantId
which 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?
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 (as AbpSession.TenantId
for sure was something other than null
). 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!
Hi @alper!
I didn't change any of the code for notifications that ship with ASPNETZERO.
I just implemented some classes:
ProjectNameNotificationNames
(similar to AppNotificationNames
)ProjectNameNotificationProvider
(similar to AppNotificationProvider
; added to notification providers in ProjectNameCoreModule.cs
)IProjectNameNotifier
(similar to IAppNotifier
)ProjectNameNotifier
(similar to AppNotifier
)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 tenantIds
nor any userIds
passed on to PublishAsync()
? Like AbpSession.TenantId
might have a value other than null
but notifications cannot be sent or received since tenant users don't have permission to do so (refering to permissionDependecy
in NotificationProvider
)? Just guessing as I don't know how to test this.
It works! ... No idea what happened ... Closing this now.
EDIT
Now I know what happened ...
appsettings.production.json
is ignored on IIS ... Instead, settings have to be done in appsettings.json
. I didn't realise that at first because I was also playing around with web.config
at the same time. Also, recycling the app-pool instead of just restarting the site might be useful.
Reopening as requested by @FlexSolution.
See this post in Xamarin forum: ACR User Dialogs not working in Android PCL
I replaced the following in CompanyName.ProjectName.Mobile.Droid.csproj
:
<Reference Include="AndHUD, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\AndHUD.1.4.1\lib\MonoAndroid81\AndHUD.dll</HintPath>
</Reference>
with
<Reference Include="AndHUD, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\AndHUD.1.2.0\lib\MonoAndroid\AndHUD.dll</HintPath>
</Reference>
This seems to work after all.
Downgrading via NuGet Package Manager will be easier, though :D
I had a similar - if not the same - issue. But it didn't always show up, just occasionally when I wanted to run the solution. And when it did show up I just cleaned the solution and tried to run it again. That was successful most of the time. But now I decided to get rid of it and searched for solutions.
~~I came across this solution https://stackoverflow.com/a/54344591/3843695 which I found to be quite helpful.
~~I basically changed the target framework to the one below, cleaned the solution, rebuilt the solution, set the target framework back to the original value, cleaned the solution, rebuilt the solution, restarted Visual Studio and now the error is gone ... The .csproj-file didn't change from what I can tell. Don't really know what caused the issue in the first place and don't really know why this approach solved it.~~
EDIT
Issue was back again when I did a Update-Database
...
@FlexSolution unfortunately no, not yet. I will try again using a clean project as soon as I find the time to do so.