SenseNet.Messaging.Event.CreateAndSave C# (CSharp) Method

CreateAndSave() public static method

public static CreateAndSave ( System.Data.Node node, NotificationType type, string who ) : void
node System.Data.Node
type NotificationType
who string
return void
        public static void CreateAndSave(Node node, NotificationType type, string who)
        {
            if (type != NotificationType.MovedFrom && type != NotificationType.MovedTo)
                if (!IsSubscriptionExist(node.Path))
                    return;

            var @event = new Event
            {
                ContentPath = node.Path,
                NotificationType = type,
                Who = who,
                CreatorId = node.CreatedById,
                LastModifierId = node.NodeModifiedById
            };
            @event.Save();
        }
        public static void CreateAndSave(string contentPath, int creatorId, int lastModifierId, NotificationType type, string who)

Same methods

Event::CreateAndSave ( string contentPath, int creatorId, int lastModifierId, NotificationType type, string who ) : void
Event::CreateAndSave ( string contentPath, int creatorId, int lastModifierId, NotificationType type, string who, System.DateTime when ) : void

Usage Example

        protected override void OnNodeMoved(object sender, NodeOperationEventArgs e)
        {
            if (!Configuration.Enabled)
            {
                return;
            }

            var currentUser    = User.Current;
            var srcnode        = e.SourceNode;
            var creatorId      = srcnode.CreatedById;
            var lastModifierId = currentUser.Id;
            var who            = GetUserName(currentUser);

            if (IsInTrash(e.OriginalSourcePath))
            {
                Event.CreateAndSave(srcnode.Path, creatorId, lastModifierId, NotificationType.Restored, who);
                return;
            }
            if (IsInTrash(srcnode.Path))
            {
                Event.CreateAndSave(e.OriginalSourcePath, creatorId, lastModifierId, NotificationType.Deleted, who);
                return;
            }
            Event.CreateAndSave(e.OriginalSourcePath, creatorId, lastModifierId, NotificationType.MovedTo, who);
            Event.CreateAndSave(srcnode.Path, creatorId, lastModifierId, NotificationType.MovedFrom, who);
        }
All Usage Examples Of SenseNet.Messaging.Event::CreateAndSave