Esempio n. 1
0
        private void ProcessAllowedURLListData(IDnaDataReader dataReader)
        {
            int currentSiteID = 1;
            int siteID = 1;
            _allowedURLsList.Clear();

            //For each row/site in the database add it's details
            if (dataReader.Read())
            {
                siteID = dataReader.GetInt32NullAsZero("SiteID");
                currentSiteID = siteID;
                List<string> siteAllowedURLs = new List<string>();
                string allowedURL = dataReader.GetStringNullAsEmpty("URL").ToLower();
                siteAllowedURLs.Add(allowedURL);

                while (dataReader.Read())
                {
                    siteID = dataReader.GetInt32NullAsZero("SiteID");
                    if (siteID != currentSiteID)
                    {
                        _allowedURLsList.Add(currentSiteID, siteAllowedURLs);
                        siteAllowedURLs.Clear();
                        currentSiteID = siteID;
                    }
                    allowedURL = dataReader.GetStringNullAsEmpty("URL").ToLower();
                    siteAllowedURLs.Add(allowedURL);
                }
                _allowedURLsList.Add(currentSiteID, siteAllowedURLs);
            }
        }
Esempio n. 2
0
 private IEnumerable<ExModerationEvent> BuildExModerationEvents(IDnaDataReader reader)
 {
     List<ExModerationEvent> activities = new List<ExModerationEvent>();
     while (reader.Read())
     {
         activities.Add(ExModerationEvent.CreateExModerationEvent(reader));
     }
     
     return activities;
 }
Esempio n. 3
0
        private List<BIEvent> GetBIEvents(IDnaDataReader reader)
        {
            List<BIEvent> biEventList = new List<BIEvent>();
            while (reader.Read())
            {
                BIEvent be = BIEvent.CreateBiEvent(reader, this, RiskModSystem);
                biEventList.Add(be);
            }

            return biEventList;
        }
 private void BuildRecentCommentsXml(IDnaDataReader dataReader)
 {
     XmlNode recentComments = CreateElementNode("RECENTCOMMENTS");
     //ForumPost post = new ForumPost();
     if (dataReader.HasRows)
     {
         while (dataReader.Read())
         {
             ForumPost.AddPostXml(dataReader, this, recentComments, InputContext);
         };
     }
     RootElement.AppendChild(recentComments);
 }
Esempio n. 5
0
 private static IEnumerable<ISnesActivity> BuildSnesEvents(IDnaDataReader reader)
 {
     var activities = new List<ISnesActivity>();
     reader.Execute();
     if (reader.HasRows)
     {
         while (reader.Read())
         {
             activities.Add(SnesActivityFactory.CreateSnesActivity(SnesActivityLogger, reader));
         }
     }
     return activities;
 }
