Beispiel #1
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);
        }
Beispiel #2
0
        public void GetNotebooks(object arguments)
        {
            string[] inputs      = (string[])arguments;
            string   username    = inputs[0];
            string   password    = inputs[1];
            string   savePath    = inputs[2];
            string   edamBaseUrl = @"https://www.evernote.com";

            UserStore.Client userStore = EvernoteHelper.GetUserStoreClient(edamBaseUrl);
            if (EvernoteHelper.VerifyEDAM(userStore) == false)
            {
                return;
            }

            try
            {
                AuthenticationResult authResult = EvernoteHelper.Authenticate(username, password, consumerKey, consumerSecret, "www.evernote.com", userStore);
                enNotebooks = ReadEvernoteNotebooks(edamBaseUrl, authResult);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EnableControls(true);
                return;
            }

            if (rdoExportSelected.Checked)
            {
                NotebookSelection nbSelect = new NotebookSelection();
                nbSelect.ShowDialog(enNotebooks);
                enNotebooks = nbSelect.nbListKeep;
                if (enNotebooks.Count == 0)
                {
                    MessageBox.Show("There were no notebooks selected and will stop processing.", "Notebooks Not Selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EnableControls(true);
                    return;
                }
            }

            try
            {
                AuthenticationResult authResult = EvernoteHelper.Authenticate(username, password, consumerKey, consumerSecret, "www.evernote.com", userStore);
                enNotebooks = ReadEvernoteNotes(edamBaseUrl, authResult);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                EnableControls(true);
                return;
            }
            Create(arguments);
        }
Beispiel #3
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);
        }