• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Api.CommentInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BBC.Dna.Api.CommentInfo的典型用法代码示例。如果您正苦于以下问题:C# CommentInfo类的具体用法?C# CommentInfo怎么用?C# CommentInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommentInfo类属于BBC.Dna.Api命名空间,在下文中一共展示了CommentInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CommentForum_BasicAddCommentWithStatsCheck

        public void CommentForum_BasicAddCommentWithStatsCheck()
		{
            CommentForum commentForum = new CommentForum
            {
                Id = Guid.NewGuid().ToString(),
                ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
                Title = "testCommentForum"
            };

            CommentForum result = CreateForum(commentForum);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.commentSummary.Total == 0);

            //add a comment 
            CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };

            CreateComment(comment, result);

            //get forum again
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.commentSummary.Total == 1);

            XmlDocument xStats = GetAllStatCounter();
            Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 3);
            
            //get forum again
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.commentSummary.Total == 1);
            xStats = GetAllStatCounter();
            Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 4);

		}
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:34,代码来源:CommentForumCachingAndStats.cs


示例2: CreateCommentforumToPost

 public static CommentForum CreateCommentforumToPost(bool allowAnonymousPosting, string title, string id, string text, string parentUri, string userName)
 {
     CommentForum postDataForum = new CommentForum();
     postDataForum.ParentUri = parentUri;
     postDataForum.Title = title;
     postDataForum.Id = id;
     postDataForum.allowNotSignedInCommenting = allowAnonymousPosting;
     postDataForum.commentList = new CommentsList();
     postDataForum.commentList.comments = new List<CommentInfo>();
     CommentInfo testCommentInfo = new CommentInfo();
     testCommentInfo.text = text;
     testCommentInfo.User.DisplayName = userName;
     postDataForum.commentList.comments.Add(testCommentInfo);
     return postDataForum;
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:15,代码来源:CommentForumTestUtils.cs


示例3: CreateTestForumAndComment

        public void CreateTestForumAndComment(ref CommentForum commentForum, ref CommentInfo returnedComment)
        {
            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();
            //create the forum
            if(string.IsNullOrEmpty(commentForum.Id))
            {
                commentForum = commentsHelper.CommentForumCreate("tests", Guid.NewGuid().ToString());
            }

            string text = "Functiontest Title" + Guid.NewGuid().ToString();
            string commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text>" +
                "</comment>", text);

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, commentForum.Id);
            // now get the response
            request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
            validator.Validate();

            //check the TextAsHtml element
            //string textAsHtml = xml.DocumentElement.ChildNodes[2].InnerXml;
            //Assert.IsTrue(textAsHtml == "<div class=\"dna-comment text\" xmlns=\"\">" + text + "</div>");

            returnedComment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
            Assert.IsTrue(returnedComment.text == text);
            Assert.IsNotNull(returnedComment.User);
            Assert.IsTrue(returnedComment.User.UserId == request.CurrentUserID);

            DateTime created = DateTime.Parse(returnedComment.Created.At);
            DateTime createdTest = BBC.Dna.Utils.TimeZoneInfo.GetTimeZoneInfo().ConvertUtcToTimeZone(DateTime.Now.AddMinutes(5));
            Assert.IsTrue(created < createdTest);//should be less than 5mins
            Assert.IsTrue(!String.IsNullOrEmpty(returnedComment.Created.Ago));
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:38,代码来源:CommentsNeroRatings_v1.cs


