public virtual void OnPostUpdate(PostUpdateEvent e)
 {
     if (used)
     {
         ProcessWork(e.Entity, e.Id, WorkType.Update, e);
     }
 }
Ejemplo n.º 2
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            var entity = default(Term);

            if (@event.TryCatchEntity(ref entity))
            {
                var statelessSession = @event.Persister.Factory.OpenStatelessSession();

                var start = entity.GetSnapshotValue<DateTime>("Start");
                var end = entity.GetSnapshotValue<DateTime>("End");
                var locked = entity.GetSnapshotValue<bool>("Locked");

                if (start == entity.Start && end == entity.End && locked == entity.Locked) // no changed
                    return;

                //var length = (entity.End - entity.Start).TotalMinutes;
                //var oldtime = (end - start).TotalMinutes;

                var log = new TermLog
                              {
                                  SourceId = entity.Id,
                                  EmployeeId = entity.GetSnapshotValue<Guid>("EmployeeId"),
                                  Type = entity.GetType().Name,
                                  Name = entity.Text,
                                  Category = _alterWay,
                                  OldTime = FormatTime(start, end),
                                  NewTime = FormatTime(entity.Start, entity.End),
                                  Remark = _batchAlteringComments
                              };
                log.Action = entity.GetAction();

                SaveLog(statelessSession, log);
                entity.EndEdit();
            }
        }
Ejemplo n.º 3
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            //try
            //{

            if (@event.Entity is Audit)
            {
                return;
            }

            if (@event.Entity is IAuditable)
            {
                var auditableEntity = @event.Entity as IAuditable;
                var entityFullName = @event.Entity.GetType().FullName;
                var entityId = @event.Id.ToString();

                if (@event.OldState == null)
                {
                    throw new AuditUpdateNotOldStatePresentExceptions(entityFullName, entityId);
                }

                var dirtyFieldIndexes = @event.Persister.FindDirty(@event.State, @event.OldState, @event.Entity,
                    @event.Session);
                var now = DateTime.Now;
                var updateId = Guid.NewGuid();

                foreach (var dirtyFieldIndex in dirtyFieldIndexes)
                {
                    var oldPropertyDetails = GetPropertyDetails(@event.OldState, dirtyFieldIndex, @event.Persister);
                    var newPropertyDetails = GetPropertyDetails(@event.State, dirtyFieldIndex, @event.Persister);

                    if (oldPropertyDetails.PropertyValue == newPropertyDetails.PropertyValue)
                    {
                        continue;
                    }

                    if (auditableEntity.LastModifiedBy == null)
                    {
                        throw new AuditUpdateLastModifiedByNotSetExceptions(entityFullName, entityId);
                    }
                    
                    AddRecord(
                        "U",
                        entityFullName,
                        entityId,
                        newPropertyDetails.PropertyName,
                        oldPropertyDetails.PropertyValue,
                        newPropertyDetails.PropertyValue,
                        now,
                        auditableEntity.LastModifiedBy.Id.ToString(),
                        updateId);
                    
                       
                }
            }
            //catch (Exception e)
            //    {
            //        string h = e.Message;
            //    }
        }
		void IPostUpdateEventListener.OnPostUpdate(PostUpdateEvent @event)
		{
			if (@event.Entity is Person)
			{
				@event.Session
					.CreateSQLQuery("update Person set Name = :newName")
					.SetString("newName", "new updated name")
					.ExecuteUpdate();
			}
		}
Ejemplo n.º 5
0
		public void OnPostUpdate(PostUpdateEvent @event)
		{
			IAuditor auditor;
			auditors.TryGetValue(@event.Persister.EntityName, out auditor);
			if (auditor == null)
			{
				return;
			}
			auditor.Updated(@event);
		}
        /// <summary>
        /// Called when [post update].
        /// </summary>
        /// <param name="event">The @event.</param>
        public void OnPostUpdate( PostUpdateEvent @event )
        {
            object entity = @event.Entity;

            int[] dirtyFieldIndexes = @event.Persister.FindDirty(@event.State, @event.OldState, @event.Entity, @event.Session);

            AuditPatientAccess (
                entity,
                @event,
                PatientAccessEventType.UpdateEvent,
                () => GetAuditNoteForEntity ( @event, dirtyFieldIndexes, new UpdateEntityAuditStrategy ( @event.OldState, @event.State ) ) );
        }
