private bool ShouldAddToResendTable(DocumentsStorage.DocumentOrTombstone item, string currentChangeVector) { if (item.Document != null) { var status = Database.DocumentsStorage.GetConflictStatus(item.Document.ChangeVector, currentChangeVector); switch (status) { case ConflictStatus.Update: return(true); case ConflictStatus.AlreadyMerged: case ConflictStatus.Conflict: return(false); default: throw new ArgumentOutOfRangeException(nameof(ConflictStatus), status.ToString()); } } return(false); }
private bool ShouldFetchFromResend(string id, DocumentsStorage.DocumentOrTombstone item, string currentChangeVector) { if (item.Document == null) { // the document was delete while it was processed by the client ItemsToRemoveFromResend.Add(id); return(false); } var status = Database.DocumentsStorage.GetConflictStatus(item.Document.ChangeVector, currentChangeVector); switch (status) { case ConflictStatus.Update: // If document was updated, but the subscription went too far. var resendStatus = Database.DocumentsStorage.GetConflictStatus(item.Document.ChangeVector, SubscriptionConnectionsState.LastChangeVectorSent); if (resendStatus == ConflictStatus.Update) { // we can clear it from resend list, and it will processed as regular document ItemsToRemoveFromResend.Add(id); return(false); } // We need to resend it return(resendStatus == ConflictStatus.AlreadyMerged); case ConflictStatus.AlreadyMerged: return(true); case ConflictStatus.Conflict: return(false); default: throw new ArgumentOutOfRangeException(nameof(ConflictStatus), status.ToString()); } }
private CollectionName GetCollection(DocumentsOperationContext context, DocumentsStorage.DocumentOrTombstone item) { return(item.Document != null ? Database.DocumentsStorage.ExtractCollectionName(context, item.Document.Data) : Database.DocumentsStorage.ExtractCollectionName(context, item.Tombstone.Collection)); }