Base solution for your next web application

Activities of "jseger"

I have an IApplicationService that does some work. I want to notify users that the work has completed. For example, content has been updated.

Now, I was going to inject my own NotificationProvider into my app service and send a message to users within the same organization.

My understanding is that if I publish a notification it will get sent to everyone who has subscribed. But if I explicitly publish a notification to a user, they will get it whether they subscribed or not. Is this correct?

What would be the best way to publish a notification to users that have subscribed that are also in the same organization.? Oh, and also have permissions to get that notification?

Yes to each user in an organization.

My question is, if I simply loop over all the users in an organization and send the notification explicitly, will the notification service respect the Subscribe/Unsubscribe options. In other words, if I send a notification to a user who has not subscribed AND who does not have permissions for that notification, will he get the notification?

This is what I'm thinking.... I haven't tried it yet. I'm about to. I created another AppService called ContentNotificationAppService. I'll call this on the client after a successful content creation. Is this the right direction? Rather than injecting some notification service in my ContentAppService?? Below is the method from ContentNoficationAppService.

public async Task ContentSubmitted(EntityDto<Guid> input) { var content = await _contents.GetAsync(input.Id); var org = await _organizations.GetAsync(content.OrganizationUnitId);

        var users = await _userManager.GetUsersInOrganizationUnit(org, false);
        var currentUser = await _userManager.GetUserByIdAsync(AbpSession.GetUserId());

        List&lt;UserIdentifier&gt; userIds = new List&lt;UserIdentifier&gt;();

        foreach(var user in users) {
            if(user.Id == currentUser.Id) {
                // we don't need to send a notification to ourselves
                continue;
            }

            // we need to see if this is a manager within our organization
            bool isManager = await _userManager.IsGrantedAsync(user.Id, AppPermissions.Pages_Content_ManageContent);
            bool isSubscribed = await _notificationSubcriptionManager.IsSubscribedAsync(user.ToUserIdentifier(), ContentAppNotificationNames.ContentSubmitted);

            if(isManager && isSubscribed) {
                userIds.Add(user.ToUserIdentifier());
            }
        }

        if (userIds.Count > 0) {
            // send the notification to the users
            await _notificationPublisher.PublishAsync(
                ContentAppNotificationNames.ContentSubmitted,
                data: new MessageNotificationData($"{currentUser.FullName} has submitted some content."),
                userIds: userIds.ToArray());
        }
    }

BTW, my managers might be in parent organizations. So I need to go up the tree first. Is this a good way to do it?

var org = await _organizations.GetAsync(header.OrganizationUnitId); // go up the organization tree while(org.Parent != null) { org = org.Parent; } // now that we're on the top, get the users var users = await _userManager.GetUsersInOrganizationUnit(org, true);

***************************** [EDIT] *********************************** This is not the correct way to get managers of an organization. Obviously, it will get ALL the users within the tenant!!

This works though. I will probably make this an extension method since I frequently need to find managers within parent organizations.

List<User> users = new List<User>();

            // go up the organization tree
            do {
                var ous = await _userManager.GetUsersInOrganizationUnit(org, false);
                users.AddRange(ous);
                org = org.Parent;
            }
            while (org != null);

Ok great. I'm running into an angular injection error.

I named my service IContentNotificationAppService. I tried to inject 'abp.services.app.contentNotification'. It complains that it cannot find 'abp.services.app.contentNotificationProvider'.

Is this due to some convention?

Nevermind..... forgot to inherit IApplicationService.

Question

I'm a little confused on how I should approach this.

Let's say I have an event that always happens on Sunday. The user makes a request to get the date of the next event. The server calculates the date by getting the date of next Sunday. The date even comes back to the client correctly. However, the angular date filter converts it to local time, which for me is Saturday.

This brings up another question. Let's say I am creating a time entry in my local time zone and I'm trying to communicate when the entry was actually created in my local time zone. In other words, I want them to know the event happened at 7:00 AM my time.

What is the best way to handle date times?

Answer

That's not quite right.

Let's say I save a UTC date time as July 1, 2017 0:00 Z. This is the DAY the event is happening. July 1st.

Now when someone 1 hour west of me opens the event, it says that it is happening June 30th.

Answer

Thanks! The article was somewhat helpful. However, I do think this is an Abp issue or at least I need further help understanding what it is doing.

The article talks about converting to and from local time. Basically, I don't want to convert. When I send a date to the server, that's date what I want to store. But it seems like Abp adjusts if for me when it maps my Dtos.

Cinco de Mayo is always May 5th. Christmas is always on December 25th. New Years is always January 1st.

Answer

Thanks. I will continue to do some tests. Maybe it will be clearer for me or at least I'll have more specific questions. I'll also play with the EventCloud source for a while.

My goal was to find out if I was missing anything obvious or if someone ran into the same issue as me.

Showing 1 to 10 of 32 entries