在DNN 7中初始化NotificationController

Ale*_*lex 3 dotnetnuke dotnetnuke-6 dotnetnuke-7

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

我试过了:

var nc = new DotNetNuke.Services.Social.Notifications.NotificationController();
Run Code Online (Sandbox Code Playgroud)

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

当然应该有东西在那里比其他ToString,GetType,EqualsGetHashCode

我需要能够创建NotificationTypes并创建通知.

谢谢

Pra*_*ani 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 });
Run Code Online (Sandbox Code Playgroud)

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