Base solution for your next web application
Open Closed

Upgrading from Boilerplate 0.8 to 1.0 #2143


User avatar
0
herbertmilhomme created

Hi,

I'm very confused and very frustrated.

public async Task WelcomeToTheApplicationAsync(User user)
        {
            await _notificationPublisher.PublishAsync(
                AppNotificationNames.WelcomeToTheApplication,
                new MessageNotificationData(L("WelcomeToTheApplicationNotificationMessage")),
                severity: NotificationSeverity.Success,
--------->  userIds: new[] { user.Id }  //ERROR
            );
        }

Arguement 4: cannot convert from 'long[]' to 'abp.useridentifier[]'

user.id doesnt fetch from User.cs but instead grabs from abp.domain.entities.entity<long>.id{get;set;} which is wierd, cause no matter how much i back track the code, i dont see where the request is made to access those lines. Even tho that isnt the issue, it's still just as confusing. I cant re-write anything, cause most of the code is tied into the assembly .dll, and wont allow me to make modifications, where i see fit.

All the solutions are tied to a github url that leads to a 404 (private) repository.

Google doesnt have any answers, and i cant perform any type of conversion, because abp.useridentifier[] isnt a type... There aren't any snippets to convert one type to the other, merely for that main issue above.

I like the idea of Boilerplate, and i did have it working at one point. But i have one 1.0 version, and another 0.8 version. I cant combine the two, and i cant add features the way i would like to have them. Speaking honestly, i only moved from WebPages to MVC because of ABP. Which was ONLY because it offered a really nice built-in webAPI feature, that i cant seem to emulate on my own. :/

I just have simple request to a solution to my dilemma. Otherwise, i'll just have to revert back to my previous tools and comfort-zone and forget all this hassle with "clean-code" >_>


4 Answer(s)
  • User Avatar
    0
    chrisk created

    Hi There,

    When you publish notifications userIds[] is UserIdentifier[]. UserIdentifier is a type you should use, it holds user id and tenant id. There is extension method on user type ToUserIdentifier() that you can use for convenience.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi, @Chrisk, thanks for your explanation.

    We changed it to support DB per tenant architecture. In a single database only a userId was enough for distributing notifications but in a application with more than one database, we also need tenantId inforamtion. That is why userId is replaced with UserIdentifier.

  • User Avatar
    0
    herbertmilhomme created

    <cite>Chrisk: </cite> Hi There,

    When you publish notifications userIds[] is UserIdentifier[]. UserIdentifier is a type you should use, it holds user id and tenant id. There is extension method on user type ToUserIdentifier() that you can use for convenience.

    I searched the entire solution for the 1.0 version and there was no

    ToUserIdentifier()
    

    Is there a namespace or a file i should be looking for? i was able to fix one cs file... but the more i transfer, the more complex the solution becomes.

    Also, the solution i used wasn't a conversion, but merely, i swapped out "user.id" with something that had the UserIdentifier type... like "userIds"

    But another cs had "AbpSession.UserId" which i believe would carry the current user logged in, as a value. but the value is a "long?" type (nullable long). i used

    Abp.UserIdentifier.Parse(AbpSession.UserId)
    

    but i'm not certain if that was the correct solution...

    <cite>ismcagdas: </cite> Hi, @Chrisk, thanks for your explanation.

    We changed it to support DB per tenant architecture. In a single database only a userId was enough for distributing notifications but in a application with more than one database, we also need tenantId inforamtion. That is why userId is replaced with UserIdentifier.

    Thank you for the explanation on why the format was switched around. But this sounds like single db vs multiple... does that mean that the entire 1.0 framework i'm using only supports one over the other? cause the two 0.8 and 1.0 has so many quirks in their differences, it's hard to believe they're not marketed as a separate entity.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    ToUserIdentifier method is defined here <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/09cb578f09ee0318b479aa31dd0ceff56a5d218d/src/Abp.Zero/Authorization/Users/AbpUserBase.cs#L56">https://github.com/aspnetboilerplate/mo ... ase.cs#L56</a>.

    It is in the module zero library.

    You are right, it might be hard to upgrae from 0.8 to 1.0. But I suggest you to do it if you have time for it. We can help if you face some other problems.

    Current version of ABP supports both single DB, multiple DB and hybrid DBs. You can store, lets say Tenant A and Tenant B's data in one database and Tenant C in another database.

    Lastly, can you share your modified user class ? You might not be able to use ToUserIdentifier if you have changed Id field of User class.