Esempio n. 6
0
        /// <summary>
        /// This method creates the crumbtrail for a given item
        /// </summary>
        /// <param name="reader">The DnaDataReader that contains the crumbtrail result set.</param>
        static public CrumbTrails GetCrumbtrailForItem(IDnaDataReader reader)
        {
            CrumbTrails crumbTrialList = new CrumbTrails();
            bool startOfTrail = true;
            CrumbTrail crumbTrail = null;
            while (reader.Read())
            {
                // Check to see if we're at the top level
                int treeLevel = reader.GetInt32("TreeLevel");
                if (treeLevel == 0)
                {
                    startOfTrail = true;
                }

                // Check to see if we're starting a new trail
                if (startOfTrail)
                {
                    if (crumbTrail != null)
                    {//add the previous to the list
                        crumbTrialList.CrumbTrail.Add(crumbTrail);
                    }
                    //start new
                    crumbTrail = new CrumbTrail();
                    startOfTrail = false;
                }

                CrumbTrailAncestor ancestor = new CrumbTrailAncestor();
                ancestor.Name = reader.GetString("DisplayName");
                ancestor.NodeId = reader.GetInt32("NodeID");
                ancestor.TreeLevel = treeLevel;
                ancestor.NodeType = reader.GetInt32("Type");
                if (reader.Exists("RedirectNodeID") && !reader.IsDBNull("RedirectNodeID"))
                {
                    ancestor.RedirectNode = new CrumbTrialAncestorRedirect();
                    ancestor.RedirectNode.id = reader.GetInt32("RedirectNodeID");
                    ancestor.RedirectNode.value = reader.GetString("RedirectNodeName");
                }
                crumbTrail.Ancestor.Add(ancestor);
            }
            if (crumbTrail != null)
            {//add the previous to the list
                crumbTrialList.CrumbTrail.Add(crumbTrail);
            }
            return crumbTrialList;
        }
        /// <summary>
        /// Creates the XML fragment for the Comment CommentBoxForum List
        /// </summary>
        /// <param name="dataReader">The SP reader</param>
        /// <param name="skip">Number of comment forums to skip</param>
        /// <param name="show">Number of comment forums to show</param>
        /// <param name="requestedSiteIDFilter">The requested Site Id filter if present</param>
        /// <param name="requestedUrlFilter">The requested HostPageUrl filter if present</param>
        public void GenerateCommentForumListXml(IDnaDataReader dataReader, int skip, int show, int requestedSiteIDFilter, string requestedUrlFilter)
        {
            XmlNode commentForumList = CreateElementNode("COMMENTFORUMLIST");
            int commentForumListCount = 0;

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    commentForumListCount = dataReader.GetInt32NullAsZero("CommentForumListCount");
                }
            }

            AddAttribute(commentForumList, "COMMENTFORUMLISTCOUNT", commentForumListCount);
            AddAttribute(commentForumList, "SKIP", skip);
            AddAttribute(commentForumList, "SHOW", show);

            if (requestedUrlFilter == String.Empty)
            {
                AddAttribute(commentForumList, "REQUESTEDSITEID", requestedSiteIDFilter);
            }
            else
            {
                AddAttribute(commentForumList, "REQUESTEDURL", StringUtils.EscapeAllXmlForAttribute(requestedUrlFilter));
            }

            //int returnedCount = 20;
            int actualForumListCount = 0;
            if (commentForumListCount > 0)
            {
                do
                {
                    AddCommentForumListXML(dataReader, commentForumList);
                    actualForumListCount++;
					// returnedCount--;
                } while (/*returnedCount > 0 &&*/ dataReader.Read());
            }

            //TODO: Move this to the right place
            RootElement.AppendChild(commentForumList);
        }
Esempio n. 8
0
        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;
        }
Esempio n. 9
0
        int GetLatestPremodPostingsModId(IDnaDataReader reader)
        {
            reader.ExecuteWithinATransaction(@"SELECT top 1 * FROM PremodPostings order by modid desc");
            reader.Read();

            if (reader.HasRows)
                return reader.GetInt32("ModId");

            return -1;
        }
Esempio n. 10
0
        int GetLatestRiskModThreadEntryQueueId(IDnaDataReader reader)
        {
            reader.ExecuteWithinATransaction(@"SELECT top 1 * FROM RiskModThreadEntryQueue order by RiskModThreadEntryQueueId desc");
            reader.Read();

            if (reader.HasRows)
                return reader.GetInt32("RiskModThreadEntryQueueId");

            return -1;
        }
