public Response <NoteContent> AddContent(TokenRequest <AddContentRequest> request) { Response <NoteContent> response = new Response <NoteContent>(); try { if (request == null || request.RequestData == null) { response.Code = -1; response.Description = "请求参数为空!"; response.ResponseData = null; } else { NoteContentManager manager = new NoteContentManager(request.Version); ManagerResult <NoteContent> result = manager.AddContent(request.RequestData.NoteContent); response.GetResultInfo(result); response.ResponseData = result.ResultData; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); response.Code = -1; } return(response); }
private void ReloadNote(int noteId) { NoteManager noteManager = new NoteManager(SysConfigInfo.WebServerBaseAddr); Response <Note> response = noteManager.GetNoteById(new GetNoteByIdRequest() { Id = noteId }, new TokenCheckInfo() { UserId = SysConfigInfo.OnlineUser.Id, Token = SysConfigInfo.OnlineUser.Token, Version = SysConfigInfo.Version }); if (response == null) { MessageBox.Show("找不到指定的服务!"); } else { if (!response.HasAccessed) { MessageBox.Show("身份验证未通过,请重新登录!"); return; } if (response.Code < 0) { MessageBox.Show("服务端异常"); } else { if (response.ResponseData == null) { MessageBox.Show("指定的Note不存在!"); } else { NoteApprovedRecordManager noteApprovedRecordManager = new NoteApprovedRecordManager(SysConfigInfo.WebServerBaseAddr); this.note = response.ResponseData; this.titleTextBox.Text = this.note.Title; this.remarkTextBox.Text = this.note.Remark; this.lastBrowsedDateTextBox.Text = this.note.LastBrowsedTime.ToString(); this.browsedTimesLabel.Text = string.Format("浏览({0})", this.note.BrowsedTimes); this.approveLabel.Text = string.Format("赞({0})", this.note.ApprovedTimes); this.commentLabel.Text = string.Format("评论({0})", this.note.CommentCount); Response <NoteBrowsedRecord> browsedResponse = noteManager.NoteGetBrowsed(new NoteGetBrowsedRequest() { NoteId = this.note.Id, UserId = SysConfigInfo.OnlineUser.Id }, new TokenCheckInfo() { UserId = SysConfigInfo.OnlineUser.Id, Token = SysConfigInfo.OnlineUser.Token, Version = SysConfigInfo.Version }); if (browsedResponse != null && browsedResponse.HasAccessed && browsedResponse.Code == 0 && browsedResponse.ResponseData != null) { MessageBox.Show("浏览成功!"); } NoteContentManager noteContentManager = new NoteContentManager(SysConfigInfo.WebServerBaseAddr); Response <List <NoteContent> > contentsResponse = noteContentManager.GetNoteContentByNoteId(new GetNoteContentsByNoteIdRequest() { NoteId = this.note.Id }, new TokenCheckInfo() { Token = SysConfigInfo.OnlineUser.Token, UserId = SysConfigInfo.OnlineUser.Id, Version = SysConfigInfo.Version }); this.noteContents = contentsResponse.ResponseData; if (this.noteContents != null && this.noteContents.Count != 0) { this.contentTextBox.Text = this.noteContents[0].Content; } } } } }