示例#1
0
        public static ISnesActivity CreateActivity(int activityType, IDnaDataReader currentRow)
        {
            CommentActivity activity;

            if (currentRow.IsDBNull("BlogUrl"))
            {
                activity = PolicyInjection.Create<MessageBoardPostActivity>();
            }
            else
            {
                activity = PolicyInjection.Create<CommentForumActivity>();
            }

            activity.Contents = new OpenSocialActivity();
            activity.ActivityId = currentRow.GetInt32("EventID");
            activity.Application = currentRow.GetString("AppId") ?? "";
            activity.ActivityType = GetActivityTypeVerb(activityType);
            activity.IdentityUserId = currentRow.GetInt32("IdentityUserId");

            activity.SetTitle(currentRow);
            activity.SetObjectTitle(currentRow);
            activity.SetObjectDescription(currentRow);
            activity.SetObjectUri(currentRow);

            activity.Contents.Type = "comment";
            activity.Contents.Body = currentRow.GetString("Body") ?? "";
            activity.Contents.PostedTime = currentRow.GetDateTime("ActivityTime").MillisecondsSinceEpoch();
            activity.Contents.DisplayName = currentRow.GetString("displayName") ?? "";
            activity.Contents.Username = currentRow.GetString("username") ?? "";

            return activity;
        }
示例#2
0
        private EmailDetailsToProcess CreateProcessorForEmail(IDnaDataReader reader)
        {
            EmailDetailsToProcess emailToProcess = new EmailDetailsToProcess();

            emailToProcess.ID = reader.GetInt32("ID");
            emailToProcess.Subject = reader.GetString("Subject");
            emailToProcess.Body = reader.GetString("Body");
            emailToProcess.FromAddress = reader.GetString("FromEmailAddress");
            emailToProcess.ToAddress = reader.GetString("ToEmailAddress");

            return emailToProcess;
        }
示例#3
0
        public static ExModerationEvent CreateExModerationEvent(IDnaDataReader dataReader)
        {
            ExModerationEvent activity = PolicyInjection.Create<ExModerationEvent>();

            activity.ModId = dataReader.GetInt32NullAsZero("modid");
            activity.Notes = dataReader.GetString("notes") ?? "";
            activity.Uri = dataReader.GetString("uri") ?? "";
            activity.DateCompleted = dataReader.GetDateTime("datecompleted");
            activity.Decision = dataReader.GetInt32NullAsZero("status");
            activity.CallBackUri = dataReader.GetString("callbackuri") ?? "";

            return activity;
        }
        public SnesEventDataReaderAdapter(IDnaDataReader dataReader)
        {
            Rating = dataReader.IsDBNull("Rating") ? null : new RatingDataReaderAdapter(dataReader);
            AppInfo = new AppInfoDataReaderAdapter(dataReader);
            ActivityType = dataReader.GetInt32("ActivityType");
            EventId = dataReader.GetInt32("EventId");
            IdentityUserId = dataReader.GetString("IdentityUserId");
            BlogUrl = dataReader.IsDBNull("BlogUrl") ? null : dataReader.GetString("BlogUrl");

            UrlBuilder = new DnaUrlBuilder
                             {
                                 PostId = dataReader.GetInt32("PostId"),
                                 ForumId = dataReader.GetInt32("ForumId"),
                                 ThreadId = dataReader.GetInt32("ThreadId"),
                                 DnaUrl = dataReader.GetString("DnaUrl")
                             };
        }
        protected override void SetProperties(IDnaDataReader reader)
        {
            base.SetProperties(reader);

            ThreadEntryId = reader.GetNullableInt32("ThreadEntryId");
            ModClassId = reader.GetInt32("ModClassId");
            SiteId = reader.GetInt32("SiteId");
            ForumId = reader.GetInt32("ForumId");
            ThreadId = reader.GetNullableInt32("ThreadId");
            UserId = reader.GetInt32("UserId");
            DatePosted = reader.GetDateTime("DatePosted");
            Text = reader.GetString("text");
            RiskModThreadEntryQueueId = reader.GetInt32("RiskModThreadEntryQueueId");
        }
示例#6
0
        protected override void SetProperties(IDnaDataReader reader)
        {
            base.SetProperties(reader);

            ThreadEntryId = reader.GetInt32("ThreadEntryId");
            ModClassId = reader.GetInt32("ModClassId");
            SiteId = reader.GetInt32("SiteId");
            ForumId = reader.GetInt32("ForumId");
            ThreadId = reader.GetInt32("ThreadId");
            UserId = reader.GetInt32("UserId");
            NextSibling = reader.GetNullableInt32("NextSibling");
            Parent = reader.GetNullableInt32("Parent");
            PrevSibling = reader.GetNullableInt32("PrevSibling");
            FirstChild = reader.GetNullableInt32("FirstChild");
            DatePosted = reader.GetDateTime("DatePosted");
            Text = reader.GetString("text");
        }
