コード例 #1
0
        public async Task SubscribeToAllAvailableNotificationsAsync(UserIdentifier user)
        {
            var notificationDefinitions = (await _notificationDefinitionManager
                                           .GetAllAvailableAsync(user))
                                          .Where(nd => nd.EntityType == null)
                                          .ToList();

            foreach (var notificationDefinition in notificationDefinitions)
            {
                await SubscribeAsync(user, notificationDefinition.Name);
            }
        }
コード例 #2
0
        public async Task SubscribeToAllAvailableNotificationsAsync(int?tenantId, long userId)
        {
            var notificationDefinitions = (await _notificationDefinitionManager
                                           .GetAllAvailableAsync(tenantId, userId))
                                          .Where(nd => nd.EntityType == null)
                                          .ToList();

            foreach (var notificationDefinition in notificationDefinitions)
            {
                await SubscribeAsync(tenantId, userId, notificationDefinition.Name);
            }
        }
コード例 #3
0
        public async Task <List <NotificationDefinitionDto> > GetAllAvailableAsync()
        {
            var subscribes = (await _notificationSubscriptionManager.GetSubscribedNotificationsAsync(LoginIdentifier))
                             .Where(x => x.EntityType == null).ToList();

            bool IsSubscribed(NotificationDefinition definition)
            {
                return(subscribes.Any(x => x.NotificationName == definition.Name));
            }

            var list = await _notificationDefinitionManager.GetAllAvailableAsync(LoginIdentifier);

            return(list.Select(x => new NotificationDefinitionDto
            {
                Name = x.Name,
                Description = x.DisplayName.Localize(_localizationContext),
                IsSubscribed = IsSubscribed(x)
            }).ToList());
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        public async Task <GetNotificationSettingsOutput> GetNotificationSettings()
        {
            var output = new GetNotificationSettingsOutput
            {
                ReceiveNotifications =
                    await SettingManager.GetSettingValueAsync <bool>(NotificationSettingNames.ReceiveNotifications),
                Notifications = (await _notificationDefinitionManager
                                 .GetAllAvailableAsync(AbpSession.ToUserIdentifier()))
                                .Where(nd => nd.EntityType == null) //Get general notifications, not entity related notifications.
                                .MapTo <List <NotificationSubscriptionWithDisplayNameDto> >()
            };
            var subscribedNotifications = (await _notificationSubscriptionManager
                                           .GetSubscribedNotificationsAsync(AbpSession.ToUserIdentifier()))
                                          .Select(ns => ns.NotificationName)
                                          .ToList();

            output.Notifications.ForEach(n => n.IsSubscribed = subscribedNotifications.Contains(n.Name));
            return(output);
        }
コード例 #5
0
 /// <summary>
 /// Gets all available notification definitions for given user.
 /// </summary>
 /// <param name="notificationDefinitionManager">Notification definition manager</param>
 /// <param name="user">User</param>
 public static IReadOnlyList <NotificationDefinition> GetAllAvailable(this INotificationDefinitionManager notificationDefinitionManager, UserIdentifier user)
 {
     return(AsyncHelper.RunSync(() => notificationDefinitionManager.GetAllAvailableAsync(user)));
 }
コード例 #6
0
 /// <summary>
 /// Gets all available notification definitions for given <see cref="tenantId"/> and <see cref="userId"/>.
 /// </summary>
 /// <param name="notificationDefinitionManager">Notification definition manager</param>
 /// <param name="tenantId">Tenant id</param>
 /// <param name="userId">User id</param>
 public static IReadOnlyList <NotificationDefinition> GetAllAvailable(this INotificationDefinitionManager notificationDefinitionManager, int?tenantId, long userId)
 {
     return(AsyncHelper.RunSync(() => notificationDefinitionManager.GetAllAvailableAsync(tenantId, userId)));
 }