Ejemplo n.º 7
0
        public virtual void OnPostUpdate(PostUpdateEvent evt)
        {
            var entityName = evt.Persister.EntityName;
            if (!VerCfg.EntCfg.IsVersioned(entityName)) return;

            var verSync = VerCfg.AuditProcessManager.Get(evt.Session);
            var workUnit = new ModWorkUnit(evt.Session, evt.Persister.EntityName, VerCfg,
                                                                         evt.Id, evt.Persister, evt.State, evt.OldState);
            verSync.AddWorkUnit(workUnit);
            if (workUnit.ContainsWork())
            {
                GenerateBidirectionalCollectionChangeWorkUnits(verSync, evt.Persister, entityName, evt.State,
                                                                    evt.OldState, evt.Session);
            }
        }
Ejemplo n.º 8
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            if (@event.Entity is AuditLogEntry)
            {
                return;
            }

            var entityFullName = @event.Entity.GetType().FullName;

            if (@event.OldState == null)
            {
                throw new ArgumentNullException("No old state available for entity type '" + entityFullName +
                                                "'. Make sure you're loading it into Session before modifying and saving it.");
            }

            var dirtyFieldIndexes = @event.Persister.FindDirty(@event.State, @event.OldState, @event.Entity, @event.Session);

            var session = @event.Session.GetSession(EntityMode.Poco);

            foreach (var dirtyFieldIndex in dirtyFieldIndexes)
            {
                //For component types, check:
                //	@event.Persister.PropertyTypes[dirtyFieldIndex] is ComponentType

                var oldValue = getStringValueFromStateArray(@event.OldState, dirtyFieldIndex);
                var newValue = getStringValueFromStateArray(@event.State, dirtyFieldIndex);

                if (oldValue == newValue)
                {
                    continue;
                }

                session.Save(new AuditLogEntry
                             	{
                             		EntityShortName = @event.Entity.GetType().Name,
                             		FieldName = @event.Persister.PropertyNames[dirtyFieldIndex],
                             		EntityFullName = entityFullName,
                             		OldValue = oldValue,
                             		NewValue = newValue,
                             		Username = Environment.UserName,
                             		EntityId = (int)@event.Id,
                             		AuditEntryType = "Update",
                             		Timestamp = DateTime.Now
                             	});
            }

            session.Flush();
        }
Ejemplo n.º 9
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            if (!(@event.Entity is Entity))
                return;

            var session = @event.Session.GetSession(EntityMode.Poco);
            var entityName = @event.Entity.GetType().Name;
            var propertyNames = @event.Persister.EntityMetamodel.PropertyNames;
            var before = Serialize(propertyNames, @event.OldState);
            var after = Serialize(propertyNames, @event.State);

            Log.Debug(before);
            Log.Debug(after);

            AuditEvent(session, @event.Id, "UPDATE", entityName, before, after);
        }
        public void OnPostUpdate(PostUpdateEvent e)
        {
            if (Params.SkipTrakingList.Contains(e.Entity.GetType().FullName)
                || e.Entity.GetType().Name.Equals("AuditRegister"))
                return;

            if (e.OldState == null)
            {
                //throw new ArgumentNullException("No old state available for entity type '" + entityFullName +
                //                                "'. Make sure you're loading it into Session before modifying and saving it.");
                return;
            }

            var dirtyFieldIndexes = e.Persister.FindDirty(e.State, e.OldState, e.Entity, e.Session);

            var session = e.Session.GetSession(EntityMode.Poco);

            foreach (var dirtyFieldIndex in dirtyFieldIndexes)
            {
                var oldValue = getStringValueFromStateArray(e.OldState, dirtyFieldIndex);
                var newValue = getStringValueFromStateArray(e.State, dirtyFieldIndex);

                if (oldValue == newValue)
                {
                    continue;
                }

                var aud = new AuditRegister()
                {
                    ColumnName = e.Persister.PropertyNames[dirtyFieldIndex],
                    ContextId = long.Parse(e.Id.ToString()),
                    NewValue = newValue.ToString(),
                    OldValue = oldValue == null ? string.Empty : oldValue.ToString(),
                    OperationDate = DateTime.Now,
                    OperationType = AuditOperationType.Update,
                    ColumnTitle = AnnotationsAttributes.GetPropertyTitle(e.Entity.GetType(), e.Persister.PropertyNames[dirtyFieldIndex]),
                    ContextUser = GetUsuarioLogado(),
                    ObjectName = AnnotationsAttributes.GetClassTitle(e.Entity.GetType())
                };

                session.Save(aud);
            }

            session.Flush();

            return;
        }
