private Note GetNote()
        {
            int pageSize = 1;

            NoteFilter filter = new NoteFilter();
            filter.Words = "intitle:\"EvernoteAPIからの検索テスト用ノート(画像あり)\"";

            NoteList notes = mNoteStore.findNotes(mAuthToken, filter, 0, pageSize);

            if (notes.TotalNotes < 1)
            {
                Console.WriteLine("エラー");
                Console.WriteLine("該当件数:" + notes.TotalNotes);
                throw new ApplicationException("ノートが取得できませんでした。");
            }

            Note note = notes.Notes[0];

            // findNotesで取得するノートには、ノートの本文やリソースが含まれていないので個別に取得しなおす。
            // 第4引数がtrueだとリソースを含んだノートが取得できる
            // 第6引数はResourceAlternateData (位置情報など)の有無
            Note fullNote = mNoteStore.getNote(mAuthToken, note.Guid,
                true, true, false, false);

            return fullNote;
        }
        private void FindTitle()
        {
            NoteFilter filter = new NoteFilter();
            filter.Words = "intitle:\"EvernoteAPIからの検索テスト用ノート(画像あり)\"";

            int pageSize = 10;

            NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
            spec.IncludeTitle = true;

            NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

            WriteNoteList(notes);
        }
        public void Run()
        {
            int pageSize = 10;

            NoteFilter filter = new NoteFilter();
            filter.Order = (int)NoteSortOrder.UPDATED;

            NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
            spec.IncludeTitle = true;

            NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

            Console.WriteLine("最も直近に変更されたノートの検索");
            Console.WriteLine("該当件数:" + notes.TotalNotes);
            foreach (NoteMetadata note in notes.Notes)
            {
                Console.WriteLine(" * " + note.Title);
            }
        }
        public void Run()
        {
            int pageSize = 10;

            NoteFilter filter = new NoteFilter();
            filter.Words = "elephant";

            NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
            spec.IncludeTitle = true;

            NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

            Console.WriteLine("特定の単語を含むノートの検索");
            Console.WriteLine("該当件数:" + notes.TotalNotes);
            foreach (NoteMetadata note in notes.Notes)
            {
                Console.WriteLine(" * " + note.Title + ", " + note.Guid);
            }
        }
Exemplo n.º 5
0
        public ISearchResults GetNotesMetaList(string searchString, NoteSortOrder sortOrder, bool ascending, int resultsPage, int pageSize)
        {
            NoteFilter noteFilter = new NoteFilter();
            noteFilter.Words = searchString;
            noteFilter.Order = (int)sortOrder;
            noteFilter.Ascending = ascending;

            NotesMetadataResultSpec resultsSpec = new NotesMetadataResultSpec();
            resultsSpec.IncludeTitle = true;
            resultsSpec.IncludeCreated = true;
            resultsSpec.IncludeNotebookGuid = true;
            resultsSpec.IncludeUpdated = true;
            resultsSpec.IncludeAttributes = true;
            resultsSpec.IncludeTagGuids = true;
            resultsSpec.IncludeContentLength = true;

            NotesMetadataList noteMetadataList;

            try {
                if (resultsPage < 1) resultsPage = 1;
                if (pageSize > 100) pageSize = 100;

                noteMetadataList = noteStore.findNotesMetadata(credentials.AuthToken, noteFilter, (resultsPage - 1) * pageSize, pageSize, resultsSpec);
            }
            catch (EDAMUserException)
            {
                throw new EvernoteServiceSDK1AuthorisationException();
            }

            List<ENNoteMetadataINoteMetadataAdapter> notesMetaWrapperList =
                noteMetadataList.Notes.ConvertAll(noteMeta => new ENNoteMetadataINoteMetadataAdapter(noteMeta));

            return new SearchResults() {
                        NotesMetadata = notesMetaWrapperList.ToList<INoteMetadata>(),
                        TotalResults = noteMetadataList.TotalNotes
                    };
        }