示例4: AddToCommentRepository

        private CommentInfo AddToCommentRepository(string commentForumUid, int conversationId, CommentInfo comment)
        {
            using (var reader = CreateReader("dna.AddComment"))
            {
                reader.AddParameter("bbcIdentityUserId", CallingUser.IdentityUserID);
                reader.AddParameter("commentForumId", commentForumUid);
                reader.AddParameter("commentText", comment.text);
                reader.AddParameter("trusetedSource", CallingUser.IsTrustedUser());
                reader.AddParameter("threadId", conversationId);
                reader.AddParameter("trustedSource", CallingUser.IsTrustedUser());
                reader.Execute();

                if(reader.HasRows && reader.Read())
                {
                    //fill in comment
                }
            }
            return comment;         
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:19,代码来源:Comments.cs


示例5: AddCommentToPreModerationQueue

 private int AddCommentToPreModerationQueue(string commentForumUid, int conversationId, CommentInfo comment, int modId)
 {
     using (var reader = CreateReader("dna.AddCommentToPreModerationQueue"))
     {
         reader.AddParameter("commentForumId", commentForumUid);
         reader.AddParameter("bbcIdentityUserId", CallingUser.IdentityUserID);
         reader.AddParameter("userName", CallingUser.UserName);
         reader.AddParameter("text", comment.text);
         reader.AddParameter("hash", GenerateHash(comment.text, commentForumUid, CallingUser.IdentityUserID));
         reader.AddParameter("threadId", conversationId);
         reader.AddParameter("subject", comment.Title);
         reader.Execute();
         if (reader.HasRows && reader.Read())
         {
             modId = reader.GetInt32NullAsZero("ModerationQueueId");
         }
     }
     return modId;
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:19,代码来源:Comments.cs


示例6: CommentListReadBySiteNameAndPrefix

        public void CommentListReadBySiteNameAndPrefix()
        {
            string prefix = "prefixtestsbycomments" + Guid.NewGuid().ToString();
            CommentForum commentForum = new CommentForum
            {
                Id = prefix + "_" + Guid.NewGuid().ToString(),
                ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
                Title = "testCommentForum"
            };
            

            //create the forum
            CommentForum result = _comments.CreateCommentForum(commentForum, site);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            //create the comment
            //set up test data
            for (int i = 0; i < 10; i++)
            {
                CommentInfo comment = new CommentInfo
                {
                    text = "this is a nunit generated comment."
                };
                comment.text += Guid.NewGuid().ToString();//have to randomize the string to post
                string IPAddress = String.Empty;
                Guid BBCUid = Guid.NewGuid();
                //normal user
                _comments.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList);
                _comments.CallingUser.CreateUserFromDnaUserID(TestUtils.TestUserAccounts.GetNormalUserAccount.UserID, site.SiteID);
                CommentInfo commentInfo = _comments.CreateComment(result, comment);
                Assert.IsTrue(commentInfo != null);
                Assert.IsTrue(commentInfo.ID > 0);
                Assert.IsTrue(commentInfo.text == comment.text);
            }


            //test good site
            CommentsList resultList = _comments.GetCommentsListBySite(site, prefix);
            Assert.IsTrue(resultList != null);
            Assert.IsTrue(resultList.TotalCount == 10);
            //test paging
            _comments.ItemsPerPage = 3;
            _comments.StartIndex = 5;
            resultList = _comments.GetCommentsListBySite(site, prefix);
            Assert.IsTrue(resultList != null);
            Assert.IsTrue(resultList.TotalCount == 10);
            Assert.IsTrue(resultList.ItemsPerPage == _comments.ItemsPerPage);
            Assert.IsTrue(resultList.StartIndex == _comments.StartIndex);

        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:52,代码来源:CommentForum.cs


示例7: CreateRatingThreadComment

        public Stream CreateRatingThreadComment(string ratingForumID, string threadID, string siteName, CommentInfo comment)
        {
            int id = 0;
            if (!Int32.TryParse(threadID, out id))
            {
                throw new DnaWebProtocolException(ApiException.GetError(ErrorType.InvalidThreadID));
            }
            CommentInfo ratingThreadCommentInfo = null;
            try
            {
                ISite site = GetSite(siteName);
                RatingForum ratingForumData = null;
                ratingForumData = _ratingObj.RatingForumReadByUID(ratingForumID, site);
                _ratingObj.CallingUser = GetCallingUser(site);
                ratingThreadCommentInfo = _ratingObj.RatingCommentCreate(ratingForumData, id, comment);

            }
            catch (ApiException ex)
            {
                throw new DnaWebProtocolException(ex);
            }
            return GetOutputStream(ratingThreadCommentInfo);

        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:24,代码来源:ReviewService.cs


示例8: SetupComment

 private CommentInfo SetupComment()
 {
     //create the comment
     CommentInfo comment = new CommentInfo
     {
         text = "this is a nunit generated comment."
     };
     comment.text += Guid.NewGuid().ToString();//have to randomize the string to post
     string IPAddress = String.Empty;
     Guid BBCUid = Guid.NewGuid();
     //normal user
     _comments.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList);
     _comments.CallingUser.CreateUserFromDnaUserID(TestUtils.TestUserAccounts.GetNormalUserAccount.UserID, site.SiteID);
     return comment;
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:15,代码来源:CommentForum.cs


示例9: CreateComment

        private CommentInfo CreateComment(CommentInfo info, CommentForum forum)
        {
            string commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
                "<text>{0}</text>" +
                "</comment>", info.text);

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();

            // Setup the request url
            string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, forum.Id);
            // now get the response
            request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            CommentInfo returnedComment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
            Assert.IsNotNull(returnedComment.User);
            Assert.IsTrue(returnedComment.User.UserId == request.CurrentUserID);

            return returnedComment;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:21,代码来源:CommentForumCachingAndStats.cs


示例10: CreateComment

        /// <summary>
        /// Creates a comment for the given comment forum id
        /// </summary>
        /// <param name="commentForum"></param>
        /// <param name="comment">The comment to add</param>
        /// <returns>The created comment object</returns>
        public CommentInfo CreateComment(Forum commentForum, CommentInfo comment)
        {
            ISite site = SiteList.GetSite(commentForum.SiteName);
            bool ignoreModeration;
            bool forceModeration;
            var notes = string.Empty;
            string profanityxml = string.Empty;
            
            List<Term> terms = null;

            ValidateComment(commentForum, comment, site, out ignoreModeration, out forceModeration, out notes, out terms);

            if (terms != null && terms.Count > 0)
            {
                profanityxml = new Term().GetProfanityXML(terms);
            }

            //create unique comment hash
            Guid guid = DnaHasher.GenerateCommentHashValue(comment.text, commentForum.Id, CallingUser.UserID);
            //add comment to db
            try
            {
                using (IDnaDataReader reader = CreateReader("commentcreate"))
                {
                    reader.AddParameter("commentforumid", commentForum.Id);
                    reader.AddParameter("userid", CallingUser.UserID);
                    if (commentForum.isContactForm)
                    {
                        reader.AddParameter("content", CONTACT_POST_TEXT);
                    }
                    else
                    {
                        reader.AddParameter("content", comment.text);
                    }
                    reader.AddParameter("hash", guid);
                    reader.AddParameter("forcemoderation", forceModeration);
                    //reader.AddParameter("forcepremoderation", (commentForum.ModerationServiceGroup == ModerationStatus.ForumStatus.PreMod?1:0));
                    reader.AddParameter("ignoremoderation", ignoreModeration);
                    reader.AddParameter("isnotable", CallingUser.IsUserA(UserTypes.Notable));
                    reader.AddParameter("applyprocesspremodexpirytime", comment.ApplyProcessPremodExpiryTime);

                    if (CallingUser.UserID != commentForum.NotSignedInUserId)
                    {//dont include as this is data protection
                        reader.AddParameter("ipaddress", IpAddress);
                        reader.AddParameter("bbcuid", BbcUid);
                    }

                    if (CallingUser.UserID == commentForum.NotSignedInUserId && comment.User != null && !String.IsNullOrEmpty(comment.User.DisplayName))
                    {//add display name for not signed in comment
                        reader.AddParameter("nickname", comment.User.DisplayName);
                    }
                    reader.AddIntReturnValue();
                    reader.AddParameter("poststyle", (int) comment.PostStyle);
                    if (!String.IsNullOrEmpty(notes))
                    {
                        reader.AddParameter("modnotes", notes);
                    }

                    if (false == string.IsNullOrEmpty(profanityxml))
                    {
                        reader.AddParameter("profanityxml", profanityxml);
                    }

                    reader.Execute();

                    if (reader.HasRows && reader.Read())
                    {
//all good - create comment
                        comment.PreModPostingsModId = reader.GetInt32NullAsZero("PreModPostingModId");
                        comment.IsPreModerated = (reader.GetInt32NullAsZero("IsPreModerated") == 1);
                        comment.hidden = (comment.IsPreModerated
                                              ? CommentStatus.Hidden.Hidden_AwaitingPreModeration
                                              : CommentStatus.Hidden.NotHidden);
                        comment.text = CommentInfo.FormatComment(comment.text, comment.PostStyle, comment.hidden, CallingUser.IsUserA(UserTypes.Editor));
                        var displayName = CallingUser.UserName;
                        if (CallingUser.UserID == commentForum.NotSignedInUserId && comment.User != null && !String.IsNullOrEmpty(comment.User.DisplayName))
                        {//add display name for not signed in comment
                            displayName = comment.User.DisplayName;
                        }
                        comment.User = UserReadByCallingUser(site);
                        comment.User.DisplayName = displayName;
                        comment.Created = new DateTimeHelper(DateTime.Now);

                        if (reader.GetInt32NullAsZero("postid") != 0)
                        {
// no id as it is may be pre moderated
                            comment.ID = reader.GetInt32NullAsZero("postid");
                            var replacement = new Dictionary<string, string>();
                            replacement.Add("sitename", site.SiteName);
                            replacement.Add("postid", comment.ID.ToString());
                            comment.ComplaintUri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                                            SiteList.GetSiteOptionValueString(site.SiteID, "General", "ComplaintUrl")
                                                                                            , replacement);

//.........这里部分代码省略.........
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:101,代码来源:Comments.cs


示例11: CommentForum_ComplaintHideComment

        public void CommentForum_ComplaintHideComment()
        {
            CommentForum commentForum = new CommentForum
            {
                Id = Guid.NewGuid().ToString(),
                ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
                Title = "testCommentForum"
            };

            CommentForum result = CreateForum(commentForum);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            Assert.IsTrue(result.commentSummary.Total == 0);

            //add a comment 
            CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };

            

            CreateComment(comment, result);

            //get forum again
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            Assert.IsTrue(result.commentSummary.Total == 1);

            // Now ste the closing date of the forum to something in the past.
            using (FullInputContext _context = new FullInputContext(true))
            {

                using (IDnaDataReader dataReader = _context.CreateDnaDataReader("hidepost"))
                {
                    dataReader.AddParameter("postid", result.commentList.comments[0].ID);
                    dataReader.AddParameter("hiddenid", 6);
                    dataReader.Execute();
                }
          
            }
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.commentList.comments[0].text == "This post has been removed.", "Comment not hidden!");
            Assert.IsTrue(result.commentList.comments[0].hidden == CommentStatus.Hidden.Removed_EditorComplaintTakedown);



        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:51,代码来源:CommentForumCachingAndStats.cs


示例12: CommentForum_PreMod_PassWithEdit

        public void CommentForum_PreMod_PassWithEdit()
        {
            CommentForum commentForum = new CommentForum
            {
                Id = Guid.NewGuid().ToString(),
                ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
                Title = "testCommentForum",
                ModerationServiceGroup = ModerationStatus.ForumStatus.PreMod
            };

            CommentForum result = CreateForum(commentForum);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            Assert.IsTrue(result.commentSummary.Total == 0);

            //add a comment 
            CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };

            

            CreateComment(comment, result);

            //get forum again
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.commentList.comments[0].hidden == CommentStatus.Hidden.Hidden_AwaitingPreModeration);
            Assert.IsTrue(result.commentList.comments[0].text == "This post is awaiting moderation.", "Comment not hidden!");
            Assert.IsTrue(result.commentSummary.Total == 1);


            string newText = " this is editted text";
            // Now ste the closing date of the forum to something in the past.
            ModerateComment(result.commentList.comments[0].ID, result.ForumID, BBC.Dna.Component.ModeratePosts.Status.PassedWithEdit, newText);

            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.commentList.comments[0].text == newText);
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:40,代码来源:CommentForumCachingAndStats.cs


示例13: CommentForum_ChangeCanWriteFlag

        public void CommentForum_ChangeCanWriteFlag()
        {
            CommentForum commentForum = new CommentForum
            {
                Id = Guid.NewGuid().ToString(),
                ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
                Title = "testCommentForum"
            };

            CommentForum result = CreateForum(commentForum);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            Assert.IsTrue(result.commentSummary.Total == 0);

            //add a comment 
            CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };



            CreateComment(comment, result);

            //get forum again
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            Assert.IsTrue(result.commentSummary.Total == 1);
            Assert.IsFalse(result.isClosed);

            // Now ste the closing date of the forum to something in the past.
            using (FullInputContext _context = new FullInputContext(true))
            {
                using (IDnaDataReader dataReader = _context.CreateDnaDataReader("updatecommentforumstatus"))
                {
                    dataReader.AddParameter("uid", result.Id);
                    dataReader.AddParameter("canwrite", 0);
                    dataReader.Execute();
                }
            }
            result = ReadForum(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.isClosed);

            //try and read it again as json - to check the isclosed forum flag is honoured.
            result = ReadForumJson(result.Id);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.isClosed);
            


        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:54,代码来源:CommentForumCachingAndStats.cs


示例14: CommentsBySite_BasicAddCommentWithStatsCheck

        public void CommentsBySite_BasicAddCommentWithStatsCheck()
        {
            CommentForum commentForum = new CommentForum
            {
                Id = Guid.NewGuid().ToString(),
                ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
                Title = "testCommentForum"
            };

            CommentForum result = CreateForum(commentForum);
            Assert.IsTrue(result != null);
            Assert.IsTrue(result.Id == commentForum.Id);
            Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
            Assert.IsTrue(result.Title == commentForum.Title);
            Assert.IsTrue(result.commentSummary.Total == 0);

            //get total for this site
            CommentsList list = ReadCommentsReadBySite("");
            Assert.IsTrue(list.TotalCount != 0);

            CommentsList listPrefix = ReadCommentsReadBySite(commentForum.Id.Substring(0, 4));
            Assert.IsTrue(listPrefix.TotalCount == 0);

            //add a comment 
            CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };
            CreateComment(comment, result);

            //get total for this site
            CommentsList listAfter = ReadCommentsReadBySite("");
            Assert.IsTrue(listAfter.TotalCount == list.TotalCount+1);

            XmlDocument xStats = GetAllStatCounter();
            Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 5);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEHITS") == 0);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEMISSES") == 3);

            CommentsList listPrefixAfter = ReadCommentsReadBySite(commentForum.Id.Substring(0, 4));
            Assert.IsTrue(listPrefixAfter.TotalCount == 1);
            xStats = GetAllStatCounter();
            Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 6);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEHITS") == 0);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEMISSES") == 4);

            //reget totals
            listAfter = ReadCommentsReadBySite("");
            Assert.IsTrue(listAfter.TotalCount == list.TotalCount + 1);
            xStats = GetAllStatCounter();
            Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 7);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEHITS") == 1);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEMISSES") == 4);

            listPrefixAfter = ReadCommentsReadBySite(commentForum.Id.Substring(0, 4));
            Assert.IsTrue(listPrefixAfter.TotalCount == 1);
            xStats = GetAllStatCounter();
            Assert.IsTrue(GetStatCounter(xStats, "RAWREQUESTS") == 8);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEHITS") == 2);
            Assert.IsTrue(GetStatCounter(xStats, "HTMLCACHEMISSES") == 4);

        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:59,代码来源:CommentForumCachingAndStats.cs