示例#7
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;
        }
示例#8
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"));
        }
示例#9
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();
        }
示例#10
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;
        }
示例#11
0
        /// <summary>
        /// Helper method to create the list after a specific stored procedure
		///		has been called to return an appropriate results set.
        /// </summary>
        /// <param name="articleList"></param>
        /// <param name="dataReader"></param>
        /// <param name="skip">Number of Articles to skip</param>
        /// <param name="show">Number of Articles to show</param>
        /// <returns></returns>
        public int CreateList(XmlElement articleList, IDnaDataReader dataReader, int skip, int show)
        {
            int count = show;
            bool records = true;

            //Read/skip over the skip number of rows so that the row that the first row that in the do below is 
            //the one required
            for (int i = 0; i < skip; i++)
            {
                records = dataReader.Read();
                if (!records)
                {
                    break;
                }
            }

            if (records)
            {
                do
                {
                    // Setup the article
                    XmlElement article = AddElementTag(articleList, "ARTICLE");

                    if (dataReader.DoesFieldExist("EntryID"))
                    {
                        AddIntElement(article, "ENTRY-ID", dataReader.GetInt32NullAsZero("EntryID"));
                    }
                    if (dataReader.DoesFieldExist("h2g2ID"))
                    {
                        AddAttribute(article, "H2G2ID", dataReader.GetInt32NullAsZero("h2g2ID"));
                        //TODO: remove the H2G2-ID from all schemas and skins...
                        AddIntElement(article, "H2G2-ID", dataReader.GetInt32NullAsZero("h2g2ID"));
                    }
                    if (dataReader.DoesFieldExist("SiteID"))
                    {
                        AddIntElement(article, "SITEID", dataReader.GetInt32NullAsZero("SiteID"));
                    }
                    if (dataReader.DoesFieldExist("RecommendationID"))
                    {
                        AddIntElement(article, "RECOMMENDATION-ID", dataReader.GetInt32NullAsZero("RecommendationID"));
                    }
                    if (dataReader.DoesFieldExist("NotificationSent"))
                    {
                        AddIntElement(article, "NOTIFIED", dataReader.GetBoolean("NotificationSent") ? 1 : 0);
                    }

                    User user = new User(InputContext);
                    if (dataReader.DoesFieldExist("Editor"))
                    {
                        // place all user details within a USER tag and structure them appropriately
                        // editor info
                        int editorID = dataReader.GetInt32NullAsZero("Editor");
                        XmlElement editorTag = AddElementTag(article, "EDITOR");
                        user.AddPrefixedUserXMLBlock(dataReader, editorID, "Editor", editorTag);
                    }

                    if (dataReader.DoesFieldExist("AuthorID"))
                    {
                        // author info
                        int authorID = dataReader.GetInt32NullAsZero("AuthorID");
                        XmlElement authorTag = AddElementTag(article, "AUTHOR");
                        user.AddPrefixedUserXMLBlock(dataReader, authorID, "Author", authorTag);
                    }

                    if (dataReader.DoesFieldExist("AcceptorID"))
                    {
                        // acceptor info (user that accepted a recommendation)
                        int acceptorID = dataReader.GetInt32NullAsZero("AcceptorID");
                        XmlElement acceptorTag = AddElementTag(article, "ACCEPTOR");
                        user.AddPrefixedUserXMLBlock(dataReader, acceptorID, "Acceptor", acceptorTag);
                    }

                    if (dataReader.DoesFieldExist("AllocatorID"))
                    {
                        // allocator info (user that allocated a recommendation to a sub)
                        int allocatorID = dataReader.GetInt32NullAsZero("AllocatorID");
                        XmlElement allocatorTag = AddElementTag(article, "ALLOCATOR");
                        user.AddPrefixedUserXMLBlock(dataReader, allocatorID, "Allocator", allocatorTag);
                    }

                    if (dataReader.DoesFieldExist("ScoutID"))
                    {
                        // scout info
                        int scoutID = dataReader.GetInt32NullAsZero("ScoutID");
                        XmlElement scoutTag = AddElementTag(article, "SCOUT");
                        user.AddPrefixedUserXMLBlock(dataReader, scoutID, "Scout", scoutTag);
                    }

                    if (dataReader.DoesFieldExist("SubEditorID"))
                    {
                        // sub editor info
                        int subEditorID = dataReader.GetInt32NullAsZero("SubEditorID");
                        XmlElement subEditorTag = AddElementTag(article, "SUBEDITOR");
                        user.AddPrefixedUserXMLBlock(dataReader, subEditorID, "SubEditor", subEditorTag);
                    }

                    if (dataReader.DoesFieldExist("Status"))
                    {
                        AddIntElement(article, "STATUS", dataReader.GetInt32NullAsZero("Status"));
                    }
                    if (dataReader.DoesFieldExist("RecommendationStatus"))
                    {
                        AddIntElement(article, "RECOMMENDATION-STATUS", dataReader.GetInt32NullAsZero("RecommendationStatus"));
                    }
                    if (dataReader.DoesFieldExist("SubbingStatus"))
                    {
                        AddIntElement(article, "SUBBING-STATUS", dataReader.GetInt32NullAsZero("SubbingStatus"));
                    }
                    if (dataReader.DoesFieldExist("Style"))
                    {
                        AddIntElement(article, "STYLE", dataReader.GetInt32NullAsZero("Style"));
                    }

                    if (dataReader.DoesFieldExist("Subject"))
                    {
                        AddTextTag(article, "SUBJECT", dataReader.GetStringNullAsEmpty("Subject"));
                    }

                    if (dataReader.DoesFieldExist("DateCreated"))
                    {
                        AddDateXml(dataReader, article, "DateCreated", "DATE-CREATED");
                    }
                    if (dataReader.DoesFieldExist("LastUpdated"))
                    {
                        AddDateXml(dataReader, article, "LastUpdated", "LASTUPDATED");
                    }
                    if (dataReader.DoesFieldExist("DateRecommended"))
                    {
                        AddDateXml(dataReader, article, "DateRecommended", "DATE-RECOMMENDED");
                    }
                    if (dataReader.DoesFieldExist("DecisionDate"))
                    {
                        AddDateXml(dataReader, article, "DecisionDate", "RECOMMENDATION-DECISION-DATE");
                    }
                    if (dataReader.DoesFieldExist("DateAllocated"))
                    {
                        AddDateXml(dataReader, article, "DateAllocated", "DATE-ALLOCATED");
                    }
                    if (dataReader.DoesFieldExist("DateReturned"))
                    {
                        AddDateXml(dataReader, article, "DateReturned", "DATE-RETURNED");
                    }

                    //TODO add Extra Info correctly
                    if (dataReader.DoesFieldExist("ExtraInfo"))
                    {
                        //Add Extra Info XML where it exists.
                        string extraInfo = dataReader.GetAmpersandEscapedStringNullAsEmpty("ExtraInfo");
                        if (extraInfo != string.Empty)
                        {
                            XmlDocument extraInfoXml = new XmlDocument();
                            extraInfoXml.LoadXml(extraInfo);
                            article.AppendChild(ImportNode(extraInfoXml.FirstChild));
                        }

                        //TODO Use Extra Info Class will need to change SP to get out the guide entry Type
                        //ExtraInfo extraInfo = new ExtraInfo();
                        //extraInfo.TryCreate(dataReader.GetInt32NullAsZero("Type"), dataReader.GetStringNullAsEmpty("ExtraInfo"));
                        //AddInside(article, extraInfo);
                    }

                    if (dataReader.DoesFieldExist("ForumPostCount"))
                    {
                        AddIntElement(article, "FORUMPOSTCOUNT", dataReader.GetInt32NullAsZero("ForumPostCount"));
                        AddIntElement(article, "FORUMPOSTLIMIT", InputContext.GetSiteOptionValueInt("Forum", "PostLimit"));
                    }

                    if (dataReader.DoesFieldExist("StartDate") && !dataReader.IsDBNull("StartDate"))
                    {
                        AddDateXml(dataReader, article, "StartDate", "DATERANGESTART");
                    }
                    // Take a day from the end date as stored in the database for UI purposes. 
                    // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. 
                    // This gets stored in the database but for display purposes we subtract a day from the database end date to return the 
                    // original dates submitted by the user inorder to match their expectations.
                    if (dataReader.DoesFieldExist("EndDate") && !dataReader.IsDBNull("EndDate"))
                    {
                        AddDateXml(dataReader.GetDateTime("EndDate").AddDays(-1), article, "DATERANGEEND");
                    }

                    if (dataReader.DoesFieldExist("TimeInterval"))
                    {
                        AddIntElement(article, "TIMEINTERVAL", dataReader.GetInt32NullAsZero("TimeInterval"));
                    }

                    if (dataReader.DoesFieldExist("LASTPOSTED"))
                    {
                        AddDateXml(dataReader, article, "LASTPOSTED", "FORUMLASTPOSTED");
                    }
                    //////////


                    if (dataReader.DoesFieldExist("BookmarkCount"))
                    {
                        AddTextTag(article, "BOOKMARKCOUNT", dataReader.GetInt32NullAsZero("BookmarkCount"));
                    }

                    if (dataReader.DoesFieldExist("ZeitgeistScore"))
                    {
                        AddElement(article, "ZEITGEIST", "<SCORE>" + dataReader.GetDoubleNullAsZero("ZeitgeistScore") + "</SCORE>");
                    }

                    #region LocationXML
                    //***********************************************************************
                    // Location Info
                    //***********************************************************************
                    if (dataReader.DoesFieldExist("Latitude") && !dataReader.IsDBNull("Latitude"))
                    {
                        AddTextTag(article, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString());
                        AddTextTag(article, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString());
                        if (dataReader.DoesFieldExist("Distance"))
                        {
                            if (dataReader.GetDoubleNullAsZero("Distance") < 0.0001)
                            {
                                AddTextTag(article, "DISTANCE", "0");
                            }
                            else
                            {
                                AddTextTag(article, "DISTANCE", dataReader.GetDoubleNullAsZero("Distance").ToString());
                            }
                        }
                        AddTextTag(article, "LOCATIONTITLE", dataReader.GetString("LocationTitle"));
                        AddTextTag(article, "LOCATIONDESCRIPTION", dataReader.GetString("LocationDescription"));
                        AddTextTag(article, "LOCATIONZOOMLEVEL", dataReader.GetInt32NullAsZero("LocationZoomLevel").ToString());
                        AddTextTag(article, "LOCATIONUSERID", dataReader.GetInt32NullAsZero("LocationUserID").ToString());
                        AddDateXml(dataReader.GetDateTime("LocationDateCreated"), article, "LOCATIONDATECREATED");
                    }
                    //***********************************************************************
                    #endregion

                    if (dataReader.DoesFieldExist("MediaAssetID"))
                    {
                        AddMediaAssetXml(dataReader, article, dataReader.GetInt32NullAsZero("MediaAssetID"));
                    }

                    if (dataReader.DoesFieldExist("CRPollID"))
                    {
                        AddPollXml(dataReader, article);
                    }



                    count--;

                } while (count > 0 && dataReader.Read());	// dataReader.Read won't get called if count == 0

                // See if there's an extra row waiting
                if (count == 0 && dataReader.Read())
                {
                    AddAttribute(articleList, "MORE", 1);
                }
            }
            return count;
        }
