/// <summary> /// /// </summary> /// <param name="dataReader"></param> /// <param name="userSearchType"></param> /// <param name="searchText"></param> /// <param name="checkAllSites"></param> /// <param name="twitterAPIException"></param> public void GenerateMemberListXml( IDnaDataReader dataReader, int userSearchType, string searchText, bool checkAllSites, string twitterAPIException) { int count = 0; XmlNode memberList = AddElementTag(RootElement, "MEMBERLIST"); AddAttribute(memberList, "USERSEARCHTYPE", userSearchType.ToString()); AddAttribute(memberList, "SEARCHTEXT", searchText); AddAttribute(memberList, "CHECKALLSITES", checkAllSites.ToString()); if (dataReader.HasRows) { if (dataReader.Read()) { XmlNode userAccounts = AddElementTag(memberList, "USERACCOUNTS"); //int previousUserID = 0; XmlNode userAccount = null; do { int userID = dataReader.GetInt32NullAsZero("USERID"); /*if (userID != previousUserID) { if (userAccount != null) { userAccounts.AppendChild(userAccount); } userAccount = CreateElementNode("USERACCOUNT"); previousUserID = userID; }*/ userAccount = CreateElementNode("USERACCOUNT"); //Start filling new user xml AddAttribute(userAccount, "USERID", userID); AddTextTag(userAccount, "SITEID", dataReader.GetInt32NullAsZero("SITEID")); AddTextTag(userAccount, "USERNAME", dataReader.GetStringNullAsEmpty("USERNAME")); AddTextTag(userAccount, "LOGINNAME", dataReader.GetStringNullAsEmpty("LOGINNAME")); AddTextTag(userAccount, "EMAIL", dataReader.GetStringNullAsEmpty("EMAIL")); AddTextTag(userAccount, "PREFSTATUS", dataReader.GetInt32NullAsZero("PREFSTATUS")); AddTextTag(userAccount, "PREFSTATUSDURATION", dataReader.GetInt32NullAsZero("PREFSTATUSDURATION")); AddTextTag(userAccount, "USERSTATUSDESCRIPTION", ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("PREFSTATUS")).ToString()); if (!dataReader.IsDBNull("DATEJOINED")) { AddDateXml(dataReader.GetDateTime("DATEJOINED"), userAccount, "DATEJOINED"); } if (!dataReader.IsDBNull("PREFSTATUSCHANGEDDATE")) { DateTime prefStatusChangedDate = dataReader.GetDateTime("PREFSTATUSCHANGEDDATE"); AddDateXml(prefStatusChangedDate, userAccount, "PREFSTATUSCHANGEDDATE"); } else { AddTextTag(userAccount, "PREFSTATUSCHANGEDDATE", ""); } AddTextTag(userAccount, "SHORTNAME", dataReader.GetStringNullAsEmpty("SHORTNAME")); AddTextTag(userAccount, "URLNAME", dataReader.GetStringNullAsEmpty("URLNAME")); if (dataReader.DoesFieldExist("IPADDRESS") && dataReader.GetStringNullAsEmpty("IPADDRESS") != String.Empty) { AddTextTag(userAccount, "IPADDRESS", dataReader.GetStringNullAsEmpty("IPADDRESS")); } if (dataReader.DoesFieldExist("BBCUID") && dataReader.GetGuidAsStringOrEmpty("BBCUID") != String.Empty) { AddTextTag(userAccount, "BBCUID", dataReader.GetGuidAsStringOrEmpty("BBCUID")); } if (userSearchType == 6) { AddTextTag(userAccount, "TWITTERUSERID", dataReader.GetStringNullAsEmpty("TwitterUserID")); } else { AddIntElement(userAccount, "SSOUSERID", dataReader.GetInt32NullAsZero("SSOUserID")); } AddTextTag(userAccount, "IDENTITYUSERID", dataReader.GetStringNullAsEmpty("IdentityUserID")); AddIntElement(userAccount, "ACTIVE", dataReader.GetInt32NullAsZero("STATUS") != 0 ? 1:0); userAccounts.AppendChild(userAccount); count++; } while (dataReader.Read()); memberList.AppendChild(userAccounts); } } AddAttribute(memberList, "COUNT", count); AddAttribute(memberList, "TWITTEREXCEPTION", twitterAPIException); //FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "memberlist", _cacheName, memberList.OuterXml); //memberList.OwnerDocument.Save(@"c:\TEMP\memberlist.xml"); }
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(); }
private void GenerateXml(IDnaDataReader reader, int h2g2Id, int postId, string exLinkUrl) { XmlElement modHistory = AddElementTag(RootElement, "MODERATION-HISTORY"); reader.Read(); if (h2g2Id > 0) AddAttribute(modHistory, "H2G2ID", h2g2Id); else if (postId > 0) { AddAttribute(modHistory, "POSTID", postId); if ( reader.HasRows ) { AddAttribute(modHistory, "FORUMID", reader.GetInt32NullAsZero("forumid") ); AddAttribute(modHistory, "THREADID", reader.GetInt32NullAsZero("threadid") ); } } else if (exLinkUrl != String.Empty) AddAttribute(modHistory, "EXLINKURL", exLinkUrl ); if (reader.HasRows) { int rowCount = 0; do { if (rowCount == 0) { AddXmlTextTag(modHistory, "SUBJECT", reader.GetStringNullAsEmpty("subject")); if (reader.DoesFieldExist("authoruserid") && !reader.IsDBNull("authoruserid")) { XmlElement editorNode = AddElementTag(modHistory, "EDITOR"); User editor = new User(InputContext); editor.AddPrefixedUserXMLBlock(reader, reader.GetInt32NullAsZero("authoruserid"), "Author", editorNode); } } XmlElement moderation = AddElementTag(modHistory, "MODERATION"); AddAttribute(moderation, "MODID", reader.GetInt32NullAsZero("modid")); AddIntElement(moderation, "STATUS", reader.GetInt32NullAsZero("status")); AddTextElement(moderation, "URLNAME", InputContext.TheSiteList.GetSite(reader.GetInt32NullAsZero("siteid")).SiteName); if (reader.DoesFieldExist("reasonid") && reader.GetInt32NullAsZero("reasonid") > 0) { AddIntElement(moderation, "REASONID", reader.GetInt32NullAsZero("reasonid")); } User user = new User(InputContext); if ( !reader.IsDBNull("lockedbyuserid") ) { XmlElement locked = AddElementTag(moderation, "LOCKED-BY"); user.AddPrefixedUserXMLBlock(reader, reader.GetInt32NullAsZero("LockedBy"), "lockedby", locked); } if (!reader.IsDBNull("referredbyuserid")) { XmlElement referred = AddElementTag(moderation, "REFERRED-BY"); user.AddPrefixedUserXMLBlock(reader, reader.GetInt32NullAsZero("referredbyuserid"), "referredby", referred); } XmlElement complaint = AddElementTag(moderation, "COMPLAINT"); AddTextElement(complaint, "COMPLAINT-TEXT", reader.GetStringNullAsEmpty("complainttext")); if (reader.DoesFieldExist("complainantuserid") && !reader.IsDBNull("complainantuserid")) { user.AddPrefixedUserXMLBlock(reader, reader.GetInt32NullAsZero("complainantuserid"), "complainant", complaint); } AddTextElement(complaint, "IPADDRESS", reader.GetStringNullAsEmpty("ipaddress")); AddTextElement(complaint, "BBCUID", reader.GetGuidAsStringOrEmpty("bbcuid").ToString()); AddTextElement(complaint, "EMAIL-ADDRESS", reader.GetStringNullAsEmpty("correspondenceemail")); AddTextElement(moderation, "NOTES", HtmlUtils.ReplaceCRsWithBRs(reader.GetStringNullAsEmpty("notes"))); AddDateXml(reader.GetDateTime("datequeued"), moderation, "DATE-QUEUED"); if (!reader.IsDBNull("datelocked")) { AddDateXml(reader.GetDateTime("datelocked"), moderation, "DATE-LOCKED"); } if (!reader.IsDBNull("datereferred")) { AddDateXml(reader.GetDateTime("datereferred"), moderation, "DATE-REFERRED"); } if (!reader.IsDBNull("datecompleted")) { AddDateXml(reader.GetDateTime("datecompleted"), moderation, "DATE-COMPLETED"); } ++rowCount; } while (reader.Read()); } }