Esempio n. 11
0
        void RiskMod_ProcessRiskAssessmentForThreadEntry(IDnaDataReader reader, int riskModId, string isRisky, out int? newThreadId, out int? newThreadEntryId)
        {
            string sql = string.Format(@"
                            declare @ret int
                            exec @ret=riskmod_processriskassessmentforthreadentry @riskmodthreadentryqueueid={0}, @risky={1}
                            ", riskModId, RiskyOrNotRisky(isRisky));
            reader.ExecuteWithinATransaction(sql);
            reader.Read();

            if (reader.DoesFieldExist("ThreadId"))
            {
                newThreadId = reader.GetInt32("ThreadID");
                newThreadEntryId = reader.GetInt32("PostID");
            }
            else
            {
                newThreadId = newThreadEntryId = null;
            }
        }
Esempio n. 12
0
        private static int CreateNewSite(IDnaDataReader reader, string urlname)
        {
            string sql = @"exec createnewsite	 @urlname = '"+urlname+"',"+
									            "@shortname = '"+urlname+"',"+
									            "@description = '"+urlname+"',"+
									            "@defaultskin = 'default',"+
									            "@skindescription = '',"+
									            "@skinset ='boards',"+
									            "@useframes =0,"+
									            "@premoderation = 0,"+
									            "@noautoswitch =0,"+
									            "@customterms = 0,"+
									            "@moderatorsemail = '[email protected]',"+
									            "@editorsemail = '[email protected]',"+
									            "@feedbackemail = '[email protected]',"+
									            "@automessageuserid = 245,"+
									            "@passworded = 0,"+
									            "@unmoderated = 0,"+
									            "@articleforumstyle =0,"+
									            "@threadorder =1,"+
									            "@threadedittimelimit = 0,"+
									            "@eventemailsubject = '',"+
									            "@eventalertmessageuserid = 254,"+ 
									            "@includecrumbtrail  = 0,"+
									            "@allowpostcodesinsearch = 0,"+ 
									            "@ssoservice = null,"+
									            "@siteemergencyclosed = 0,"+
									            "@allowremovevote = 0,"+
									            "@queuepostings = 0,"+
									            "@modclassid = 1,"+
									            "@identitypolicy = 'http://identity/policies/dna/adult'";

            reader.ExecuteDEBUGONLY(sql);
            reader.Read();
            int siteid = reader.GetInt32("siteid");
            return siteid;
        }
Esempio n. 13
0
        private void GenerateUsersArticleAssetsXML(IDnaDataReader dataReader, MediaAssetParameters mediaAssetParams)
        {
            int count = 0;
            int total = 0;
            bool more = false;

            XmlElement articleAsset = AddElementTag(_builderRoot, "ARTICLEMEDIAASSETINFO");
            AddAttribute(articleAsset, "CONTENTTYPE", mediaAssetParams.ContentType);
            AddAttribute(articleAsset, "SORTBY", mediaAssetParams.SortBy);
            AddAttribute(articleAsset, "SKIPTO", mediaAssetParams.Skip);
            AddAttribute(articleAsset, "SHOW", mediaAssetParams.Show);
            AddTextElement(articleAsset, "ACTION", "showusersarticleswithassets");

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    User user = new User(InputContext);
                    user.AddUserXMLBlock(dataReader, mediaAssetParams.UserID, articleAsset);

                    count = dataReader.GetInt32NullAsZero("COUNT");
                    total = dataReader.GetInt32NullAsZero("TOTAL");
                    if (total > mediaAssetParams.Skip + mediaAssetParams.Show)
                    {
                        more = true;
                    }

                    do
                    {
                        XmlElement article = AddElementTag(articleAsset, "ARTICLE");
                        AddAttribute(article, "H2G2ID",  dataReader.GetInt32NullAsZero("H2G2ID"));

                        AddTextElement(article, "SUBJECT", dataReader.GetStringNullAsEmpty("SUBJECT"));

                        XmlDocument extrainfo = new XmlDocument();
                        extrainfo.LoadXml(dataReader.GetStringNullAsEmpty("EXTRAINFO"));
                        article.AppendChild(ImportNode(extrainfo.FirstChild));

                        AddDateXml(dataReader, article, "DateCreated", "DATECREATED");
                        AddDateXml(dataReader, article, "LastUpdated", "LASTUPDATED");

                        MakeXml(dataReader, article);

                    } while (dataReader.Read());
                }
            }

            AddAttribute(articleAsset, "COUNT", count);
            AddAttribute(articleAsset, "TOTAL", total);
            AddAttribute(articleAsset, "MORE", more);
        }
Esempio n. 14
0
        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"));
        }
Esempio n. 15
0
        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"));
        }
Esempio n. 16
0
        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();
        }
