3

如何NotificationController在 DNN 7.1.2 中初始化 a?

我试过了:

var nc = new DotNetNuke.Services.Social.Notifications.NotificationController();

然而这是空的并且没有方法可以调用......我初始化错误的东西吗?

除了ToString, GetType,EqualsGetHashCode

我需要能够创建 NotificationTypes 并创建 Notifications。

谢谢

4

2 回答 2

5

您可以使用NotificationsController.Instance.SendNotification方法发送通知。这是示例:

var notificationType = NotificationsController.Instance.GetNotificationType("HtmlNotification");
var portalSettings = PortalController.GetCurrentPortalSettings();
var sender = UserController.GetUserById(portalSettings.PortalId, portalSettings.AdministratorId);

var notification = new Notification {NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID};
NotificationsController.Instance.SendNotification(notification, portalSettings.PortalId, null, new List<UserInfo> { user });

这将向特定用户发送通知。

于 2013-11-13T10:26:34.730 回答
1

如果您需要创建自己的通知类型,请使用下面的代码作为指南,它将创建一个 NotificationType“GroupApprovedNotification”。这是来自核心组模块。

type = new NotificationType { Name = "GroupApprovedNotification", Description = "Group Approved Notification", DesktopModuleId = deskModuleId };
if (NotificationsController.Instance.GetNotificationType(type.Name) == null)
{
    NotificationsController.Instance.CreateNotificationType(type);

}
于 2014-02-28T03:35:33.877 回答