Exemplo n.º 6
0
        public void Read(TProtocol iprot)
        {
            TField field;

            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        NoteGuid = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.String)
                    {
                        PlainText = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.Struct)
                    {
                        Filter = new NoteFilter();
                        Filter.Read(iprot);
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 4:
                    if (field.Type == TType.String)
                    {
                        ReferenceUri = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
Exemplo n.º 7
0
    public static void Main(string[] args)
    {
        // Developer token for Evernote API
        String authToken = "S=s1:U=2261f:E=13eccfa5d71:C=13775493171:P=1cd:A=en-devtoken:H=fe7ee8dac619c7d380a0f9f3731a8698";

        String evernoteHost = "sandbox.evernote.com";

        Uri userStoreUrl = new Uri("https://" + evernoteHost + "/edam/user");
        TTransport userStoreTransport = new THttpClient(userStoreUrl);
        TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport);
        UserStore.Client userStore = new UserStore.Client(userStoreProtocol);

        FNHSessionManager<NoteEntry> sessionManager = new FNHSessionManager<NoteEntry>(FNHSessionManager<NoteEntry>.DatabaseType.MySQL);
        FNHRepository<NoteEntry> repository = new FNHRepository<NoteEntry>(sessionManager);

        bool versionOK =
            userStore.checkVersion("Evernote EDAMTest (C#)",
               Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR,
               Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR);
        Console.WriteLine("Is my Evernote API version up to date? " + versionOK);
        if (!versionOK) {
            return;
        }

        // Get the URL used to interact with the contents of the user's account
        // When your application authenticates using OAuth, the NoteStore URL will
        // be returned along with the auth token in the final OAuth request.
        // In that case, you don't need to make this call.
        String noteStoreUrl = userStore.getNoteStoreUrl(authToken);

        TTransport noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
        TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
        NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol);

        // Lists all of the notebooks in the user's account with a notebook count
        List<Notebook> notebooks = noteStore.listNotebooks(authToken);
        Console.WriteLine("Found " + notebooks.Count + " notebooks:");
        foreach (Notebook notebook in notebooks) {
            Console.WriteLine("  * " + notebook.Name);
        }

        //The offset represents the index of the first note that is to be returned
        int offset = 0;

        //maxNotes represents the number of note that is to be returned
        int maxNotes = 15;

        //NoteFilter is a struct that contains a list of criteria you can search notes for.
        //In this app, NoteFilter.Words will be used to return notes containing a certain string.
        NoteFilter filter = new NoteFilter();

        Console.WriteLine();
        Console.WriteLine("What word do you want to search through the notes for?");
        Console.WriteLine("Enter word: ");
        filter.Words = Console.ReadLine();
        //filter.Words = "business";

        //Creates a new NoteList struct, which returns a list of individual notes out of a larger set of them
        NoteList noteList = new NoteList();

        //This finds all notes containing the word that was given by the user
        noteList = noteStore.findNotes(authToken, filter, offset, maxNotes);

        //This stores the Guids of the notes containing the word
        ArrayList guidList = new ArrayList();

        // For each note in the list of notes...
        foreach (Note fetchedNote in noteList.Notes)
        {
            //Console.WriteLine("  * " + fetchedNote.Guid);

            // Add guid to list
            guidList.Add(fetchedNote.Guid);
        }

        // For each guid in the list...
        foreach (String Guid in guidList)
        {
            // Get the contents of the matching notes
            String text = noteStore.getNoteContent(authToken, Guid);

            // Then split the contents by line
            string[] split = Regex.Split(text, "\\n");

            Console.WriteLine();

            int MAX = split.Length;

            String line1;
            String line2;
            String line3;

            // This for-loop cycles through each line in the array of lines and tests if the line contains the word.
            // If so, it sets the note Guid as well as the surrounding lines as properties to a new Entry object.

            for (int n = 0; n < MAX; n++)
            {
                Boolean b = split[n].Contains(filter.Words);

                if (b == true)
                {
                    line2 = split[n];
                    line1 = split[n - 1];
                    line3 = split[n + 1];

                    Entry postgresEntry = new Entry();
                    postgresEntry.setGuid(Guid);
                    postgresEntry.setLine1(line1);
                    postgresEntry.setLine2(line2);
                    postgresEntry.setLine3(line3);

                    Console.WriteLine("Note GUID: " + postgresEntry.getGuid());
                    Console.WriteLine();
                    postgresEntry.displayLines();
                    postgresEntry.InsertRow();
                    Console.WriteLine();
                    //postgresEntry.getLastInsertedRow();

                    NoteEntry mysqlNote = new NoteEntry();
                    mysqlNote.Guid = Guid;
                    mysqlNote.Line1 = line1;
                    mysqlNote.Line2 = line2;
                    mysqlNote.Line3 = line3;

                    repository.Create(mysqlNote);
                }
            }
        }

        Console.WriteLine();
        Console.WriteLine("These lines have been saved to a Postgresql database using ODBC.");
        Console.WriteLine("They have also been saved to a MySQL database using Fluent NHibernate.");
        Console.WriteLine();
        Console.WriteLine("Which row do you want to retrieve from the MySQL database?");
        String id = Console.ReadLine();
        int num = int.Parse(id);
        NoteEntry noteEntry = repository.RetrieveById(num);

        Console.WriteLine("This is entry " + num + " retrieved from the MySQL database...");
        Console.WriteLine();
        Console.WriteLine("GUID: " + noteEntry.Guid);
        Console.WriteLine("Line 1: " + noteEntry.Line1);
        Console.WriteLine("Line 2: " + noteEntry.Line2);
        Console.WriteLine("Line 3: " + noteEntry.Line3);
        Console.WriteLine();

        Console.WriteLine("Click ENTER to continue...");
        Console.ReadLine();
    }