示例#12
0
        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;
        }
示例#13
0
        /// <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;
        }
示例#14
0
 void TestNullableStringField(IDnaDataReader reader, string fieldName, string expected)
 {
     if (reader.IsDBNull(fieldName))
         Assert.IsNull(expected);
     else
         Assert.AreEqual(expected, reader.GetString(fieldName));
 }
示例#15
0
        /// <summary>
        /// With the returned data set generate the XML for the Article Search page
        /// </summary>
        /// <param name="dataReader">The returned search resultset</param>
        /// <param name="asp">The Article Search Params</param>
        private void GenerateArticleSearchXml(IDnaDataReader dataReader, ArticleSearchParams asp)
        {
            RootElement.RemoveAll();
            XmlNode articleSearch = AddElementTag(RootElement, "ARTICLESEARCH");

            AddAttribute(articleSearch, "CONTENTTYPE", asp.ContentType);
            AddAttribute(articleSearch, "SORTBY", asp.SortBy);
            AddAttribute(articleSearch, "SKIPTO", asp.Skip);
            AddAttribute(articleSearch, "SHOW", asp.Show);
            AddAttribute(articleSearch, "DATESEARCHTYPE", asp.DateSearchType);
            AddAttribute(articleSearch, "TIMEINTERVAL", asp.TimeInterval);
            AddAttribute(articleSearch, "ARTICLESTATUS", asp.ArticleStatus);
            AddAttribute(articleSearch, "ARTICLETYPE", asp.ArticleType);
            AddAttribute(articleSearch, "LATITUDE", asp.Latitude);
            AddAttribute(articleSearch, "LONGITUDE", asp.Longitude);
            AddAttribute(articleSearch, "RANGE", asp.Range);
            AddAttribute(articleSearch, "POSTCODE", asp.PostCode);
            AddAttribute(articleSearch, "PLACENAME", asp.Placename);
            AddAttribute(articleSearch, "LOCATIONSEARCHTYPE", asp.LocationSearchType);

            //Add the new descending order attribute
            if (asp.DescendingOrder)
            {
                AddAttribute(articleSearch, "DESCENDINGORDER", 1);
            }
            else
            {
                AddAttribute(articleSearch, "DESCENDINGORDER", 0);
            }

            //Add the requested searchphraselist
            GeneratePhraseXml(asp.SearchPhraseList, (XmlElement)articleSearch);

            //Add Date Search Params if we are doing a date search
            if (asp.DateSearchType != 0)
            {
                AddDateXml(asp.StartDate, articleSearch, "DATERANGESTART");
                // Take a day from the end date as used in the database for UI purposes. 
                // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. 
                // This gets used in the database but for display purposes we subtract a day from the database end date to return the 
                // original dates submitted by the user inorder to match their expectations.
                AddDateXml(asp.EndDate.AddDays(-1), articleSearch, "DATERANGEEND");
            }

            AddTextTag(articleSearch, "FREETEXTSEARCH", asp.FreeTextSearchCondition);

            XmlNode articles = AddElementTag(articleSearch, "ARTICLES");
            int total = 0;
            int count = 0;

            //Generate Hot-List from Search Results.
            PopularPhrases popularPhrases = null;
            if (InputContext.GetSiteOptionValueBool("articlesearch", "generatepopularphrases"))
            {
                popularPhrases = new PopularPhrases();
            }

            if (dataReader.HasRows)
            {
                // process first results set: the Article Key phrase results set
                Dictionary<int, ArrayList> articleKeyPhrases = new Dictionary<int, ArrayList>();
                ArrayList phraselist = new ArrayList();
                int h2g2ID = 0;

                if (dataReader.Read())
                {
                    int previousH2G2ID = 0;

                    do
                    {
                        h2g2ID = dataReader.GetInt32NullAsZero("H2G2ID");

                        if (h2g2ID != previousH2G2ID)
                        {
                            //New now have a new article so clean up the last one
                            if (previousH2G2ID != 0)
                            {
                                articleKeyPhrases.Add(previousH2G2ID, phraselist);
                                phraselist = new ArrayList();
                            }
                        }

                        //set the previous h2g2id to this one
                        previousH2G2ID = h2g2ID;

                        //Create fill an new Phrase object
                        Phrase nameSpacedPhrase = new Phrase();

                        String nameSpace = String.Empty;
                        String phraseName = dataReader.GetStringNullAsEmpty("phrase");

                        if (phraseName != String.Empty)
                        {
                            if (dataReader.Exists("namespace"))
                            {
                                nameSpace = dataReader.GetStringNullAsEmpty("namespace");
                            }
                            nameSpacedPhrase.NameSpace = nameSpace;
                            nameSpacedPhrase.PhraseName = phraseName;

                            //add it to the list
                            phraselist.Add(nameSpacedPhrase);

                            //Record Popular Phrases.
                            if (popularPhrases != null)
                            {
                                popularPhrases.AddPhrase(phraseName, nameSpace);
                            }
                        }

                    } while (dataReader.Read());
                }

                articleKeyPhrases.Add(h2g2ID, phraselist);

                dataReader.NextResult();

                if (dataReader.Read())
                {
                    total = dataReader.GetInt32NullAsZero("TOTAL");

                    //The stored procedure returns one row for each article. The article's keyphrases have been stored in articleKeyPhrases.
                    XmlNode article = CreateElementNode("ARTICLE");
                    do
                    {
                        count++;
                        h2g2ID = dataReader.GetInt32NullAsZero("H2G2ID");

                        //Start filling new article xml
                        AddAttribute(article, "H2G2ID", h2g2ID);

                        int editorID = dataReader.GetInt32NullAsZero("editor");
                        XmlNode editor = CreateElementNode("EDITOR");
                        User user = new User(InputContext);
                        user.AddUserXMLBlock(dataReader, editorID, editor);
                        article.AppendChild(editor);

                        AddTextTag(article, "STATUS", dataReader.GetInt32NullAsZero("status"));
                        AddXmlTextTag(article, "SUBJECT", dataReader.GetStringNullAsEmpty("SUBJECT"));
                        AddTextTag(article, "TYPE", dataReader.GetInt32NullAsZero("type"));

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

                        //Add Extra Info XML where it exists.
                        string extraInfo = dataReader.GetAmpersandEscapedStringNullAsEmpty("EXTRAINFO");
                        if (extraInfo != string.Empty)
                        {

                            XmlDocument extraInfoXml = new XmlDocument();
                            extraInfoXml.LoadXml(extraInfo);
                            article.AppendChild(ImportNode(extraInfoXml.FirstChild));

                        }

                        AddTextTag(article, "NUMBEROFPOSTS", dataReader.GetInt32NullAsZero("ForumPostCount"));
                        AddDateXml(dataReader, article, "LASTPOSTED", "FORUMLASTPOSTED");
                        if (!dataReader.IsDBNull("StartDate"))
                        {
                            AddDateXml(dataReader, article, "StartDate", "DATERANGESTART");
                            // Take a day from the end date as stored in the database for UI purposes. 
                            // E.g. User submits a date range of 01/09/1980 to 02/09/1980. They mean for this to represent 2 days i.e. 01/09/1980 00:00 - 03/09/1980 00:00. 
                            // This gets stored in the database but for display purposes we subtract a day from the database end date to return the 
                            // original dates submitted by the user inorder to match their expectations.
                            AddDateXml(dataReader.GetDateTime("EndDate").AddDays(-1), article, "DATERANGEEND");

                            AddTextTag(article, "TIMEINTERVAL", dataReader.GetInt32NullAsZero("TimeInterval"));
                        }


                        if (dataReader.DoesFieldExist("BookmarkCount"))
                        {
                            AddTextTag(article, "BOOKMARKCOUNT", dataReader.GetInt32NullAsZero("BookmarkCount"));
                        }

                        if (dataReader.DoesFieldExist("ZeitgeistScore"))
                        {
                            AddElement(article, "ZEITGEIST", "<SCORE>" + dataReader.GetDoubleNullAsZero("ZeitgeistScore") + "</SCORE>");
                        }

                        

                        #region LocationXML
                        //***********************************************************************
                        // Location Info
                        //***********************************************************************
                        if (dataReader.DoesFieldExist("Latitude") && !dataReader.IsDBNull("Latitude"))
                        {
                            AddTextTag(article, "LATITUDE", dataReader.GetDoubleNullAsZero("Latitude").ToString());
                            AddTextTag(article, "LONGITUDE", dataReader.GetDoubleNullAsZero("Longitude").ToString());
                            if (dataReader.DoesFieldExist("Distance"))
                            {
                                if (dataReader.GetDoubleNullAsZero("Distance") < 0.0001)
                                {
                                    AddTextTag(article, "DISTANCE", "0");
                                }
                                else
                                {
                                    AddTextTag(article, "DISTANCE", dataReader.GetDoubleNullAsZero("Distance").ToString());
                                }
                            }
                            AddTextTag(article, "LOCATIONTITLE", dataReader.GetString("LocationTitle"));
                            AddTextTag(article, "LOCATIONDESCRIPTION", dataReader.GetString("LocationDescription"));
                            AddTextTag(article, "LOCATIONZOOMLEVEL", dataReader.GetInt32NullAsZero("LocationZoomLevel").ToString());
                            AddTextTag(article, "LOCATIONUSERID", dataReader.GetInt32NullAsZero("LocationUserID").ToString());
                            AddDateXml(dataReader.GetDateTime("LocationDateCreated"), article, "LOCATIONDATECREATED");
                        }
                        //***********************************************************************
                        #endregion
                        //***********************************************************************
                        // Media Asset Info
                        //***********************************************************************
                        int mediaAssetID = dataReader.GetInt32NullAsZero("MediaAssetID");

                        if (mediaAssetID != 0)
                        {
                            AddMediaAssetXml(dataReader, article, mediaAssetID);
                        }
                        //***********************************************************************

                        AddPollXml(dataReader, article);

                        if (articleKeyPhrases.ContainsKey(h2g2ID))
                        {
                            GeneratePhraseXml(articleKeyPhrases[h2g2ID], (XmlElement)article);
                        }

                        XmlNode previousarticle = article.CloneNode(true);
                        articles.AppendChild(previousarticle);
                        article.RemoveAll();

                    } while (dataReader.Read());
                }
            }
            articleSearch.AppendChild(articles);
            AddAttribute(articleSearch, "COUNT", count);
            AddAttribute(articleSearch, "TOTAL", total);

            if (popularPhrases != null)
            {
                //Include popularPhrase statistics.
                XmlElement popularPhrasesXml = popularPhrases.GenerateXml();
                articleSearch.AppendChild(ImportNode(popularPhrasesXml));
            }

            FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "articlesearch", _cacheName, articleSearch.OuterXml);

            //articleSearch.OwnerDocument.Save(@"c:\TEMP\Articlesearch.xml");
        }
        public OpenSocialActivityDataReaderAdapter(IDnaDataReader dataReader)
        {
            Body = dataReader.GetString("Body");

            PostedTime = dataReader.GetDateTime("ActivityTime").MillisecondsSinceEpoch();
            DisplayName = dataReader.GetString("displayName");
            ObjectTitle = dataReader.GetString("ObjectTitle");
            ObjectDescription =dataReader.GetString("Body");
            UserName = dataReader.GetString("Username");
            ApplicationActivityObjectId = dataReader.GetInt32("PostID");

            var appName = dataReader.GetString("DnaUrl") ?? "";

            ObjectUri = (dataReader.GetString("ObjectUriFormat") ?? "").FormatReplacementStrings(dataReader.GetInt32("ForumID"), 
                dataReader.GetInt32("ThreadID"), dataReader.GetInt32("PostID"), appName, dataReader.GetString("BlogUrl") ?? "", 
                dataReader.GetString("ObjectUri") ?? "");

            ContentPermaUrl = (dataReader.GetString("ContentPermaUrl") ?? "").FormatReplacementStrings(dataReader.GetInt32("ForumID"),
                dataReader.GetInt32("ThreadID"), dataReader.GetInt32("PostID"), appName, dataReader.GetString("BlogUrl") ?? "",
                dataReader.GetString("ObjectUri") ?? "");
                
            CustomActivityType = dataReader.GetString("CustomActivityType") ?? "";

        }