示例15: CreateRatingThreadCommentHtml

 public Stream CreateRatingThreadCommentHtml(string ratingForumID, string threadid, string siteName, NameValueCollection formsData)
 {
     CommentInfo ratingThreadCommentInfo = null;
     try
     {
         ratingThreadCommentInfo = new CommentInfo { text = formsData["text"] };
         if (!String.IsNullOrEmpty(formsData["PostStyle"]))
         {
             try
             {
                 ratingThreadCommentInfo.PostStyle =
                     (PostStyle.Style)Enum.Parse(typeof(PostStyle.Style), formsData["PostStyle"], true);
             }
             catch
             {
                 throw new DnaWebProtocolException(ApiException.GetError(ErrorType.InvalidPostStyle));
             }
         }
     }
     catch (ApiException ex)
     {
         throw new DnaWebProtocolException(ex);
     }
     return CreateRatingThreadComment(ratingForumID, threadid, siteName, ratingThreadCommentInfo);
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:25,代码来源:ReviewService.cs


示例16: CommentCreateFromReader

        /// <summary>
        /// Creates a commentinfo object
        /// </summary>
        /// <param name="reader">A reader with all information</param>
        /// <param name="site">site information</param>
        /// <returns>Comment info object</returns>
        private CommentInfo CommentCreateFromReader(IDnaDataReader reader, ISite site)
        {
            var commentInfo = new CommentInfo
                                  {
                                      Created =
                                          new DateTimeHelper(DateTime.Parse(reader.GetDateTime("Created").ToString())),
                                      User = UserReadById(reader, site),
                                      ID = reader.GetInt32NullAsZero("id")
                                  };

            commentInfo.hidden = (CommentStatus.Hidden) reader.GetInt32NullAsZero("hidden");
            if (reader.IsDBNull("poststyle"))
            {
                commentInfo.PostStyle = PostStyle.Style.richtext;
            }
            else
            {
                commentInfo.PostStyle = (PostStyle.Style) reader.GetTinyIntAsInt("poststyle");
            }

            commentInfo.IsEditorPick = reader.GetBoolean("IsEditorPick");
            commentInfo.Index = reader.GetInt32NullAsZero("PostIndex");

            //get complainant
            var replacement = new Dictionary<string, string>();
            replacement.Add("sitename", site.SiteName);
            replacement.Add("postid", commentInfo.ID.ToString());
            commentInfo.ComplaintUri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                                SiteList.GetSiteOptionValueString(site.SiteID, "General", "ComplaintUrl"),
                                                                                replacement);

            replacement = new Dictionary<string, string>();
            replacement.Add("commentforumid", reader.GetString("forumuid"));
            replacement.Add("sitename", site.SiteName);
            commentInfo.ForumUri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                            UriDiscoverability.UriType.CommentForumById,
                                                                            replacement);

            replacement = new Dictionary<string, string>();
            replacement.Add("parentUri", reader.GetString("parentUri"));
            replacement.Add("postid", commentInfo.ID.ToString());
            commentInfo.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.Comment,
                                                                       replacement);

            if(reader.DoesFieldExist("nerovalue"))
            {
                commentInfo.NeroRatingValue = reader.GetInt32NullAsZero("nerovalue");
            }

            if (reader.DoesFieldExist("neropositivevalue"))
            {
                commentInfo.NeroPositiveRatingValue = reader.GetInt32NullAsZero("neropositivevalue");
            }

            if (reader.DoesFieldExist("neronegativevalue"))
            {
                commentInfo.NeroNegativeRatingValue = reader.GetInt32NullAsZero("neronegativevalue");
            }
            
            if (reader.DoesFieldExist("tweetid"))
            {
                commentInfo.TweetId = reader.GetLongNullAsZero("tweetid");
            }

            commentInfo.text = CommentInfo.FormatComment(reader.GetStringNullAsEmpty("text"), commentInfo.PostStyle, commentInfo.hidden, commentInfo.User.Editor);

            if (reader.DoesFieldExist("twitterscreenname"))
            {
                commentInfo.TwitterScreenName = reader.GetStringNullAsEmpty("twitterscreenname");
            }

            if (reader.DoesFieldExist("retweetid"))
            {
                commentInfo.RetweetId = reader.GetLongNullAsZero("retweetid");
            }

            if (reader.DoesFieldExist("retweetedby"))
            {
                commentInfo.RetweetedBy = reader.GetStringNullAsEmpty("retweetedby");
            }

            if (reader.DoesFieldExist("DmID"))
            {
                if (reader.IsDBNull("DmID") == false)
                {
                    commentInfo.DistressMessage = IncludeDistressMessage(reader, site);
                }
            }

            return commentInfo;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:97,代码来源:Comments.cs


示例17: CreateComment

 public Stream CreateComment(string commentForumId, string siteName, CommentInfo comment)
 {
     ISite site = GetSite(siteName);
     if (site == null)
     {
         throw ApiException.GetError(ErrorType.UnknownSite);
     }
     CommentInfo commentInfo;
     try
     {
         CommentForum commentForumData = _commentObj.GetCommentForumByUid(commentForumId, site, true);
         _commentObj.CallingUser = GetCallingUser(site);
         if (commentForumData == null)
         {
             throw ApiException.GetError(ErrorType.ForumUnknown);
         }
         commentInfo = _commentObj.CreateComment(commentForumData, comment);
     }
     catch (ApiException ex)
     {
         throw new DnaWebProtocolException(ex);
     }
     return GetOutputStream(commentInfo);
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:24,代码来源:CommentsService.cs


示例18: IncludeDistressMessage

        private CommentInfo IncludeDistressMessage(IDnaDataReader reader, ISite site)
        {
            var commentInfo = new CommentInfo();

            commentInfo.Created = new DateTimeHelper(DateTime.Parse(reader.GetDateTime("DmCreated").ToString()));
            commentInfo.ID = reader.GetInt32NullAsZero("DmId");
            commentInfo.User = DmUserFromReader(reader, site);

            commentInfo.hidden = (CommentStatus.Hidden)reader.GetInt32NullAsZero("DmHidden");
            if (reader.IsDBNull("DmPostStyle"))
            {
                commentInfo.PostStyle = PostStyle.Style.richtext;
            }
            else
            {
                commentInfo.PostStyle = (PostStyle.Style)reader.GetTinyIntAsInt("DmPostStyle");
            }
            commentInfo.Index = reader.GetInt32NullAsZero("DmPostIndex");

            commentInfo.text = CommentInfo.FormatComment(reader.GetStringNullAsEmpty("DmText"), 
                commentInfo.PostStyle, 
                commentInfo.hidden, 
                commentInfo.User.Editor);

            var replacement = new Dictionary<string, string>();
            replacement.Add("commentforumid", reader.GetString("forumuid"));
            replacement.Add("sitename", site.SiteName);
            commentInfo.ForumUri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                            UriDiscoverability.UriType.CommentForumById,
                                                                            replacement);
            replacement = new Dictionary<string, string>();
            replacement.Add("parentUri", reader.GetString("parentUri"));
            replacement.Add("postid", commentInfo.ID.ToString());
            commentInfo.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.Comment,
                                                                       replacement);

            return commentInfo;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:38,代码来源:Comments.cs