Exemplo n.º 8
0
 /// <summary>
 /// Performs a search of the Notes in the User’s account based on a configurable filter, returning a paginated subset.
 /// </summary>
 public NoteList FindNotes(NoteFilter filter, int offset, int maxNotes)
 {
     lock (this)
         using (var httpClient = GetHttpClient())
         {
             return GetNoteStoreClient(httpClient).findNotes(this.authToken, filter, offset, maxNotes);
         }
 }
Exemplo n.º 9
0
 public void send_findNoteCounts(string authenticationToken, NoteFilter filter, bool withTrash)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("findNoteCounts", TMessageType.Call, seqid_));
   findNoteCounts_args args = new findNoteCounts_args();
   args.AuthenticationToken = authenticationToken;
   args.Filter = filter;
   args.WithTrash = withTrash;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT || NETFX_CORE
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
Exemplo n.º 10
0
      public NoteCollectionCounts findNoteCounts(string authenticationToken, NoteFilter filter, bool withTrash)
      {
        #if !SILVERLIGHT && !NETFX_CORE
        send_findNoteCounts(authenticationToken, filter, withTrash);
        return recv_findNoteCounts();

        #else
        var asyncResult = Begin_findNoteCounts(null, null, authenticationToken, filter, withTrash);
        return End_findNoteCounts(asyncResult);

        #endif
      }