示例#17
0
        string GetNextIndentityId(IDnaDataReader reader)
        {
            string sql = @"select IdentityUserID from signinuseridmapping 
                           where cast(identityuserid as bigint) = (select max(cast(identityuserid as bigint)) from signinuseridmapping)";
            reader.ExecuteWithinATransaction(sql);
            reader.Read();
            string identityId = reader.GetString("IdentityUserID");
            reader.Close();

            Int64 id = Int64.Parse(identityId);

            return (id+1).ToString();
        }
示例#18
0
//        create procedure fetcharticlemoderationhistory @h2g2id int


        /*

use smallguide
begin tran

select j1.forumid,u1.*
		FROM Users u1
		INNER JOIN Journals J1 ON J1.UserID = u1.UserID and J1.SiteID = 1
		--INNER JOIN FaveForums f ON f.ForumID = J1.ForumID
		--INNER JOIN Users u ON f.UserID = u.UserID
		--INNER JOIN Journals J on J.UserID = u.UserID --and J.SiteID = 1
		--INNER JOIN Forums fo ON fo.ForumID = J.ForumID

insert FaveForums values (5819,5)

exec watchingusers @userid =5, @siteid =1, @skip = 0, @show = 100000
rollback tran
use master

         
                         */

        #endregion


        #region Helper methods



        EmailValues GetUserEmailValues(IDnaDataReader reader, int userId)
        {
            string sql = string.Format(@"SELECT DecryptedEmail = dbo.udf_decryptemailaddress(EncryptedEmail,UserID), EncryptedEmail, HashedEmail FROM Users WHERE UserId=" + userId);
            reader.ExecuteWithOpenKey(sql);
            reader.Read();

            EmailValues emailValues = new EmailValues();

            emailValues.DecryptedEmail = reader.GetString("DecryptedEmail");
            emailValues.EncryptedEmail = reader.GetSqlBinary("EncryptedEmail");
            emailValues.HashedEmail = reader.GetSqlBinary("HashedEmail");

            reader.Close();

            return emailValues;
        }
