示例#1
0
        /// <summary>
        /// Updates the growing object's header and change history.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="updates">The header update definition.</param>
        /// <param name="isAuditUpdate">if set to <c>true</c> audit the update.</param>
        protected virtual void UpdateGrowingObject(EtpUri uri, UpdateDefinition <T> updates = null, bool isAuditUpdate = true)
        {
            var current = GetEntity(uri);

            // Update the growing object's header
            var filter = MongoDbUtility.GetEntityFilter <T>(uri);
            var fields = MongoDbUtility.CreateUpdateFields <T>();

            Logger.Debug($"Updating date time last change for URI: {uri}");
            updates = MongoDbUtility.BuildUpdate(updates, fields);

            var mongoUpdate = new MongoDbUpdate <T>(Container, GetCollection(), null, IdPropertyName);

            mongoUpdate.UpdateFields(filter, updates);

            // Join existing Transaction
            var transaction = Transaction;

            transaction.Attach(MongoDbAction.Update, DbCollectionName, IdPropertyName, current.ToBsonDocument(), uri);
            transaction.Save();

            if (!isAuditUpdate)
            {
                return;
            }

            var changeType = WitsmlOperationContext.Current.Request.Function == Functions.AddToStore
                ? Witsml141.ReferenceData.ChangeInfoType.add
                : Witsml141.ReferenceData.ChangeInfoType.update;

            // Audit entity
            AuditEntity(uri, changeType);
        }
示例#2
0
        /// <summary>
        /// Updates the data row count for the log.
        /// </summary>
        /// <param name="uri">The URI.</param>
        protected override void UpdateDataRowCount(EtpUri uri)
        {
            var current      = GetEntity(uri);
            var dataRowCount = ChannelDataChunkAdapter.GetDataRowCount(uri);

            if (current.DataRowCount.Equals(dataRowCount))
            {
                return;
            }

            // Update the dataRowCount in the header
            var updates = GetDataRowCountUpdate(null, current, dataRowCount);
            var filter  = MongoDbUtility.GetEntityFilter <Log>(uri);
            var fields  = MongoDbUtility.CreateUpdateFields <Log>();

            Logger.Debug($"Updating dataRowCount for URI: {uri}");
            updates = MongoDbUtility.BuildUpdate(updates, fields);

            var mongoUpdate = new MongoDbUpdate <Log>(Container, GetCollection(), null, IdPropertyName);

            mongoUpdate.UpdateFields(filter, updates);

            // Join existing Transaction
            var transaction = Transaction;

            transaction.Attach(MongoDbAction.Update, DbCollectionName, IdPropertyName, current.ToBsonDocument(), uri);
            transaction.Save();
        }
示例#3
0
        /// <summary>
        /// Updates the IsActive field of a wellbore.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="isActive">IsActive flag on wellbore is set to the value.</param>
        public void UpdateIsActive(EtpUri uri, bool isActive)
        {
            var wellboreEntity = GetEntity(uri);

            if (wellboreEntity == null)
            {
                Logger.DebugFormat("Wellbore not found with uri '{0}'", uri);
                return;
            }

            if (wellboreEntity.IsActive.GetValueOrDefault() == isActive)
            {
                return;
            }

            Logger.DebugFormat("Updating wellbore isActive for uid '{0}' and name '{1}'.", wellboreEntity.Uid, wellboreEntity.Name);

            var filter = MongoDbUtility.GetEntityFilter <Wellbore>(uri);
            var fields = MongoDbUtility.CreateUpdateFields <Wellbore>();

            var wellboreUpdate = MongoDbUtility.BuildUpdate <Wellbore>(null, "IsActive", isActive);

            wellboreUpdate = MongoDbUtility.BuildUpdate(wellboreUpdate, fields);

            var mongoUpdate = new MongoDbUpdate <Wellbore>(Container, GetCollection(), null);

            mongoUpdate.UpdateFields(filter, wellboreUpdate);

            // Join existing Transaction
            var transaction = Transaction;

            transaction.Attach(MongoDbAction.Update, DbCollectionName, IdPropertyName, wellboreEntity.ToBsonDocument(), uri);
            transaction.Save();

            // Audit entity
            AuditEntity(uri, ChangeInfoType.update);
        }