如何在DNN 7.1.2中初始化NotificationController
?
我试过了:
var nc = new DotNetNuke.Services.Social.Notifications.NotificationController();
然而,这是空的,没有方法可以调用......我是在初始化错误的东西吗?
除了ToString
,GetType
,Equals
和GetHashCode
我需要能够创建NotificationTypes并创建通知。
由于
答案 0 :(得分: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 });
这会向特定用户发送通知。
答案 1 :(得分: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);
}