示例19: CreateCommentHtml

        public void CreateCommentHtml(string commentForumId, string siteName, NameValueCollection formsData)
        {
            ErrorType error;
            DnaWebProtocolException dnaWebProtocolException = null;
            CommentInfo commentInfo;
            try
            {
                commentInfo = new CommentInfo {text = formsData["text"]};
                if (!String.IsNullOrEmpty(formsData["PostStyle"]))
                {
                    try
                    {
                        commentInfo.PostStyle =
                            (PostStyle.Style) Enum.Parse(typeof (PostStyle.Style), formsData["PostStyle"]);
                    }
                    catch
                    {
                        throw new DnaWebProtocolException(ApiException.GetError(ErrorType.InvalidPostStyle));
                    }
                }
                CreateComment(commentForumId, siteName, commentInfo);
                error = ErrorType.Ok;
            }
            catch (DnaWebProtocolException ex)
            {
                error = ex.ErrorType;

                dnaWebProtocolException = ex;
            }


            string ptrt = WebFormat.GetPtrtWithResponse(error.ToString());
            if (String.IsNullOrEmpty(ptrt))
            {
//none returned...
                if (error == ErrorType.Ok)
                {
                    WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Created;
                    return;
                }
                else
                {
                    throw dnaWebProtocolException;
                }
            }
            //do response redirect...
            WebOperationContext.Current.OutgoingResponse.Location = ptrt;
            WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.MovedPermanently;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BEPUphysics.Space类代码示例发布时间:2022-05-24
下一篇:
C# Api.CommentForum类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap