Example #1
0
 protected void SendToSubscribers(List <Subscription <T> > allSubscriptions, EntityChangeType type, T entity)
 {
     foreach (Subscription <T> subscription in allSubscriptions)
     {
         subscription.HandleChange(new EntityChange <T>(type, entity.Clone()));
     }
 }
Example #2
0
        private async Task SendToSubscribersAsync(EntityChangeType type, T entity)
        {
            var allSubscriptions = new List <Subscription <T> >();

            using (await Lock.LockAsync())
                GetSubscriptions(entity, allSubscriptions);
            SendToSubscribers(allSubscriptions, type, entity);
        }
 public LocalMessageHelper(Entity entity, UserConnection userConnection, EntityChangeType changeType)
 {
     _entity              = entity;
     _entity.UseLazyLoad  = true;
     _userConnection      = userConnection;
     _entitySchemaColumns = _entity.Schema.Columns;
     _changeType          = changeType;
     SetCurrentUser();
 }
 public IList <EntityDifference> GetDifferences(EntityChangeType changeType)
 {
     if (changeType == EntityChangeType.Remove)
     {
         return(_entityChange?.DeleteEntry);
     }
     else
     {
         return(_entityChange?.ChangeDifference.Values.ToList().Where(f => f.Type == changeType).ToList());
     }
 }
        protected virtual void PublishMessage(EntityChangeType changeType, T document)
        {
            var orgEntity = document as IOwnedByOrganization;
            var message   = new EntityChanged {
                ChangeType     = changeType,
                Id             = document.Id,
                OrganizationId = orgEntity != null ? orgEntity.OrganizationId : null,
                Type           = _entityType
            };

            PublishMessage(message);
        }
 private void RecordChange(object domainObject, EntityChangeType changeType, PropertyDiff[] propertyDiffs)
 {
     if (IsChangeSetPublishable((DomainObject)domainObject))
     {
         // update all change trackers
         var entity = (Entity)domainObject;
         foreach (var changeTracker in _changeTrackers)
         {
             changeTracker.RecordChange(entity, changeType, propertyDiffs);
         }
     }
 }
    public EntityRecordInfo GetReord(int frame, int ID, EntityChangeType changeType)
    {
        for (int i = 0; i < m_list.Count; i++)
        {
            if (m_list[i].frame == frame &&
                m_list[i].id == ID &&
                m_list[i].changeType == changeType)
            {
                return(m_list[i]);
            }
        }

        return(null);
    }
 private void Actualize(object source, EntityChangeType entityChangeType)
 {
     if (GlobalAppSettings.FeatureUseSysSettingsEngine)
     {
         var         sourceEntity   = (Entity)source;
         var         userConnection = sourceEntity.UserConnection;
         TCoreEntity coreEntity     = CreateCoreEntity(userConnection);
         sourceEntity.GetColumnValueNames()
         .Where(columnName => sourceEntity.IsColumnValueLoaded(columnName))
         .Join(coreEntity.GetColumnValueNames(), x => x, y => y, (x, y) => x)
         .ForEach(columnName => coreEntity.SetColumnValue(columnName, sourceEntity.GetColumnValue(columnName)));
         ActualizeCoreEntity(userConnection, coreEntity, entityChangeType);
     }
 }
Example #9
0
        protected override void OnEntityChanged(EntityChangeType type, Build oldBuild, Build newBulid,
                                                IList <Action <EntityChange <Build> > > changeListeners)
        {
            switch (type)
            {
            case EntityChangeType.Insert:
            case EntityChangeType.Update:
                _engineIdIndex.OnEntityUpdated(oldBuild, newBulid, changeListeners);
                break;

            case EntityChangeType.Delete:
                _engineIdIndex.OnEntityDeleted(oldBuild, changeListeners);
                break;
            }
        }
Example #10
0
        protected override void OnEntityChanged(EntityChangeType type, Build oldBuild, Build newBulid,
                                                IList <Subscription <Build> > allSubscriptions)
        {
            switch (type)
            {
            case EntityChangeType.Insert:
            case EntityChangeType.Update:
                _engineIdIndex.OnEntityUpdated(oldBuild, newBulid, allSubscriptions);
                break;

            case EntityChangeType.Delete:
                _engineIdIndex.OnEntityDeleted(oldBuild, allSubscriptions);
                break;
            }
        }
        /// <inheritdoc />
        public override void CancelExecuting(params object[] parameters)
        {
            base.CancelExecuting(parameters);
            IProcessEngine processEngine = UserConnection.ProcessEngine;

            processEngine.RemoveActivityProcessListener(CurrentActivityId, UId, ActivityConsts.CanceledStatusUId);
            if (!GetIsActivityEntitySchema())
            {
                var editMode = (RecordEditMode)Enum.ToObject(typeof(RecordEditMode), EditMode);
                EntityChangeType entityChangeType = editMode == RecordEditMode.New
                                        ? EntityChangeType.Inserted
                                        : EntityChangeType.Updated;
                processEngine.RemoveProcessListener(RecordId, ObjectSchemaId, UId, entityChangeType);
            }
        }
