public ValueTask <RepositoryEntityState> PreSaveChangesAsync(RepositoryEntityState entityState, object entity, CancellationToken cancellationToken = default) { entityState = PreSaveChanges(entityState, entity); return(new ValueTask <RepositoryEntityState>(entityState)); }
public async ValueTask <RepositoryEntityState> PreSaveChangesAsync(RepositoryEntityState entityState, object entity, CancellationToken cancellationToken = default) { if (entity is IDomainEventProvider domainEventProvider) { var entityEvents = domainEventProvider.GetDomainEvents(); var completedEventCount = 0; if (entityEvents == null || entityEvents.Count == 0) { return(entityState); } foreach (var @event in entityEvents) { try { await _eventDispatcher.DispatchAsync(@event); completedEventCount++; } catch (Exception ex) { _logger.LogWarning(ex, "There has a error when dispatch domain event."); } } if (completedEventCount != entityEvents.Count) { //count is not equal. prove the existence of failed events } } return(entityState); }
public RepositoryEntityState PreSaveChanges(RepositoryEntityState entityState, object entity) { if (entity is IDomianEventProvider domianEventProvider) { var entityEvents = domianEventProvider.GetDomainEvents(); var completedEventCount = 0; if (entityEvents == null || entityEvents.Count == 0) { return(entityState); } foreach (var @event in entityEvents) { try { _eventDispatcher.Dispatch(@event); completedEventCount++; } catch { } } if (completedEventCount != entityEvents.Count) { //count is not equal. prove the existence of failed events } } return(entityState); }
public ValueTask <RepositoryEntityState> PreSaveChangesAsync(RepositoryEntityState entityState, object entity, CancellationToken cancellationToken = default) { _auditExecutor.Execute(entity, entityState); return(new ValueTask <RepositoryEntityState>(entityState)); }
public RepositoryEntityState PreSaveChanges(RepositoryEntityState entityState, object entity) { if (entity is ISoftDeletion softDeletion) { if (entityState == RepositoryEntityState.Deleted) { softDeletion.IsDeleted = true; entityState = RepositoryEntityState.Modified; } else { softDeletion.IsDeleted = false; } } return(entityState); }
public virtual void Execute(object needAuditEntity, RepositoryEntityState entityState) { //Only deal with micake domain object. var entityType = needAuditEntity.GetType(); if (!typeof(IPersistentObject).IsAssignableFrom(entityType) && !DomainTypeHelper.IsDomainObject(entityType)) { return; } var model = new AuditObjectModel(needAuditEntity, entityState); foreach (var auditProvider in _providers) { auditProvider.ApplyAudit(model); } }
public RepositoryEntityState PreSaveChanges(RepositoryEntityState entityState, object entity) { _auditExecutor.Execute(entity, entityState); return(entityState); }
public AuditObjectModel(object entity, RepositoryEntityState state) { AuditEntity = entity; EntityState = state; }