Ejemplo n.º 11
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            if (@event.Entity is ISearchable == false)
                return;

            using (var session = sessionFactory.OpenSession())
            {
                session.FlushMode = FlushMode.Never;
                var entity = (ISearchable)(session.Get(@event.Entity.GetType(), ((ISearchable) @event.Entity).Id));
                if (entity.IsActive)
                {
                    Indexer.WriteChangesToLucene(entity);
                }
                else
                {
                    Indexer.RemoveFromLucene(entity);
                }
            }
        }
        /// <summary>
        /// The on post update.
        /// </summary>
        /// <param name="event">
        /// The event.
        /// </param>
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            if (!(@event.Entity is IEntity))
            {
                return;
            }

            var updatedPropertyNames = new List<string>();

            for (var i = 0; i < @event.OldState.Length; ++i)
            {
                if (object.Equals(@event.OldState[i], @event.State[i]))
                {
                    continue;
                }

                updatedPropertyNames.Add(@event.Persister.PropertyNames[i]);
            }

            var domainEvent = CreateDomainEvent(typeof(EntityUpdatedEvent<>), @event.Entity, (IEnumerable<string>)updatedPropertyNames.AsReadOnly());
            DomainEvents.Raise(domainEvent);
        }
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            System.Diagnostics.Debug.WriteLine("*** OnPostUpdate Start ***");

            var product = @event.Entity as SampleSolrApp.Models.Nh.Product;
            if (product != null)
            {
                var productWriter = StructureMap.ObjectFactory.GetInstance<SolrNet.ISolrOperations<SampleSolrApp.Models.Nh.Product>>();
                productWriter.Add(product);
                productWriter.Commit();
                System.Diagnostics.Debug.WriteLine("*** Product updated and commited ***");
            }

            var manufacturer = @event.Entity as SampleSolrApp.Models.Nh.Manufacturer;
            if (manufacturer != null)
            {
                var manufacturerWriter = StructureMap.ObjectFactory.GetInstance<SolrNet.ISolrOperations<SampleSolrApp.Models.Nh.Manufacturer>>();
                manufacturerWriter.Add(manufacturer);
                manufacturerWriter.Commit();
                System.Diagnostics.Debug.WriteLine("*** Manufacturer updated and commited ***");
            }

            System.Diagnostics.Debug.WriteLine("*** OnPostUpdate End ***");
        }
		public void OnPostUpdate(PostUpdateEvent @event)
		{
			log.Debug(LogMessage);
			assertionDelegate(@event);
		}
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            AuditLogItem ali = AuditLogItem.Find(@event.Entity.GetType());
            if ((ali.AuditLogAction & PPWAuditLogActionEnum.UPDATE) == PPWAuditLogActionEnum.UPDATE)
            {
                string identityName = IdentityNameHelper.GetIdentityName();
                DateTime now = DateTime.Now;
                string entityName = @event.Entity.GetType().Name;

                if (@event.OldState == null)
                {
                    throw new ProgrammingError(
                        String.Format(
                            "No old state available for entity type '{1}'.{0}Make sure you're loading it into Session before modifying and saving it.",
                            Environment.NewLine,
                            entityName));
                }

                List<AuditLog> logs = new List<AuditLog>();
                int[] dirtyFieldIndexes = @event.Persister.FindDirty(@event.State, @event.OldState, @event.Entity, @event.Session);
                foreach (int dirtyFieldIndex in dirtyFieldIndexes)
                {
                    string oldValue = GetStringValueFromStateArray(@event.OldState, dirtyFieldIndex);
                    string newValue = GetStringValueFromStateArray(@event.State, dirtyFieldIndex);

                    if (oldValue != newValue)
                    {
                        string propertyName = @event.Persister.PropertyNames[dirtyFieldIndex];
                        PPWAuditLogActionEnum auditLogAction;
                        if (ali.Properties.TryGetValue(propertyName, out auditLogAction))
                        {
                            if ((auditLogAction & PPWAuditLogActionEnum.UPDATE) == PPWAuditLogActionEnum.NONE)
                            {
                                logs.Add(new AuditLog
                                {
                                    EntryType = "U",
                                    EntityName = entityName,
                                    EntityId = (long?)@event.Id,
                                    PropertyName = propertyName,
                                    OldValue = oldValue,
                                    NewValue = newValue,
                                    CreatedBy = identityName,
                                    CreatedAt = now,
                                });
                            }
                        }
                    }
                }
                if (logs.Count > 0)
                {
                    using (ISession session = @event.Session.GetSession(EntityMode.Poco))
                    {
                        logs.ForEach(o => session.Save(o));
                        session.Flush();
                    }
                }
            }
        }
        public void OnPostUpdate(PostUpdateEvent evt) {
            String entityName = evt.Persister.EntityName;

            if (verCfg.EntCfg.IsVersioned(entityName)) {
                AuditSync verSync = verCfg.AuditSyncManager.get(evt.Session);

                IAuditWorkUnit workUnit = new ModWorkUnit(evt.Session, evt.Persister.EntityName, verCfg,
                        evt.Id, evt.Persister, evt.State, evt.OldState);
                verSync.AddWorkUnit(workUnit);

                if (workUnit.ContainsWork()) {
                    GenerateBidirectionalCollectionChangeWorkUnits(verSync, evt.Persister, entityName, evt.State,
                            evt.OldState, evt.Session);
                }
                //Simon - TODO - same as above
                //verSync.BeforeCompletion();
            }
        }
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     EventDispatcher.RaiseEvent(@event.Entity, typeof (UpdatedEvent));
 }
