public void OnPostInsert(PostInsertEvent @event) { if (IsEnabled) { var entity = default(Term); if (@event.TryCatchEntity(ref entity)) { var statelessSession = @event.Persister.Factory.OpenStatelessSession(); using (var tx = statelessSession.BeginTransaction()) { var employeeId = entity.GetSnapshotValue <Guid>("EmployeeId"); var backup = new BackupTerm(entity.Id, employeeId, entity.Start, entity.End, entity.Text, entity.Background, entity.Level); if (entity.Bottom != null) { backup.ParentTermId = entity.Bottom.Id; } statelessSession.Insert(backup); tx.Commit(); } } } }
public void OnPostInsert(PostInsertEvent @event) { var seat = default(Seat); if (@event.TryCatchEntity(ref seat)) { if (_seatBoxRepository == null) { _seatBoxRepository = ServiceLocator.Current.GetInstance <ISeatBoxRepository>(); } _seatBoxRepository.MakePersistent(new SeatBox(seat)); } }
public void OnPostInsert(PostInsertEvent @event) { var entity = default(Term); if (@event.TryCatchEntity(ref entity)) { var statelessSession = @event.Persister.Factory.OpenStatelessSession(); var log = new TermLog { SourceId = entity.Id, EmployeeId = entity.GetSnapshotValue <Guid>("EmployeeId"), Action = "I", Type = entity.GetType().Name, Name = entity.Text, Category = _alterWay, OldTime = null, NewTime = FormatTime(entity.Start, entity.End), Remark = _batchAlteringComments }; SaveLog(statelessSession, log); } }