void CheckLatestPremodPostings(IDnaDataReader reader, int modId, int userid, int forumid, int? threadid, int? inReplyTo, string body, int postStyle, int siteid, byte isComment, int? riskModThreadEntryQueueId) { reader.ExecuteWithinATransaction(@"SELECT * FROM PremodPostings where ModId="+modId); reader.Read(); // Nasty tweak. With PremodPostings, when it creates a thread mod entry, it sets threadid=null and postid=0 // posttoforuminternal returns 0 for both thread id and threadentry id, so here we're treating 0 as null threadid = NullIf(threadid, 0); Assert.AreEqual(userid, reader.GetInt32("userid")); Assert.AreEqual(forumid, reader.GetInt32("forumid")); TestNullableIntField(reader, "threadid", threadid); TestNullableIntField(reader, "inReplyTo", inReplyTo); Assert.AreEqual(body, reader.GetString("body")); Assert.AreEqual(postStyle, reader.GetInt32("postStyle")); Assert.AreEqual(siteid, reader.GetInt32("siteid")); Assert.AreEqual(isComment, reader.GetByte("isComment")); TestNullableIntField(reader, "riskModThreadEntryQueueId", riskModThreadEntryQueueId); }
void CheckLatestThreadMod(IDnaDataReader reader, int forumid, int? threadid, int? postid, int? lockedby, int status, string notes, int siteid, byte isPremodPosting) { reader.ExecuteWithinATransaction(@"SELECT top 1 * FROM ThreadMod order by ModId desc"); reader.Read(); // Nasty tweak. With PremodPostings, when it creates a thread mod entry, it sets threadid=null and postid=0 // posttoforuminternal returns 0 for both thread id and threadentry id, so here we're treating 0 as null threadid = NullIf(threadid, 0); Assert.AreEqual(forumid, reader.GetInt32("forumid")); TestNullableIntField(reader, "threadid", threadid); TestNullableIntField(reader, "postid", postid); TestNullableIntField(reader, "lockedby", lockedby); Assert.AreEqual(status, reader.GetInt32("status")); TestNullableStringField(reader, "notes", notes); Assert.AreEqual(siteid, reader.GetInt32("siteid")); Assert.AreEqual(isPremodPosting,reader.GetByte("isPremodPosting")); }
void CheckLatestThreadEntry(IDnaDataReader reader, int threadid, int forumid, int userid, int? nextSibling, int? parent, int? prevSibling, int? firstChild, int entryID, int? hidden, int postIndex, byte postStyle, string text) { reader.ExecuteWithinATransaction(@"SELECT top 1 * FROM ThreadEntries order by EntryID desc"); reader.Read(); Assert.AreEqual(threadid, reader.GetInt32("threadid")); Assert.AreEqual(forumid, reader.GetInt32("forumid")); Assert.AreEqual(userid, reader.GetInt32("userid")); TestNullableIntField(reader, "nextSibling", nextSibling); TestNullableIntField(reader, "parent", parent); TestNullableIntField(reader, "prevSibling", prevSibling); TestNullableIntField(reader, "firstChild", firstChild); Assert.AreEqual(entryID, reader.GetInt32("entryID")); TestNullableIntField(reader, "hidden", hidden); Assert.AreEqual(postIndex, reader.GetInt32("postIndex")); Assert.AreEqual(postStyle, reader.GetByte("postStyle")); Assert.AreEqual(text, reader.GetString("text")); }
void CheckLatestThread(IDnaDataReader reader, int threadid, int forumid, byte canRead, byte canWrite, int siteid) { reader.ExecuteWithinATransaction(@"SELECT top 1 * FROM Threads order by ThreadID desc"); reader.Read(); Assert.AreEqual(threadid, reader.GetInt32("threadid")); Assert.AreEqual(forumid, reader.GetInt32("forumid")); Assert.AreEqual(canRead, reader.GetByte("canRead")); Assert.AreEqual(canWrite, reader.GetByte("canWrite")); Assert.AreEqual(siteid, reader.GetInt32("siteid")); }
void CheckRiskModThreadEntryQueue(IDnaDataReader reader, int? ThreadEntryId, char PublishMethod, bool? IsRisky, TestDate DateAssessed, int SiteId, int ForumId, int? ThreadId, int UserId, string UserName, int? InReplyTo, string Subject, string Text, byte PostStyle, string IPAddress, string BBCUID, DateTime EventDate, byte AllowEventEntries, int NodeId, int? QueueId, int ClubId, byte IsNotable, byte IsComment, string ModNotes, byte IsThreadedComment) { reader.ExecuteWithinATransaction(@"SELECT rm.* FROM RiskModThreadEntryQueue rm WHERE RiskModThreadEntryQueueId=" + GetLatestRiskModThreadEntryQueueId(reader)); reader.Read(); // Nasty tweak. The RiskModThreadEntryQueue table always stores undefined ThreadId and ThreadEntryId values // as NULL. We treat zero values as NULL for comparision purposes ThreadId = NullIf(ThreadId, 0); ThreadEntryId = NullIf(ThreadEntryId, 0); TestNullableIntField(reader, "ThreadEntryId", ThreadEntryId); TestPublishMethod(reader, PublishMethod); TestNullableBoolField(reader, "IsRisky", IsRisky); TestNullableDateField(reader, "DateAssessed", DateAssessed); Assert.AreEqual(SiteId,reader.GetInt32("SiteId")); Assert.AreEqual(ForumId,reader.GetInt32("ForumId")); TestNullableIntField(reader, "ThreadId", ThreadId); Assert.AreEqual(UserId,reader.GetInt32("UserId")); Assert.AreEqual(UserName, reader.GetString("UserName")); TestNullableIntField(reader, "InReplyTo", InReplyTo); Assert.AreEqual(Subject,reader.GetString("Subject")); Assert.AreEqual(Text,reader.GetString("Text")); Assert.AreEqual(PostStyle, reader.GetByte("PostStyle")); Assert.AreEqual(IPAddress,reader.GetString("IPAddress")); Assert.AreEqual(BBCUID,reader.GetGuidAsStringOrEmpty("BBCUID")); //Assert.AreEqual(EventDate,reader.GetInt32("EventDate")); Assert.AreEqual(AllowEventEntries,reader.GetByte("AllowEventEntries")); //Assert.AreEqual(NodeId,reader.GetInt32("NodeId")); TestNullableIntField(reader, "QueueId", QueueId); Assert.AreEqual(ClubId,reader.GetInt32("ClubId")); Assert.AreEqual(IsNotable, reader.GetByte("IsNotable")); Assert.AreEqual(IsComment, reader.GetByte("IsComment")); TestNullableStringField(reader, "ModNotes", ModNotes); Assert.AreEqual(IsThreadedComment, reader.GetByte("IsThreadedComment")); reader.Close(); }
/// <summary> /// Creates a ratinginfo object /// </summary> /// <param name="reader">A reader with all information</param> /// <returns>Rating Info object</returns> public RatingInfo RatingCreateFromReader(IDnaDataReader reader, ISite site) { RatingInfo ratingInfo = new RatingInfo { Created = new DateTimeHelper(DateTime.Parse(reader.GetDateTime("Created").ToString())), User = base.UserReadById(reader, site), ID = reader.GetInt32NullAsZero("id"), rating = reader.GetByte("rating") }; ratingInfo.hidden = (CommentStatus.Hidden)reader.GetInt32NullAsZero("hidden"); if (reader.IsDBNull("poststyle")) { ratingInfo.PostStyle = PostStyle.Style.richtext; } else { ratingInfo.PostStyle = (PostStyle.Style)reader.GetTinyIntAsInt("poststyle"); } ratingInfo.IsEditorPick = reader.GetBoolean("IsEditorPick"); ratingInfo.Index = reader.GetInt32NullAsZero("PostIndex"); //get complainant Dictionary<string, string> replacement = new Dictionary<string, string>(); replacement.Add("sitename", site.SiteName); replacement.Add("postid", ratingInfo.ID.ToString()); ratingInfo.ComplaintUri = UriDiscoverability.GetUriWithReplacments(BasePath, SiteList.GetSiteOptionValueString(site.SiteID, "General", "ComplaintUrl"), replacement); replacement = new Dictionary<string, string>(); replacement.Add("RatingForumid", reader.GetString("forumuid")); replacement.Add("sitename", site.SiteName); ratingInfo.ForumUri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.RatingsByRatingForumId, replacement); replacement = new Dictionary<string, string>(); replacement.Add("parentUri", reader.GetString("parentUri")); replacement.Add("postid", ratingInfo.ID.ToString()); ratingInfo.Uri = UriDiscoverability.GetUriWithReplacments(BasePath, UriDiscoverability.UriType.Comment, replacement); //Get Editors Pick ( this should be expanded to include any kind of poll ) /*EditorsPick editorsPick = new EditorsPick(_dnaDiagnostics, _connection, _caching); if (editorsPick.LoadPollResultsForItem(commentInfo.ID) && editorsPick.Id > 0) { commentInfo.EditorsPick = new EditorsPickInfo { Id = editorsPick.Id, Response = editorsPick.Result }; }*/ ratingInfo.text = CommentInfo.FormatComment(reader.GetString("text"), ratingInfo.PostStyle, ratingInfo.hidden, ratingInfo.User.Editor); return ratingInfo; }