Exemplo n.º 1
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.º 2
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.º 3
0
        /// <summary>
        /// Evernoteにファイルをアップロードします
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uploadButton_Click(object sender, RoutedEventArgs e)
        {
            FileList list = this.DataContext as FileList;

            try
            {
                foreach (var f in list.FileNames)
                {
                    ENNote resourceNote = new ENNote();
                    resourceNote.Title   = "My test note with a resource";
                    resourceNote.Content = ENNoteContent.NoteContentWithString("Hello, resource!");
                    byte[]     file     = File.ReadAllBytes(f);
                    FileInfo   fInfo    = new FileInfo(f);
                    ENResource resource = new ENResource(file, MimeTypeMap.GetMimeType(fInfo.Extension), fInfo.Name);
                    resourceNote.Resources.Add(resource);
                    ENNoteRef resourceRef = ENSession.SharedSession.UploadNote(resourceNote, null);
                }
            }
            catch (Exception ex)
            {
                ModernDialog.ShowMessage("アップロード中にエラーが発生しました。", "お知らせ", MessageBoxButton.OK);
                return;
            }
            ModernDialog.ShowMessage("アップロードが完了しました。", "お知らせ", MessageBoxButton.OK);
        }
Exemplo n.º 4
0
        private void butLeer_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                if (ENSession.SharedSession.IsAuthenticated == false)
                {
                    ENSession.SharedSession.AuthenticateToEvernote();
                }
                if (!ENSession.SharedSession.IsAuthenticated)
                {
                    throw new Exception("No autenticado");
                }

                string textToFind = "";

                List <ENNotebook> myNotebookList = ENSession.SharedSession.ListNotebooks();
                cbMostrar.Enabled = false;
                textBox1.Text     = "";
                textBox2.Text     = "";
                _plain            = "";
                _cifrado          = "";
                string texto_nota = "";

                foreach (ENNotebook en in myNotebookList)
                {
                    List <ENSessionFindNotesResult> myResultsList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch(textToFind), en,
                                                                                                      ENSession.SearchScope.All, ENSession.SortOrder.RecentlyUpdated, 500);

                    foreach (ENSessionFindNotesResult note in myResultsList)
                    {
                        if (note.Title.Equals(tbNota.Text))
                        {
                            _noteBook   = en;
                            _noteRef    = note.NoteRef;
                            _note       = ENSession.SharedSession.DownloadNote(note.NoteRef);
                            texto_nota += _note.TextContent;
                        }
                    }
                    Application.DoEvents();
                }
                if (texto_nota.Length > 0)
                {
                    _plain            = StringCipher.Decrypt(texto_nota, tbContrasenia.Text);
                    _cifrado          = texto_nota;
                    textBox1.Text     = _cifrado;
                    textBox2.Text     = _plain;
                    cbMostrar.Enabled = true;
                    cbMostrar.Checked = true;
                    textBox2.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Leer Nota", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            Cursor = Cursors.Default;
        }
Exemplo n.º 5
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.º 6
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);
                }
            }
        }
        public static void CreateSampleNote(bool readOnly, string tag)
        {
            EvernoteConnection.Create();

            ENNote sampleNote = new ENNote();

            if (readOnly)
            {
                List <string> tags = new List <string>();
                tags.Add(tag);
                sampleNote.TagNames = tags;
                sampleNote.Title    = "My read-only note";
            }
            else
            {
                sampleNote.Title = "My writeable note";
            }

            sampleNote.Content = ENNoteContent.NoteContentWithString("Hello, world! " + DateTime.Now);
            ENNoteRef noteRef = EvernoteConnection.CurrentSession.UploadNote(sampleNote, null);
        }
Exemplo n.º 8
0
 ///**
 // *  Retrieves a note store client appropriate for accessing the note pointed to by the note ref.
 // *  Useful for "bridging" between the high-level and EDAM APIs.
 // *
 // *  @param noteRef A valid note ref.
 // *
 // *  @return A client for the note store that contains the note ref's note.
 // */
 new public ENNoteStoreClient NoteStoreForNoteRef(ENNoteRef noteRef)
 {
     return(base.NoteStoreForNoteRef(noteRef));
 }
Exemplo n.º 9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Be sure to put your own consumer key and consumer secret here.
            ENSession.SetSharedSessionConsumerKey("your key", "your secret");

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

            // Get a list of all notebooks in the user's account.
            List <ENNotebook> myNotebookList = ENSession.SharedSession.ListNotebooks();

            // Create a new note (in the user's default notebook) with some plain text content.
            ENNote myPlainNote = new ENNote();

            myPlainNote.Title   = "My plain text note";
            myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello, world!");
            ENNoteRef myPlainNoteRef = ENSession.SharedSession.UploadNote(myPlainNote, null);

            // Share this new note publicly.  "shareUrl" is the public URL to distribute to access the note.
            string shareUrl = ENSession.SharedSession.ShareNote(myPlainNoteRef);

            // Create a new note (in the user's default notebook) with some HTML content.
            ENNote myFancyNote = new ENNote();

            myFancyNote.Title   = "My first note";
            myFancyNote.Content = ENNoteContent.NoteContentWithSanitizedHTML("<p>Hello, world - <i>this</i> is a <b>fancy</b> note - and here is a table:</p><br /> <br/><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\"><tr><td>Red</td><td>Green</td></tr><tr><td>Blue</td><td>Yellow</td></tr></table>");
            ENNoteRef myFancyNoteRef = ENSession.SharedSession.UploadNote(myFancyNote, null);

            // Delete the HTML content note we just created.
            ENSession.SharedSession.DeleteNote(myFancyNoteRef);

            // Create a new note with a resource.
            ENNote myResourceNote = new ENNote();

            myResourceNote.Title   = "My test note with a resource";
            myResourceNote.Content = ENNoteContent.NoteContentWithString("Hello, resource!");
            byte[]     myFile     = StreamFile("<complete path and filename of a JPG file on your computer>"); // Be sure to replace this with a real JPG file
            ENResource myResource = new ENResource(myFile, "image/jpg", "My First Picture.jpg");

            myResourceNote.Resources.Add(myResource);
            ENNoteRef myResourceRef = ENSession.SharedSession.UploadNote(myResourceNote, null);

            // Search for some text across all notes (i.e. personal, shared, and business).
            // Change the Search Scope parameter to limit the search to only personal, shared, business - or combine flags for some combination.
            string textToFind = "some text to find*";
            List <ENSessionFindNotesResult> myNotesList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch(textToFind), null, ENSession.SearchScope.All, ENSession.SortOrder.RecentlyUpdated, 500);
            int personalCount = 0;
            int sharedCount   = 0;
            int businessCount = 0;

            foreach (ENSessionFindNotesResult note in myNotesList)
            {
                if (note.NoteRef.Type == ENNoteRef.ENNoteRefType.TypePersonal)
                {
                    personalCount++;
                }
                else if (note.NoteRef.Type == ENNoteRef.ENNoteRefType.TypeShared)
                {
                    sharedCount++;
                }
                else if (note.NoteRef.Type == ENNoteRef.ENNoteRefType.TypeBusiness)
                {
                    businessCount++;
                }
            }

            if (myNotesList.Count > 0)
            {
                // Given a NoteRef instance, download that note.
                ENNote myDownloadedNote = ENSession.SharedSession.DownloadNote(myNotesList[0].NoteRef);

                // Serialize a NoteRef.
                byte[] mySavedRef = myNotesList[0].NoteRef.AsData();
                // And deserialize it.
                ENNoteRef newRef = ENNoteRef.NoteRefFromData(mySavedRef);

                // Download the thumbnail for a note; then display it on this app's form.
                byte[] thumbnail = ENSession.SharedSession.DownloadThumbnailForNote(myNotesList[0].NoteRef, 120);
                try
                {
                    MemoryStream ms = new MemoryStream(thumbnail, 0, thumbnail.Length);
                    ms.Position = 0;
                    System.Drawing.Image image1 = System.Drawing.Image.FromStream(ms, false, false);
                    pictureBoxThumbnail.Image = image1;
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
 public string EvernoteNoteLink(ENNoteRef noteRef)
 {
         string shardId = ShardIdForNoteRef(noteRef);
         return String.Format("evernote:///view/{0}/{1}/{2}/{2}/", UserID, shardId, noteRef.Guid);
 }
			///**
			// *  Retrieves a note store client appropriate for accessing the note pointed to by the note ref.
			// *  Useful for "bridging" between the high-level and EDAM APIs.
			// *
			// *  @param noteRef A valid note ref.
			// *
			// *  @return A client for the note store that contains the note ref's note.
			// */
            new public ENNoteStoreClient NoteStoreForNoteRef(ENNoteRef noteRef)
            {
                return base.NoteStoreForNoteRef(noteRef);
            }
Exemplo n.º 12
0
            public string EvernoteNoteLink(ENNoteRef noteRef)
            {
                string shardId = ShardIdForNoteRef(noteRef);

                return(String.Format("evernote:///view/{0}/{1}/{2}/{2}/", UserID, shardId, noteRef.Guid));
            }