Ejemplo n.º 18
0
		private void PostCommitUpdate()
		{
			IPostUpdateEventListener[] postListeners = Session.Listeners.PostCommitUpdateEventListeners;
			if (postListeners.Length > 0)
			{
				PostUpdateEvent postEvent = new PostUpdateEvent(Instance, Id, state, previousState, Persister, (IEventSource)Session);
				foreach (IPostUpdateEventListener listener in postListeners)
				{
					listener.OnPostUpdate(postEvent);
				}
			}
		}
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     var entity = @event.Entity as EntityBase;
     return;
 }
Ejemplo n.º 20
0
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     RaiseOnSave(@event.Entity);
 }
 public void OnPostUpdate(PostUpdateEvent ev)
 {
     DispatchEvents(ev.Entity as AggregateRoot);
 }
Ejemplo n.º 22
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            LogHelper.TraceIfEnabled<NhEventListeners>("OnPostUpdate for '{0}' with id '{1}'",
                                                     () => @event.Entity.GetType().Name, () => @event.Id);

            AggregateDataInterceptor.CheckNodeVersionId(@event.Entity, EnsureVersionIdsInitialised());
        }
 public void OnPostUpdate(PostUpdateEvent updateEvent)
 {
     OutputCacheManager.EntityChanged(updateEvent.Entity);
 }
 public void OnPostUpdate(PostUpdateEvent @event)
 {
 }
Ejemplo n.º 25
0
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     Debug.WriteLine("EventListener.OnPostUpdate: {0}", @event.Id);
 }
Ejemplo n.º 26
0
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     log.Debug("OnPostUpdate :" + @event);
 }
Ejemplo n.º 27
0
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     LogHelper.TraceIfEnabled<NhEventListeners>("OnPostUpdate for '{0}' with id '{1}'",
                                              () => @event.Entity.GetType().Name, () => @event.Id);
 }
Ejemplo n.º 28
0
 public abstract void Updated(PostUpdateEvent eventArgs);
Ejemplo n.º 29
0
 public void OnPostUpdate(PostUpdateEvent @event)
 {
     var persistableObject = @event.Entity as IPersistableObject;
     persistableObject.OnUpdated();
 }