Esempio n. 17
0
        void RiskModTestPostHelper(IDnaDataReader reader, int forumid, int? threadid, int? inreplyto, int userid, string content, out int? newthreadid, out int? newthreadentryid, bool ignoremoderation, bool forcepremodposting)
        {
            string sql = string.Format(@"
                
                -- Pretend this user has never posted to this forum, to make sure the check in posttoforuminternal
                -- that stops the same user from creating a new conversation within a minute of the last one, doesn't stop the post
                update threadentries set forumid=-{0} where forumid={0} and userid={3}

                declare @hash uniqueidentifier, @returnthread int, @returnpost int, @premodpostingmodid int, @ispremoderated int
                set @hash=newid()
                exec posttoforuminternal    @userid= {3}, 
										    @forumid = {0}, 
										    @inreplyto = {2}, 
										    @threadid = {1}, 
										    @subject ='The Cabinet', 
										    @content ='{4}', 
										    @poststyle =1, 
										    @hash =@hash,
										    @keywords ='', 
										    @nickname ='the furry one', 
										    @returnthread = @returnthread OUTPUT, 
										    @returnpost = @returnpost OUTPUT, 
										    @type = NULL, 
										    @eventdate = NULL,
										    @forcemoderate = 0, 
										    @forcepremoderation = 0,
										    @ignoremoderation = {6}, 
										    @allowevententries = 1, 
										    @nodeid = 0, 
										    @ipaddress = 'testip',
										    @queueid = null, 
										    @clubid = 0, 
										    @premodpostingmodid =@premodpostingmodid OUTPUT,
										    @ispremoderated =@ispremoderated OUTPUT, 
										    @bbcuid = '{5}',
										    @isnotable = 0, 
										    @iscomment = 0,
										    @modnotes = NULL,
										    @isthreadedcomment = 0,
										    @ignoreriskmoderation = 0,
										    @forcepremodposting = {7},
										    @forcepremodpostingdate = NULL,
										    @riskmodthreadentryqueueid = NULL;

                -- put the userids back
                update threadentries set forumid={0} where forumid =-{0} and userid={3}

                select @returnthread AS returnthread, @returnpost as returnpost",
                                            forumid,
                                            threadid.HasValue ? threadid.ToString() : "NULL",
                                            inreplyto.HasValue ? inreplyto.ToString() : "NULL",
                                            userid,
                                            content,
                                            testGUID.ToString(),
                                            ignoremoderation ? 1 : 0,
                                            forcepremodposting ? 1 : 0);

            reader.ExecuteWithinATransaction(sql);
            reader.Read();
            newthreadid = reader.GetNullableInt32("returnthread");
            newthreadentryid = reader.GetNullableInt32("returnpost");
            reader.Close();
        }
Esempio n. 18
0
 void GetRiskModTestSiteAndForum(IDnaDataReader reader, out int siteid, out int forumid)
 {
     reader.ExecuteWithinATransaction(@"  select top 1 g.forumid,g.siteid 
                                         from topics t
                                         join guideentries g on g.h2g2id=t.h2g2id
                                         order by topicid");
     reader.Read();
     forumid = reader.GetInt32("forumid");
     siteid = reader.GetInt32("siteid");
     reader.Close();
 }
Esempio n. 19
0
 int CountEventQueueEntries(IDnaDataReader reader)
 {
     reader.ExecuteWithinATransaction("select count(*) as C from eventqueue");
     reader.Read();
     int c = reader.GetInt32("C");
     reader.Close();
     return c;
 }
Esempio n. 20
0
        /// <summary>
        /// With the returned data set generate the XML for the Article History page
        /// </summary>
        /// <param name="dataReader">Data set to turn into XML</param>
        /// <param name="entryID">Article to get the history of </param>
        private void GenerateArticleHistoryXml(IDnaDataReader dataReader, int entryID)
        {
            int count = 0;

            XmlElement articleHistory = AddElementTag(RootElement, "ARTICLEHISTORY");

            AddAttribute(articleHistory, "EntryID", entryID);

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    XmlElement items = AddElementTag(articleHistory, "ITEMS");

                    do
                    {
                        XmlElement item = AddElementTag(items, "ITEM");

                        AddIntElement(item, "USERID", dataReader.GetInt32NullAsZero("userid"));
                        AddIntElement(item, "ACTION", dataReader.GetInt32NullAsZero("action"));

                        AddTextTag(item, "COMMENT", dataReader.GetStringNullAsEmpty("comment"));

                        if (!dataReader.IsDBNull("dateperformed"))
                        {
                            AddDateXml(dataReader, item, "dateperformed", "DATEPERFORMED");
                        }
                        else
                        {
                            AddTextTag(item, "DATEPERFORMED", "");
                        }

                        count++;

                    } while (dataReader.Read());
                }
            }

            AddAttribute(articleHistory, "COUNT", count);
        }