Example #12
0
 private void UpdateListners(Entity entity, BaseDataBlob db, EntityChangeType change)
 {
     if (EntityListners.Count > 0)
     {
         var changeData = new EntityChangeData()
         {
             Entity     = entity,
             Datablob   = db,
             ChangeType = change
         };
         foreach (var item in EntityListners)
         {
             item.AddChange(changeData);
         }
     }
 }
        public object ExecuteWithChanges(
            DbCommand cmd,
            string entityName,
            EntityChangeType changeType,
            Func <string> changeDescriber = null)
        {
            _log.DebugFormat("Executing command: \r\n {0}", cmd.CommandText);
            object result;

            using (var conn = DB.OpenConnection())
                using (var tx = conn.BeginTransaction())
                {
                    try
                    {
                        cmd.Connection  = conn;
                        cmd.Transaction = tx;
                        result          = cmd.ExecuteScalar();

                        if (result != null)
                        {
                            if (Admin.IsChangesEnabled)
                            {
                                var changeCmd = CreateChangeCommand(entityName, changeType, result.ToString(), changeDescriber);
                                _log.DebugFormat("Executing change command: \r\n {0}", changeCmd.CommandText);
                                changeCmd.Connection  = conn;
                                changeCmd.Transaction = tx;
                                changeCmd.ExecuteNonQuery();
                            }

                            _log.Debug("Commit transaction");
                            tx.Commit();
                        }
                        else
                        {
                            Rollback(tx);
                        }
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex);
                        Rollback(tx);
                        throw;
                    }
                }

            return(result);
        }
Example #14
0
        private static PropertyData WriteProperty(object oldValue, object newValue, EntityChangeType changeType)
        {
            var data = new PropertyData();

            // for Updates and Deletes, write the old value
            if (changeType != EntityChangeType.Create)
            {
                data.OldValue = WritePropertyValue(oldValue);
            }

            // for Creates and Updates, write the new value
            if (changeType != EntityChangeType.Delete)
            {
                data.NewValue = WritePropertyValue(newValue);
            }
            return(data);
        }
