public void OnPostInsert(PostInsertEvent e)
        {
            if ( Params.SkipTrakingList.Contains(e.Entity.GetType().FullName)
                || e.Entity.GetType().Name.Equals("AuditRegister"))
                return;

            foreach (var p in e.Entity.GetType().GetProperties())
            {
                var aud = new AuditRegister()
                {

                    ColumnName = p.Name,
                    ContextId = long.Parse(e.Id.ToString()),
                    NewValue = p.GetValue(e.Entity) == null ? string.Empty : p.GetValue(e.Entity).ToString(),
                    OperationDate = DateTime.Now,
                    OperationType = AuditOperationType.Insert,
                    ColumnTitle = AnnotationsAttributes.GetPropertyTitle(e.Entity.GetType(), p.Name),
                    ContextUser = GetUsuarioLogado(),
                    ObjectName = AnnotationsAttributes.GetClassTitle(e.Entity.GetType())
                };

                e.Session.Save(aud);
            }

            return;
        }
        public void OnPostUpdate(PostUpdateEvent e)
        {
            if (Params.SkipTrakingList.Contains(e.Entity.GetType().FullName)
                || e.Entity.GetType().Name.Equals("AuditRegister"))
                return;

            if (e.OldState == null)
            {
                //throw new ArgumentNullException("No old state available for entity type '" + entityFullName +
                //                                "'. Make sure you're loading it into Session before modifying and saving it.");
                return;
            }

            var dirtyFieldIndexes = e.Persister.FindDirty(e.State, e.OldState, e.Entity, e.Session);

            var session = e.Session.GetSession(EntityMode.Poco);

            foreach (var dirtyFieldIndex in dirtyFieldIndexes)
            {
                var oldValue = getStringValueFromStateArray(e.OldState, dirtyFieldIndex);
                var newValue = getStringValueFromStateArray(e.State, dirtyFieldIndex);

                if (oldValue == newValue)
                {
                    continue;
                }

                var aud = new AuditRegister()
                {
                    ColumnName = e.Persister.PropertyNames[dirtyFieldIndex],
                    ContextId = long.Parse(e.Id.ToString()),
                    NewValue = newValue.ToString(),
                    OldValue = oldValue == null ? string.Empty : oldValue.ToString(),
                    OperationDate = DateTime.Now,
                    OperationType = AuditOperationType.Update,
                    ColumnTitle = AnnotationsAttributes.GetPropertyTitle(e.Entity.GetType(), e.Persister.PropertyNames[dirtyFieldIndex]),
                    ContextUser = GetUsuarioLogado(),
                    ObjectName = AnnotationsAttributes.GetClassTitle(e.Entity.GetType())
                };

                session.Save(aud);
            }

            session.Flush();

            return;
        }
        public void OnPostDelete(PostDeleteEvent e)
        {
            if (Params.SkipTrakingList.Contains(e.Entity.GetType().FullName)
                || e.Entity.GetType().Name.Equals("AuditRegister"))
                return;

            var entityFullName = e.Entity.GetType().FullName;

            var aud = new AuditRegister()
            {
                ContextId = long.Parse(e.Id.ToString()),
                OperationDate = DateTime.Now,
                OperationType = AuditOperationType.Delete,
                ObjectName = AnnotationsAttributes.GetClassTitle(e.Entity.GetType()),
                ContextUser = GetUsuarioLogado(),
            };

            e.Session.GetSession(EntityMode.Poco).Save(aud);
        }