public void DeleteNotes(IList <string> deletedNoteUUIDs) { NoteFilter noteFilter = new NoteFilter(); noteFilter.NotebookGuid = _tomboyNotebook.Guid; NoteList evernoteList = _noteStore.findNotes(_authToken, noteFilter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX); foreach (string guid in deletedNoteUUIDs) { bool foundNote = false; foreach (Evernote.EDAM.Type.Note evernote in evernoteList.Notes) { if (GetCorrectGuid(evernote) == guid) { foundNote = true; evernote.Deleted = (long)DateTime.Now.Subtract(Epoch).TotalMilliseconds; _noteStore.updateNote(_authToken, evernote); } } if (!foundNote) { Logger.Error("[Evernote] Could not find note " + guid + " to delete."); } } }
/// <summary> /// A collection notes that belong to this base asset filtered by the passed in filter /// </summary> public ICollection <Note> GetNotes(NoteFilter filter) { filter = filter ?? new NoteFilter(); filter.Asset.Clear(); filter.Asset.Add(this); return(Instance.Get.Notes(filter)); }
internal List <Entity.Notebook> ReadEvernoteNotebooks(String edamBaseUrl, AuthenticationResult authResult) { string authToken = authResult.AuthenticationToken; NoteStore.Client noteStore = EvernoteHelper.GetNoteStoreClient(edamBaseUrl, authResult.User); List <Notebook> notebooks = noteStore.listNotebooks(authToken); UpdateProgress("Retrieving Notebook List"); foreach (Notebook notebook in notebooks) { Entity.Notebook enNotebook = new Entity.Notebook(); enNotebook.Name = (notebook.Stack + " " + notebook.Name).Trim(); enNotebook.Guid = notebook.Guid; int intProgress = Helper.GetNotebookProgress(enNotebooks.Count, notebooks.Count, 1, 20); UpdateProgress(intProgress); NoteFilter nf = new NoteFilter(); nf.NotebookGuid = enNotebook.Guid; NoteList nl = noteStore.findNotes(authToken, nf, 0, 1); if (nl.Notes.Count > 0) { enNotebooks.Add(enNotebook); } } enNotebooks.Sort(delegate(Entity.Notebook p1, Entity.Notebook p2) { return(p1.Name.CompareTo(p2.Name)); }); return(enNotebooks); }
/// <summary> /// Performs a search of the Notes in the User’s account based on a configurable filter, returning a paginated subset. /// </summary> public NoteList FindNotes(NoteFilter filter, int offset, int maxNotes) { lock (this) using (var httpClient = GetHttpClient()) { return(GetNoteStoreClient(httpClient).findNotes(this.authToken, filter, offset, maxNotes)); } }
/// <summary> /// Performs a search based on a configurable filter, returning the number of Notes that would match this filter for each Notebook and Tag. /// </summary> public NoteCollectionCounts FindNoteCounts(NoteFilter filter) { lock (this) using (var httpClient = GetHttpClient()) { return(GetNoteStoreClient(httpClient).findNoteCounts(this.authToken, filter)); } }
private bool SelectedTagExistsInTags() { // An invalid selected tag can exist if the user edited a note (deleted a tag) and // returned to the overview, which still remembers this selected tag. NoteFilter noteFilter = new NoteFilter(null, SelectedTag); return(noteFilter.ContainsTag(Tags)); }
public ActionResult ShowNotes(User user, NoteFilter filter, FetchOptions options) { var model = new NotesListViewModel { Notes = noteRepository.GetUsersNotes(CurrentUser, filter, options) }; return(View(model)); }
public IList <string> GetAllNoteUUIDs() { NoteFilter filter = new NoteFilter(); filter.NotebookGuid = _tomboyNotebook.Guid; NoteList notes = _noteStore.findNotes(_authToken, filter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX); return(notes.Notes.Select(GetCorrectGuid).ToList()); }
public void ContainsTag_FindsTagCaseInsensitive() { NoteFilter filter = new NoteFilter(string.Empty, "mytag"); List <string> tagList = new List <string> { "something", "MyTag" }; Assert.IsTrue(filter.ContainsTag(tagList)); Assert.IsFalse(filter.ContainsTag(null)); }
public IList <Note> GetNotesByTags(params string[] args) { var tags = AllTags.Where(m => args.Contains(m.Name)).Select(m => m.Guid).ToList(); var filter = new NoteFilter { TagGuids = tags }; var notes = Note.FindNotes(filter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX); return(notes.Notes.OrderBy(m => m.Title).ToList()); }
public IList <Note> GetUsersNotes(User user, NoteFilter filter = null, FetchOptions options = null) { var crit = session.CreateCriteria <Note>(); crit.Add(Restrictions.Eq("Autor.Id", user.Id)); SetupFilter(crit, filter); if (options != null) { SetFetchOptions(crit, options); } return(crit.List <Note>()); }
private void ApplyFilter(string filter) { string normalizedFilter = SearchableHtmlConverter.NormalizeWhitespaces(filter); NoteFilter noteFilter = new NoteFilter(normalizedFilter); FilteredNotes.Clear(); foreach (NoteViewModel noteViewModel in AllNotes) { if (!noteViewModel.InRecyclingBin && noteFilter.ContainsPattern(noteViewModel.SearchableContent)) { FilteredNotes.Add(noteViewModel); } } }
/// <summary> /// This will read a set of annotated notes from the specified notebook. That is, this method will attempt to get the note, its attributes, the content and resolve images in the content. /// Using this call you'd likely have stored the version against each notebookid in your local data store. /// </summary> /// <param name="authToken">Your auth token to authenticate against the api.</param> /// <param name="notebookid">The Id of the notebook to filter on.</param> /// <param name="version">This is compared with the UpdateCount which is a value Evernote store at the account level to say if ANY of the notebooks have been updated. /// You can get this from the UserService.GetVersion() method. The first call will always get the latest.</param> /// <param name="version">This is the timestamp of the last note you retrieved. The first call will get the latest notes.</param> /// <param name="raw">Html returns the full XML with much of the content resolved. Strip will return pure text. Basic will strip most of the XML but resolve images etc and leave basic HTML elements in there - useful is writing to a webpage.</param> /// <param name="timestamp"></param> /// <returns></returns> public IList <NoteModel> GetNotes(Guid notebookid, long?timestamp, out long newtimestamp, TextResolver resolver = TextResolver.basic) { // initialize newtimestamp = 0; if (!timestamp.HasValue) { timestamp = 0; } // add in a filter int pageSize = 10; int pageNumber = 0; NoteFilter filter = new NoteFilter(); filter.Order = (int)Evernote.EDAM.Type.NoteSortOrder.UPDATED; filter.Ascending = false; filter.NotebookGuid = notebookid.ToString(); // set the notebook to filter on // what do we want back from the query? //NotesMetadataResultSpec resultSpec = new NotesMetadataResultSpec() { IncludeTitle = true, IncludeUpdated = true }; // execute the query for the notes NoteList newNotes = _Instance.findNotes(_authToken, filter, pageNumber * pageSize, pageSize);//, resultSpec); // initialize response collection IList <NoteModel> notes = new List <NoteModel>(); // store the latest timestamp if (newNotes.Notes != null && newNotes.Notes.Count > 0) { newtimestamp = newNotes.Notes.FirstOrDefault().Updated; } // enumerate and build response foreach (Note note in newNotes.Notes) { // if the db timestamp is the same or later than the note then ignore it // is the timestamp which is the last time this project was checked if (timestamp >= note.Updated) { continue; } notes.Add(BuildNote(note, resolver)); } return(notes); }
public ISearchResults GetNotesMetaList(string searchString, NoteSortOrder sortOrder, bool ascending, int resultsPage, int pageSize) { NoteFilter noteFilter = new NoteFilter(); noteFilter.Words = searchString; noteFilter.Order = (int)sortOrder; noteFilter.Ascending = ascending; NotesMetadataResultSpec resultsSpec = new NotesMetadataResultSpec(); resultsSpec.IncludeTitle = true; resultsSpec.IncludeCreated = true; resultsSpec.IncludeNotebookGuid = true; resultsSpec.IncludeUpdated = true; resultsSpec.IncludeAttributes = true; resultsSpec.IncludeTagGuids = true; resultsSpec.IncludeContentLength = true; NotesMetadataList noteMetadataList; try { if (resultsPage < 1) { resultsPage = 1; } if (pageSize > 100) { pageSize = 100; } noteMetadataList = noteStore.findNotesMetadata(credentials.AuthToken, noteFilter, (resultsPage - 1) * pageSize, pageSize, resultsSpec); } catch (EDAMUserException) { throw new EvernoteServiceSDK1AuthorisationException(); } List <ENNoteMetadataINoteMetadataAdapter> notesMetaWrapperList = noteMetadataList.Notes.ConvertAll(noteMeta => new ENNoteMetadataINoteMetadataAdapter(noteMeta)); return(new SearchResults() { NotesMetadata = notesMetaWrapperList.ToList <INoteMetadata>(), TotalResults = noteMetadataList.TotalNotes }); }
public void UploadNotes(IList <Note> notes) { //TODO - this could take a long time, think of a better way to do this //TODO - an alternative is to just try to Update and evernote (without checking whether it exists), //TODO - but the _noteStore.updateNote function throws an Exception on error, instead of returning false //TODO - and using exceptions for process control is costly. NoteFilter noteFilter = new NoteFilter(); noteFilter.NotebookGuid = _tomboyNotebook.Guid; NoteList evernoteList = _noteStore.findNotes(_authToken, noteFilter, 0, Evernote.EDAM.Limits.Constants.EDAM_USER_NOTES_MAX); Logger.Debug("[Evernote] Uploading " + notes.Count + " notes"); foreach (Note note in notes) { bool foundNote = false; Evernote.EDAM.Type.Note enote = null; foreach (Evernote.EDAM.Type.Note evernote in evernoteList.Notes) { if (GetCorrectGuid(evernote) == note.Id) { foundNote = true; enote = evernote; break; } } if (foundNote) { if (!UpdateEvernote(enote, note)) { Logger.Error("[Evernote] Could not update Evernote: " + note); throw new TomboySyncException("Could not Update Evernote"); } } else { //does not exist, so create a new note. if (!CreateNewEvernote(note)) { Logger.Debug("[Evernote] Problem creating note with id" + note.Id); throw new TomboySyncException("Couldn't create Evernote"); } } } }
private void ApplyFilter(string filter) { SettingsModel settings = _settingsService?.LoadSettingsOrDefault(); string normalizedFilter = SearchableHtmlConverter.NormalizeWhitespaces(filter); NoteFilter noteFilter = new NoteFilter(normalizedFilter); FilteredNotes.Clear(); foreach (NoteViewModel noteViewModel in AllNotes) { bool hideNote = noteViewModel.InRecyclingBin || (settings.HideClosedSafeNotes && noteViewModel.IsLocked) || !noteFilter.ContainsPattern(noteViewModel.SearchableContent); if (!hideNote) { FilteredNotes.Add(noteViewModel); } } }
void TestInResponseTo(Note expected, Note not, Note expectedNote) { NoteFilter filter = new NoteFilter(); filter.Asset.Add(SandboxProject); filter.InResponseTo.Add(expectedNote); ResetInstance(); expected = Instance.Get.NoteByID(expected.ID); not = Instance.Get.NoteByID(not.ID); ICollection <Note> results = SandboxProject.GetNotes(filter); Assert.IsTrue(FindRelated(expected, results), "Expected to find Note that matched filter."); Assert.IsFalse(FindRelated(not, results), "Expected to NOT find Note that doesn't match filter."); foreach (Note result in results) { Assert.AreEqual(expectedNote, result.InResponseTo); } }
protected virtual void SetupFilter(ICriteria crit, NoteFilter filter) { if (filter != null) { if (!string.IsNullOrEmpty(filter.Name)) { crit.Add(Restrictions.Like("Name", filter.Name, MatchMode.Anywhere)); } if (filter.DateCreated != null) { if (filter.DateCreated.From.HasValue) { crit.Add(Restrictions.Ge("DateCreated", filter.DateCreated.From.Value)); } if (filter.DateCreated.To.HasValue) { crit.Add(Restrictions.Le("DateCreated", filter.DateCreated.To.Value)); } } } }
private static IEnumerable <Note> FindNotes(NoteFilter noteFilter) { int offset = 0; int pageSize = 50; int totalSize = -1; do { if (totalSize > -1) { pageSize = Math.Min(pageSize, totalSize - offset); } NoteList noteList = _recipesStore.FindNotes(noteFilter, offset, pageSize); totalSize = noteList.TotalNotes; offset += noteList.Notes.Count; foreach (var note in noteList.Notes) { yield return(note); } } while (offset < totalSize); }
internal List <Entity.Notebook> ReadEvernoteNotes(String edamBaseUrl, AuthenticationResult authResult) { string authToken = authResult.AuthenticationToken; NoteStore.Client noteStore = EvernoteHelper.GetNoteStoreClient(edamBaseUrl, authResult.User); List <Notebook> notebooks = noteStore.listNotebooks(authToken); int nbCount = 1; foreach (Entity.Notebook enNotebook in enNotebooks) { int intProgress = Helper.GetNotebookProgress(nbCount++, enNotebooks.Count, 20, 60); UpdateProgress(intProgress); NoteFilter nf = new NoteFilter(); nf.NotebookGuid = enNotebook.Guid; NoteList nl = noteStore.findNotes(authToken, nf, 0, 500);//500 notes limit per notebook foreach (Note note in nl.Notes) { UpdateProgress(intProgress, "Retrieving " + enNotebook.Name + ", " + note.Title); Entity.Note enNote = new Entity.Note(); enNote.Title = note.Title; enNote.ShortDateString = note.Updated.ToString(); string enmlContent = noteStore.getNoteContent(authToken, note.Guid); enNote.LoadXml(enmlContent); if (enNotebook.Notes == null) { enNotebook.Notes = new List <Entity.Note>(); } enNotebook.Notes.Add(enNote); } } enNotebooks.Sort(delegate(Entity.Notebook p1, Entity.Notebook p2) { return(p1.Name.CompareTo(p2.Name)); }); return(enNotebooks); }
public override void StartSync(IRemoteStorageSyncPersistance data, List <INote> localnotes, List <INote> localdeletednotes) { _data = (EvernoteData)data; RefreshToken(); TTransport noteStoreTransport = new THttpClient(new Uri(@"https://sandbox.evernote.com/shard/s1/notestore")); //TODO use url from OAuth TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport); nsClient = new NoteStore.Client(noteStoreProtocol); var state = nsClient.getSyncState(_token); if (_data.SyncStateUpdateCount != state.UpdateCount) { _logger.Debug(EvernotePlugin.Name, string.Format("Remote has changed SyncState: {0} -> '{1}'", _data.SyncStateUpdateCount, state.UpdateCount)); NoteFilter filter = new NoteFilter(); filter.Order = (int)NoteSortOrder.UPDATED; NotesMetadataResultSpec spec = new NotesMetadataResultSpec(); spec.IncludeUpdateSequenceNum = true; bucket = nsClient.findNotesMetadata(_token, filter, 0, 9999, spec); _data.SyncStateUpdateCount = state.UpdateCount; } else { _logger.Debug(EvernotePlugin.Name, "Remote has not changed - no need for download - SyncState := " + state.UpdateCount); bucket = null; } remoteDirty = false; }
public static List <NoteDM> GetAll(NoteFilter filter) { List <NoteDM> notes = GetAll(); if (filter.MinDate != default(DateTime)) { notes = notes.Where(n => n.CreationDate >= filter.MinDate).ToList(); } if (filter.MaxDate != default(DateTime)) { notes = notes.Where(n => n.CreationDate <= filter.MaxDate).ToList(); } if (!string.IsNullOrWhiteSpace(filter.Authors)) { string[] authors = filter.Authors.Split(';'); notes = notes.Where(n => authors.Any(a => a == AccountDM.GetUserName(n.Author))).ToList(); } if (!string.IsNullOrWhiteSpace(filter.LikedBy)) { string[] likedBy = filter.LikedBy.Split(';'); notes = notes.Where(n => likedBy.Any(a => NoteDM.IsLiked(AccountDM.GetUserId(a), n.Id))).ToList(); } return(notes); }
/// <summary> /// Get notes filtered by the criteria specified in the passed in filter. /// </summary> /// <param name="filter">Limit the items returned. If null, then all items returned.</param> /// <returns>ICollection of items as specified in the filter.</returns> public ICollection <Note> Notes(NoteFilter filter) { return(Get <Note>(filter ?? new NoteFilter())); }
static Global() { business = new Business(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); filter = new NoteFilter(); }
public static void RunImpl(DependencyObject dispatcherOwner, ViewModel viewModel) { if (authToken == "your developer token") { ShowMessage(dispatcherOwner, "Please fill in your devleoper token in Sample.cs"); return; } // Instantiate the libraries to connect the service TTransport userStoreTransport = new THttpClient(new Uri(UserStoreUrl)); TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport); UserStore.Client userStore = new UserStore.Client(userStoreProtocol); // Check that the version is correct bool versionOK = userStore.checkVersion("Evernote EDAMTest (WP7)", Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR, Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR); InvokeOnUIThread(dispatcherOwner, () => viewModel.IsVersionOk = versionOK); Debug.WriteLine("Is my Evernote API version up to date? " + versionOK); if (!versionOK) { return; } // Get the URL used to interact with the contents of the user's account // When your application authenticates using OAuth, the NoteStore URL will // be returned along with the auth token in the final OAuth request. // In that case, you don't need to make this call. String noteStoreUrl = userStore.getNoteStoreUrl(authToken); TTransport noteStoreTransport = new THttpClient(new Uri(noteStoreUrl)); TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport); NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol); // Listing all the user's notebook List <Notebook> notebooks = noteStore.listNotebooks(authToken); Debug.WriteLine("Found " + notebooks.Count + " notebooks:"); InvokeOnUIThread(dispatcherOwner, () => { foreach (var notebook in notebooks) { viewModel.Notebooks.Add(notebook); } }); // Find the default notebook Notebook defaultNotebook = notebooks.Single(notebook => notebook.DefaultNotebook); // Printing the names of the notebooks foreach (Notebook notebook in notebooks) { Debug.WriteLine(" * " + notebook.Name); } // Listing the first 10 notes in the default notebook NoteFilter filter = new NoteFilter { NotebookGuid = defaultNotebook.Guid }; NoteList notes = noteStore.findNotes(authToken, filter, 0, 10); InvokeOnUIThread(dispatcherOwner, () => { foreach (var note in notes.Notes) { viewModel.Notes.Add(note); } }); foreach (Note note in notes.Notes) { Debug.WriteLine(" * " + note.Title); } // Creating a new note in the default notebook Debug.WriteLine("Creating a note in the default notebook: " + defaultNotebook.Name); Note newNote = new Note { NotebookGuid = defaultNotebook.Guid, Title = "Test note from EDAMTest.cs", Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">" + "<en-note>Here's an Evernote test note<br/>" + "</en-note>" }; Note createdNote = noteStore.createNote(authToken, newNote); ShowMessage(dispatcherOwner, "Successfully created new note with GUID: " + createdNote.Guid); }
public void ContainsTag_AcceptsNullParameters() { NoteFilter filter = new NoteFilter(string.Empty, null); Assert.IsTrue(filter.ContainsTag(null)); }
public ActionResult Index(NoteFilter noteFilter, UserFilter userFilter, FetchOptions options) { var notes = noteRepository.Find(noteFilter, options); return(View(notes)); }
public static List <DisplayNoteVM> DisplayAll(NoteFilter filter) { return(Mapper.Map <List <DisplayNoteVM> >(GetAll(filter))); }