Example #15
0
        public object ExecuteWithChanges(
            DbCommand cmd,
            EntityRecord entityRecord,
            EntityChangeType changeType,
            Func<string> changeDescriber = null)
        {
            _log.DebugFormat("Executing command: \r\n {0}", cmd.CommandText);
            object result;
            using (var conn = DB.OpenConnection(_admin.ConnectionStringName))
            using (var tx = conn.BeginTransaction())
            {
                try
                {
                    cmd.Connection = conn;
                    cmd.Transaction = tx;
                    result = cmd.ExecuteScalar();

                    if (result != null)
                    {
                        if (_admin.IsChangesEnabled)
                        {
                            var changeCmd = CreateChangeCommand(entityRecord, changeType, result.ToString(), changeDescriber);
                            _log.DebugFormat("Executing change command: \r\n {0}", changeCmd.CommandText);
                            changeCmd.Connection = conn;
                            changeCmd.Transaction = tx;
                            changeCmd.ExecuteNonQuery();
                        }

                        _log.Debug("Commit transaction");
                        tx.Commit();
                    }
                    else
                    {
                        Rollback(tx);
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex);
                    Rollback(tx);
                    throw;
                }
            }

            return result;
        }
        protected virtual DateTime GetChangeTime(EntityChangeType entityChangeType, object entity)
        {
            switch (entityChangeType)
            {
            case EntityChangeType.Created:
                return((entity as IHasCreationTime)?.CreationTime ?? Clock.Now);

            case EntityChangeType.Deleted:
                return((entity as IHasDeletionTime)?.DeletionTime ?? Clock.Now);

            case EntityChangeType.Updated:
                return((entity as IHasModificationTime)?.LastModificationTime ?? Clock.Now);

            default:
                Logger.ErrorFormat("Unexpected {0} - {1}", nameof(entityChangeType), entityChangeType);
                return(Clock.Now);
            }
        }
        /// <inheritdoc />
        public override bool CompleteExecuting(params object[] parameters)
        {
            bool isActivityEntitySchema = GetIsActivityEntitySchema();
            Guid activityStatusId       = isActivityEntitySchema
                                ? Guid.Empty
                                : ProcessUserTaskUtilities.GetActivityStatus(UserConnection, CurrentActivityId);
            IProcessEngine processEngine = UserConnection.ProcessEngine;

            if (GetIsMatchedConditions())
            {
                if (!isActivityEntitySchema && activityStatusId != ActivityConsts.CanceledStatusUId)
                {
                    activityStatusId = ActivityConsts.CompletedStatusUId;
                }
                processEngine.RemoveActivityProcessListener(CurrentActivityId, UId, activityStatusId);
                if (!GetIsActivityEntitySchema())
                {
                    var editMode = (RecordEditMode)Enum.ToObject(typeof(RecordEditMode), EditMode);
                    EntityChangeType entityChangeType = editMode == RecordEditMode.New
                                                ? EntityChangeType.Inserted
                                                : EntityChangeType.Updated;
                    processEngine.RemoveProcessListener(RecordId, ObjectSchemaId, UId, entityChangeType);
                }
                if (GenerateDecisionsFromColumn)
                {
                    ResultParameter = GetResultParameter();
                }
                return(base.CompleteExecuting(parameters));
            }
            if ((RecordEditMode)Enum.ToObject(typeof(RecordEditMode), EditMode) == RecordEditMode.New)
            {
                string serializedFilters = IsMatchConditions && DataSourceFilters.IsNotNullOrEmpty()
                                        ? ConvertToProcessDataSourceFilters(ObjectSchemaId, DataSourceFilters)
                                        : null;
                processEngine.AddProcessListener(RecordId, ObjectSchemaId, UId, serializedFilters);
                EditMode = (int)RecordEditMode.Existing;
            }
            if (activityStatusId == ActivityConsts.NewStatusUId)
            {
                ProcessUserTaskUtilities.SetActivityStatus(UserConnection, CurrentActivityId,
                                                           ActivityConsts.InProgressUId);
            }
            return(false);
        }
Example #18
0
        private Guid AddLog(EntityEntry entry, EntityChangeType entityChangeType)
        {
            var  entityName = entry.Entity.GetType().Name;
            Guid recordId   = Guid.Parse(entry.Property("Id").CurrentValue.ToString());

            Log log = new Log
            {
                ChangeDate = DateTime.Now,
                ChangeType = entityChangeType,
                EntityName = entityName,
                RecordId   = recordId,
                UserId     = null,
                VisitId    = this.visitId
            };

            this.resumeDbContext.Logs.Add(log);

            return(log.Id);
        }
Example #19
0
        /// <summary>
        /// Save record with information about entity change
        /// </summary>
        /// <param name="entityName">Entity name</param>
        /// <param name="entityKey">Entity key of changed record</param>
        /// <param name="changeType">Change type</param>
        /// <param name="description">Description for update change type</param>
        private void AddEntityChange(string entityName, string entityKey, EntityChangeType changeType, string description = null)
        {
            if (AdminInitialise.ChangeEntity == null)
            {
                return;
            }

            var table = new DynamicModel(AdminInitialise.ConnectionString, tableName: AdminInitialise.ChangeEntity.TableName, primaryKeyField: "EntityChangeId");

            dynamic changeRecord = new ExpandoObject();

            changeRecord.EntityName  = entityName;
            changeRecord.EntityKey   = entityKey;
            changeRecord.ChangeType  = changeType;
            changeRecord.Description = description;
            changeRecord.ChangedOn   = DateTime.UtcNow;
            changeRecord.ChangedBy   = HttpContext.Current.User.Identity.Name;

            table.Insert(changeRecord);
        }
Example #20
0
        protected override async Task PublishMessageAsync(EntityChangeType changeType, User user)
        {
            if (user.OrganizationIds.Any())
            {
                foreach (var organizationId in user.OrganizationIds)
                {
                    var message = new EntityChanged {
                        ChangeType     = changeType,
                        Id             = user.Id,
                        OrganizationId = organizationId,
                        Type           = _entityType
                    };

                    await _messagePublisher.PublishAsync(message);
                }
            }
            else
            {
                await base.PublishMessageAsync(changeType, user);
            }
        }
