示例#1
0
        /// <summary>
        /// Creating log record and saving it to DB
        /// </summary>
        private void NewAuditRecord(Item curentity, string fieldName, string newValue, string oldValue, AuditRecordType operationType)
        {
            string entityType = curentity.GetType().ToString();
            string stringTableName = entityType.Substring(entityType.LastIndexOf('.') + 1);
            ItemTypes tableName = ItemTypes.Undefined;
            Enum.TryParse(stringTableName, true, out tableName);
            FieldNames enumFieldName = FieldNames.Undefined;
            Enum.TryParse(fieldName, true, out enumFieldName);

            AuditLog record = new AuditLog()
            {
                AuditID = Guid.NewGuid(),
                EntityID = curentity.Id,
                AuditDate = DateTime.Now,
                User = currentUser.Id,
                TableName = tableName,
                FieldName = enumFieldName,
                NewValue = newValue,
                OldValue = oldValue,
                OwnerId = curentity.OwnerId,
                OperationType = operationType
            };
            LogRepo.BeginTransaction();
            LogRepo.Save(record);
            LogRepo.Commit();
            LogRepo.Evict(record);
        }