示例#19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="forumId"></param>
        /// <param name="index"></param>
        /// <param name="applySkin">whether we need to apply the transform to the post</param>
        /// <returns></returns>
        public static ThreadSummary CreateThreadSummaryFromReader(IDnaDataReader reader, int forumId, int index, bool applySkin)
        {
            var thread = new ThreadSummary();
            thread.ForumId = forumId;
            thread.Index = index;
            thread.Type = string.Empty; //TODO: remove as this is a legacy ripley element


            if (reader.DoesFieldExist("ThisCanRead"))
            {
                thread.CanRead = (byte)(reader.GetBoolean("ThisCanRead") ? 1 : 0);
            }

            if (reader.DoesFieldExist("ThisCanWrite"))
            {
                thread.CanWrite = (byte)(reader.GetBoolean("ThisCanWrite") ? 1 : 0);

            }

           
            thread.ThreadId = reader.GetInt32NullAsZero("ThreadID");            
            thread.DateLastPosted = new DateElement(reader.GetDateTime("LastPosted"));
            if (reader.DoesFieldExist("cnt"))
            {
                thread.TotalPosts = reader.GetInt32NullAsZero("cnt");
            }
            
            if (reader.DoesFieldExist("firstpostentryid"))
            {
                thread.FirstPost = ThreadPostSummary.CreateThreadPostFromReader(reader, "FirstPost", reader.GetInt32NullAsZero("firstpostentryid"), applySkin);
            }

            if (reader.DoesFieldExist("lastpostentryid"))
            {
                thread.LastPost = ThreadPostSummary.CreateThreadPostFromReader(reader, "LastPost", reader.GetInt32NullAsZero("lastpostentryid"), applySkin);
            }

            if (reader.DoesFieldExist("FirstSubject"))
            {
                if (thread.FirstPost != null)
                {
                    thread.Subject = ThreadPost.FormatSubject(reader.GetString("FirstSubject"), (CommentStatus.Hidden)thread.FirstPost.Hidden);
                }
                else
                {
                    thread.Subject = ThreadPost.FormatSubject(reader.GetString("FirstSubject"), CommentStatus.Hidden.NotHidden );
                }
            }


            if(reader.DoesFieldExist("IsSticky"))
            {//conditionally check if field exists..
                thread.IsSticky = (reader.GetInt32NullAsZero("IsSticky")==1);
            }
            return thread;
        }
