/// <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; }
private static Contribution CreateContributionInternal(IDnaDataReader reader) { Contribution contribution = new Contribution(); // Make sure we got something back if (reader.HasRows && reader.Read()) { contribution.Body = reader.GetStringNullAsEmpty("Body"); contribution.PostIndex = reader.GetLongNullAsZero("PostIndex"); contribution.SiteName = reader.GetStringNullAsEmpty("SiteName"); contribution.SiteType = (SiteType)Enum.Parse(typeof(SiteType), reader.GetStringNullAsEmpty("SiteType")); contribution.SiteDescription = reader.GetStringNullAsEmpty("SiteDescription"); contribution.SiteUrl = reader.GetStringNullAsEmpty("UrlName"); contribution.FirstSubject = reader.GetStringNullAsEmpty("FirstSubject"); contribution.Subject = reader.GetStringNullAsEmpty("Subject"); contribution.Timestamp = new DateTimeHelper(reader.GetDateTime("TimeStamp")); contribution.Title = reader.GetStringNullAsEmpty("ForumTitle"); contribution.ThreadEntryID = reader.GetInt32("ThreadEntryID"); contribution.CommentForumUrl = reader.GetStringNullAsEmpty("CommentForumUrl"); contribution.GuideEntrySubject = reader.GetStringNullAsEmpty("GuideEntrySubject"); contribution.TotalPostsOnForum = reader.GetInt32NullAsZero("TotalPostsOnForum"); contribution.AuthorUserId = reader.GetInt32NullAsZero("AuthorUserId"); contribution.AuthorUsername = reader.GetStringNullAsEmpty("AuthorUsername"); contribution.AuthorIdentityUsername = reader.GetStringNullAsEmpty("AuthorIdentityUsername"); bool forumCanWrite = reader.GetByteNullAsZero("ForumCanWrite") == 1; bool isEmergencyClosed = reader.GetInt32NullAsZero("SiteEmergencyClosed") == 1; //bool isSiteScheduledClosed = reader2.GetByteNullAsZero("SiteScheduledClosed") == 1; DateTime closingDate = DateTime.MaxValue; if (reader.DoesFieldExist("forumclosedate") && !reader.IsDBNull("forumclosedate")) { closingDate = reader.GetDateTime("forumclosedate"); contribution.ForumCloseDate = new DateTimeHelper(closingDate); } contribution.isClosed = (!forumCanWrite || isEmergencyClosed || (closingDate != null && DateTime.Now > closingDate)); } else { throw ApiException.GetError(ErrorType.ThreadPostNotFound); } return contribution; }