コード例 #1
0
 /// <summary>Constructor.</summary>
 /// <param name="parent">The audit entry parent.</param>
 /// <param name="propertyName">Name of the property audited.</param>
 /// <param name="oldValue">The old value audited.</param>
 /// <param name="newValue">The new value audited.</param>
 public AuditEntryProperty(AuditEntry parent, string propertyName, object oldValue, object newValue)
 {
     NewValue     = newValue;
     OldValue     = oldValue;
     Parent       = parent;
     PropertyName = propertyName;
 }
コード例 #2
0
        /// <summary>Audit entity added.</summary>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityAdded(AuditEntry entry, EntityEntry objectStateEntry)
        {
            foreach (var propertyEntry in objectStateEntry.Metadata.GetProperties())
            {
                var property = objectStateEntry.Property(propertyEntry.Name);

                if (property.Metadata.IsKey() || entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
                {
                    var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null?
                                             entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, propertyEntry.Name, null, property.CurrentValue)) :
                                                 new AuditEntryProperty();

                    var value = property.CurrentValue;

                    if (entry.Parent.CurrentOrDefaultConfiguration.IgnoreEntityAddedDefaultValue && property.Metadata.FieldInfo != null && property.Metadata.FieldInfo.FieldType != typeof(object) && property.CurrentValue != null)
                    {
                        var checkDefaultValue = DefaultValue(property.Metadata.FieldInfo.FieldType);
                        if (checkDefaultValue != null && checkDefaultValue.Equals(property.CurrentValue))
                        {
                            value = null;
                        }
                    }

                    auditEntryProperty.Build(entry, propertyEntry.Name, null, value);
                    entry.Properties.Add(auditEntryProperty);
                }
            }
        }
コード例 #3
0
        public void Build(AuditEntry parent, string relationName, string propertyName, object oldValue, DbUpdatableDataRecord dbUpdatableDataRecord, int dbUpdatableDataRecordPosition)
        {
            InternalPropertyName = propertyName;

            if (!IsValueSet)
            {
                DbUpdatableDataRecord         = dbUpdatableDataRecord;
                DbUpdatableDataRecordPosition = dbUpdatableDataRecordPosition;
                OldValue = oldValue;
            }

            if (Parent == null)
            {
                Parent = parent;
            }

            if (PropertyName == null)
            {
                PropertyName = parent.Parent.CurrentOrDefaultConfiguration.PropertyNameFactory != null?
                               parent.Parent.CurrentOrDefaultConfiguration.PropertyNameFactory(ObjectContext.GetObjectType(parent.Entry.Entity.GetType()), propertyName) :
                                   propertyName;
            }

            if (RelationName == null)
            {
                RelationName = relationName;
            }
        }
コード例 #4
0
 /// <summary>Constructor.</summary>
 /// <param name="parent">The audit entry parent.</param>
 /// <param name="propertyName">Name of the property audited.</param>
 /// <param name="oldValue">The old value audited.</param>
 /// <param name="newValue">The new value audited.</param>
 public AuditEntryProperty(AuditEntry parent, string propertyName, object oldValue, object newValue)
 {
     NewValue = newValue;
     OldValue = oldValue;
     Parent = parent;
     PropertyName = propertyName;
 }
コード例 #5
0
        /// <summary>Audit entity added.</summary>
        /// <param name="auditEntry">The audit entry.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        /// <param name="record">The record.</param>
        /// <param name="prefix">The prefix.</param>
        public static void AuditEntityAdded(AuditEntry auditEntry, ObjectStateEntry objectStateEntry, DbUpdatableDataRecord record, string prefix = "")
        {
            for (var i = 0; i < record.FieldCount; i++)
            {
                var name  = record.GetName(i);
                var value = record.GetValue(i);

                if (auditEntry.Parent.Configuration.UseNullForDBNullValue && value == DBNull.Value)
                {
                    value = null;
                }

                var valueRecord = value as DbUpdatableDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityAdded(auditEntry, objectStateEntry, valueRecord, string.Concat(prefix, name, "."));
                }
                else if (objectStateEntry.EntitySet.ElementType.KeyMembers.Any(x => x.Name == name) || auditEntry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(auditEntry.Entry, string.Concat(prefix, name)))
                {
                    var auditEntryProperty = auditEntry.Parent.Configuration.AuditEntryPropertyFactory != null?
                                             auditEntry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(auditEntry, objectStateEntry, string.Concat(prefix, name), null, value)) :
                                                 new AuditEntryProperty();

                    auditEntryProperty.Build(auditEntry, string.Concat(prefix, name), null, value);
                    auditEntry.Properties.Add(auditEntryProperty);
                }
            }
        }
