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); }
private void ConfigureSession() { if (string.IsNullOrWhiteSpace(_settings.SessionNoteStoreUrl)) { throw new Exception("Evernote Note Store Url has not been configured."); } if (string.IsNullOrWhiteSpace(_settings.SessionDeveloperToken)) { throw new Exception("Evernote Developer token has not been configured."); } _logger.Debug("Authenticating to EverNote"); try { ENSessionAdvanced.SetSharedSessionDeveloperToken(_settings.SessionDeveloperToken, _settings.SessionNoteStoreUrl); ENSessionAdvanced.SharedSession.SourceApplication = "NoteSync"; if (!ENSessionAdvanced.SharedSession.IsAuthenticated) { ENSessionAdvanced.SharedSession.AuthenticateToEvernote(); } } catch (Exception e) { _logger.Warn(e); } _logger.Info("Authenticated to EverNote"); }
public EvernoteRepository(ILogger logger, EvernoteSettings settings) { _settings = settings; _logger = logger; ConfigureSession(); _session = ENSessionAdvanced.SharedSession; }
private static void AuthenticateSession(string sessionDeveloperToken, string sessionNoteStoreUrl) { ENSessionAdvanced.SetSharedSessionDeveloperToken(sessionDeveloperToken, sessionNoteStoreUrl); if (ENSessionAdvanced.SharedSession.IsAuthenticated == false) { ENSessionAdvanced.SharedSession.AuthenticateToEvernote(); } }
private void Connect() { var s = Settings.Load(); // 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(s.Host, s.Key, s.Server); if (ENSession.SharedSession.IsAuthenticated == false) { ENSession.SharedSession.AuthenticateToEvernote(); } }
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; }
public void SetSharedSessionDeveloper(string sessionDeveloperToken, string sessionNoteStoreUrl) { ENSessionAdvanced.SetSharedSessionDeveloper(sessionDeveloperToken, sessionNoteStoreUrl); }
public void SetSharedSessionConsumerKey(string sessionConsumerKey, string sessionConsumerSecret, string sessionHost = null) { ENSessionAdvanced.SetSharedSessionConsumerKey(sessionConsumerKey, sessionConsumerSecret, sessionHost); }
static void Main(string[] args) { string developerToken; if (args.Length > 0) { developerToken = args[0]; } else { Console.WriteLine("Enter developer token:"); developerToken = Console.ReadLine(); } string notestoreUrl; if (args.Length > 1) { notestoreUrl = args[1]; } else { Console.WriteLine("Enter note store URL:"); notestoreUrl = Console.ReadLine(); } string outputPath; if (args.Length > 2) { outputPath = args[2]; } else { Console.WriteLine("Enter output path:"); outputPath = Console.ReadLine(); } ENSessionAdvanced.SetSharedSessionDeveloperToken( developerToken, notestoreUrl); var session = ENSessionAdvanced.SharedSession; var notebooks = session.PrimaryNoteStore.ListLinkedNotebooks(); LinkedNotebook recipes = notebooks.First(notebook => notebook.ShareName == "recipes"); _recipesStore = session.NoteStoreForLinkedNotebook(recipes); var recipesByTag = new Dictionary <string, IList <string> >(); foreach (var note in FindNotes(new NoteFilter())) { foreach (string tagName in GetTagNames(note)) { IList <string> recipeNames; if (recipesByTag.TryGetValue(tagName, out recipeNames)) { string title = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(note.Title); recipeNames.Add(title); } else { recipeNames = new List <string> { note.Title }; recipesByTag[tagName] = recipeNames; } } } using (var writer = new StreamWriter(outputPath)) { WriteRecipesByTag(recipesByTag, writer); } }