Exemplo n.º 11
0
 public void send_findNotesMetadata(string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("findNotesMetadata", TMessageType.Call, seqid_));
   findNotesMetadata_args args = new findNotesMetadata_args();
   args.AuthenticationToken = authenticationToken;
   args.Filter = filter;
   args.Offset = offset;
   args.MaxNotes = maxNotes;
   args.ResultSpec = resultSpec;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT || NETFX_CORE
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
Exemplo n.º 12
0
      public NotesMetadataList findNotesMetadata(string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
      {
        #if !SILVERLIGHT && !NETFX_CORE
        send_findNotesMetadata(authenticationToken, filter, offset, maxNotes, resultSpec);
        return recv_findNotesMetadata();

        #else
        var asyncResult = Begin_findNotesMetadata(null, null, authenticationToken, filter, offset, maxNotes, resultSpec);
        return End_findNotesMetadata(asyncResult);

        #endif
      }
Exemplo n.º 13
0
 public void send_findNotes(string authenticationToken, NoteFilter filter, int offset, int maxNotes)
 {
     oprot_.WriteMessageBegin(new TMessage("findNotes", TMessageType.Call, seqid_));
     findNotes_args args = new findNotes_args();
     args.AuthenticationToken = authenticationToken;
     args.Filter = filter;
     args.Offset = offset;
     args.MaxNotes = maxNotes;
     args.Write(oprot_);
     oprot_.WriteMessageEnd();
     oprot_.Transport.Flush();
 }
Exemplo n.º 14
0
 public void send_findNoteCounts(string authenticationToken, NoteFilter filter)
 {
     oprot_.WriteMessageBegin(new TMessage("findNoteCounts", TMessageType.Call, seqid_));
     findNoteCounts_args args = new findNoteCounts_args();
     args.AuthenticationToken = authenticationToken;
     args.Filter = filter;
     args.Write(oprot_);
     oprot_.WriteMessageEnd();
     oprot_.Transport.Flush();
 }
        public List<Note> FindNotes(string word, int pageSize)
        {
            try {
                NoteFilter filter = new NoteFilter();
                filter.Words = word;
                NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
                spec.IncludeTitle = true;

                NotesMetadataList notes = mNoteStore.findNotesMetadata(mAuthToken, filter, 0, pageSize, spec);

                List<Note> list = new List<Note>();
                foreach (NoteMetadata note in notes.Notes)
                {
                    // findNotesMetadataで取得するノートには、ノートの本文やリソースが含まれていないので個別に取得しなおす。
                    // 第4引数がtrueだとリソースを含んだノートが取得できる
                    // 第6引数はResourceAlternateData (位置情報など)の有無
                    Note fullNote = mNoteStore.getNote(mAuthToken, note.Guid,
                        true, true, false, false);
                    list.Add(fullNote);
                }

                return list;
            }
            catch (EDAMUserException ex)
            {
                throw new ApplicationException("Evernoteアクセスに失敗しました。"
                    + "ErrorCode=" + ex.ErrorCode
                    + ", Parameter=" + ex.Parameter
                    + ", EvernoteHost=" + mEvernoteHost,
                    ex);
            }
        }
Exemplo n.º 16
0
        public static void RunImpl(object state)
        {
            if (authToken == "your developer token") {
            {
                ShowMessage("Please fill in your devleoper token in Sample.cs");
                return;
            }

            // Instantiate the libraries to connect the service
            TTransport userStoreTransport = new THttpClient(new Uri(UserStoreUrl));
            TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport);
            UserStore.Client userStore = new UserStore.Client(userStoreProtocol);

            // Check that the version is correct
            bool versionOK =
                userStore.checkVersion("Evernote EDAMTest (WP7)",
                   Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR,
                   Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR);
            InvokeOnUIThread(() => ViewModel.TheViewModel.VersionOK = versionOK);
            Debug.WriteLine("Is my Evernote API version up to date? " + versionOK);
            if (!versionOK)
            {
                return;
            }

            // Get the URL used to interact with the contents of the user's account
            // When your application authenticates using OAuth, the NoteStore URL will
            // be returned along with the auth token in the final OAuth request.
            // In that case, you don't need to make this call.
            String noteStoreUrl = userStore.getNoteStoreUrl(authToken);

            TTransport noteStoreTransport = new THttpClient(new Uri(authResult.NoteStoreUrl));
            TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
            NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol);

            // Listing all the user's notebook
            List<Notebook> notebooks = noteStore.listNotebooks(authToken);
            Debug.WriteLine("Found " + notebooks.Count + " notebooks:");
            InvokeOnUIThread(() => notebooks.ForEach(notebook => ViewModel.TheViewModel.Notebooks.Add(notebook)));

            // Find the default notebook
            Notebook defaultNotebook = notebooks.Single(notebook => notebook.DefaultNotebook);

            // Printing the names of the notebooks
            foreach (Notebook notebook in notebooks)
            {
                Debug.WriteLine("  * " + notebook.Name);
            }

            // Listing the first 10 notes in the default notebook
            NoteFilter filter = new NoteFilter { NotebookGuid = defaultNotebook.Guid };
            NoteList notes = noteStore.findNotes(authToken, filter, 0, 10);
            InvokeOnUIThread(() => notes.Notes.ForEach(note => ViewModel.TheViewModel.Notes.Add(note)));
            foreach (Note note in notes.Notes)
            {
                Debug.WriteLine("  * " + note.Title);
            }

            // Creating a new note in the default notebook
            Debug.WriteLine("Creating a note in the default notebook: " + defaultNotebook.Name);

            Note newNote = new Note
                            {
                                NotebookGuid = defaultNotebook.Guid,
                                Title = "Test note from EDAMTest.cs",
                                Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                                          "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">" +
                                          "<en-note>Here's an Evernote test note<br/>" +
                                          "</en-note>"
                            };

            Note createdNote = noteStore.createNote(authToken, newNote);

            ShowMessage("Successfully created new note with GUID: " + createdNote.Guid);
        }
