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());
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }