private IEnumerator ConfirmAddCommentInternal() { yield return(m_appDirector.VerifyInternetConnection()); string commentText = m_commentNewText.GetComponentInChildren <Text>().text; yield return(m_backEndAPI.Comment_CreateComment(m_postId, commentText)); if (m_backEndAPI.IsLastAPICallSuccessful()) { CommentResult newCommentResult = new CommentResult(); newCommentResult.commentId = m_backEndAPI.GetCommentResult().data.id.ToString(); newCommentResult.text = m_backEndAPI.GetCommentResult().data.attributes.text.ToString(); newCommentResult.edited = m_backEndAPI.GetCommentResult().data.attributes.edited; newCommentResult.userId = m_user.m_id; newCommentResult.userHandle = m_user.m_handle; m_commentResults.Add(newCommentResult); DisplayCommentResultsOnItems(); m_currImageSphere.AddToCommentCount(1); string commentCountText = m_currImageSphere.GetCommentCount().ToString() + (m_currImageSphere.GetCommentCount() == 1 ? " comment" : " comments"); m_commentCountInList.GetComponentInChildren <Text>().text = commentCountText; m_commentCountInSummary.GetComponentInChildren <Text>().text = commentCountText; } }
public async Task InvalidCommentIsNotAnalyzed() { var nonAnalyzedComment = new CommentResult( new Comment("this-is-non-analyzed-post", "I have not been analyzed", "Non analyzed")); var analyzedComment = new CommentResult( new Comment("this-is-analyzed-post", "I have been analyzed", "Analyzed")); var commentFormMock = new Mock <ICommentForm>(); commentFormMock.Setup(x => x.HasErrors) .Returns(true); commentFormMock.Setup(x => x.TryCreateComment()) .Returns(nonAnalyzedComment); var commentFormFactoryMock = new Mock <ICommentFormFactory>(); commentFormFactoryMock.Setup(x => x.CreateCommentForm(It.IsAny <IFormCollection>())) .Returns(commentFormMock.Object); var textAnalyzerMock = new Mock <ITextAnalyzer>(); textAnalyzerMock.Setup(x => x.CanAnalyze) .Returns(true); textAnalyzerMock.Setup(x => x.AnalyzeAsync(It.IsAny <Comment>())) .ReturnsAsync(analyzedComment); ICommentFactory commentFactory = new CommentFactory( commentFormFactoryMock.Object, textAnalyzerMock.Object); var actualComment = await commentFactory.CreateFromFormAsync(Mock.Of <IFormCollection>()) .ConfigureAwait(false); Assert.Equal(nonAnalyzedComment, actualComment); }
internal void LoadedComment() { string commentUrl = commentUrl = CommonData.GetMoreVideoComment + "&videoId=" + VideoId + "&pageCount=" + CommentPageCount; System.Diagnostics.Debug.WriteLine("获取剧集评论 url:" + commentUrl); HttpHelper.httpGet(commentUrl, (ar) => { string result = HttpHelper.SyncResultTostring(ar); if (result != null) { CommentResult commentResult = null; try { commentResult = JsonConvert.DeserializeObject <CommentResult>(result); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("LoadChannelCompleted json 解析错误" + ex.Message); App.JsonError(result); } if (commentResult == null) { JsonError(result); } else if (commentResult.err_code == HttpHelper.rightCode && commentResult.data.Count > 0) { if (CallbackManager.currentPage != null) { CallbackManager.currentPage.Dispatcher.BeginInvoke(() => { if (CommentPageCount == 1) { Comments = commentResult.data; } else if (CommentPageCount > 1) { Comments.AddRange(commentResult.data); } if (Comments.Count == 30 * CommentPageCount) { MoreCommentVisibility = Visibility.Visible; } else { MoreCommentVisibility = Visibility.Collapsed; } _commentPageCount++; }); } } } else { //App.ShowToast("获取数据失败,请检查网络或重试"); } }); }
internal static void FillComment(ObjectComment comment, CommentResult result) { comment.ComId = result.COM_ID; comment.ObjId = result.OBJ_ID; comment.UsrId = result.USR_ID; comment.Username = result.UserName; comment.Text = result.COM_Text; comment.Status = (CommentStatus)result.COM_Status; comment.CreateDate = result.COM_InsertedDate; comment.UpdateDate = result.COM_UpdatedDate; comment.ObjType = result.OBJ_Type; }
private void StoreCaption() { Posts.Post postViewed = m_posts.GetPostFromID(m_postId); CommentResult newCommentResult = new CommentResult(); newCommentResult.commentId = m_postId; newCommentResult.text = postViewed.caption; newCommentResult.edited = postViewed.edited; newCommentResult.userId = postViewed.userId; newCommentResult.userHandle = postViewed.userHandle; m_commentResults.Add(newCommentResult); }
public async Task <JsonResult> AddCommentAsync(Guid postID, Guid contentID, [FromForm] CommentResult commentResult) { if (postID == Guid.Empty) { throw new ArgumentNullException("PostID"); } if (contentID == Guid.Empty) { throw new ArgumentNullException("ContentID"); } if (!this.User.Identity.IsAuthenticated && string.IsNullOrEmpty(commentResult.UserEmail)) { throw new UnauthorizedAccessException("User not Authenticated and UserEmail is empty also."); } Comment comment = new Comment(); comment.ID = commentResult.CommentID = Guid.NewGuid(); comment.PostID = postID; comment.ParentCommentID = commentResult.ParentCommentID; comment.IsDeleted = false; comment.CreateAt = DateTime.Now; comment.Content = commentResult.Comment; comment.ContentID = contentID; comment.IsDeleted = false; if (this.User.Identity.IsAuthenticated) { var userID = this.User.GetUserID(); var userName = this.User.Identity.Name; comment.UserID = userID; comment.UserName = userName; } else if (!string.IsNullOrEmpty(commentResult.UserEmail)) { comment.UserEmail = commentResult.UserEmail; comment.UserName = commentResult.UserName; } string strSql = @" INSERT INTO comments(ID, Content, ContentID, CreateAt, IsDeleted, ParentCommentID, PostID, UserEmail, UserID, UserName) VALUES (@ID, @Content, @ContentID, @CreateAt, @IsDeleted, @ParentCommentID, @PostID, @UserEmail, @UserID, @UserName);"; await this.db.BlogDb.ExecuteAsync(strSql, comment); return(Json(commentResult)); }
public static ObjectComment Load(Guid comId) { ObjectComment comment = new ObjectComment(); try { CSBooster_DataContext cdc = new CSBooster_DataContext(Helper.GetSiemeConnectionString()); CommentResult result = cdc.hisp_Comments_GetComment(comId).ElementAtOrDefault(0); if (result != null) { FillComment(comment, result); } } catch { } return(comment); }
public static ObjectComment Load(Guid comId) { ObjectComment comment = new ObjectComment(); try { CSBooster_DataContext cdc = new CSBooster_DataContext(ConfigurationManager.ConnectionStrings["CSBoosterConnectionString"].ConnectionString); CommentResult result = cdc.hisp_Comments_GetComment(comId).ElementAtOrDefault(0); if (result != null) { FillComment(comment, result); } } catch { } return(comment); }
public JsonResult GetInformationGroup(int examId) { string functionName = System.Reflection.MethodBase.GetCurrentMethod().Name; try { //Check id exam exist in the database if (!_examRepository.ExamExist(examId)) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.examNotFound)); return(Json(MessageResult.GetMessage(MessageType.EXAM_NOT_FOUND))); } if (!ModelState.IsValid) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.notFound)); return(Json(MessageResult.GetMessage(MessageType.NOT_FOUND))); } List <CommentEntity> listComment = _commentRepository.GetCommentByExamId(examId); List <CommentResult> listResult = new List <CommentResult>(); foreach (var comment in listComment) { CommentResult result = new CommentResult(); AccountEntity account = _accountRepository.GetAccountById(comment.AccountId); result.name = account.FullName; result.dateTime = comment.DateTimeComment; result.content = comment.Content; listResult.Add(result); } return(Json(listResult)); } catch (Exception ex) { Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(ex.Message)); return(Json(MessageResult.ShowServerError(ex.Message))); } }
private void StoreNewCommentResults() { VReelJSON.Model_Comments comments = m_backEndAPI.GetCommentsResult(); if (comments != null) { foreach (VReelJSON.CommentData commentData in comments.data) { CommentResult newCommentResult = new CommentResult(); newCommentResult.commentId = commentData.id.ToString(); newCommentResult.text = commentData.attributes.text.ToString(); newCommentResult.edited = commentData.attributes.edited; newCommentResult.userId = commentData.relationships.user.data.id; newCommentResult.userHandle = Helper.GetHandleFromIDAndUserData(comments.included, newCommentResult.userId); m_commentResults.Add(newCommentResult); } m_nextPageOfResults = null; if (comments.meta.next_page) { m_nextPageOfResults = comments.meta.next_page_id; } } }
private async Task ReplyComment(UserAuthorization user, CommentResult comment) { try { var actorUrn = comment.Actor; Random r = new Random(); var createCommentRequest = new CreateCommentRequest { Actor = actorUrn, Message = new CommentMessage { Text = "test 1" + r.Next() }, ParentComment = comment.Urn }; var response = await api.SocialActions.CreateCommentOnUrnAsync(user, comment.Urn, createCommentRequest); } catch (Exception) { } }
public async Task OnPostAsync([FromRoute] Guid postID, [FromRoute] Guid contentID, [FromForm] CommentResult commentResult) { if (postID == Guid.Empty) { throw new ArgumentNullException("PostID"); } if (contentID == Guid.Empty) { throw new ArgumentNullException("ContentID"); } if (!this.User.Identity.IsAuthenticated && string.IsNullOrEmpty(commentResult.UserEmail)) { throw new UnauthorizedAccessException("User not Authenticated and UserEmail is empty also."); } Comment comment = new Comment(); comment.ID = commentResult.CommentID = Guid.NewGuid(); comment.PostID = postID; comment.ParentCommentID = commentResult.ParentCommentID; comment.IsDeleted = false; comment.CreateAt = DateTime.Now; comment.Content = commentResult.Comment; comment.ContentID = contentID; comment.IsDeleted = false; if (this.User.Identity.IsAuthenticated) { var userID = this.User.GetUserID(); var userName = this.User.Identity.Name; comment.UserID = userID; comment.UserName = userName; } else if (!string.IsNullOrEmpty(commentResult.UserEmail)) { comment.UserEmail = commentResult.UserEmail; comment.UserName = commentResult.UserName; } string strSql = @" INSERT INTO comments(ID, Content, ContentID, CreateAt, IsDeleted, ParentCommentID, PostID, UserEmail, UserID, UserName) VALUES (@ID, @Content, @ContentID, @CreateAt, @IsDeleted, @ParentCommentID, @PostID, @UserEmail, @UserID, @UserName);"; await this.db.BlogDb.ExecuteAsync(strSql, comment); strSql = @"SELECT * FROM comments WHERE ID = @ID AND IsDeleted = 0;"; this.Comment = await this.db.BlogDb.QueryFirstOrDefaultAsync <Comment>(strSql, new { comment.ID }); this.ViewData["ContentID"] = contentID; }