コード例 #1
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent ev)
 {
     // Hi Vladimir, please put a breakpoint here.
     // Then try to enroll a student to a course, using WPF app, which would execute EnrollCommand.
     // Once this breakpoint hits, open up SSMS Query Analyzer and execute "select * from Enrollment" sql statement
     // It would just hang, until debugger steps out of this method.
     DispatchEvents(ev.AffectedOwnerOrNull);
 }
コード例 #2
0
 public Task OnPostUpdateCollectionAsync(PostCollectionUpdateEvent @event, CancellationToken cancellationToken)
 {
     try
     {
         AddEvent(@event, this);
         return(Task.CompletedTask);
     }
     catch (System.Exception ex)
     {
         return(Task.FromException <object>(ex));
     }
 }
コード例 #3
0
 private void PostUpdate()
 {
     IPostCollectionUpdateEventListener[] postListeners = Session.Listeners.PostCollectionUpdateEventListeners;
     if (postListeners.Length > 0)
     {
         PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(Persister, Collection, (IEventSource)Session);
         for (int i = 0; i < postListeners.Length; i++)
         {
             postListeners[i].OnPostUpdateCollection(postEvent);
         }
     }
 }
コード例 #4
0
 private async Task PostUpdateAsync(CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     IPostCollectionUpdateEventListener[] postListeners = Session.Listeners.PostCollectionUpdateEventListeners;
     if (postListeners.Length > 0)
     {
         PostCollectionUpdateEvent postEvent = new PostCollectionUpdateEvent(Persister, Collection, (IEventSource)Session);
         for (int i = 0; i < postListeners.Length; i++)
         {
             await(postListeners[i].OnPostUpdateCollectionAsync(postEvent, cancellationToken)).ConfigureAwait(false);
         }
     }
 }
コード例 #5
0
        public void OnPostUpdateCollection(PostCollectionUpdateEvent e)
        {
            var entity = e.AffectedOwnerOrNull;

            if (entity == null || entity is AuditLogEntry)
            {
                return;
            }

            var factory = GetFactory(entity.GetType());

            if (factory != null)
            {
                SaveEntries(factory.CreateEntries(e).ToList(), e);
            }
        }
コード例 #6
0
        public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
        {
            var item = @event.AffectedOwnerOrNull;

            if (item != null)
            {
                var message  = string.Empty;
                var needSave = false;
                if (item is User && @event.Collection.Role.Contains("AvaliableAddresses"))
                {
                    var oldList = ((IList <object>)@event.Collection.StoredSnapshot).Cast <Address>().ToList();
                    message = string.Format("$$$У пользователя {0} - ({1}) отключены все адреса доставки: {2}",
                                            ((User)item).Id,
                                            ((User)item).Name,
                                            UpdateCollectionListner.GetListString(oldList));
                    needSave = true;
                }
                if (item is Address && @event.Collection.Role.Contains("AvaliableForUsers"))
                {
                    var oldList = ((IList <object>)@event.Collection.StoredSnapshot).Cast <User>().ToList();
                    message = string.Format("$$$Адрес {0} - ({1}) отключен у всех пользователей: {2}",
                                            ((Address)item).Id,
                                            ((Address)item).Name,
                                            UpdateCollectionListner.GetListString(oldList));
                    needSave = true;
                }
                if (needSave)
                {
                    AuditListener.LoadData(@event.Session, () => @event.Session.Save(new AuditRecord(message, ((dynamic)@event.AffectedOwnerOrNull).Client)
                    {
                        MessageType = LogMessageType.System,
                        IsHtml      = true
                    }));
                }
            }
        }
コード例 #7
0
 public async Task OnPostUpdateCollectionAsync(PostCollectionUpdateEvent @event, CancellationToken cancellationToken)
 {
     DispatchEvents(@event.AffectedOwnerIdOrNull as AggregateRoot);
 }
