internal static ENNoteStoreClient NoteStoreClient(string url, string authenticationToken)
			{
				ENNoteStoreClient enClient = new ENNoteStoreClient();
				enClient.CachedNoteStoreUrl = url;
				enClient.CachedAuthenticationToken = authenticationToken;
				return enClient;
			}
Exemplo n.º 2
0
        private static void InteractiveRemoveReadOnlyTags()
        {
            List <ENSessionFindNotesResult> readOnlyNotes = FindNotes(READONLY_TAG_SEARCH);

            Console.WriteLine("all readonly notes: " + readOnlyNotes.Count);
            Debug.WriteLine("all readonly notes: " + readOnlyNotes.Count);

            foreach (ENSessionFindNotesResult readOnlyNote in readOnlyNotes)
            {
                Console.WriteLine(string.Format("Untag '{0}'?", readOnlyNote.Title));
                Console.Write("Y / N: ");

                if ("Y" == Console.ReadLine().ToUpper())
                {
                    ENNoteRef         noteRef   = readOnlyNote.NoteRef;
                    ENNoteStoreClient noteStore = ENSessionAdvanced.SharedSession.NoteStoreForNoteRef(noteRef);
                    List <string>     tagGuids  = noteStore.GetNoteTagNames(noteRef.Guid);
                    List <Tag>        tags      = noteStore.ListTags();
                    Tag  readOnlyTag            = tags.Find(x => x.Name.Contains(READONLY_TAG));
                    Note loadedNote             = noteStore.GetNote(noteRef.Guid, true, false, false, false);

                    loadedNote.TagGuids.Remove(readOnlyTag.Guid);
                    noteStore.UpdateNote(loadedNote);
                    Console.WriteLine("Removed readonly tag: " + readOnlyNote.Title);
                    Debug.WriteLine("Removed readonly tag: " + readOnlyNote.Title);
                }
                else
                {
                    Console.WriteLine("Skipped: " + readOnlyNote.Title);
                    Debug.WriteLine("Skipped: " + readOnlyNote.Title);
                }
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Supply your key using ENSessionAdvanced instead of ENEsssion, to indicate your use of the Advanced interface.
            // Be sure to put your own consumer key and consumer secret here.
            ENSessionAdvanced.SetSharedSessionConsumerKey("your key", "your secret");

            if (ENSession.SharedSession.IsAuthenticated == false)
            {
                ENSession.SharedSession.AuthenticateToEvernote();
            }

            // Create a note (in the user's default notebook) with an attribute set (in this case, the ReminderOrder attribute to create a Reminder).
            ENNoteAdvanced myNoteAdv = new ENNoteAdvanced();

            myNoteAdv.Title   = "Sample note with Reminder set";
            myNoteAdv.Content = ENNoteContent.NoteContentWithString("Hello, world - this note has a Reminder on it.");
            myNoteAdv.EdamAttributes["ReminderOrder"] = DateTime.Now.ToEdamTimestamp();
            ENNoteRef myRef = ENSession.SharedSession.UploadNote(myNoteAdv, null);

            // Now we'll create an EDAM Note.
            // First create the ENML content for the note.
            ENMLWriter writer = new ENMLWriter();

            writer.WriteStartDocument();
            writer.WriteString("Hello again, world.");
            writer.WriteEndDocument();
            // Create a note locally.
            Note myNote = new Note();

            myNote.Title   = "Sample note from the Advanced world";
            myNote.Content = writer.Contents.ToString();
            // Create the note in the service, in the user's personal, default notebook.
            ENNoteStoreClient store = ENSessionAdvanced.SharedSession.PrimaryNoteStore;
            Note resultNote         = store.CreateNote(myNote);
        }
Exemplo n.º 4
0
        private static void ResetUntaggedNotesToReadWrite()
        {
            // find notes with the contentClass but no tag
            List <ENSessionFindNotesResult> untaggedNotes = FindNotes(READONLY_NOTAG_CONTENT_CLASS_SEARCH);

            Console.WriteLine("untagged notes to reset to r/w: " + untaggedNotes.Count);
            Debug.WriteLine("untagged notes to reset to r/w: " + untaggedNotes.Count);

            // Clear the contentClass for anything without the ReadOnly tag
            foreach (ENSessionFindNotesResult noteToSetReadWrite in untaggedNotes)
            {
                ENNoteRef         noteRef   = noteToSetReadWrite.NoteRef;
                ENNoteStoreClient noteStore = ENSessionAdvanced.SharedSession.NoteStoreForNoteRef(noteRef);
                List <string>     tags      = noteStore.GetNoteTagNames(noteRef.Guid);
                Note loadedNote             = noteStore.GetNote(noteRef.Guid, true, false, false, false);

                loadedNote.Attributes.ContentClass = null;
                noteStore.UpdateNote(loadedNote);
            }
        }
Exemplo n.º 5
0
        private static void SetTaggedNotesToReadOnly()
        {
            // find notes with readonly tag but no contentClass
            List <ENSessionFindNotesResult> notesToSetReadOnly = FindNotes(READONLYTAG_NOCONTENTCLASS_SEARCH);

            Console.WriteLine("newly-tagged notes to mark readonly: " + notesToSetReadOnly.Count);
            Debug.WriteLine("newly-tagged notes to mark readonly: " + notesToSetReadOnly.Count);

            // add r/o contentClass to every found note (with r/o tag)
            foreach (ENSessionFindNotesResult noteToSetReadOnly in notesToSetReadOnly)
            {
                ENNoteRef         noteRef   = noteToSetReadOnly.NoteRef;
                ENNoteStoreClient noteStore = ENSessionAdvanced.SharedSession.NoteStoreForNoteRef(noteRef);
                Note loadedNote             = noteStore.GetNote(noteRef.Guid, true, false, false, false);
                if (null == loadedNote.Attributes.ContentClass)
                {
                    loadedNote.Attributes.ContentClass = READONLY_CONTENT_CLASS;
                    noteStore.UpdateNote(loadedNote);
                }
            }
        }