private void SaveEntries(IEnumerable <AuditLogEntry> entries, IDatabaseEventArgs e) { try { if (entries == null || !entries.Any()) { return; } var session = e.Session.GetSession(EntityMode.Poco); entries.Apply(x => session.Save(x)); session.Flush(); } catch (Exception ex) { var exceptionLogger = Container.Instance.Resolve <IExceptionLogger>(); exceptionLogger.LogException(ex); } }
private void GenerateBidirectionalCollectionChangeWorkUnits(AuditProcess auditProcess, IDatabaseEventArgs evt, PersistentCollectionChangeWorkUnit workUnit, RelationDescription rd) { // Checking if this is enabled in configuration ... if (!VerCfg.GlobalCfg.GenerateRevisionsForCollections) return; // Checking if this is not a bidirectional relation - then, a revision needs also be generated for // the other side of the relation. // relDesc can be null if this is a collection of simple values (not a relation). if (rd != null && rd.Bidirectional) { var relatedEntityName = rd.ToEntityName; var relatedIdMapper = VerCfg.EntCfg[relatedEntityName].IdMapper; foreach (var changeData in workUnit.CollectionChanges) { var relatedObj = changeData.GetChangedElement(); var relatedId = relatedIdMapper.MapToIdFromEntity(relatedObj); auditProcess.AddWorkUnit(new CollectionChangeWorkUnit(evt.Session, evt.Session.BestGuessEntityName(relatedObj), VerCfg, relatedId, relatedObj)); } } }
private static ValidationContext CreateValidationContext(IDatabaseEventArgs @event, object entity) { return(new ValidationContext(entity, new SessionProvider(@event.Session), null)); }
private static ValidationContext CreateValidationContext(IDatabaseEventArgs @event, object entity) { return new ValidationContext(entity, new SessionProvider(@event.Session), null); }