Example #21
0
        protected override void PublishMessage(EntityChangeType changeType, User user)
        {
            if (user.OrganizationIds.Any())
            {
                foreach (var organizationId in user.OrganizationIds)
                {
                    var message = new EntityChanged {
                        ChangeType     = changeType,
                        Id             = user.Id,
                        OrganizationId = organizationId,
                        Type           = _entityType
                    };

                    _messagePublisher.Publish(message);
                }
            }
            else
            {
                base.PublishMessage(changeType, user);
            }
        }
Example #22
0
        private void UpdateListners(Entity entity, BaseDataBlob db, EntityChangeType change)
        {
            //listners to this work on thier own threads and are not affected by this one.
            if (EntityListners.Count > 0)
            {
                var changeData = new EntityChangeData()
                {
                    Entity     = entity,
                    Datablob   = db,
                    ChangeType = change
                };
                foreach (var item in EntityListners)
                {
                    item.AddChange(changeData);
                }
            }


            //this one works on the active (ie this) thread
            entity.InvokeChangeEvent(change, db);
        }
Example #23
0
        private DbCommand CreateChangeCommand(
            EntityRecord entityRecord,
            EntityChangeType changeType,
            string keyValue,
            Func<string> changeDescriber = null)
        {
            if(changeType == EntityChangeType.Insert)
            {
                entityRecord.SetKeyValue(keyValue);
            }

            var cmd = DB.CreateCommand(_admin.ConnectionStringName);

            var changeEntity = _admin.ChangeEntity;
            var table = changeEntity.Table;
            var entityNameColumn = changeEntity["EntityName"].Column;
            var entityKeyColumn = changeEntity["EntityKey"].Column;
            var changeTypeColumn = changeEntity["ChangeType"].Column;
            var recordDisplayColumn = changeEntity["RecordDisplayName"].Column;
            var descriptionColumn = changeEntity["Description"].Column;
            var changedOnColumn = changeEntity["ChangedOn"].Column;
            var changedByColumn = changeEntity["ChangedBy"].Column;

            var sql =
$@"INSERT INTO {table} ({entityNameColumn}, {entityKeyColumn}, {changeTypeColumn}, {recordDisplayColumn}, {descriptionColumn}, {changedOnColumn}, {changedByColumn})
VALUES (@0,@1,@2,@3,@4,@5,@6);";

            cmd.AddParam(entityRecord.Entity.Name);
            cmd.AddParam(keyValue);
            cmd.AddParam(changeType);
            cmd.AddParam(entityRecord.ToString());
            cmd.AddParam(changeDescriber == null ? null : changeDescriber());
            cmd.AddParam(DateTime.UtcNow);
            cmd.AddParam(_user.CurrentUserName());

            cmd.CommandText = sql;

            return cmd;
        }
Example #24
0
		/// <summary>
		/// Records that the specified change occured to the specified entity.
		/// </summary>
		/// <param name="entity"></param>
		/// <param name="changeType"></param>
		/// <param name="propertyDiffs"></param>
		internal void RecordChange(Entity entity, EntityChangeType changeType, PropertyDiff[] propertyDiffs)
		{
			var thisChange = new ChangeRecord(entity, changeType, propertyDiffs);

			// check if this entity was already recorded in the list
			// note that reference equality is used because we do not know how the Equals method of the entity may be implemented
			// for example, it may define equality based on a property whose value has changed, which would break this logic
			var prevRecordIndex = _changeRecords.FindIndex(r => ReferenceEquals(r.Entity, entity));
			if (prevRecordIndex > -1)
			{
				// this entity was already marked as changed
				var previousChange = _changeRecords[prevRecordIndex];

				// compound the previous change record with this one
				_changeRecords[prevRecordIndex] = thisChange.Compound(previousChange);
			}
			else
			{
				// record this change in the change set
				_changeRecords.Add(thisChange);
			}
		}
