Exemple #1
0
		public override void AuditEntityFieldSet(IEntityCore entity, int fieldIndex, object originalValue)
		{
			AuditEntity auditInfo = new AuditEntity();
			auditInfo.AuditorToUse = null;
			auditInfo.Table = ((IEntity)entity).Fields[fieldIndex].SourceObjectName;
			auditInfo.Field = ((IEntity)entity).Fields[fieldIndex].Name;
			
			// save old and new data
			if (originalValue != null)
				auditInfo.OldData = originalValue.ToString().Substring(0, Math.Min(originalValue.ToString().Length, AuditFields.OldData.MaxLength));
			if (entity.GetCurrentFieldValue(fieldIndex) != null)
				auditInfo.NewData = entity.GetCurrentFieldValue(fieldIndex).ToString().Substring(0, Math.Min(entity.GetCurrentFieldValue(fieldIndex).ToString().Length, AuditFields.NewData.MaxLength));
			else
				auditInfo.NewData = null;

			// get the primary keys fields
		    var prop = entity.GetType().GetProperty("Fields");
			var fields = ((IEntityFields)prop.GetValue(entity, null)).Where(x => x.IsPrimaryKey);
			string key = "";
            foreach (EntityField field in fields)
			{
				key += (key != "" ? "," : "") + field.CurrentValue;
			}
			auditInfo.Key = key;

			// save currently logged in user
            if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.User != null)
				auditInfo.CreatedBy = System.Web.HttpContext.Current.User.Identity.Name.ToLower();
			else
				auditInfo.CreatedBy = "";
			auditInfo.CreatedDate = DateTime.UtcNow;

			_auditInfoEntities.Add(auditInfo);
		}
Exemple #2
0
        /// <summary>
        /// Audits when an entity field is set succesfully to a new value.
        /// </summary>
        /// <param name="entity">The entity a field was set to a new value.</param>
        /// <param name="fieldIndex">Index of the field which got a new value.</param>
        /// <param name="originalValue">The original value of the field with the index passed in
        /// before it received a new value.</param>
        public override void AuditEntityFieldSet(IEntityCore entity, int fieldIndex, object originalValue)
        {
            // avoid to audit into AuditInfoEntity (this would create an overflow effect). This is necessary if this auditor is injected into
            // all entities, thus also in the AuditInfoEntity
            if (entity is AuditInfoEntity)
            {
                return;
            }

            // Ignore the fieldSet of a new Order. The first original field values of an order can be reconstructed via the
            // AuditEntityFieldSet/AuditUpdateofExistingEntity history. However you also may colect AuditEntityFieldSet here
            // and then assign the sync those assigning OrderId when AuditInsertOfNewEntity is raised. The approach is up to you.
            if (entity.IsNew)
            {
                return;
            }

            // used to store the change experimented by a field.
            string originalValueAsString = string.Empty;
            string currentValue          = string.Empty;

            // sets VALUE OR NULL for originalValue and uses it as string.
            if (originalValue != null)
            {
                originalValueAsString = originalValue.ToString();
            }
            else
            {
                originalValueAsString = "NULL";
            }

            // sets VALUE OR NULL for currentValue and uses it as string.
            if (entity.GetCurrentFieldValue(fieldIndex) != null)
            {
                currentValue = entity.GetCurrentFieldValue(fieldIndex).ToString();
            }
            else
            {
                currentValue = "NULL";
            }

            // post the field change info
            AddOrderAuditEntryToList(
                GetPrimaryKeyValueFromOrderEntity(entity),
                AuditType.EntityFieldSet,
                string.Format("FieldSet: {0}. OriginalValue: {1}. CurrentValue: {2}",
                              ((IEntity)entity).Fields[fieldIndex].Name,
                              originalValueAsString, currentValue));
        }
        /// <summary>
        /// Audits when an entity field is set succesfully to a new value.
        /// </summary>
        /// <param name="entity">The entity a field was set to a new value.</param>
        /// <param name="fieldIndex">Index of the field which got a new value.</param>
        /// <param name="originalValue">The original value of the field with the index passed in
        /// before it received a new value.</param>
        public override void AuditEntityFieldSet(IEntityCore entity, int fieldIndex, object originalValue)
        {
            // avoid to audit into AuditInfoEntity (this would create an overflow effect). This is necessary if this auditor is injected into
            // all entities, thus also in the AuditInfoEntity
            if (entity is AuditInfoEntity)
            {
                return;
            }

            // used to store the change experimented by a field.
            string originalValueAsString = string.Empty;
            string currentValue          = string.Empty;

            // sets VALUE OR NULL for originalValue and uses it as string.
            if (originalValue != null)
            {
                originalValueAsString = originalValue.ToString();
            }
            else
            {
                originalValueAsString = "NULL";
            }

            // sets VALUE OR NULL for currentValue and uses it as string.
            if (entity.GetCurrentFieldValue(fieldIndex) != null)
            {
                currentValue = entity.GetCurrentFieldValue(fieldIndex).ToString();
            }
            else
            {
                currentValue = "NULL";
            }


            // construct audit info record
            StringWriter auditInfo = ConstructAuditRecord(entity.LLBLGenProEntityName,
                                                          AuditType.EntityFieldSet,
                                                          string.Format("{0}. FieldSet: {1}. OriginalValue: {2}. CurrentValue: {3}",
                                                                        GetPrimaryKeyInfoFromEntity(entity),
                                                                        ((IEntity)entity).Fields[fieldIndex].Name,
                                                                        originalValueAsString, currentValue));

            // add to later-persist list
            AddAuditRecordStringToBulkStream(auditInfo.GetStringBuilder().ToString());
        }