コード例 #8
0
        public override void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
        {
            var collection        = @event.Collection;
            var collectionEntry   = @event.Session.PersistenceContext.GetCollectionEntry(@event.Collection);
            var collectionEntries = collection.Entries(collectionEntry.LoadedPersister);

            List <Attachment> attachmentsList = new List <Attachment>();

            foreach (var entry in collectionEntries)
            {
                if (entry is IAttachment)
                {
                    var attach = entry as Attachment;
                    attachmentsList.Add(attach);
                }
            }

            if (attachmentsList != null || attachmentsList.Count() > 0)
            {
                var attachEntry = attachmentsList.LastOrDefault();
                if (attachEntry != null)
                {
                    Filter filterQ = new Filter();
                    filterQ.Query = string.Format("Attachments in (Id = {0})", attachEntry.Id);
                    var findEntity = EntityManager <ITaskBase> .Instance.Find(filterQ, null).FirstOrDefault();

                    TaskBase taskAttach = (TaskBase)findEntity;

                    taskAttach.GeneralAttach.Clear();
                    foreach (var item in attachmentsList)
                    {
                        PublicAPI.Services.Security.RunBySystemUser(() =>
                        {
                            var attachm               = item as Attachment;
                            Attachments new_attach    = new Attachments();
                            new_attach.CreationDate   = (DateTime)attachm.CreationDate;
                            new_attach.CreationAuthor = attachm.CreationAuthor;
                            new_attach.File           = attachm.File;
                            new_attach.Name           = attachm.File.Name;
                            new_attach.IsAttachments  = true;
                            new_attach.Save();
                            taskAttach.GeneralAttach.Add(new_attach);
                        });
                    }
                }
            }

            foreach (var entry in collectionEntries)
            {
                // Обработка списка измененных комментариев
                if (entry is IComment)
                {
                    Filter filter = new Filter();
                    filter.Query = string.Format("Comments in (Id = {0})", (entry as IComment).Id);
                    var listKA = EntityManager <ITaskBase> .Instance.Find(filter, null);

                    if (listKA.Count > 0)
                    {
                        TaskBase task = (TaskBase)listKA.FirstOrDefault();
                        var      tid  = task.Id.ToString();
                        var      comm = task.Comments.LastOrDefault();
                        Logger.Log.Error("Comment: Id: " + tid + " // Comment: " + comm.Text);

                        PublicAPI.Services.Security.RunBySystemUser(() =>
                        {
                            Comments new_comm       = new Comments();
                            new_comm.CreationDate   = (DateTime)comm.CreationDate;
                            new_comm.CreationAuthor = comm.CreationAuthor;

                            User user      = comm.CreationAuthor;
                            string userStr = "";
                            if (!string.IsNullOrWhiteSpace(user.LastName) && !string.IsNullOrWhiteSpace(user.FirstName) && !string.IsNullOrWhiteSpace(user.MiddleName))
                            {
                                userStr = user.LastName + " " + user.FirstName[0] + "." + user.MiddleName[0] + ".";
                            }
                            else if (!string.IsNullOrWhiteSpace(user.LastName) && !string.IsNullOrWhiteSpace(user.FirstName))
                            {
                                userStr = user.LastName + " " + user.FirstName[0] + ".";
                            }

                            new_comm.Text       = String.Format("{0} - {1}: {2}", comm.CreationDate.Value.ToString(), userStr, comm.Text); //    comm.Text;
                            new_comm.IsComments = true;
                            new_comm.Save();
                            task.GeneralComment.Add(new_comm);
                        });
                        break;
                    }
                }
            }
        }
コード例 #9
0
 public async Task OnPostUpdateCollectionAsync(PostCollectionUpdateEvent @event, CancellationToken cancellationToken) => await DispatchEvents(@event);
コード例 #10
0
 /*****************************************************************************************************************
 *  PostUpdateCollection triggered after a collection update, e.g. the number of slots changed in snack machine,
 *  PostUpdate wouldn't work because snack machine entity itself wouldn't change, and so NHibernate wouldn't
 *  trigger the PostUpdate event for it, it would fire a PostUpdateCollection event instead.
 *****************************************************************************************************************/
 public void OnPostUpdateCollection(PostCollectionUpdateEvent ev) => DispatchEvents(ev.AffectedOwnerIdOrNull as AggregateRoot);
コード例 #11
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
 {
     DispatchEvents(@event.AffectedOwnerOrNull as AggregateRoot);
 }
コード例 #12
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
 {
     ProcessCollectionEvent(@event);
 }
コード例 #13
0
        public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
        {
            var t = PublishEvents(@event.AffectedOwnerOrNull, CancellationToken.None);

            Task.WaitAll(t);
        }
コード例 #14
0
 public async Task OnPostUpdateCollectionAsync(PostCollectionUpdateEvent @event, CancellationToken cancellationToken)
 {
     await PublishEvents(@event.AffectedOwnerOrNull, cancellationToken);
 }
コード例 #15
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
 {
     var colMap = @event.Session.SessionFactory.GetCollectionMetadata(@event.Collection.Role);
 }
コード例 #16
0
 public virtual IEnumerable <AuditLogEntry> CreateEntries(PostCollectionUpdateEvent e)
 {
     return(CreateCollectionEntries(e.AffectedOwnerOrNull, (Guid)e.AffectedOwnerIdOrNull, e.Collection));
 }
コード例 #17
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent ev)
 {
     DispatchEvents(ev.AffectedOwnerOrNull as Entity);
 }
コード例 #18
0
 public IEnumerable <AuditLogEntry> CreateEntries(PostCollectionUpdateEvent e)
 {
     yield break;
 }
コード例 #19
0
 public Task OnPostUpdateCollectionAsync(PostCollectionUpdateEvent @event, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
コード例 #20
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
 {
 }
コード例 #21
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
 {
     AddEvent(@event, this);
 }
コード例 #22
0
 public void OnPostUpdateCollection(PostCollectionUpdateEvent @event)
 {
     log.Debug("OnPostUpdateCollection :" + @event);
 }