コード例 #1
0
ファイル: BaseService.cs プロジェクト: Inforward/Guideport
        protected void AddAuditData(Auditable entity, int userId)
        {
            entity.CreateUserID  = userId;
            entity.CreateDate    = DateTime.Now;
            entity.CreateDateUtc = DateTime.UtcNow;

            UpdateAuditData(entity, userId);
        }
コード例 #2
0
        protected void AddAuditData(Auditable entity)
        {
            entity.CreateUserID  = CurrentUser.UserID;
            entity.CreateDate    = DateTime.Now;
            entity.CreateDateUtc = DateTime.UtcNow;

            UpdateAuditData(entity);
        }
コード例 #3
0
ファイル: MappingProfile.cs プロジェクト: Sorik98/TMDT
 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;
 }
コード例 #4
0
ファイル: MappingProfile.cs プロジェクト: Sorik98/TMDT
 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;
 }
コード例 #5
0
        protected void UpdateAuditData(Auditable entity)
        {
            entity.ModifyUserID  = CurrentUser.UserID;
            entity.ModifyDate    = DateTime.Now;
            entity.ModifyDateUtc = DateTime.UtcNow;

            if (entity.CreateUserID <= 0)
            {
                AddAuditData(entity);
            }
        }
コード例 #6
0
    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);
    }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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;
                }
            }
        }
コード例 #10
0
        //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);
        }
コード例 #11
0
        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;
                }
            }
        }
コード例 #12
0
        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);
        }
コード例 #13
0
 public BaseIdentityDbContext(DbContextOptions <TContext> options, Auditable auditor)
     : base(options) => _auditor = auditor;
コード例 #14
0
        public override bool Equals(Auditable other)
        {
            var token = (PushNotificationToken)other;

            return(Token == token.Token);
        }
コード例 #15
0
 public BaseAuditableDbContext(DbContextOptions <TContext> options, Auditable auditor, string defaultSchema = "dbo")
     : base(options)
 {
     _defaultSchema = defaultSchema;
     _auditor       = auditor;
 }
コード例 #16
0
 protected BaseEntity()
 {
     AuditInfo = new Auditable();
 }
コード例 #17
0
ファイル: Utils.cs プロジェクト: Karriz/herenthere
 public static void SetAuditable(this Auditable o, DateTime timeStamp)
 {
     o.createdBy = "system";
     o.timeStamp = timeStamp;
 }
コード例 #18
0
ファイル: Utils.cs プロジェクト: Karriz/herenthere
 public static void SetAuditable(this Auditable o)
 {
     o.createdBy = "system";
     o.timeStamp = DateTime.Now;
 }
コード例 #19
0
ファイル: MappingProfile.cs プロジェクト: Sorik98/TMDT
 public static void SetAuditForCreate(this Auditable model, AuditableDTO dto)
 {
     model.CreateBy   = dto.CreateBy;
     model.CreateDate = DateTime.Now;
     model.AuthStatus = AuthStatus.Submitted;
 }
コード例 #20
0
ファイル: BaseService.cs プロジェクト: Inforward/Guideport
 protected void UpdateAuditData(Auditable entity, int userId)
 {
     entity.ModifyUserID  = userId;
     entity.ModifyDate    = DateTime.Now;
     entity.ModifyDateUtc = DateTime.UtcNow;
 }