コード例 #6
0
        public static void AuditEntityAdded(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.EntityAdded
            };


            // CHECK if the key should be resolved in POST Action
#if EF5 || EF6
            if (objectStateEntry.EntityKey.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }
            AuditEntityAdded(entry, objectStateEntry.CurrentValues);
#elif EF7
    // TODO: We must check if the key IsTemporary! We can maybe use flag...
    //if (!objectStateEntry.IsKeySet)
    //{
                entry.DelayedKey = objectStateEntry;
            //}
            AuditEntityAdded(entry, objectStateEntry);
#endif

            audit.Entries.Add(entry);
        }
コード例 #7
0
        public void Build(AuditEntry parent, string relationName, string propertyName, object oldValue, object newValue)
        {
            InternalPropertyName = propertyName;

            if (!IsValueSet)
            {
                NewValue = newValue;
                OldValue = oldValue;
            }

            if (Parent == null)
            {
                Parent = parent;
            }

            if (PropertyName == null)
            {
                PropertyName = propertyName;
            }

            if (RelationName == null)
            {
                RelationName = relationName;
            }
        }
コード例 #8
0
        /// <summary>Audit entity modified.</summary>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityModified(Audit audit, AuditEntry entry, EntityEntry objectStateEntry)
        {
            bool hasModified = false;

            foreach (var propertyEntry in objectStateEntry.Metadata.GetProperties())
            {
                var property = objectStateEntry.Property(propertyEntry.Name);

                if (property.Metadata.IsKey() || entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
                {
                    if (!audit.Configuration.IgnorePropertyUnchanged || property.Metadata.IsKey() || property.IsModified)
                    {
                        var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null?
                                                 entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, propertyEntry.Name, property.OriginalValue, property.CurrentValue)) :
                                                     new AuditEntryProperty();

                        auditEntryProperty.Build(entry, propertyEntry.Name, property.OriginalValue, property);
                        entry.Properties.Add(auditEntryProperty);

                        if (property.IsModified)
                        {
                            hasModified = true;
                        }
                    }
                }
            }

            if (audit.Configuration.IgnoreEntityUnchanged)
            {
                if (!hasModified)
                {
                    entry.Properties.Clear();
                }
            }
        }
コード例 #9
0
        public void Build(AuditEntry parent, string relationName, string propertyName, object oldValue, PropertyEntry propertyEntry)
        {
            InternalPropertyName = propertyName;

            if (!IsValueSet)
            {
                PropertyEntry = propertyEntry;
                OldValue      = oldValue;
            }

            if (Parent == null)
            {
                Parent = parent;
            }

            if (PropertyName == null)
            {
#if EF5 || EF6
                PropertyName = parent.Parent.CurrentOrDefaultConfiguration.PropertyNameFactory != null?
                               parent.Parent.CurrentOrDefaultConfiguration.PropertyNameFactory(ObjectContext.GetObjectType(parent.Entry.Entity.GetType()), propertyName) :
                                   propertyName;
#elif EFCORE
                PropertyName = parent.Parent.CurrentOrDefaultConfiguration.PropertyNameFactory != null?
                               parent.Parent.CurrentOrDefaultConfiguration.PropertyNameFactory(parent.Entry.Entity.GetType(), propertyName) :
                                   propertyName;
#endif
            }

            if (RelationName == null)
            {
                RelationName = relationName;
            }
        }