Esempio n. 21
0
        private void GenerateUsersMediaAssetsXML(IDnaDataReader dataReader, MediaAssetParameters mediaAssetParams)
        {
            int count = 0;
            int total = 0;
            bool more = false;

            XmlElement usersMediaAssets = AddElementTag(_builderRoot, "MEDIAASSETINFO");
            AddAttribute(usersMediaAssets, "CONTENTTYPE", mediaAssetParams.ContentType);
            AddAttribute(usersMediaAssets, "SORTBY", mediaAssetParams.SortBy);
            AddAttribute(usersMediaAssets, "SKIPTO", mediaAssetParams.Skip);
            AddAttribute(usersMediaAssets, "SHOW", mediaAssetParams.Show);
            AddTextElement(usersMediaAssets, "ACTION", "showusersassets");

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    User user = new User(InputContext);
                    user.AddUserXMLBlock(dataReader, mediaAssetParams.UserID, usersMediaAssets);

                    count = dataReader.GetInt32NullAsZero("COUNT");
                    total = dataReader.GetInt32NullAsZero("TOTAL");
                    if (total > mediaAssetParams.Skip + mediaAssetParams.Show)
                    {
                        more = true;
                    }

                    do
                    {
                        MakeXml(dataReader, usersMediaAssets);
                    } while (dataReader.Read());
                }
            }

            AddAttribute(usersMediaAssets, "COUNT", count);
            AddAttribute(usersMediaAssets, "TOTAL", total);
            AddAttribute(usersMediaAssets, "MORE", more);
        }
Esempio n. 22
0
        /// <summary>
        /// Generates the Xml structure containing the Hierarchy data
        /// </summary>
        /// <param name="siteID">Get the hierarchy for a given site</param>
        /// <param name="dataReader">Results from the database</param>
        private void GenerateHierarchyForSiteXML(int siteID, IDnaDataReader dataReader)
        {
            XmlElement hierarchyNodes = (XmlElement)RootElement.AppendChild(RootElement.OwnerDocument.CreateElement("HIERARCHYNODES"));
            hierarchyNodes.SetAttribute("SITEID", siteID.ToString());
            bool builtTopNode = false;
            // Got through the results building the tree
            while (dataReader.Read())
            {
                // Check to see if we've built the top level node yet
                if (!builtTopNode)
                {
                    XmlElement topElement = (XmlElement)AddElement(hierarchyNodes);
                    topElement.SetAttribute("NODEID", dataReader.GetInt32("ParentID").ToString());
                    topElement.SetAttribute("NAME", dataReader.GetString("ParentName").Trim());
                    topElement.SetAttribute("TREELEVEL", "0");
                    topElement.SetAttribute("TYPE", dataReader.GetInt32("Type").ToString());
                    builtTopNode = true;
                }

                int parentID = dataReader.GetInt32("ParentID");
                int treeLevel = dataReader.GetInt32("TreeLevel");
                XmlElement parent = (XmlElement)RootElement.SelectSingleNode("//NODE[@NODEID='" + parentID + "'][@TREELEVEL='" + (treeLevel - 1) + "']");
                if (parent == null)
                {
                    // Create the parent
                    parent = AddElement((XmlElement)RootElement.SelectSingleNode("LOCATION[@TREELEVEL='" + (treeLevel - 1) + "']"));
                    parent.SetAttribute("NODEID", parentID.ToString());
                    parent.SetAttribute("NAME", dataReader.GetString("ParentName").Trim());
                    int newTreeLevel = treeLevel - 1;
                    parent.SetAttribute("TREELEVEL", newTreeLevel.ToString());
                    parent.SetAttribute("TYPE", dataReader.GetInt32("ParentType").ToString());
                }

                XmlElement newElement = (XmlElement)AddElement(parent);
                newElement.SetAttribute("NODEID", dataReader.GetInt32("NodeID").ToString());
                newElement.SetAttribute("NAME", dataReader.GetString("DisplayName").Trim());
                newElement.SetAttribute("TREELEVEL", treeLevel.ToString());
                newElement.SetAttribute("TYPE", dataReader.GetInt32("Type").ToString());
            }

            AddCachedXmlElement(hierarchyNodes, siteID);
        }