示例#20
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);
        }
示例#21
0
 void TestPublishMethod(IDnaDataReader reader, char expectedPublishMethod)
 {
     string pm = reader.GetString("PublishMethod");
     Assert.AreEqual(expectedPublishMethod, pm[0]);
     Assert.IsTrue(pm.Length == 1);
     Assert.IsTrue(pm[0] == 'A' || pm[0] == 'B');
 }
示例#22
0
        /// <summary>
        /// This method creates the crumbtrail for a given item
        /// </summary>
        /// <param name="reader">The DnaDataReader that contains the crumbtrail result set.</param>
        private void GetCrumbtrailForItem(IDnaDataReader reader)
        {
            XmlNode crumbtrailsNode = AddElementTag(RootElement, "CRUMBTRAILS");
            bool startOfTrail = true;
            XmlNode crumbtrailNode = 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)
                {
                    crumbtrailNode = AddElementTag(crumbtrailsNode, "CRUMBTRAIL");
                    startOfTrail = false;
                }

                XmlNode ancestorNode = AddElementTag(crumbtrailNode, "ANCESTOR");
                AddIntElement(ancestorNode, "NODEID", reader.GetInt32("NodeID"));
                AddTextElement((XmlElement)ancestorNode, "NAME", reader.GetString("DisplayName"));
                AddIntElement(ancestorNode, "TREELEVEL", treeLevel);
                AddIntElement(ancestorNode, "NODETYPE", reader.GetInt32("Type"));
                if (reader.Exists("RedirectNodeID") && !reader.IsDBNull("RedirectNodeID"))
                {
                    XmlNode redirectNode = AddTextElement((XmlElement)ancestorNode, "REDIRECTNODE", reader.GetString("RedirectNodeName"));
                    AddAttribute(redirectNode,"ID", reader.GetInt32("RedirectNodeID"));
                }
            }
        }