Example #25
0
        private DbCommand CreateChangeCommand(
            EntityRecord entityRecord,
            EntityChangeType changeType,
            string keyValue,
            Func <string> changeDescriber = null)
        {
            if (changeType == EntityChangeType.Insert)
            {
                entityRecord.SetKeyValue(keyValue);
            }

            var cmd = DB.CreateCommand(_admin.ConnectionStringName);

            var changeEntity        = _admin.ChangeEntity;
            var table               = changeEntity.Table;
            var entityNameColumn    = changeEntity["EntityName"].Column;
            var entityKeyColumn     = changeEntity["EntityKey"].Column;
            var changeTypeColumn    = changeEntity["ChangeType"].Column;
            var recordDisplayColumn = changeEntity["RecordDisplayName"].Column;
            var descriptionColumn   = changeEntity["Description"].Column;
            var changedOnColumn     = changeEntity["ChangedOn"].Column;
            var changedByColumn     = changeEntity["ChangedBy"].Column;

            var sql =
                $@"INSERT INTO {table} ({entityNameColumn}, {entityKeyColumn}, {changeTypeColumn}, {recordDisplayColumn}, {descriptionColumn}, {changedOnColumn}, {changedByColumn})
VALUES (@0,@1,@2,@3,@4,@5,@6);";

            cmd.AddParam(entityRecord.Entity.Name);
            cmd.AddParam(keyValue);
            cmd.AddParam(changeType);
            cmd.AddParam(entityRecord.ToString());
            cmd.AddParam(changeDescriber == null ? null : changeDescriber());
            cmd.AddParam(DateTime.UtcNow);
            cmd.AddParam(_user.CurrentUserName());

            cmd.CommandText = sql;

            return(cmd);
        }
        private DbCommand CreateChangeCommand(
            string entityName,
            EntityChangeType changeType,
            string keyValue,
            Func<string> changeDescriber = null)
        {
            var cmd = DB.CreateCommand();

            var sql =
@"INSERT INTO {0} ([EntityName], [EntityKey], [ChangeType], [Description], [ChangedOn], [ChangedBy])
VALUES (@0,@1,@2,@3,@4,@5);".Fill(Admin.ChangeEntity.TableName);

            cmd.AddParam(entityName);
            cmd.AddParam(keyValue);
            cmd.AddParam(changeType);
            cmd.AddParam(changeDescriber == null ? null : changeDescriber());
            cmd.AddParam(DateTime.UtcNow);
            cmd.AddParam(_user.Current());

            cmd.CommandText = sql;

            return cmd;
        }
        private DbCommand CreateChangeCommand(
            string entityName,
            EntityChangeType changeType,
            string keyValue,
            Func <string> changeDescriber = null)
        {
            var cmd = DB.CreateCommand();

            var sql =
                @"INSERT INTO {0} ([EntityName], [EntityKey], [ChangeType], [Description], [ChangedOn], [ChangedBy])
VALUES (@0,@1,@2,@3,@4,@5);".Fill(Admin.ChangeEntity.TableName);

            cmd.AddParam(entityName);
            cmd.AddParam(keyValue);
            cmd.AddParam(changeType);
            cmd.AddParam(changeDescriber == null ? null : changeDescriber());
            cmd.AddParam(DateTime.UtcNow);
            cmd.AddParam(_user.Current());

            cmd.CommandText = sql;

            return(cmd);
        }
Example #28
0
        /// <summary>
        /// Records that the specified change occured to the specified entity.
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="changeType"></param>
        /// <param name="propertyDiffs"></param>
        internal void RecordChange(Entity entity, EntityChangeType changeType, PropertyDiff[] propertyDiffs)
        {
            var thisChange = new ChangeRecord(entity, changeType, propertyDiffs);

            // check if this entity was already recorded in the list
            // note that reference equality is used because we do not know how the Equals method of the entity may be implemented
            // for example, it may define equality based on a property whose value has changed, which would break this logic
            var prevRecordIndex = _changeRecords.FindIndex(r => ReferenceEquals(r.Entity, entity));

            if (prevRecordIndex > -1)
            {
                // this entity was already marked as changed
                var previousChange = _changeRecords[prevRecordIndex];

                // compound the previous change record with this one
                _changeRecords[prevRecordIndex] = thisChange.Compound(previousChange);
            }
            else
            {
                // record this change in the change set
                _changeRecords.Add(thisChange);
            }
        }
Example #29
0
        public AuditServiceDto(string user, string type, DateTime time, EntityChangeType changeType)
        {
            UsersName = user;
            Type      = type;
            Date      = time;
            switch (changeType)
            {
            case EntityChangeType.Created:
                Reason = "Created";
                break;

            case EntityChangeType.Updated:
                Reason = "Updated";
                break;

            case EntityChangeType.Deleted:
                Reason = "Deleted";
                break;
            }


            AuditDetails = new List <AuditDetailDto>();
        }
Example #30
0
		/// <summary>
		/// Constructor
		/// </summary>
		public EntityChange(EntityRef entityRef, EntityChangeType changeType, PropertyChange[] propertyChanges)
		{
			_entityRef = entityRef;
			_changeType = changeType;
			_propertyChanges = propertyChanges;
		}
