Подписаться на DNN Вход в систему События - PullRequest
0 голосов
/ 08 июля 2019

Я пытаюсь подключиться к DNN User Authenticated Event, реализуя IUserEventHandlers. DNN не вызывает событие.

public interfaceIUserEventHandlers

{

   void UserAuthenticated(object sender, UserEventArgs args);

   void UserCreated(object sender, UserEventArgs args);

   void UserDeleted(object sender, UserEventArgs args);

   void UserRemoved(object sender, UserEventArgs args);

   void UserApproved(object sender, UserEventArgs args);

}

Как подключиться к событию DNN Login Authenticated?

1 Ответ

1 голос
/ 09 июля 2019

Это должно сделать. Удалите ненужные «используя»

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Services.Mail;
using DotNetNuke.Services.Social.Notifications;
using System.ComponentModel.Composition;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Entities.Profile;
using DotNetNuke.Entities.Tabs.Actions;
using DotNetNuke.Security.Roles;
using DotNetNuke.Services.FileSystem.EventArgs;
using DotNetNuke.Services.Log.EventLog;
using System.Net;

// For this I added a reference to the System.ComponentModel.Composition.dll
namespace TestProject.DotNetNuke.Entities.Users
{
    [Export(typeof(IUserEventHandlers))]
    public class UserEventHandlers : IUserEventHandlers
    {
        private void IUserEventHandlers_UserCreated(object sender, UserEventArgs args)
        {
            var x = "d";
        }

        private void IUserEventHandlers_UserDeleted(object sender, UserEventArgs args)
        {
            var x = "d";
        }
        public void IUserEventHandlers_UserAuthenticated(object sender, UserEventArgs args)
        {
            var x = "d";
        }

        public void IUserEventHandlers_UserUpdated(object sender, UpdateUserEventArgs args)
        {
            var x = "d";
        }

        private void IUserEventHandlers_UserRemoved(object sender, UserEventArgs args)
        {
            var x = "d";
        }

        private void IUserEventHandlers_UserApproved(object sender, UserEventArgs args)
        {
            System.Net.Mail.SendMail(args.User, MessageType.UserRegistrationPublic, PortalSettings.Current);
            DeleteAllNotifications(args.User.UserID);
        }

        private void DeleteAllNotifications(int userId)
        {
            var nt = NotificationsController.Instance.GetNotificationType("NewUnauthorizedUserRegistration");
            var notifications = NotificationsController.Instance.GetNotificationByContext(nt.NotificationTypeId, userId.ToString(CultureInfo.InvariantCulture));

            foreach (var notification in notifications)
                NotificationsController.Instance.DeleteNotification(notification.NotificationID);
        }
    }
}
...