Пример #1
0
        public async Task HandleEventAsync(CreateEventData eventData)
        {
            var userDefaultCultureName = await SettingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);

            if (userDefaultCultureName.IsNullOrWhiteSpace())
            {
                userDefaultCultureName = CultureInfo.CurrentUICulture.Name;
            }
            // 使用系统区域语言发布通知
            using (CultureHelper.Use(userDefaultCultureName, userDefaultCultureName))
            {
                var noticeNormalizerName      = NotificationNameNormalizer.NormalizerName(TenantNotificationNames.NewTenantRegistered);
                var tenantAdminUserIdentifier = new UserIdentifier(eventData.AdminUserId, eventData.AdminEmailAddress);

                // 管理用户订阅租户创建通知
                await NotificationSubscriptionManager.SubscribeAsync(eventData.Id, tenantAdminUserIdentifier, noticeNormalizerName.Name);

                var notificationData = NotificationData.CreateTenantNotificationData(eventData.Id);
                notificationData.WriteStandardData(
                    L("NewTenantRegisteredNotificationTitle"),
                    L("NewTenantRegisteredNotificationMessage", eventData.Name),
                    DateTime.Now, eventData.AdminEmailAddress);

                // 发布租户创建通知
                await NotificationDispatcher.DispatchAsync(noticeNormalizerName, notificationData,
                                                           eventData.Id, NotificationSeverity.Success);
            }
        }
Пример #2
0
        protected override async Task SendErrorNotifierAsync(ExceptionSendNotifierContext context)
        {
            var notificationDispatcher = context.ServiceProvider.GetRequiredService <INotificationDispatcher>();
            var notificationName       = NotificationNameNormalizer
                                         .NormalizerName(AbpExceptionHandlingNotificationNames.NotificationName);
            NotificationData notificationData;

            if (CurrentTenant.IsAvailable)
            {
                notificationData = NotificationData.CreateTenantNotificationData(CurrentTenant.Id.Value);
            }
            else
            {
                notificationData = NotificationData.CreateNotificationData();
            }
            // 写入通知数据
            //TODO:集成TextTemplate完成格式化的推送
            notificationData.WriteStandardData(
                context.Exception.GetType().FullName, context.Exception.Message,
                DateTime.Now, "System");

            await notificationDispatcher.DispatchAsync(notificationName, notificationData,
                                                       CurrentTenant.Id, NotificationSeverity.Error);
        }