示例#23
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);
        }
 public AppInfoDataReaderAdapter(IDnaDataReader dataReader)
 {
     AppId = dataReader.GetString("AppId");
     ApplicationName = dataReader.GetString("AppName");
 }
示例#25
0
        /// <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;
        }
示例#26
0
文件: Forum.cs 项目: rocketeerbkw/DNA
        /// <summary>
        /// Creates the XML block for a posting in a thread
        /// </summary>
        /// <param name="reader">The IDnaDataReader that contains the information about the posting</param>
        /// <param name="threadNode">The node to add the posting node to</param>
        /// <param name="usersPrefix">Pass in 'First' if the post is the first post in the thread, and 'last' if it's the last.</param>
        /// <returns>The new post node</returns>
        private XmlNode CreateThreadPostingXml(IDnaDataReader reader, XmlNode threadNode, string usersPrefix)
        {
            XmlNode postingNode = AddElementTag(threadNode, usersPrefix + "POST");
            AddAttribute(postingNode, "POSTID", reader.GetInt32(usersPrefix + "PostEntryID"));
            AddAttribute(postingNode, "HIDDEN", reader.GetInt32NullAsZero(usersPrefix + "PostHidden"));

            User postingUser = new User(InputContext);
            postingUser.AddPrefixedUserXMLBlock(reader, reader.GetInt32(usersPrefix + "PostUserID"), usersPrefix + "Post", postingNode);

            if (!reader.IsDBNull(usersPrefix + "PostHidden") && reader.GetInt32(usersPrefix + "PostHidden") > 0)
            {
                AddTextElement((XmlElement)postingNode, "TEXT", "Hidden");
            }
            else
            {
                string text = reader.GetString(usersPrefix + "PostText");

                // Do the translate to plain text here!

                XmlNode textNode = AddTextElement((XmlElement)postingNode, "TEXT", text);
            }

            return postingNode;
        }