Example #31
0
 public EntityChange(EntityChangeType type, T entity)
 {
     Type   = type;
     Entity = entity;
 }
Example #32
0
        public override void LocalMessageExecuting(EntityChangeType changeType)
        {
            var lmHelper = new Terrasoft.Configuration.LocalMessageHelper(this.Entity, UserConnection, changeType);

            lmHelper.CreateLocalMessage();
        }
		private static Dictionary<string, PropertyData> WriteExtendedProperties(PropertyChange propertyChange, EntityChangeType changeType)
		{
			var result = new Dictionary<string, PropertyData>();

			var collectionName = propertyChange.PropertyName;
			var oldColl = propertyChange.OldValue == null ? new Hashtable() : (IDictionary)propertyChange.OldValue;
			var newColl = propertyChange.NewValue == null ? new Hashtable() : (IDictionary)propertyChange.NewValue;

			// obtain unique set of keys over both items
			var keys = CollectionUtils.Unique(CollectionUtils.Concat(oldColl.Keys, newColl.Keys));

			// enumerate each key
			foreach (var key in keys)
			{
				var oldValue = oldColl.Contains(key) ? oldColl[key] : null;
				var newValue = newColl.Contains(key) ? newColl[key] : null;

				// has this "property" changed?
				if (!Equals(oldValue, newValue))
				{
					var propertyName = string.Concat(collectionName, ".", key);
					var propertyData = WriteProperty(oldValue, newValue, changeType);
					result.Add(propertyName, propertyData);
				}
			}
			return result;
		}
Example #34
0
    public EntityRecordInfo GetReord(int frame, int ID, /*string systemName, RecordEntityTiming timing, */ EntityChangeType changeType)
    {
        for (int i = 0; i < m_list.Count; i++)
        {
            if (m_list[i].frame == frame &&
                m_list[i].id == ID
                //&& m_list[i].systemName == systemName
                //&& m_list[i].timing == timing
                && m_list[i].changeType == changeType)
            {
                return(m_list[i]);
            }
        }

        throw new Exception("Not Find EntityRecordInfo by : id -> " + ID + " frame " + frame + " changeType " + changeType /*+ " systemName " + systemName + " timing " + timing*/);
    }
Example #35
0
    public bool GetReordIsExist(int frame, int ID, /* string systemName, RecordEntityTiming timing,*/ EntityChangeType changeType)
    {
        for (int i = 0; i < m_list.Count; i++)
        {
            if (m_list[i].frame == frame &&
                m_list[i].id == ID
                //&& m_list[i].systemName == systemName
                //&& m_list[i].timing == timing
                && m_list[i].changeType == changeType)
            {
                return(true);
            }
        }

        return(false);
    }
 public EntityDifference(string entityType, EntityChangeType type, string navigation)
 {
     this.EntityType = entityType;
     this.Type       = type;
     this.Navigation = navigation;
 }
Example #37
0
		public ChangeRecord(Entity entity, EntityChangeType changeType, PropertyDiff[] propertyDiffs)
		{
			_entity = entity;
			_changeType = changeType;
			_propertyDiffs = propertyDiffs;
		}
Example #38
0
 public ChangeInfo(string entityName, EntityChangeType type, string description = "")
 {
     EntityName = entityName;
     Type = type;
     Description = description;
 }
		private void RecordChange(object domainObject, EntityChangeType changeType, PropertyDiff[] propertyDiffs)
		{
			if(IsChangeSetPublishable((DomainObject)domainObject))
			{
				// update all change trackers
				var entity = (Entity)domainObject;
				foreach (var changeTracker in _changeTrackers)
				{
					changeTracker.RecordChange(entity, changeType, propertyDiffs);
				}
			}
		}
Example #40
0
		public ProductChangedMessage(object sender, IProduct product, EntityChangeType changeType)
			:base(sender)
		{
			Product = product;
			ChangeType = changeType;
		}
		private static PropertyData WriteProperty(object oldValue, object newValue, EntityChangeType changeType)
		{
			var data = new PropertyData();

			// for Updates and Deletes, write the old value
			if (changeType != EntityChangeType.Create)
			{
				data.OldValue = WritePropertyValue(oldValue);
			}

			// for Creates and Updates, write the new value
			if (changeType != EntityChangeType.Delete)
			{
				data.NewValue = WritePropertyValue(newValue);
			}
			return data;
		}