public UpdateAsync ( Authenticator authentication, AbstractEntry payload, object userData ) : void | ||
authentication | Authenticator | |
payload | AbstractEntry | |
userData | object | |
return | void |
public void SaveGoogleNote(NoteMatch match) { Outlook.NoteItem outlookNoteItem = match.OutlookNote; //try //{ //ToDo: Somewhow, the content is not uploaded to Google, only an empty document //match.GoogleNote = SaveGoogleNote(match.GoogleNote); //New approach how to update an existing document: https://developers.google.com/google-apps/documents-list/#updatingchanging_documents_and_files // Instantiate the ResumableUploader component. ResumableUploader uploader = new ResumableUploader(); // Set the handlers for the completion and progress events //uploader.AsyncOperationProgress += new AsyncOperationProgressEventHandler(OnProgress); //ToDo: Therefoe I use DocumentService.UploadDocument instead and move it to the NotesFolder string oldOutlookGoogleNoteId = NotePropertiesUtils.GetOutlookGoogleNoteId(this, outlookNoteItem); if (match.GoogleNote.DocumentEntry.Id.Uri != null) { //DocumentsRequest.Delete(new Uri(Google.GData.Documents.DocumentsListQuery.documentsBaseUri + "/" + match.GoogleNote.ResourceId), match.GoogleNote.ETag); ////DocumentsRequest.Delete(match.GoogleNote); //ToDo: Currently, the Delete only removes the Notes label from the document but keeps the document in the root folder //NotePropertiesUtils.ResetOutlookGoogleNoteId(this, outlookNoteItem); ////ToDo: Currently, the Delete only removes the Notes label from the document but keeps the document in the root folder //Document deletedNote = LoadGoogleNotes(match.GoogleNote.DocumentEntry.Id); //if (deletedNote != null) // DocumentsRequest.Delete(deletedNote); // Start the update process. uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnGoogleNoteUpdated); uploader.UpdateAsync(authenticator, match.GoogleNote.DocumentEntry, match); //uploader.Update(_authenticator, match.GoogleNote.DocumentEntry); } else { uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnGoogleNoteCreated); CreateGoogleNote(match.GoogleNote, match, DocumentsRequest, uploader, authenticator); } match.AsyncUpdateCompleted = false; //Google.GData.Documents.DocumentEntry entry = DocumentsRequest.Service.UploadDocument(NotePropertiesUtils.GetFileName(outlookNoteItem.EntryID, SyncProfile), match.GoogleNote.Title.Replace(":", String.Empty)); //Document newNote = LoadGoogleNotes(entry.Id); //match.GoogleNote = DocumentsRequest.MoveDocumentTo(GoogleNotesFolder, newNote); //First delete old temporary file, because it was saved with old GoogleNoteID, because every sync to Google becomes a new ID, because updateMedia doesn't work //File.Delete(NotePropertiesUtils.GetFileName(oldOutlookGoogleNoteId, SyncProfile)); //UpdateNoteMatchId(match); //} //finally //{ // Marshal.ReleaseComObject(outlookNoteItem); // outlookNoteItem = null; //} }
private void OnGoogleNoteCreated(object sender, AsyncOperationCompletedEventArgs e) { DocumentEntry entry = e.Entry as DocumentEntry; Assert.IsNotNull(entry); Logger.Log("Created Google note", EventType.Information); //Now update the same entry //Instantiate the ResumableUploader component. ResumableUploader uploader = new ResumableUploader(); uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnGoogleNoteUpdated); uploader.UpdateAsync(_authenticator, entry, e.UserState); }