private static void AddChangeToPropertyChangesStackTree <TEntity, TPrimaryKey>( EntityPropertyChange entityPropertyChange, Dictionary <string, string> propertyChangesStackTreeDictionary, TEntity entity) where TEntity : class, IEntity <TPrimaryKey> { if (propertyChangesStackTreeDictionary.ContainsKey(entityPropertyChange.PropertyName)) { propertyChangesStackTreeDictionary[entityPropertyChange.PropertyName] += " -> " + entityPropertyChange.OriginalValue; } else { var propertyCurrentValue = "PropertyNotExist"; var propertyInfo = typeof(TEntity).GetProperty(entityPropertyChange.PropertyName); if (propertyInfo != null) { var val = propertyInfo.GetValue(entity); propertyCurrentValue = val == null ? "null" : val.ToJsonString(); } propertyChangesStackTreeDictionary.Add( entityPropertyChange.PropertyName, propertyCurrentValue + " -> " + entityPropertyChange.OriginalValue ); } }
private static void RevokeChange <TEntity, TPrimaryKey>( Dictionary <string, string> snapshotPropertiesDictionary, EntityPropertyChange entityPropertyChange, TEntity entity) where TEntity : class, IEntity <TPrimaryKey> { snapshotPropertiesDictionary[entityPropertyChange.PropertyName] = entityPropertyChange.OriginalValue; }
private EntityPropertyChange CreateEntityPropertyChange(object oldValue, object newValue, IProperty property) { var entityPropertyChange = new EntityPropertyChange() { PropertyName = property.Name.TruncateWithPostfix(EntityPropertyChange.MaxPropertyNameLength), PropertyTypeFullName = property.ClrType.FullName.TruncateWithPostfix( EntityPropertyChange.MaxPropertyTypeFullNameLength ), TenantId = AbpSession.TenantId }; entityPropertyChange.SetNewValue(newValue?.ToJsonString()); entityPropertyChange.SetOriginalValue(oldValue?.ToJsonString()); return(entityPropertyChange); }