コード例 #10
0
        /// <summary>Audit entity modified.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="entry">The entry.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        /// <param name="orginalRecord">The orginal record.</param>
        /// <param name="currentRecord">The current record.</param>
        /// <param name="prefix">The prefix.</param>
        public static void AuditEntityModified(Audit audit, AuditEntry entry, ObjectStateEntry objectStateEntry, DbDataRecord orginalRecord, DbUpdatableDataRecord currentRecord, string prefix = "")
        {
            for (var i = 0; i < orginalRecord.FieldCount; i++)
            {
                var name          = orginalRecord.GetName(i);
                var originalValue = orginalRecord.GetValue(i);
                var currentValue  = currentRecord.GetValue(i);

                var valueRecord = originalValue as DbDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityModified(audit, entry, objectStateEntry, valueRecord, currentValue as DbUpdatableDataRecord, string.Concat(prefix, name, "."));
                }

                else if (objectStateEntry.EntityKey.EntityKeyValues.Any(x => x.Key == name) ||
                         entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, name))
                {
                    if (!audit.Configuration.IgnorePropertyUnchanged ||
                        objectStateEntry.EntityKey.EntityKeyValues.Any(x => x.Key == name) ||
                        !Equals(currentValue, originalValue))
                    {
                        var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null?
                                                 entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, string.Concat(prefix, name), originalValue, currentValue)) :
                                                     new AuditEntryProperty();

                        auditEntryProperty.Build(entry, string.Concat(prefix, name), originalValue, currentValue);
                        entry.Properties.Add(auditEntryProperty);
                    }
                }
            }
        }
コード例 #11
0
        public static void AuditEntityAdded(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.EntityAdded
            };


            // CHECK if the key should be resolved in POST Action
#if EF5 || EF6
            if (objectStateEntry.EntityKey.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }
            AuditEntityAdded(entry, objectStateEntry.CurrentValues);
#elif EF7
            // TODO: We must check if the key IsTemporary! We can maybe use flag...
            //if (!objectStateEntry.IsKeySet)
            //{
            entry.DelayedKey = objectStateEntry;
            //}
            AuditEntityAdded(entry, objectStateEntry);
#endif

            audit.Entries.Add(entry);
        }
コード例 #12
0
        /// <summary>Audit entity deleted.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityDeleted(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.EntityDeleted
            };

            AuditEntityDeleted(entry, objectStateEntry.OriginalValues);
            audit.Entries.Add(entry);
        }
コード例 #13
0
        /// <summary>Audit entity deleted.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityDeleted(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.EntityDeleted
            };

            AuditEntityDeleted(entry, objectStateEntry.OriginalValues);
            audit.Entries.Add(entry);
        }
コード例 #14
0
    /// <summary>Audit entity deleted.</summary>
    /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityDeleted(AuditEntry entry, EntityEntry objectStateEntry)
        {
            foreach (var propertyEntry in objectStateEntry.Metadata.GetProperties())
            {
                var property = objectStateEntry.Property(propertyEntry.Name);

                if (entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, propertyEntry.Name, property.OriginalValue, null));
                }
            }
        }
コード例 #15
0
        /// <summary>Audit entity deleted.</summary>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityDeleted(AuditEntry entry, EntityEntry objectStateEntry)
        {
            foreach (var propertyEntry in objectStateEntry.Metadata.GetProperties())
            {
                var property = objectStateEntry.Property(propertyEntry.Name);

                if (entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, propertyEntry.Name, property.OriginalValue, null));
                }
            }
        }
コード例 #16
0
        public static void AuditEntityModified(Audit audit, EntityEntry objectStateEntry, AuditEntryState state)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = state
            };

#if EF5 || EF6
            AuditEntityModified(audit, entry, objectStateEntry, objectStateEntry.OriginalValues, objectStateEntry.CurrentValues);
#elif EFCORE
            AuditEntityModified(audit, entry, objectStateEntry);
#endif
            audit.Entries.Add(entry);
        }
コード例 #17
0
        public AuditEntryPropertyArgs(AuditEntry parent, EntityEntry entityEntry, string relationName, string propertyName, object oldValue, object newValue)
#endif
        {
            AuditEntry   = parent;
            NewValue     = newValue;
            OldValue     = oldValue;
            PropertyName = propertyName;
            RelationName = relationName;

#if EF5 || EF6
            ObjectStateEntry = objectStateEntry;
#elif EFCORE
            EntityEntry = entityEntry;
#endif
        }
