コード例 #1
0
ファイル: MongoDbDataAdapter.cs プロジェクト: wdstest/witsml
        /// <summary>
        /// Audits the entity. Override this method to adjust the audit record
        /// before it is submitted to the database or to prevent the audit.
        /// </summary>
        /// <param name="entity">The changed entity.</param>
        /// <param name="auditHistory">The audit history.</param>
        /// <param name="isNewEntry">if set to <c>true</c> add a new entry.</param>
        protected virtual void AuditEntity(T entity, DbAuditHistory auditHistory, bool isNewEntry)
        {
            // Ensure change log support has not been disabled
            if (!_isDbAuditHistoryEnabled)
            {
                return;
            }

            if (isNewEntry)
            {
                AuditHistoryAdapter?.InsertEntity(auditHistory);
            }
            else
            {
                AuditHistoryAdapter?.ReplaceEntity(auditHistory, auditHistory.GetUri());
            }

            var dataObject = entity as IDataObject;

            if (dataObject != null)
            {
                var collection = dataObject.CreateCollection();
                AuditHistoryAdapter?.QueueNotification(collection, auditHistory);
            }
            else
            {
                AuditHistoryAdapter?.QueueNotification(entity, auditHistory);
            }
        }
コード例 #2
0
        public void DbAuditHistory_Test_Add()
        {
            _dataAdapter.Add(null, _changeLog);

            var changeLog = _dataAdapter.Get(_changeLog.GetUri());

            Assert.IsNotNull(changeLog);
            Assert.AreEqual(_changeLog.Uid, changeLog.Uid);
            Assert.AreEqual(_changeLog.Name, changeLog.Name);
            Assert.AreEqual(_changeLog.UidObject, changeLog.UidObject);
            Assert.AreEqual(_changeLog.NameObject, changeLog.NameObject);
            Assert.AreEqual(_changeLog.LastChangeType, changeLog.LastChangeType);
        }
コード例 #3
0
        /// <summary>
        /// Audits the entity. Override this method to adjust the audit record
        /// before it is submitted to the database or to prevent the audit.
        /// </summary>
        /// <param name="entity">The changed entity.</param>
        /// <param name="auditHistory">The audit history.</param>
        /// <param name="isNewEntry">if set to <c>true</c> add a new entry.</param>
        protected virtual void AuditEntity(T entity, DbAuditHistory auditHistory, bool isNewEntry)
        {
            if (isNewEntry)
            {
                AuditHistoryAdapter?.InsertEntity(auditHistory);
            }
            else
            {
                AuditHistoryAdapter?.ReplaceEntity(auditHistory, auditHistory.GetUri());
            }

            var dataObject = entity as IDataObject;

            if (dataObject != null)
            {
                var collection = dataObject.CreateCollection();
                AuditHistoryAdapter?.QueueNotification(collection, auditHistory);
            }
            else
            {
                AuditHistoryAdapter?.QueueNotification(entity, auditHistory);
            }
        }