public override RemoteUploadResult UploadNoteToRemote(ref INote inote, out INote conflict, out bool keepNoteRemoteDirtyWithConflict, ConflictResolutionStrategy strategy) { var note = (EvernoteNote)inote; keepNoteRemoteDirtyWithConflict = false; var remote = bucket.Notes.FirstOrDefault(p => Guid.Parse(p.Guid) == note.ID); remoteDirty = true; if (remote == null) { inote = APICreateNewNote(note); conflict = null; return(RemoteUploadResult.Uploaded); } else { if (remote.UpdateSequenceNum > note.UpdateSequenceNumber) { if (strategy == ConflictResolutionStrategy.UseClientVersion || strategy == ConflictResolutionStrategy.UseClientCreateConflictFile || strategy == ConflictResolutionStrategy.ManualMerge) { conflict = APIDownloadNote(note.ID); inote = APIUpdateNote(note); return(RemoteUploadResult.Conflict); } else if (strategy == ConflictResolutionStrategy.UseServerVersion || strategy == ConflictResolutionStrategy.UseServerCreateConflictFile) { conflict = inote.Clone(); inote = APIDownloadNote(note.ID); return(RemoteUploadResult.Conflict); } else { throw new ArgumentException("strategy == " + strategy); } } else { inote = APIUpdateNote(note); conflict = null; return(RemoteUploadResult.Uploaded); } } }
public override RemoteUploadResult UploadNoteToRemote(ref INote inote, out INote conflict, out bool keepNoteRemoteDirtyWithConflict, ConflictResolutionStrategy strategy) { keepNoteRemoteDirtyWithConflict = false; using (var web = CreateAuthenticatedClient()) { var note = (SimpleNote)inote; var remote = buckets.index.FirstOrDefault(p => p.id == note.ID); if (remote == null) { conflict = null; inote = SimpleNoteAPI.UploadNewNote(web, note, _config, this); return(RemoteUploadResult.Uploaded); } else { if (remote.v > note.LocalVersion) { if (strategy == ConflictResolutionStrategy.UseClientVersion || strategy == ConflictResolutionStrategy.UseClientCreateConflictFile || strategy == ConflictResolutionStrategy.ManualMerge) { conflict = SimpleNoteAPI.GetNoteData(web, note.ID, _config, this); inote = SimpleNoteAPI.ChangeExistingNote(web, note, _config, this, out _); return(RemoteUploadResult.Conflict); } else if (strategy == ConflictResolutionStrategy.UseServerVersion || strategy == ConflictResolutionStrategy.UseServerCreateConflictFile) { conflict = inote.Clone(); inote = SimpleNoteAPI.GetNoteData(web, note.ID, _config, this); return(RemoteUploadResult.Conflict); } else { throw new ArgumentException("strategy == " + strategy); } } else { conflict = null; bool updated; inote = SimpleNoteAPI.ChangeExistingNote(web, note, _config, this, out updated); return(updated ? RemoteUploadResult.Uploaded : RemoteUploadResult.UpToDate); } } } }
public override RemoteUploadResult UploadNoteToRemote(ref INote inote, out INote conflict, out bool keepNoteRemoteDirtyWithConflict, ConflictResolutionStrategy strategy) { keepNoteRemoteDirtyWithConflict = false; using (var web = CreateAuthenticatedClient()) { var note = (NextcloudNote)inote; var remote = remoteNotes.FirstOrDefault(p => p.id == note.RemoteID); if (remote == null) { conflict = null; inote = NextcloudAPI.UploadNewNote(web, note, _config); return(RemoteUploadResult.Uploaded); } else { if (remote.modified > note.RemoteTimestamp) { if (strategy == ConflictResolutionStrategy.UseClientVersion || strategy == ConflictResolutionStrategy.UseClientCreateConflictFile || strategy == ConflictResolutionStrategy.ManualMerge) { conflict = NextcloudAPI.GetNoteData(web, note.RemoteID, _config); inote = NextcloudAPI.ChangeExistingNote(web, note, _config); return(RemoteUploadResult.Conflict); } else if (strategy == ConflictResolutionStrategy.UseServerVersion || strategy == ConflictResolutionStrategy.UseServerCreateConflictFile) { conflict = inote.Clone(); inote = NextcloudAPI.GetNoteData(web, note.RemoteID, _config); return(RemoteUploadResult.Conflict); } else { throw new ArgumentException("strategy == " + strategy); } } else { conflict = null; inote = NextcloudAPI.ChangeExistingNote(web, note, _config); return(RemoteUploadResult.Uploaded); } } } }