コード例 #18
0
        /// <summary>Audit entity modified.</summary>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityModified(Audit audit, AuditEntry entry, EntityEntry objectStateEntry)
        {
            foreach (var propertyEntry in objectStateEntry.Metadata.GetProperties())
            {
                var property = objectStateEntry.Property(propertyEntry.Name);

                if (entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
                {
                    if (!audit.Configuration.IgnorePropertyUnchanged || property.Metadata.IsKey() || property.IsModified)
                    {
                        entry.Properties.Add(new AuditEntryProperty(entry, propertyEntry.Name, property.OriginalValue, property.CurrentValue));
                    }
                }
            }
        }
コード例 #19
0
        public static void AuditEntityDeleted(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.EntityDeleted
            };


#if EF5 || EF6
            AuditEntityDeleted(entry, objectStateEntry.OriginalValues);
#elif EFCORE
            AuditEntityDeleted(entry, objectStateEntry);
#endif
            audit.Entries.Add(entry);
        }
コード例 #20
0
        /// <summary>Audit entity added.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityAdded(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.EntityAdded
            };

            // CHECK if the key should be resolved in POST Action
            if (objectStateEntry.EntityKey.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }

            AuditEntityAdded(entry, objectStateEntry.CurrentValues);
            audit.Entries.Add(entry);
        }
コード例 #21
0
        public static void AuditEntityDeleted(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.EntityDeleted
            };


#if EF5 || EF6
            AuditEntityDeleted(entry, objectStateEntry.OriginalValues);
#elif EFCORE
            AuditEntityDeleted(entry, objectStateEntry);
#endif
            audit.Entries.Add(entry);
        }
コード例 #22
0
        /// <summary>Audit entity added.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityAdded(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.EntityAdded
            };

            // CHECK if the key should be resolved in POST Action
            if (objectStateEntry.EntityKey.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }

            AuditEntityAdded(entry, objectStateEntry.CurrentValues);
            audit.Entries.Add(entry);
        }
コード例 #23
0
        public static Entity.AuditEntry Import(Z.EntityFramework.Plus.AuditEntry entry)
        {
            var customAuditEntry = new Entity.AuditEntry
            {
                EntitySetName  = entry.EntitySetName,
                EntityTypeName = entry.EntityTypeName,
                State          = (int)entry.State,
                StateName      = entry.StateName,
                CreatedBy      = entry.CreatedBy,
                CreatedDate    = entry.CreatedDate
            };

            customAuditEntry.AuditEntryProperties = entry.Properties.Select(x => Import(x)).ToList();

            return(customAuditEntry);
        }
コード例 #24
0
        /// <summary>Audit entity added.</summary>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityAdded(AuditEntry entry, EntityEntry objectStateEntry)
        {
            foreach (var propertyEntry in objectStateEntry.Metadata.GetProperties())
            {
                var property = objectStateEntry.Property(propertyEntry.Name);

                if (property.Metadata.IsKey() || entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, propertyEntry.Name))
                {
                    var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null?
                                             entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, propertyEntry.Name, null, property.CurrentValue)) :
                                                 new AuditEntryProperty();

                    auditEntryProperty.Build(entry, propertyEntry.Name, null, property.CurrentValue);
                    entry.Properties.Add(auditEntryProperty);
                }
            }
        }
コード例 #25
0
        public static void AuditEntityAdded(AuditEntry entry, DbUpdatableDataRecord record, string prefix = "")
        {
            for (var i = 0; i < record.FieldCount; i++)
            {
                var name  = record.GetName(i);
                var value = record.GetValue(i);

                var valueRecord = value as DbUpdatableDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityAdded(entry, valueRecord, string.Concat(prefix, name, "."));
                }
                else
                {
                    entry.Properties.Add(new AuditEntryProperty(string.Concat(prefix, name), null, value));
                }
            }
        }
コード例 #26
0
        /// <summary>Audit entity deleted.</summary>
        /// <param name="entry">The entry.</param>
        /// <param name="record">The record.</param>
        /// <param name="prefix">The prefix.</param>
        public static void AuditEntityDeleted(AuditEntry entry, DbDataRecord record, string prefix = "")
        {
            for (var i = 0; i < record.FieldCount; i++)
            {
                var name  = record.GetName(i);
                var value = record.GetValue(i);

                var valueRecord = value as DbDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityDeleted(entry, valueRecord, string.Concat(prefix, name, "."));
                }
                else if (entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, name))
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, string.Concat(prefix, name), value, null));
                }
            }
        }
コード例 #27
0
        /// <summary>Audit entity modified.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityModified(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.EntityModified
            };

            if (audit.Configuration.IsSoftAdded != null && audit.Configuration.IsSoftAdded(objectStateEntry.Entity))
            {
                entry.State = AuditEntryState.EntitySoftAdded;
            }
            else if (audit.Configuration.IsSoftDeleted != null && audit.Configuration.IsSoftDeleted(objectStateEntry.Entity))
            {
                entry.State = AuditEntryState.EntitySoftDeleted;
            }

            AuditEntityModified(audit, entry, objectStateEntry.OriginalValues, objectStateEntry.CurrentValues);
            audit.Entries.Add(entry);
        }
コード例 #28
0
        /// <summary>Audit entity modified.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditEntityModified(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.EntityModified
            };

            if (audit.Configuration.IsSoftAdded != null && audit.Configuration.IsSoftAdded(objectStateEntry.Entity))
            {
                entry.State = AuditEntryState.EntitySoftAdded;
            }
            else if (audit.Configuration.IsSoftDeleted != null && audit.Configuration.IsSoftDeleted(objectStateEntry.Entity))
            {
                entry.State = AuditEntryState.EntitySoftDeleted;
            }

            AuditEntityModified(audit, entry, objectStateEntry.OriginalValues, objectStateEntry.CurrentValues);
            audit.Entries.Add(entry);
        }
コード例 #29
0
        public static void AuditEntityDeleted(AuditEntry entry, DbDataRecord record, string prefix = "")
        {
            for (var i = 0; i < record.FieldCount; i++)
            {
                var name = record.GetName(i);
                var value = record.GetValue(i);

                var valueRecord = value as DbDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityDeleted(entry, valueRecord, string.Concat(prefix, name, "."));
                }
                else
                {
                    entry.Properties.Add(new AuditEntryProperty(string.Concat(prefix, name), value, null));
                }
            }
        }
コード例 #30
0
        /// <summary>Audit entity added.</summary>
        /// <param name="auditEntry">The audit entry.</param>
        /// <param name="record">The record.</param>
        /// <param name="prefix">The prefix.</param>
        public static void AuditEntityAdded(AuditEntry auditEntry, DbUpdatableDataRecord record, string prefix = "")
        {
            for (var i = 0; i < record.FieldCount; i++)
            {
                var name = record.GetName(i);
                var value = record.GetValue(i);

                var valueRecord = value as DbUpdatableDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityAdded(auditEntry, valueRecord, string.Concat(prefix, name, "."));
                }
                else if (auditEntry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(auditEntry.Entry, name))
                {
                    auditEntry.Properties.Add(new AuditEntryProperty(auditEntry, string.Concat(prefix, name), null, value));
                }
            }
        }
コード例 #31
0
        public static void AuditRelationDeleted(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.RelationshipDeleted
            };

            var values = objectStateEntry.OriginalValues;
            for (var i = 0; i < values.FieldCount; i++)
            {
                var relationName = values.GetName(i);
                var value = (EntityKey) values.GetValue(i);
                foreach (var keyValue in value.EntityKeyValues)
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, relationName, keyValue.Key, keyValue.Value, null));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #32
0
        public static void AuditRelationDeleted(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.RelationshipDeleted
            };

            var values = objectStateEntry.OriginalValues;

            for (var i = 0; i < values.FieldCount; i++)
            {
                var relationName = values.GetName(i);
                var value        = (EntityKey)values.GetValue(i);
                foreach (var keyValue in value.EntityKeyValues)
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, relationName, keyValue.Key, keyValue.Value, null));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #33
0
        /// <summary>Audit relationship deleted.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditRelationDeleted(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.RelationshipDeleted
            };

            var values = objectStateEntry.OriginalValues;
            for (var i = 0; i < values.FieldCount; i++)
            {
                var relationName = values.GetName(i);
                var value = (EntityKey) values.GetValue(i);
                foreach (var keyValue in value.EntityKeyValues)
                {
                    // todo: better add a new property association?
                    var keyName = string.Concat(relationName, ";", keyValue.Key);
                    entry.Properties.Add(new AuditEntryProperty(keyName, keyValue.Value, null));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #34
0
        public static void AuditEntityModified(Audit audit, AuditEntry entry, DbDataRecord orginalRecord, DbUpdatableDataRecord currentRecord, string prefix = "")
        {
            for (var i = 0; i < orginalRecord.FieldCount; i++)
            {
                var name = orginalRecord.GetName(i);
                var originalValue = orginalRecord.GetValue(i);
                var currentValue = currentRecord.GetValue(i);

                var valueRecord = originalValue as DbDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityModified(audit, entry, valueRecord, currentValue as DbUpdatableDataRecord, string.Concat(prefix, name, "."));
                }
                else
                {
                    if (audit.Configuration.IncludePropertyUnchanged || !Equals(currentValue, originalValue))
                    {
                        entry.Properties.Add(new AuditEntryProperty(string.Concat(prefix, name), originalValue, currentValue));
                    }
                }
            }
        }
コード例 #35
0
        public static void AuditEntityModified(Audit audit, AuditEntry entry, DbDataRecord orginalRecord, DbUpdatableDataRecord currentRecord, string prefix = "")
        {
            for (var i = 0; i < orginalRecord.FieldCount; i++)
            {
                var name          = orginalRecord.GetName(i);
                var originalValue = orginalRecord.GetValue(i);
                var currentValue  = currentRecord.GetValue(i);

                var valueRecord = originalValue as DbDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityModified(audit, entry, valueRecord, currentValue as DbUpdatableDataRecord, string.Concat(prefix, name, "."));
                }
                else
                {
                    if (audit.Configuration.IncludePropertyUnchanged || !Equals(currentValue, originalValue))
                    {
                        entry.Properties.Add(new AuditEntryProperty(string.Concat(prefix, name), originalValue, currentValue));
                    }
                }
            }
        }
