protected void AddAuditData(Auditable entity, int userId) { entity.CreateUserID = userId; entity.CreateDate = DateTime.Now; entity.CreateDateUtc = DateTime.UtcNow; UpdateAuditData(entity, userId); }
protected void AddAuditData(Auditable entity) { entity.CreateUserID = CurrentUser.UserID; entity.CreateDate = DateTime.Now; entity.CreateDateUtc = DateTime.UtcNow; UpdateAuditData(entity); }
public static void SetAuditForReject(this Auditable model, AuditableDTO dto) { model.CreateBy = dto.CreateBy; model.CreateDate = dto.CreateDate.Value; model.LastUpdateDate = dto.LastUpdateDate.HasValue?dto.LastUpdateDate.Value : (DateTime?)null; model.LastUpdateBy = dto.LastUpdateBy; model.AuthBy = dto.AuthBy; model.AuthDate = DateTime.Now; model.AuthStatus = AuthStatus.Rejected; }
public static void SetAuditForDTO(this AuditableDTO dto, Auditable model) { dto.CreateBy = model.CreateBy; dto.CreateDate = model.CreateDate; dto.AuthBy = model.AuthBy; dto.AuthDate = model.AuthDate; dto.AuthStatus = model.AuthStatus; dto.LastUpdateDate = model.LastUpdateDate; dto.LastUpdateBy = model.LastUpdateBy; }
protected void UpdateAuditData(Auditable entity) { entity.ModifyUserID = CurrentUser.UserID; entity.ModifyDate = DateTime.Now; entity.ModifyDateUtc = DateTime.UtcNow; if (entity.CreateUserID <= 0) { AddAuditData(entity); } }
public override void OnSaveOrUpdate(SaveOrUpdateEvent @event) { Auditable a = @event.Entity as Auditable; if (a != null) { if (this.GetEntityState(@event.Entity, @event.EntityName, @event.Entry, @event.Session) == EntityState.Transient) { a.create_dt = DateTime.Now; a.create_by = @event.Session.Load <Staff>(CurrentStaff.Id); } } base.OnSaveOrUpdate(@event); }
public bool OnPreInsert(PreInsertEvent @event) { if (@event.Entity is IAuditable) { DateTime now = DateTime.UtcNow; IAuditable audit = @event.Entity as IAuditable; audit.AuditInfo.IsDeleted = false; audit.AuditInfo.CreationDate = now; audit.AuditInfo.ModificationDate = now; audit.AuditInfo.CreationUser = Thread.CurrentPrincipal.Identity.Name; audit.AuditInfo.ModificationUser = Thread.CurrentPrincipal.Identity.Name; Auditable auditable = audit.AuditInfo; Set(@event.Persister, @event.State, "AuditInfo", auditable); return(false); } return(false); }
public bool OnPreUpdate(PreUpdateEvent event_item) { Auditable audit = event_item.Entity as Auditable; if (audit == null) { return(false); } DateTime?modified_date = DateTime.Now; string identity_of_updater = get_identity(); store(event_item.Persister, event_item.State, "modified_date", modified_date); store(event_item.Persister, event_item.State, "entered_by", identity_of_updater); audit.modified_date = modified_date; audit.entered_by = identity_of_updater; //insert auditing object here return(false); }
public static void DipuOnDerive(this Auditable @this, ObjectOnDerive method) { var derivation = method.Derivation; var user = new Users(@this.Strategy.Session).GetCurrentAuthenticatedUser(); if (user != null) { var changeSet = derivation.ChangeSet; if (changeSet.Created.Contains(@this.Id)) { @this.CreationDate = DateTime.UtcNow; @this.CreatedBy = user; } if (changeSet.Associations.Contains(@this.Id)) { @this.LastModifiedDate = DateTime.UtcNow; @this.LastModifiedBy = user; } } }
//http://ayende.com/Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp-ipreinserteventlistener.aspx public bool OnPreInsert(PreInsertEvent event_item) { Auditable audit = event_item.Entity as Auditable; if (audit == null) { return(false); } DateTime?entered_date = DateTime.Now; DateTime?modified_date = DateTime.Now; string identity_of_updater = get_identity(); store(event_item.Persister, event_item.State, "entered_date", entered_date); store(event_item.Persister, event_item.State, "modified_date", modified_date); store(event_item.Persister, event_item.State, "updating_user", identity_of_updater); audit.entered_date = entered_date; audit.modified_date = modified_date; audit.updating_user = identity_of_updater; return(false); }
public static void CoreOnDerive(this Auditable @this, ObjectOnDerive method) { var user = @this.Strategy.Session.GetUser(); if (user != null) { var derivation = method.Derivation; var changeSet = derivation.ChangeSet; if (changeSet.Created.Contains(@this.Id)) { @this.CreationDate = @this.Strategy.Session.Now(); @this.CreatedBy = user; } if (changeSet.Associations.Contains(@this.Id)) { @this.LastModifiedDate = @this.Strategy.Session.Now(); @this.LastModifiedBy = user; } } }
private void BuildAuditForEntity(EntityEntry entry, Auditable isAudit, string username, AuditEntity auditEntity) { string id = entry.CurrentValues[isAudit.EntityIdPropertyName].ToString(); var list = new List <AuditEntityProperty>(); var type = entry.Entity.GetType(); auditEntity.ActionId = (int)entry.State; auditEntity.EntityName = type.Name; auditEntity.EntityId = id; foreach (var property in entry.CurrentValues.Properties) { var curVal = entry.CurrentValues[property.Name]; object oldVal = null; if (entry.State == EntityState.Modified) { oldVal = entry.OriginalValues[property.Name]; } if (NotEqual(oldVal, curVal)) { list.Add(new AuditEntityProperty { PropertyName = property.Name, OldValue = oldVal == null ? null : oldVal.ToString(), NewValue = curVal == null ? null : curVal.ToString(), AuditEntity = auditEntity, }); } } auditEntity.AuditEntityProperties = list; AuditEntities.Add(auditEntity); }
public BaseIdentityDbContext(DbContextOptions <TContext> options, Auditable auditor) : base(options) => _auditor = auditor;
public override bool Equals(Auditable other) { var token = (PushNotificationToken)other; return(Token == token.Token); }
public BaseAuditableDbContext(DbContextOptions <TContext> options, Auditable auditor, string defaultSchema = "dbo") : base(options) { _defaultSchema = defaultSchema; _auditor = auditor; }
protected BaseEntity() { AuditInfo = new Auditable(); }
public static void SetAuditable(this Auditable o, DateTime timeStamp) { o.createdBy = "system"; o.timeStamp = timeStamp; }
public static void SetAuditable(this Auditable o) { o.createdBy = "system"; o.timeStamp = DateTime.Now; }
public static void SetAuditForCreate(this Auditable model, AuditableDTO dto) { model.CreateBy = dto.CreateBy; model.CreateDate = DateTime.Now; model.AuthStatus = AuthStatus.Submitted; }
protected void UpdateAuditData(Auditable entity, int userId) { entity.ModifyUserID = userId; entity.ModifyDate = DateTime.Now; entity.ModifyDateUtc = DateTime.UtcNow; }