コード例 #1
0
 /// <summary>
 /// 创建笔记 返回note的对象 还是传入参数的那个对象
 /// </summary>
 /// <returns></returns>
 public YDNote CreateNote(YDNote note)
 {
     var source = MultipartPostPart.CreateFormPart("source", note.source);
     var author = MultipartPostPart.CreateFormPart("author", note.author);
     var title = MultipartPostPart.CreateFormPart("title", note.title);
     var noteBook = MultipartPostPart.CreateFormPart("notebook", note.notebook);
     var content = MultipartPostPart.CreateFormPart("content", note.content);
     var multiparts = new List<MultipartPostPart>()
                          {
                              source,author,title,content,noteBook
                          };
     var request = Consumer.PrepareAuthorizedRequest(_createNoteEndPoint, this.AccessToken, multiparts);
     var response = Consumer.Channel.WebRequestHandler.GetResponse(request);
     string body = response.GetResponseReader().ReadToEnd();
     var newNote = JsonConvert.DeserializeObject<YDNote>(body);
     note.path = newNote.path;
     note = this.GetNote(newNote.path);
     return note;
 }
コード例 #2
0
 protected void Button6_Click(object sender, EventArgs e)
 {
     var youDao = new YDWebConsumer(YDAuthBaseInfo.ServiceDescription, this.TokenManager);
     var noteApi = new YDNoteAPI(youDao, this.AccessToken);
     var note = new YDNote()
                    {
                       source="",author = "kklldog",
                       content = "<content>内容</content><br/><finishtime>ttt</finishtime>",
                       notebook ="",title = "testNote1"
                    };
     var newNote = noteApi.CreateNote(note);
     this.lbl.Text = newNote.content + newNote.create_time;
 }
コード例 #3
0
        /// <summary>
        /// 移动笔记
        /// </summary>
        /// <param name="souceNote">笔记</param>
        /// <param name="target">目标笔记本</param>
        /// <returns>返回原来那个笔记的对象但是path替换为move过后的</returns>
        public YDNote MoveNote(YDNote souceNote, YDNoteBook target)
        {
            var extraData = new Dictionary<string, string>()
                                {
                                    { "notebook", target.path },
                                    {"path",souceNote.path}
                                };
            var request = Consumer.PrepareAuthorizedRequest(_moveNoteEndPoint, this.AccessToken, extraData);
            var response = Consumer.Channel.WebRequestHandler.GetResponse(request);
            string body = response.GetResponseReader().ReadToEnd();
            var newNote = JsonConvert.DeserializeObject<YDNote>(body);
            souceNote = this.GetNote(newNote.path);

            return souceNote;
        }
コード例 #4
0
 /// <summary>
 /// 修改笔记
 /// </summary>
 /// <param name="note"></param>
 public void UpdateNote(YDNote note)
 {
     var source = MultipartPostPart.CreateFormPart("source", note.source);
     var author = MultipartPostPart.CreateFormPart("author", note.author);
     var title = MultipartPostPart.CreateFormPart("title", note.title);
     var path = MultipartPostPart.CreateFormPart("path", note.path);
     var content = MultipartPostPart.CreateFormPart("content", note.content);
     var multiparts = new List<MultipartPostPart>()
                          {
                              source,author,title,content,path
                          };
     var request = Consumer.PrepareAuthorizedRequest(_updateNoteEndPoint, this.AccessToken, multiparts);
     try
     {
         Consumer.Channel.WebRequestHandler.GetResponse(request);
     }
     catch
     {
         throw new Exception("UPDATE NOTE FAILED");
     }
 }
コード例 #5
0
        /// <summary>
        /// 删除笔记
        /// </summary>
        /// <param name="note">笔记</param>
        public void DeleteNote(YDNote note)
        {
            var extraData = new Dictionary<string, string>()
                                {
                                    {"path",note.path}
                                };
            var request = Consumer.PrepareAuthorizedRequest(_deleteNoteEndPoint, this.AccessToken, extraData);
            try
            {
                Consumer.Channel.WebRequestHandler.GetResponse(request);
            }
            catch
            {

                throw new Exception("DELETE NOTE FAILED");
            }
        }