Exemple #1
0
        void connectToEvernote()
        {
            Console.WriteLine("Connecting to Evernote...");
            try {
                ENSession.SetSharedSessionDeveloperToken("S=s1:U=900da:E=151ab755e3b:C=14a53c43030:P=1cd:A=en-devtoken:V=2:H=a26c9a039a23f8a387534810682c5d7f",
                                                         "https://evernote.com/shard/s1/notestore");
                if (!ENSession.SharedSession.IsAuthenticated)
                {
                    ENSession.SharedSession.AuthenticateToEvernote();
                    Console.WriteLine("Got EN Connection");
                }
                else
                {
                    Console.WriteLine("Authenticated");
                }
            } catch (Exception e) {
                Console.WriteLine(e.Message);
            }

            List <ENSessionFindNotesResult> myNotesList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch("tag:книга tag:"),
                                                                                            null, ENSession.SearchScope.All,
                                                                                            ENSession.SortOrder.RecentlyUpdated, 20);

            if (myNotesList.Count > 0)
            {
                foreach (ENSessionFindNotesResult result in myNotesList)
                {
                    // Each ENSessionFindNotesResult has a noteRef along with other important metadata.
                    Console.WriteLine("Found note with title: " + result.Title);
                }
            }
        }
Exemple #2
0
 private void InitializeEvernote()
 {
     ENSession.SetSharedSessionConsumerKey(Properties.Settings.Default.ConsumerKey, Properties.Settings.Default.ConsumerSecret, EVERNOTE_SANDBOX_HOST);
     if (ENSession.SharedSession.IsAuthenticated == false)
     {
         ENSession.SharedSession.AuthenticateToEvernote();
     }
 }
        private string GetUserInfos(AccessToken accessToken)
        {
            ENSession.SetSharedSessionDeveloperToken(accessToken.Token, accessToken.NoteStoreUrl);
            var session = new ENSession();

            session.PerformPostAuthentication();
            return(session.UserDisplayName);
        }
Exemple #4
0
        public static void Create()
        {
            string authToken = System.Configuration.ConfigurationManager.AppSettings["authToken"];

            EvernoteReadOnlyTagsException.Assert(!string.IsNullOrEmpty(authToken), "No auth token configured.");

            string url = System.Configuration.ConfigurationManager.AppSettings["URL"];

            EvernoteReadOnlyTagsException.Assert(!string.IsNullOrEmpty(url), "No URL configured.");

            ENSessionAdvanced.SetSharedSessionDeveloperToken(authToken, url);
            if (ENSession.SharedSession.IsAuthenticated == false)
            {
                ENSession.SharedSession.AuthenticateToEvernote();
            }

            // BUG: this will always be true in the current Evernote SDK :(
            EvernoteReadOnlyTagsException.Assert(ENSession.SharedSession.IsAuthenticated, "Authentication failed");

            session = ENSession.SharedSession;
        }
Exemple #5
0
 public void SetSharedSessionConsumerKey(string sessionConsumerKey, string sessionConsumerSecret, string sessionHost = null)
 {
     ENSession.SetSharedSessionConsumerKey(sessionConsumerKey, sessionConsumerSecret, sessionHost);
 }
Exemple #6
0
 new public static void SetSharedSessionDeveloper(string sessionDeveloperToken, string sessionNoteStoreUrl)
 {
     ENSession.ENSessionInterfaceType = InterfaceType.Advanced;
     ENSession.SetSharedSessionDeveloper(sessionDeveloperToken, sessionNoteStoreUrl);
 }
Exemple #7
0
 new public static void SetSharedSessionConsumerKey(string sessionConsumerKey, string sessionConsumerSecret, string sessionHost = null)
 {
     ENSession.ENSessionInterfaceType = InterfaceType.Advanced;
     ENSession.SetSharedSessionConsumerKey(sessionConsumerKey, sessionConsumerSecret, sessionHost);
 }
        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 void SetSharedSessionDeveloperToken(string sessionDeveloperToken, string sessionNoteStoreUrl)
 {
     ENSession.SetSharedSessionDeveloperToken(sessionDeveloperToken, sessionNoteStoreUrl);
 }
Exemple #10
0
 private void Form1_Load(object sender, EventArgs e)
 {
     ENSession.SetSharedSessionDeveloperToken(Properties.Resources.ResourceManager.GetString("Token"),
                                              Properties.Resources.ResourceManager.GetString("StoreUrl"));
 }