예제 #1
0
 public void OnSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent e)
 {
     if (e.Entity is IOnSave)
     {
         (e.Entity as IOnSave).OnSave(this, e);
     }
 }
 public void OnSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent e)
 {
     NHibernate.Persister.Entity.IEntityPersister p = e.Session.GetEntityPersister(null, e.Entity);
     if (p.IsVersioned)
     {
         object version = p.GetVersion(e.Entity, e.Session.EntityMode);
         object currversion = p.GetCurrentVersion(e.Entity, e.Session);
         if (version.Equals(currversion))
             throw new StaleObjectStateException(e.EntityName, e.Entry.Id);
     }
 }
예제 #3
0
 public void OnSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent e)
 {
     if (!(e.Entity is IUsesRegistry) || (e.Entity as IUsesRegistry).Registry != null)
     {
         return;
     }
     Arbinada.GenieLamp.Warehouse.Domain.Core.EntityRegistry r = new Arbinada.GenieLamp.Warehouse.Domain.Core.EntityRegistry();
     r.EntityType = Arbinada.GenieLamp.Warehouse.Domain.Core.EntityType.GetByFullName(e.Entity.GetType().FullName);
     r.Save(e.Session.Transaction);
     (e.Entity as IUsesRegistry).Registry = r;
 }
예제 #4
0
 public virtual void OnSave(EventHandlerBase sender, NHibernate.Event.SaveOrUpdateEvent e)
 {
     if (Tester != null)
     {
         Tester.OnSave++;
         if (Tester.ThrowOnSave)
         {
             throw new Exception("Store.OnSave()");
         }
     }
 }
 public void OnSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent e)
 {
     NHibernate.Persister.Entity.IEntityPersister p = e.Session.GetEntityPersister(null, e.Entity);
     if (p.IsVersioned)
     {
         //TODO: check types etc...
         DateTime oldversion = (DateTime) p.GetVersion(e.Entity, e.Session.EntityMode);
         DateTime currversion = (DateTime) p.GetCurrentVersion(e.Entity, e.Session);
         if (oldversion < currversion.AddMinutes(-30))
             throw new StaleObjectStateException(e.EntityName, e.Entry.Id);
     }
 }
예제 #6
0
        protected override object PerformSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent @event)
        {
            object _object = base.PerformSaveOrUpdate(@event);

            if (Researcher.Current != null && @event.Entity == Researcher.Current.ActiveProject)
            {
                NHibernateHelper.OnActiveProjectModified(@event.Entity, new EventArgs());
            }
            // on project new/update/delete the researcher save is being called
            if (@event.Entity == Researcher.Current)
            {
                NHibernateHelper.OnProjectModified(@event.Entity, new EventArgs());
            }

            return(_object);
        }
예제 #7
0
        protected override object PerformSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent evt)
        {
            var auditable = evt.Entity as IAuditable;
            var entity    = evt.Entity as IEntity;

            if (auditable != null && entity != null)
            {
                var principle = Thread.CurrentPrincipal;
                if (entity.IsTransient)
                {
                    auditable.CreatedOn = DateTime.Now;
                    auditable.CreatedBy = principle.Identity.Name;
                }
                auditable.ChangedOn = DateTime.Now;
                auditable.ChangedBy = principle.Identity.Name;
            }
            return(base.PerformSaveOrUpdate(evt));
        }
예제 #8
0
 public void OnSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent e)
 {
     DoAudit(e.Entity as IUsesAudit);
 }