コード例 #36
0
        /// <summary>Audit relationship deleted.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditRelationDeleted(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.RelationshipDeleted
            };

            var values = objectStateEntry.OriginalValues;

            for (var i = 0; i < values.FieldCount; i++)
            {
                var relationName = values.GetName(i);
                var value        = (EntityKey)values.GetValue(i);
                foreach (var keyValue in value.EntityKeyValues)
                {
                    // todo: better add a new property association?
                    var keyName = string.Concat(relationName, ";", keyValue.Key);
                    entry.Properties.Add(new AuditEntryProperty(keyName, keyValue.Value, null));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #37
0
        /// <summary>Audit relationship added.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditRelationAdded(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.RelationshipAdded
            };

            var values = objectStateEntry.CurrentValues;


            var value_0 = (EntityKey)values.GetValue(0);
            var value_1 = (EntityKey)values.GetValue(1);

            if (value_0.IsTemporary || value_1.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }
            else
            {
                var relationName_0 = values.GetName(0);
                var relationName_1 = values.GetName(1);

                foreach (var keyValue in value_0.EntityKeyValues)
                {
                    var keyName = string.Concat(relationName_0, ";", keyValue.Key);
                    entry.Properties.Add(new AuditEntryProperty(keyName, null, keyValue.Value));
                }

                foreach (var keyValue in value_1.EntityKeyValues)
                {
                    var keyName = string.Concat(relationName_1, ";", keyValue.Key);
                    entry.Properties.Add(new AuditEntryProperty(keyName, null, keyValue.Value));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #38
0
        /// <summary>Audit relationship added.</summary>
        /// <param name="audit">The audit to use to add changes made to the context.</param>
        /// <param name="objectStateEntry">The object state entry.</param>
        public static void AuditRelationAdded(Audit audit, ObjectStateEntry objectStateEntry)
        {
            var entry = new AuditEntry(objectStateEntry)
            {
                State = AuditEntryState.RelationshipAdded
            };

            var values = objectStateEntry.CurrentValues;


            var value_0 = (EntityKey) values.GetValue(0);
            var value_1 = (EntityKey) values.GetValue(1);

            if (value_0.IsTemporary || value_1.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }
            else
            {
                var relationName_0 = values.GetName(0);
                var relationName_1 = values.GetName(1);

                foreach (var keyValue in value_0.EntityKeyValues)
                {
                    var keyName = string.Concat(relationName_0, ";", keyValue.Key);
                    entry.Properties.Add(new AuditEntryProperty(keyName, null, keyValue.Value));
                }

                foreach (var keyValue in value_1.EntityKeyValues)
                {
                    var keyName = string.Concat(relationName_1, ";", keyValue.Key);
                    entry.Properties.Add(new AuditEntryProperty(keyName, null, keyValue.Value));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #39
0
        /// <summary>Audit entity deleted.</summary>
        /// <param name="entry">The entry.</param>
        /// <param name="record">The record.</param>
        /// <param name="prefix">The prefix.</param>
        public static void AuditEntityDeleted(AuditEntry entry, ObjectStateEntry objectStateEntry, DbDataRecord record, string prefix = "")
        {
            for (var i = 0; i < record.FieldCount; i++)
            {
                var name  = record.GetName(i);
                var value = record.GetValue(i);

                var valueRecord = value as DbDataRecord;
                if (valueRecord != null)
                {
                    // Complex Type
                    AuditEntityDeleted(entry, objectStateEntry, valueRecord, string.Concat(prefix, name, "."));
                }
                else if (objectStateEntry.EntityKey.EntityKeyValues.Any(x => x.Key == name) || entry.Parent.CurrentOrDefaultConfiguration.IsAuditedProperty(entry.Entry, name))
                {
                    var auditEntryProperty = entry.Parent.Configuration.AuditEntryPropertyFactory != null?
                                             entry.Parent.Configuration.AuditEntryPropertyFactory(new AuditEntryPropertyArgs(entry, objectStateEntry, string.Concat(prefix, name), value, null)) :
                                                 new AuditEntryProperty();

                    auditEntryProperty.Build(entry, string.Concat(prefix, name), value, null);
                    entry.Properties.Add(auditEntryProperty);
                }
            }
        }
コード例 #40
0
        public static void AuditRelationAdded(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.RelationshipAdded
            };

            var values = objectStateEntry.CurrentValues;


            var leftKeys = (EntityKey) values.GetValue(0);
            var rightKeys = (EntityKey) values.GetValue(1);

            if (leftKeys.IsTemporary || rightKeys.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }
            else
            {
                var leftRelationName = values.GetName(0);
                var rightRelationName = values.GetName(1);

                foreach (var keyValue in leftKeys.EntityKeyValues)
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, leftRelationName, keyValue.Key, null, keyValue.Value));
                }

                foreach (var keyValue in rightKeys.EntityKeyValues)
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, rightRelationName, keyValue.Key, null, keyValue.Value));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #41
0
        public static void AuditRelationAdded(Audit audit, EntityEntry objectStateEntry)
#endif
        {
            var entry = new AuditEntry(audit, objectStateEntry)
            {
                State = AuditEntryState.RelationshipAdded
            };

            var values = objectStateEntry.CurrentValues;


            var leftKeys  = (EntityKey)values.GetValue(0);
            var rightKeys = (EntityKey)values.GetValue(1);

            if (leftKeys.IsTemporary || rightKeys.IsTemporary)
            {
                entry.DelayedKey = objectStateEntry;
            }
            else
            {
                var leftRelationName  = values.GetName(0);
                var rightRelationName = values.GetName(1);

                foreach (var keyValue in leftKeys.EntityKeyValues)
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, leftRelationName, keyValue.Key, null, keyValue.Value));
                }

                foreach (var keyValue in rightKeys.EntityKeyValues)
                {
                    entry.Properties.Add(new AuditEntryProperty(entry, rightRelationName, keyValue.Key, null, keyValue.Value));
                }
            }

            audit.Entries.Add(entry);
        }
コード例 #42
0
 public void Build(AuditEntry parent, string propertyName, object oldValue, DbUpdatableDataRecord dbUpdatableDataRecord, int dbUpdatableDataRecordPosition)
 {
     Build(parent, null, propertyName, oldValue, dbUpdatableDataRecord, dbUpdatableDataRecordPosition);
 }
コード例 #43
0
 public void Build(AuditEntry parent, string propertyName, object oldValue, PropertyEntry propertyEntry)
 {
     Build(parent, null, propertyName, oldValue, propertyEntry);
 }
コード例 #44
0
 /// <summary>Constructor.</summary>
 /// <param name="parent">The audit entry parent.</param>
 /// <param name="propertyName">Name of the property audited.</param>
 /// <param name="oldValue">The old value audited.</param>
 /// <param name="newValue">The new value audited.</param>
 public void Build(AuditEntry parent, string propertyName, object oldValue, object newValue)
 {
     Build(parent, null, propertyName, oldValue, newValue);
 }