Exemple #4
0
        /// <summary>
        /// Audits when an entity field is set succesfully to a new value.
        /// </summary>
        /// <param name="entity">The entity a field was set to a new value.</param>
        /// <param name="fieldIndex">Index of the field which got a new value.</param>
        /// <param name="originalValue">The original value of the field with the index passed in
        /// before it received a new value.</param>
        public override void AuditEntityFieldSet(IEntityCore entity, int fieldIndex, object originalValue)
        {
            // avoid to adit an AuditInfoEntity. This would create an Overflow efect.
            if (entity is AuditInfoEntity)
            {
                return;
            }

            // used to store the change experimented by a field.
            string originalValueAsString = string.Empty;
            string currentValue          = string.Empty;

            // sets VALUE OR NULL for originalValue and uses it as string.
            if (originalValue != null)
            {
                originalValueAsString = originalValue.ToString();
            }
            else
            {
                originalValueAsString = "NULL";
            }

            // sets VALUE OR NULL for currentValue and uses it as string.
            if (entity.GetCurrentFieldValue(fieldIndex) != null)
            {
                currentValue = entity.GetCurrentFieldValue(fieldIndex).ToString();
            }
            else
            {
                currentValue = "NULL";
            }

            // post the field change info
            AddAuditEntryToList(
                entity.LLBLGenProEntityName,
                AuditType.EntityFieldSet,
                string.Format("{0}. FieldSet: {1}. OriginalValue: {2}. CurrentValue: {3}",
                              GetPrimaryKeyInfoFromEntity(entity),
                              ((IEntity2)entity).Fields[fieldIndex].Name,
                              originalValueAsString, currentValue));
        }
        /// <summary>
        /// Audits when an entity field is set succesfully to a new value.
        /// </summary>
        /// <param name="entity">The entity a field was set to a new value.</param>
        /// <param name="fieldIndex">Index of the field which got a new value.</param>
        /// <param name="originalValue">The original value of the field with the index passed in
        /// before it received a new value.</param>
        public override void AuditEntityFieldSet(IEntityCore entity, int fieldIndex, object originalValue)
        {
            // avoid to audit into AuditInfoEntity (this would create an overflow effect). This is necessary if this auditor is injected into
            // all entities, thus also in the AuditInfoEntity
            if (entity is AuditInfoEntity)
            {
                return;
            }

            // used to store the change experimented by a field.
            string originalValueAsString = originalValue == null ? "NULL" : originalValue.ToString();
            var    currentValue          = entity.GetCurrentFieldValue(fieldIndex);
            string currentValueAsString  = currentValue == null ? "NULL" : currentValue.ToString();

            // post the field change info
            AddAuditEntryToList(entity.LLBLGenProEntityName, AuditType.EntityFieldSet,
                                string.Format("{0}. FieldSet: {1}. OriginalValue: {2}. CurrentValue: {3}",
                                              GetPrimaryKeyInfoFromEntity(entity), entity.Fields.GetFieldInfo(fieldIndex).Name,
                                              originalValueAsString, currentValueAsString));
        }
Exemple #6
0
        /// <summary>
        /// Audits when an entity field is set succesfully to a new value.
        /// </summary>
        /// <param name="entity">The entity a field was set to a new value.</param>
        /// <param name="fieldIndex">Index of the field which got a new value.</param>
        /// <param name="originalValue">The original value of the field with the index passed in
        /// before it received a new value.</param>
        public override void AuditEntityFieldSet(IEntityCore entity, int fieldIndex, object originalValue)
        {
            // Ignore the fieldSet of a new Order. The first original field values of an order can be reconstructed via the
            // AuditEntityFieldSet/AuditUpdateofExistingEntity history. However you also may colect AuditEntityFieldSet here
            // and then assign the sync those assigning OrderId when AuditInsertOfNewEntity is raised. The approach is up to you.
            if (entity.IsNew)
            {
                return;
            }

            // used to store the change experimented by a field.
            string originalValueAsString = originalValue == null ? "NULL" : originalValue.ToString();
            var    currentValue          = entity.GetCurrentFieldValue(fieldIndex);
            string currentValueAsString  = currentValue == null ? "NULL" : currentValue.ToString();

            // post the field change audit info
            AddOrderAuditEntryToList(
                GetPrimaryKeyValueFromOrderEntity(entity),
                AuditType.EntityFieldSet,
                string.Format("FieldSet: {0}. OriginalValue: {1}. CurrentValue: {2}",
                              entity.Fields.GetFieldInfo(fieldIndex).Name,
                              originalValueAsString, currentValueAsString));
        }