Exemplo n.º 17
0
 public IAsyncResult Begin_findNotesMetadata(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
 {
   return send_findNotesMetadata(callback, state, authenticationToken, filter, offset, maxNotes, resultSpec);
 }
Exemplo n.º 18
0
 public NoteCollectionCounts findNoteCounts(string authenticationToken, NoteFilter filter)
 {
     send_findNoteCounts(authenticationToken, filter);
     return recv_findNoteCounts();
 }
Exemplo n.º 19
0
 public IAsyncResult send_findNotesMetadata(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, int offset, int maxNotes, NotesMetadataResultSpec resultSpec)
Exemplo n.º 20
0
 public NoteList findNotes(string authenticationToken, NoteFilter filter, int offset, int maxNotes)
 {
     send_findNotes(authenticationToken, filter, offset, maxNotes);
     return recv_findNotes();
 }
Exemplo n.º 21
0
 public IAsyncResult Begin_findNoteCounts(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, bool withTrash)
 {
   return send_findNoteCounts(callback, state, authenticationToken, filter, withTrash);
 }
Exemplo n.º 22
0
 public void Read(TProtocol iprot)
 {
     TField field;
     iprot.ReadStructBegin();
     while (true)
     {
       field = iprot.ReadFieldBegin();
       if (field.Type == TType.Stop) {
     break;
       }
       switch (field.ID)
       {
     case 1:
       if (field.Type == TType.String) {
     this.authenticationToken = iprot.ReadString();
     this.__isset.authenticationToken = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.Struct) {
     this.filter = new NoteFilter();
     this.filter.Read(iprot);
     this.__isset.filter = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 3:
       if (field.Type == TType.I32) {
     this.offset = iprot.ReadI32();
     this.__isset.offset = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 4:
       if (field.Type == TType.I32) {
     this.maxNotes = iprot.ReadI32();
     this.__isset.maxNotes = true;
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
Exemplo n.º 23
0
 public IAsyncResult send_findNoteCounts(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, bool withTrash)
Exemplo n.º 24
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.String) {
           AuthenticationToken = iprot.ReadString();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Filter = new NoteFilter();
           Filter.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.I32) {
           Offset = iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 4:
         if (field.Type == TType.I32) {
           MaxNotes = iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 5:
         if (field.Type == TType.Struct) {
           ResultSpec = new NotesMetadataResultSpec();
           ResultSpec.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Exemplo n.º 25
0
 /// <summary>
 /// Performs a search based on a configurable filter, returning the number of Notes that would match this filter for each Notebook and Tag.
 /// </summary>
 public NoteCollectionCounts FindNoteCounts(NoteFilter filter)
 {
     lock (this)
         using (var httpClient = GetHttpClient())
         {
             return GetNoteStoreClient(httpClient).findNoteCounts(this.authToken, filter);
         }
 }
Exemplo n.º 26
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 1:
         if (field.Type == TType.String) {
           AuthenticationToken = iprot.ReadString();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Filter = new NoteFilter();
           Filter.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.Bool) {
           WithTrash = iprot.ReadBool();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Exemplo n.º 27
0
        public static void RunImpl(object state)
        {
            // Username and password of the Evernote user account to access
            const string username = ""; // Enter your username here
            const string password = ""; // Enter your password here

            if ((ConsumerKey == String.Empty) || (ConsumerSecret == String.Empty))
            {
                ShowMessage("Please provide your API key in Sample.cs");
                return;
            }
            if ((username == String.Empty) || (password == String.Empty))
            {
                ShowMessage("Please provide your username and password in Sample.cs");
                return;
            }

            // Instantiate the libraries to connect the service
            TTransport userStoreTransport = new THttpClient(new Uri(UserStoreUrl));
            TProtocol userStoreProtocol = new TBinaryProtocol(userStoreTransport);
            UserStore.Client userStore = new UserStore.Client(userStoreProtocol);

            // Check that the version is correct
            bool versionOK =
                userStore.checkVersion("C# EDAMTest",
                   Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR,
                   Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR);
            InvokeOnUIThread(() => ViewModel.TheViewModel.VersionOK = versionOK);
            Debug.WriteLine("Is my EDAM protocol version up to date? " + versionOK);
            if (!versionOK)
            {
                return;
            }

            // Now we are going to authenticate
            AuthenticationResult authResult;
            try
            {
                authResult = userStore.authenticate(username, password, ConsumerKey, ConsumerSecret);
            }
            catch (EDAMUserException ex)
            {
                HandleAuthenticateException(EvernoteHost, ConsumerKey, ex);
                return;
            }
            Debug.WriteLine("We are connected to the service");

            // User object received after authentication
            User user = authResult.User;
            String authToken = authResult.AuthenticationToken;
            InvokeOnUIThread(() => ViewModel.TheViewModel.AuthToken = authToken);

            Debug.WriteLine("Authentication successful for: " + user.Username);
            Debug.WriteLine("Authentication token = " + authToken);

            // Creating the URL of the NoteStore based on the user object received
            String noteStoreUrl = EDAMBaseUrl + "/edam/note/" + user.ShardId;

            TTransport noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
            TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
            NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol);

            // Listing all the user's notebook
            List<Notebook> notebooks = noteStore.listNotebooks(authToken);
            Debug.WriteLine("Found " + notebooks.Count + " notebooks:");
            InvokeOnUIThread(() => notebooks.ForEach(notebook => ViewModel.TheViewModel.Notebooks.Add(notebook)));

            // Find the default notebook
            Notebook defaultNotebook = notebooks.Single(notebook => notebook.DefaultNotebook);

            // Printing the names of the notebooks
            foreach (Notebook notebook in notebooks)
            {
                Debug.WriteLine("  * " + notebook.Name);
            }

            // Listing the first 10 notes in the default notebook
            NoteFilter filter = new NoteFilter { NotebookGuid = defaultNotebook.Guid };
            NoteList notes = noteStore.findNotes(authToken, filter, 0, 10);
            InvokeOnUIThread(() => notes.Notes.ForEach(note => ViewModel.TheViewModel.Notes.Add(note)));
            foreach (Note note in notes.Notes)
            {
                Debug.WriteLine("  * " + note.Title);
            }

            // Creating a new note in the default notebook
            Debug.WriteLine("Creating a note in the default notebook: " + defaultNotebook.Name);

            Note newNote = new Note
                            {
                                NotebookGuid = defaultNotebook.Guid,
                                Title = "Test note from EDAMTest.cs",
                                Content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                                          "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">" +
                                          "<en-note>Here's an Evernote test note<br/>" +
                                          "</en-note>"
                            };

            Note createdNote = noteStore.createNote(authToken, newNote);

            ShowMessage("Successfully created new note with GUID: " + createdNote.Guid);
        }
Exemplo n.º 28
0
 public IAsyncResult Begin_findNoteOffset(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, string guid)
 {
   return send_findNoteOffset(callback, state, authenticationToken, filter, guid);
 }
Exemplo n.º 29
0
		public List<ENSessionFindNotesResult> FindNotes(ENNoteSearch noteSearch, ENNotebook notebook, SearchScope scope, SortOrder order, int maxResults)
		{
			if (!IsAuthenticated)
			{
				throw new ENAuthExpiredException();
			}

			// App notebook scope is internally just an "all" search, because we don't a priori know where the app
			// notebook is. There's some room for a fast path in this flow if we have a saved linked record to a
			// linked app notebook, but that case is likely rare enough to prevent complexifying this code for.
			if (scope.HasFlag(SearchScope.AppNotebook))
			{
				scope = SearchScope.All;
			}

			// Validate the scope and sort arguments.
			if (notebook != null && scope != SearchScope.None)
			{
				ENSDKLogger.ENSDKLogError("No search scope necessary if notebook provided.");
				scope = SearchScope.None;
			}
			else if (notebook == null && scope == SearchScope.None)
			{
				ENSDKLogger.ENSDKLogError("Search scope or notebook must be specified. Defaulting to personal scope.");
				scope = SearchScope.DefaultScope;
			}

			bool requiresLocalMerge = false;
			if (scope != SearchScope.None)
			{
				// Check for multiple scopes. Because linked scope can subsume multiple linked notebooks, that *always* triggers
				// the multiple scopes. If not, then both personal and business must be set together.
				if ((scope.HasFlag(SearchScope.Personal) && scope.HasFlag(SearchScope.Business)) || scope.HasFlag(SearchScope.PersonalLinked))
				{
					// If we're asked for multiple scopes, relevance is not longer supportable (since we
					// don't know how to combine relevance on the client), so default to updated date,
					// which is probably the closest proxy to relevance.
					if (order.HasFlag(SortOrder.Relevance))
					{
						ENSDKLogger.ENSDKLogError("Cannot sort by relevance across multiple search scopes. Using update date.");
						order = (EvernoteSDK.ENSession.SortOrder)EN_FLAG_CLEAR(order, SortOrder.Relevance);
						order = (EvernoteSDK.ENSession.SortOrder)EN_FLAG_SET(order, SortOrder.RecentlyUpdated);
					}
					requiresLocalMerge = true;
				}
			}

			NotesMetadataResultSpec resultSpec = new NotesMetadataResultSpec();
			resultSpec.IncludeNotebookGuid = true;
			resultSpec.IncludeTitle = true;
			resultSpec.IncludeCreated = true;
			resultSpec.IncludeUpdated = true;
			resultSpec.IncludeUpdateSequenceNum = true;

			NoteFilter noteFilter = new NoteFilter();
			noteFilter.Words = noteSearch.SearchString;

			if (order.HasFlag(SortOrder.Title))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.TITLE;
			}
			else if (order.HasFlag(SortOrder.RecentlyCreated))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.CREATED;
			}
			else if (order.HasFlag(SortOrder.RecentlyUpdated))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.UPDATED;
			}
			else if (order.HasFlag(SortOrder.Relevance))
			{
				noteFilter.Order = (System.Int32)NoteSortOrder.RELEVANCE;
			}

			// "Normal" sort is ascending for titles, and descending for dates and relevance.
			bool sortAscending = order.HasFlag(SortOrder.Title) ? true : false;
			if (order.HasFlag(SortOrder.Reverse))
			{
				sortAscending = !sortAscending;
			}
			noteFilter.Ascending = sortAscending;

			if (notebook != null)
			{
				noteFilter.NotebookGuid = notebook.Guid;
			}

			// Set up context
			ENSessionFindNotesContext context = new ENSessionFindNotesContext();
			context.scopeNotebook = notebook;
			context.scope = scope;
			context.order = order;
			context.noteFilter = noteFilter;
			context.resultSpec = resultSpec;
			context.maxResults = maxResults;
			context.findMetadataResults = new List<NoteMetadata>();
			context.requiresLocalMerge = requiresLocalMerge;
			context.sortAscending = sortAscending;

			// If we have a scope notebook, we already know what notebook the results will appear in.
			// If we don't have a scope notebook, then we need to query for all the notebooks to determine
			// where to search.
			if (context.scopeNotebook == null)
			{
				context = FindNotes_ListNotebooks(context);
				return context.results;
			}

			context = FindNotes_FindInPersonalScope(context);
			return context.results;
		}
Exemplo n.º 30
0
      public int findNoteOffset(string authenticationToken, NoteFilter filter, string guid)
      {
        #if !SILVERLIGHT && !NETFX_CORE
        send_findNoteOffset(authenticationToken, filter, guid);
        return recv_findNoteOffset();

        #else
        var asyncResult = Begin_findNoteOffset(null, null, authenticationToken, filter, guid);
        return End_findNoteOffset(asyncResult);

        #endif
      }
Exemplo n.º 31
0
 public IAsyncResult send_findNoteOffset(AsyncCallback callback, object state, string authenticationToken, NoteFilter filter, string guid)
        public void Read(TProtocol iprot)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                TField field;
                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            NoteGuid = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.String)
                        {
                            PlainText = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.Struct)
                        {
                            Filter = new NoteFilter();
                            Filter.Read(iprot);
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 4:
                        if (field.Type == TType.String)
                        {
                            ReferenceUri = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 5:
                        if (field.Type == TType.String)
                        {
                            Context = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 6:
                        if (field.Type == TType.String)
                        {
                            CacheKey = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }