private void UpdateGrowingObject(T current, bool isHeaderUpdateOnly, bool?isAppending = null, double?startIndex = null, double?endIndex = null, string indexUom = null) { // Currently growing if (IsObjectGrowing(current)) { return; } var changeHistory = AuditHistoryAdapter.GetCurrentChangeHistory(); changeHistory.UpdatedHeader = true; // Currently not growing with header only update if (isHeaderUpdateOnly) { UpdateGrowingObject(current.GetUri()); return; } // Currently not growing with start/end indexes changed AuditHistoryAdapter.SetChangeHistoryIndexes(changeHistory, startIndex, endIndex, indexUom); // Currently not growing with stations updated/appended/deleted var isObjectGrowingToggled = isAppending.GetValueOrDefault() ? true : (bool?)null; UpdateGrowingObject(current, null, isObjectGrowingToggled); }
/// <summary> /// Updates the growing status for the specified growing object. If isObjectGrowing has a value it will update /// the objectGrowing flag for the entity. /// </summary> /// <param name="entity">The entity.</param> /// <param name="updates">The header update definition.</param> /// <param name="isObjectGrowing">Is the object currently growing.</param> protected virtual void UpdateGrowingObject(T entity, UpdateDefinition <T> updates, bool?isObjectGrowing = null) { var uri = GetUri(entity); var isCurrentObjectGrowing = IsObjectGrowing(entity); var isAuditUpdate = !isObjectGrowing.GetValueOrDefault(); // Set change history object growing flag var changeHistory = AuditHistoryAdapter.GetCurrentChangeHistory(); changeHistory.ObjectGrowingState = isCurrentObjectGrowing; // Check to see if the object growing flag needs to be toggled if (isObjectGrowing.HasValue && isCurrentObjectGrowing != isObjectGrowing) { // Only allow DbGrowingObjectDataAdapter to set flag to false Logger.Debug($"Updating object growing flag for URI: {uri}; Value: {isObjectGrowing.Value}"); var flag = MongoDbUtility.CreateObjectGrowingFields <T>(isObjectGrowing.Value); updates = MongoDbUtility.BuildUpdate(updates, flag); // Only audit an append of data when first toggling object growing flag changeHistory.ObjectGrowingState = isObjectGrowing; isAuditUpdate = true; } UpdateGrowingObject(uri, updates, isAuditUpdate); // If the object is not currently growing do not update wellbore isActive if (!isObjectGrowing.GetValueOrDefault()) { return; } // Update dbGrowingObject timestamp DbGrowingObjectAdapter.UpdateLastAppendDateTime(uri, GetWellboreUri(uri)); // Update Wellbore isActive UpdateWellboreIsActive(uri, true); }