Esempio n. 23
0
 /// <summary>
 /// Generates the XML for a call to view a particular media asset
 /// </summary>
 /// <param name="dataReader"></param>
 /// <param name="mediaAssetParams"></param>
 private void GenerateMediaAssetXML(IDnaDataReader dataReader, MediaAssetParameters mediaAssetParams)
 {
     XmlElement mediaAssetInfo = AddElementTag(_builderRoot, "MEDIAASSETINFO");
     AddTextElement(mediaAssetInfo, "ACTION", "View");
     AddIntElement(mediaAssetInfo, "ID", mediaAssetParams.MediaAssetID);
     if (dataReader.HasRows)
     {
         if (dataReader.Read())
         {
             MakeXml(dataReader, mediaAssetInfo);
         }
     }
 }
Esempio n. 24
0
 /// <summary>
 /// Fills the userData Dictionary with Groups DB data
 /// </summary>
 /// <param name="sp">Stored Procedure Data Reader object</param>
 /// <returns></returns>
 private bool FillUserGroupsDataDictionary(IDnaDataReader sp)
 {
     bool success = false;
     if (_gotUserGroupsData)
     {
         while (sp.Read())
         {
             _userGroupsData.Add(sp["Name"].ToString().ToLower());
         }
         success = true;
     }
     return success;
 }
Esempio n. 25
0
        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"));
        }
Esempio n. 26
0
        private static void MockCurrentRowDataReader(IDnaDataReader reader)
        {
            Expect.Call(reader.Execute()).Return(reader);
            Expect.Call(reader.HasRows).Return(true);
            var readReturn = new Queue<bool>();
            readReturn.Enqueue(true);
            readReturn.Enqueue(false);
            Expect.Call(reader.Read()).Return(true).WhenCalled( x => x.ReturnValue = readReturn.Dequeue());
            Expect.Call(reader.Dispose);
            Expect.Call(reader.GetString("AppId")).Return("iPlayer");
            Expect.Call(reader.GetString("IdentityUserId")).Return("0");

            //Expect.Call(reader.GetInt32NullAsZero("PostId")).Repeat.Times(2).Return(1);

            //Expect.Call(reader.GetStringNullAsEmpty("DnaUrl")).Return("http://www.bbc.co.uk/dna/");
            //Expect.Call(reader.GetInt32NullAsZero("ForumID")).Repeat.Any().Return(1234);
            //Expect.Call(reader.GetInt32NullAsZero("ThreadId")).Repeat.Any().Return(54321);
            //Expect.Call(reader.GetInt32("ActivityType")).Repeat.Times(2).Return(5);
            //Expect.Call(reader.GetInt32("EventID")).Return(1234);
            //string appId = Guid.NewGuid().ToString();
            //Expect.Call(reader.GetStringNullAsEmpty("AppId")).Return(appId);
            //Expect.Call(reader.GetStringNullAsEmpty("Body")).Return("here is some text");
            //DateTime now = new DateTime(1970, 1, 1, 0, 0, 0);
            //Expect.Call(reader.GetDateTime("ActivityTime")).Return(now);
            //Expect.Call(reader.GetInt32("IdentityUserId")).Return(12345456);
            //Expect.Call(reader.GetStringNullAsEmpty("AppName")).Return("iPlayer");

            //Expect.Call(reader.GetStringNullAsEmpty("BlogUrl")).Repeat.Times(2).Return("http://www.bbc.co.uk/blogs/test");

            return;
        }