示例#27
0
文件: User.cs 项目: rocketeerbkw/DNA
        /// <summary>
        /// Method for reading user data from user procedure calls
        /// </summary>
        /// <param name="reader">The StoredProcedure reader that contains the data</param>
        private void ReadUserDetails(IDnaDataReader reader)
        {
            UserID = reader.GetInt32("userid");
            UserName = reader.GetString("username");

            IdentityUserID = reader.GetStringNullAsEmpty("IdentityUserID");
            IdentityUserName = reader.GetStringNullAsEmpty("IdentityUserName");

            _status = reader.GetInt32("status");
            _prefStatus = reader.GetInt32("PrefStatus");
            
            if (_status == 1)//normal global status
            {
                if (reader.GetInt32("PrefStatus") == 4)//banned
                {
                    _status = 0;
                }
            }
            //NO NO emails
            Email = reader.GetString("email");
            SiteSuffix = reader.GetStringNullAsEmpty("SiteSuffix");
            LastSynchronisedDate = reader.GetDateTime("LastUpdatedDate");
            if (reader.Exists("AcceptSubscriptions"))
            {
                AcceptSubscriptions = reader.GetBoolean("AcceptSubscriptions");
            }

            if (reader.Exists("SinBin"))
            {
                IsAutoSinBin = reader.GetInt32NullAsZero("SinBin");
            }

            //PrimarySiteId = reader.GetInt32NullAsZero("PrimarySiteId");
        }
示例#28
0
        public static string CreateTitleString(IDnaDataReader currentRow, 
            string activityVerb, string activityUrl, string activityHostNameUrl)
        {
            var activityName = currentRow.GetString("AppName") ?? "";

            return string.Format(titleTemplate,
                activityVerb,
                activityUrl,
                activityHostNameUrl,
                activityName);
        }