// Evernote has a bunch of junk in it's xml tomboy doesn't care about, and tomboy
        // also requires some specific tags. So strip out evernote's and add tomboys
        // TODO - Really, Really need to convert the html-like tags, not just strip them
        // TODO -  so that we can keep things like bulleted lists, font sizes, etc
        public string CreateTomboyNoteContent(Evernote.EDAM.Type.Note note)
        {
            string evernoteContent;

            try
            {
                evernoteContent = _noteStore.getNoteContent(_authToken, note.Guid);
            }
            catch (Exception e)
            {
                evernoteContent = "Could not retrieve Evernote Content";
            }
            ExportManager exportManager = new ExportManager(EvernoteToTomboyXSLTResourceName);
            string        tomboyContent;

            try
            {
                tomboyContent = exportManager.ApplyXSL(evernoteContent, note.Title, null, ValidationType.DTD);
            }
            catch (Exception e)
            {
                tomboyContent = "Evernote Export failed." +
                                " Please report a bug at http://bugzilla.gnome.org with the following: (strip out confidential information)" +
                                e + "\n" + note;
            }

            string content = TomboyHeader + "\n" + "<title>" + note.Title + "</title>" +
                             "<text xml:space=\"preserve\"><note-content version=\"0.1\">" + "\n";

            content += tomboyContent;
            content += "</note-content></text>\n";
            DateTime date;

            if (note.Updated > DateTime.MinValue.Ticks && note.Updated < DateTime.MaxValue.Ticks)
            {
                date = Epoch.Add(TimeSpan.FromTicks(note.Updated * 10000));
            }
            else
            {
                date = DateTime.Now;
            }
            content += "<last-change-date>" + date + "</last-change-date>\n";
            content += "<last-metadata-change-date>" + date + "</last-metadata-change-date>\n";
            if (note.Created > DateTime.MinValue.Ticks && note.Created < DateTime.MaxValue.Ticks)
            {
                date = Epoch.Add(TimeSpan.FromTicks(note.Created * 10000));
            }
            content += "<create-date>" + date + "</create-date>\n";

            content += "</note>";
            return(content);
        }
예제 #2
0
        /// <summary>
        /// Builds a note that can be displayed within Viq.
        /// </summary>
        /// <param name="note"></param>
        /// <param name="resolver"></param>
        /// <returns></returns>
        private NoteModel BuildNote(Note note, TextResolver resolver)
        {
            // we have a note so we need to get the full content - we will extract the text for now and maybe images
            string content = _Instance.getNoteContent(_authToken, note.Guid);

            // we have a new note - etl the data
            NoteModel newnote = new NoteModel();

            newnote.ExternalId   = new Guid(note.Guid);
            newnote.Title        = note.Title;
            newnote.Timestamp    = note.Updated;
            newnote.Text         = ParseContent(note, content, resolver);
            newnote.DateCreated  = DateTime.Now;
            newnote.DateModified = DateTime.Now;
            newnote.Notebook     = new Guid(note.NotebookGuid);

            return(newnote);
        }
예제 #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);
        }