Esempio n. 27
0
        /// <summary>
        /// With the returned data set generate the XML for the Solo Guide Entries page
        /// </summary>
        /// <param name="dataReader">Data set to turn into XML</param>
        /// <param name="skip">Number of items to skip</param>
        /// <param name="show">Number of items to show</param>
        /// <param name="action">Number of items to skip</param>
        /// <param name="userID">User ID</param>
        /// <param name="oldGroupID"></param>
        /// <param name="newGroupID"></param>
        /// <param name="refreshGroups"></param>
        private void GenerateSoloGuideEntriesXml(IDnaDataReader dataReader, int skip, int show, string action, int userID, int oldGroupID, int newGroupID, int refreshGroups)
        {
            int count = 0;

            XmlElement soloGuideEntriesUserList = AddElementTag(RootElement, "SOLOGUIDEENTRIES");
            AddAttribute(soloGuideEntriesUserList, "SKIP", skip);
            AddAttribute(soloGuideEntriesUserList, "SHOW", show);
            
            XmlElement actionXml = AddElementTag(soloGuideEntriesUserList, "ACTION");
            AddTextTag(actionXml, "ACTION", action);
            AddIntElement(actionXml, "USERID", userID);
            AddIntElement(actionXml, "OLDGROUPID", oldGroupID);
            AddIntElement(actionXml, "NEWGROUPID", newGroupID);
            AddIntElement(actionXml, "REFRESHGROUPS", refreshGroups);

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    XmlElement users = AddElementTag(soloGuideEntriesUserList, "SOLOUSERS");

                    do
                    {
                        int soloUserID = dataReader.GetInt32NullAsZero("UserID");
                        XmlElement soloEditedEntryUser = AddElementTag(users, "SOLOUSER");
                        User user = new User(InputContext);
                        user.AddUserXMLBlock(dataReader, soloUserID, soloEditedEntryUser);
                        AddIntElement(soloEditedEntryUser, "ENTRY-COUNT", dataReader.GetInt32NullAsZero("Count"));

                        count++;

                    } while (count < show && dataReader.Read());
                    if (dataReader.Read())
                    {
                        AddAttribute(soloGuideEntriesUserList, "MORE", 1);
                    }
                }
            }

            AddAttribute(soloGuideEntriesUserList, "COUNT", count);
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
        /// <summary>
        /// Method that reads the datareader and extracts the template and field info
        /// </summary>
        /// <param name="dataReader"></param>
        private void ReadTemplateData(IDnaDataReader dataReader)
        {
            if (dataReader.HasRows)
            {
                //Clear existing field data List ready for new set
                _uiFieldData.Clear();
                if (dataReader.Read())
                {
                    _name = dataReader.GetStringNullAsEmpty("TemplateName");
                    _UITemplateID = dataReader.GetInt32NullAsZero("UITemplateID");
                    _builderGUID = dataReader.GetGuid("BuilderGUID");

                    if (dataReader.NextResult())
                    {
                        while (dataReader.Read())
                        {
                            UIField uiField = new UIField(InputContext);
                            uiField.LoadFieldFromDatabase(dataReader);
                            _uiFieldData.Add(uiField.Name, uiField);
                        }
                    }
                }
            }
            else
            {
                AddErrorXml("ReadTemplateData", "No template data returned, invalid UI Template ID.", null);
                _hasErrors = true;
            }
        }
Esempio n. 30
0
        int GetLatestThreadEntryId(IDnaDataReader reader)
        {
            reader.ExecuteWithinATransaction(@"SELECT top 1 * FROM ThreadEntries order by EntryId desc");
            reader.Read();

            return reader.GetInt32("EntryId");
        }