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
        static public SiteEvent CreateComplaintArticleEventActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
        {
            SiteEvent siteEvent = null;
            try
            {
                siteEvent = new SiteEvent();
                siteEvent.SiteId = dataReader.GetInt32NullAsZero("siteid");
                siteEvent.Date = new Date(dataReader.GetDateTime("DateCreated"));
                siteEvent.Type = SiteActivityType.ComplaintArticle;

                var complainantUserName = dataReader.GetStringNullAsEmpty("complainantUserName");
                if (String.IsNullOrEmpty(complainantUserName))
                {
                    complainantUserName = "******";
                }

                siteEvent.ActivityData = XElement.Parse(
                           string.Format(DataFormat,
                            dataReader.GetInt32NullAsZero("complaintantID_userid"), complainantUserName,
                            dataReader.GetInt32NullAsZero("h2g2id"), dataReader.GetStringNullAsEmpty("subject"),
                            dataReader.GetStringNullAsEmpty("complainttext"))
                            );
                siteEvent.UserId = 0;
                siteEvent.SaveEvent(creator);
            }
            catch(Exception e)
            {
                siteEvent = null;
                SiteEventsProcessor.SiteEventLogger.LogException(e);
            }

            return siteEvent;
        }
Esempio n. 3
0
        public static Link CreateLinkFromReader(IDnaDataReader reader)
        {
            Link link = new Link();
            link.Type = reader.GetStringNullAsEmpty("destinationtype");

            link.LinkId = reader.GetInt32NullAsZero("linkid");
            link.TeamId =  reader.GetInt32NullAsZero("teamid");
            link.Relationship =  reader.GetStringNullAsEmpty("relationship");
            link.Private =  reader.GetTinyIntAsInt("private");
            link.Description = reader.GetStringNullAsEmpty("linkdescription");
            link.DateLinked = new DateElement(reader.GetDateTime("DateLinked"));

            link.Submitter = new UserElement() { user = BBC.Dna.Objects.User.CreateUserFromReader(reader, "submitter") };

            //Create appropriate URL from link type. 
            int destinationId = reader.GetInt32NullAsZero("DestinationID");
            switch (link.Type)
            {
                case "article":
                {
                    link.DnaUid =  "A" + destinationId.ToString();
                    break;
                }
                case "userpage":
                {
                    link.DnaUid =  "U" + destinationId.ToString();
                    break;
                }
                case "category":
                {
                    link.DnaUid =  "C" + destinationId.ToString();
                    break;
                }
                case "forum":
                {
                    link.DnaUid =  "F" + destinationId.ToString();
                    break;
                }
                case "thread":
                {
                    link.DnaUid =  "T" + destinationId.ToString();
                    break;
                }
                case "posting":
                {
                    link.DnaUid =  "TP" + destinationId.ToString();
                    break;
                }
                default: // "club" )
                {
                    link.DnaUid =  "G" + destinationId.ToString();
                    break;
                }
            }
            return link;
        }
Esempio n. 4
0
 static public SiteEvent CreateNewUserEventActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
 {
     SiteEvent siteEvent = null;
     try
     {
         siteEvent = new SiteEvent();
         siteEvent.SiteId = dataReader.GetInt32NullAsZero("siteid");
         siteEvent.Date = new Date(dataReader.GetDateTime("DateCreated"));
         siteEvent.Type = SiteActivityType.NewUserToSite;
         siteEvent.ActivityData = XElement.Parse(
                    string.Format(DataFormat,
                     dataReader.GetInt32NullAsZero("user_userid"), dataReader.GetStringNullAsEmpty("user_username"),
                     dataReader.GetInt32NullAsZero("siteid"))
                     );
         siteEvent.UserId = dataReader.GetInt32NullAsZero("user_userid");
         siteEvent.SaveEvent(creator);
         
     }
     catch(Exception e)
     {
         siteEvent = null;
         SiteEventsProcessor.SiteEventLogger.LogException(e);
     }
     return siteEvent;
 }
Esempio n. 5
0
        /// <summary>
        /// Gets the topic elements from the current reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        static public TopicElement GetTopicFromReader(IDnaDataReader reader)
        {
            var topicEdit = new TopicElement();
            topicEdit.TopicId = reader.GetInt32NullAsZero("topicid");
            topicEdit.H2G2Id = reader.GetInt32NullAsZero("h2g2ID");
            topicEdit.SiteId = reader.GetInt32NullAsZero("SiteID");
            topicEdit.TopicStatus = (TopicStatus)reader.GetInt32NullAsZero("TopicStatus");
            topicEdit.Title = reader.GetStringNullAsEmpty("TITLE");
            topicEdit.ForumId = reader.GetInt32NullAsZero("ForumID");
            topicEdit.Description = reader.GetStringNullAsEmpty("description");
            topicEdit.Position = reader.GetInt32NullAsZero("position");
            topicEdit.TopicLinkId = reader.GetInt32NullAsZero("topiclinkid");
            topicEdit.Createdby = new TopicCreatedDate
              {
                  CreatedDate = new DateElement(reader.GetDateTime("createddate")),
                  Username = reader.GetStringNullAsEmpty("CreatedByUserName"),
                  Userid = reader.GetInt32NullAsZero("CreatedByUserID")
              };

            topicEdit.Updatedby = new TopicLastUpdated()
            {
                LastUpdated = new DateElement(reader.GetDateTime("LastUpdated")),
                Username = reader.GetStringNullAsEmpty("UpdatedByUserName"),
                Userid = reader.GetInt32NullAsZero("UpdatedByUserID")
            };
            topicEdit.Style = reader.GetInt32NullAsZero("style");
            topicEdit.ForumPostCount = reader.GetInt32NullAsZero("forumpostcount");
            topicEdit.FrontPageElement.Elementid = reader.GetInt32NullAsZero("FP_ElementID");
            topicEdit.FrontPageElement.Position = reader.GetInt32NullAsZero("FP_Position");
            topicEdit.FrontPageElement.Title = reader.GetStringNullAsEmpty("FP_Title");
            topicEdit.FrontPageElement.TemplateElement = reader.GetInt32NullAsZero("FP_Template");
            topicEdit.FrontPageElement.Text = reader.GetStringNullAsEmpty("FP_Text");
            topicEdit.FrontPageElement.ImageName = reader.GetStringNullAsEmpty("FP_ImageName");
            topicEdit.FrontPageElement.ImageAltText = reader.GetStringNullAsEmpty("FP_ImageAltText");
            topicEdit.FrontPageElement.ForumPostCount = reader.GetInt32NullAsZero("forumpostcount");
            topicEdit.FrontPageElement.TopicId = reader.GetInt32NullAsZero("topicid");
            
            topicEdit.Fastmod = reader.GetInt32NullAsZero("fastmod");
            topicEdit.Editkey = reader.GetGuid("editkey");
            topicEdit.FrontPageElement.Editkey = reader.GetGuid("FP_EditKey");

            return topicEdit;
        }
Esempio n. 6
0
        public static PostThreadInfo CreatePostThreadInfoFromReader(IDnaDataReader reader)
        {
            PostThreadInfo postThreadInfo = new PostThreadInfo();
            postThreadInfo.ForumId = reader.GetInt32NullAsZero("ForumId");
            postThreadInfo.ThreadId = reader.GetInt32NullAsZero("ThreadId");
            string type = reader.GetStringNullAsEmpty("Type");
            if (type == "")
            {
                postThreadInfo.Type = 0;
            }
            else if (type == "Notice")
            {
                postThreadInfo.Type = 1;
            }
            else if (type == "Event")
            {
                postThreadInfo.Type = 2;
            }
            else 
            {
                postThreadInfo.Type = 3;
            }

            if (reader.DoesFieldExist("FirstPostId"))
            {
                postThreadInfo.FirstPostId = reader.GetInt32NullAsZero("FirstPostId");
            }
            if (reader["DateFirstPosted"] != DBNull.Value)
            {
                postThreadInfo.DateFirstPosted = new DateElement(reader.GetDateTime("DateFirstPosted"));
            }
            if (reader["LastReply"] != DBNull.Value)
            {
                postThreadInfo.ReplyDate = new DateElement(reader.GetDateTime("LastReply"));
            }

            postThreadInfo.Subject = reader.GetStringNullAsEmpty("FirstSubject");
            postThreadInfo.ForumTitle = reader.GetStringNullAsEmpty("ForumTitle");
            if (reader.DoesFieldExist("JournalUserID"))
            {
                postThreadInfo.Journal = new UserElement() { user = BBC.Dna.Objects.User.CreateUserFromReader(reader, "Journal") };
            }
            return postThreadInfo;
        }
        static public SiteEvent CreateArticleModerationDecisionActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
        {
            SiteEvent siteEventArticleModerationDecision = null;
            try
            {
                siteEventArticleModerationDecision = new SiteEvent();
                siteEventArticleModerationDecision.SiteId = dataReader.GetInt32NullAsZero("siteid");
                siteEventArticleModerationDecision.Date = new Date(dataReader.GetDateTime("DateCreated"));
            
                var statusId = dataReader.GetInt32NullAsZero("statusid");

                
                switch ((ModerationDecisionStatus)statusId)
                {
                    case ModerationDecisionStatus.Fail:
                        siteEventArticleModerationDecision.Type = SiteActivityType.ModerateArticleFailed;
                        siteEventArticleModerationDecision.ActivityData = XElement.Parse(
                            string.Format(DataFormatFailed, dataReader.GetInt32NullAsZero("h2g2id"),
                            dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                            dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                            dataReader.GetStringNullAsEmpty("ModReason")
                            ));

                        break;


                    case ModerationDecisionStatus.Referred:
                        siteEventArticleModerationDecision.Type = SiteActivityType.ModerateArticleReferred;
                        siteEventArticleModerationDecision.ActivityData = XElement.Parse(
                            string.Format(DataFormatReferred, dataReader.GetInt32NullAsZero("h2g2id"),
                            dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                            dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                            dataReader.GetStringNullAsEmpty("Notes"))
                            );
                        break;

                    default:
                        siteEventArticleModerationDecision = null;
                        break;
                }
                siteEventArticleModerationDecision.UserId = 0;
                siteEventArticleModerationDecision.SaveEvent(creator);
            }
            catch(Exception e)
            {
                siteEventArticleModerationDecision = null;
                SiteEventsProcessor.SiteEventLogger.LogException(e);
            }

            return siteEventArticleModerationDecision;
        }
Esempio n. 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataReader"></param>
        /// <param name="userSearchType"></param>
        /// <param name="searchText"></param>
        /// <param name="checkAllSites"></param>
        /// <param name="twitterAPIException"></param>
        public void GenerateMemberListXml(
            IDnaDataReader dataReader,
            int userSearchType,
            string searchText,
            bool checkAllSites,
            string twitterAPIException)
        {
            int count = 0;

            XmlNode memberList = AddElementTag(RootElement, "MEMBERLIST");
            AddAttribute(memberList, "USERSEARCHTYPE", userSearchType.ToString());
            AddAttribute(memberList, "SEARCHTEXT", searchText);
            AddAttribute(memberList, "CHECKALLSITES", checkAllSites.ToString());
            

            if (dataReader.HasRows)
            {
                if (dataReader.Read())
                {
                    XmlNode userAccounts = AddElementTag(memberList, "USERACCOUNTS");

                    //int previousUserID = 0;
                    XmlNode userAccount = null;
                    do
                    {
                        int userID = dataReader.GetInt32NullAsZero("USERID");
                        /*if (userID != previousUserID)
                        {
                            if (userAccount != null)
                            {
                                userAccounts.AppendChild(userAccount);
                            }
                            userAccount = CreateElementNode("USERACCOUNT");
                            previousUserID = userID;
                        }*/
                        userAccount = CreateElementNode("USERACCOUNT");

                        //Start filling new user xml
                        AddAttribute(userAccount, "USERID", userID);
                        AddTextTag(userAccount, "SITEID", dataReader.GetInt32NullAsZero("SITEID"));

                        AddTextTag(userAccount, "USERNAME", dataReader.GetStringNullAsEmpty("USERNAME"));
                        AddTextTag(userAccount, "LOGINNAME", dataReader.GetStringNullAsEmpty("LOGINNAME"));
                        AddTextTag(userAccount, "EMAIL", dataReader.GetStringNullAsEmpty("EMAIL"));
                        AddTextTag(userAccount, "PREFSTATUS", dataReader.GetInt32NullAsZero("PREFSTATUS"));
                        AddTextTag(userAccount, "PREFSTATUSDURATION", dataReader.GetInt32NullAsZero("PREFSTATUSDURATION"));
                        AddTextTag(userAccount, "USERSTATUSDESCRIPTION", ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("PREFSTATUS")).ToString());
                        if (!dataReader.IsDBNull("DATEJOINED"))
                        {
                            AddDateXml(dataReader.GetDateTime("DATEJOINED"), userAccount, "DATEJOINED");
                        }
                        if (!dataReader.IsDBNull("PREFSTATUSCHANGEDDATE"))
                        {
                            DateTime prefStatusChangedDate = dataReader.GetDateTime("PREFSTATUSCHANGEDDATE");
                            AddDateXml(prefStatusChangedDate, userAccount, "PREFSTATUSCHANGEDDATE");
                        }
                        else
                        {
                            AddTextTag(userAccount, "PREFSTATUSCHANGEDDATE", "");
                        }

                        AddTextTag(userAccount, "SHORTNAME", dataReader.GetStringNullAsEmpty("SHORTNAME"));
                        AddTextTag(userAccount, "URLNAME", dataReader.GetStringNullAsEmpty("URLNAME"));

                        if (dataReader.DoesFieldExist("IPADDRESS") && dataReader.GetStringNullAsEmpty("IPADDRESS") != String.Empty)
                        {
                            AddTextTag(userAccount, "IPADDRESS", dataReader.GetStringNullAsEmpty("IPADDRESS"));
                        }
                        if (dataReader.DoesFieldExist("BBCUID") && dataReader.GetGuidAsStringOrEmpty("BBCUID") != String.Empty)
                        {
                            AddTextTag(userAccount, "BBCUID", dataReader.GetGuidAsStringOrEmpty("BBCUID"));
                        }

                        if (userSearchType == 6)
                        {
                            AddTextTag(userAccount, "TWITTERUSERID", dataReader.GetStringNullAsEmpty("TwitterUserID"));
                        }
                        else
                        {
                            AddIntElement(userAccount, "SSOUSERID", dataReader.GetInt32NullAsZero("SSOUserID"));
                        }
                        AddTextTag(userAccount, "IDENTITYUSERID", dataReader.GetStringNullAsEmpty("IdentityUserID"));
                        AddIntElement(userAccount, "ACTIVE", dataReader.GetInt32NullAsZero("STATUS") != 0 ? 1:0);
                        userAccounts.AppendChild(userAccount);

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

                    memberList.AppendChild(userAccounts);
                }
            }

            AddAttribute(memberList, "COUNT", count);

            AddAttribute(memberList, "TWITTEREXCEPTION", twitterAPIException);

            //FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "memberlist", _cacheName, memberList.OuterXml);

            //memberList.OwnerDocument.Save(@"c:\TEMP\memberlist.xml");
        }
        /// <summary>
        /// Adds the MediaAsset XML data to the XML document
        /// </summary>
        /// <param name="dataReader">Record set containing the data</param>
        /// <param name="parent">parent to add the xml to</param>
        /// <param name="mediaAssetID">Media asset id in question</param>
        private void AddMediaAssetXml(IDnaDataReader dataReader, XmlNode parent, int mediaAssetID)
        {
            // TODO: move this method into a MedaiAsset class - it's duplicated in ArticleSearch.cs.
            string FTPPath = String.Empty;

            XmlNode mediaAsset = CreateElementNode("MEDIAASSET");

            AddAttribute(mediaAsset, "MEDIAASSETID", mediaAssetID);

            AddAttribute(mediaAsset, "CONTENTTYPE", dataReader.GetInt32NullAsZero("ContentType"));

            GenerateFTPDirectoryString(mediaAssetID, ref FTPPath);
            AddTextTag(mediaAsset, "FTPPATH", FTPPath);

            AddTextTag(mediaAsset, "CAPTION", dataReader.GetStringNullAsEmpty("Caption"));

            int ownerID = dataReader.GetInt32NullAsZero("OwnerID");

            XmlNode owner = CreateElementNode("OWNER");
            User user = new User(InputContext);
            user.AddUserXMLBlock(dataReader, ownerID, owner);
            mediaAsset.AppendChild(owner);

            AddTextTag(mediaAsset, "MIMETYPE", dataReader.GetStringNullAsEmpty("Mimetype"));

            //Extra extendedable element stuff removed for time being
            XmlDocument extraelementinfo = new XmlDocument();
            extraelementinfo.LoadXml("<EXTRAELEMENTXML>" + dataReader.GetStringNullAsEmpty("EXTRAELEMENTXML") + "</EXTRAELEMENTXML>");
            mediaAsset.AppendChild(ImportNode(extraelementinfo.FirstChild));

            AddTextTag(mediaAsset, "HIDDEN", dataReader.GetInt32NullAsZero("Hidden"));

            string externalLinkID = String.Empty;
            string externalLinkType = String.Empty;

            string externalLinkURL = dataReader.GetStringNullAsEmpty("ExternalLinkURL");
            GetIDFromLink(externalLinkURL, ref externalLinkID, ref externalLinkType);

            AddTextTag(mediaAsset, "EXTERNALLINKTYPE", externalLinkType);
            AddTextTag(mediaAsset, "EXTERNALLINKURL", externalLinkURL);
            AddTextTag(mediaAsset, "EXTERNALLINKID", externalLinkID);

            parent.AppendChild(mediaAsset);
        }
Esempio n. 10
0
        /// <summary>
        /// Creates user object from given reader and user id
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        static public User CreateUserFromReader(IDnaDataReader reader, string prefix)
        {

            //IUser user = new User(_dnaDataReaderCreator, _dnaDiagnostics, _cacheManager);
            IUser user = new User();

            if (reader.Exists(prefix + "userID"))
            {
                user.UserId = reader.GetInt32NullAsZero(prefix  + "userID");
            }
            else if (reader.Exists(prefix + "ID"))
            {
                user.UserId = reader.GetInt32NullAsZero(prefix + "ID");
            }

            if (reader.Exists(prefix + "IdentityUserID"))
            {
                user.IdentityUserId = reader.GetStringNullAsEmpty(prefix + "IdentityUserId");
            }

            if (reader.Exists(prefix + "IdentityUserName"))
            {
                user.IdentityUserName = reader.GetStringNullAsEmpty(prefix + "IdentityUserName");
            }
            else if (reader.Exists(prefix + "LoginName"))
            {
                user.IdentityUserName = reader.GetStringNullAsEmpty(prefix + "LoginName");
            }

            /*
            if (reader.Exists(prefix + "FirstNames"))
            {

                user.FirstNames = reader.GetStringNullAsEmpty(prefix + "FirstNames") ?? "";
            }

            if(reader.Exists(prefix + "LastName"))
            {

                user.LastName = reader.GetStringNullAsEmpty(prefix + "LastName") ?? "";
            }
            */
            if(reader.Exists(prefix + "Status"))
            {
                
                user.Status= reader.GetInt32NullAsZero(prefix + "Status");
            }

            if(reader.Exists(prefix + "TaxonomyNode"))
            {
                
                user.TaxonomyNode= reader.GetInt32NullAsZero(prefix + "TaxonomyNode");
            }
            if (reader.Exists(prefix + "UserName"))
            {
                user.UserName = reader.GetStringNullAsEmpty(prefix + "UserName") ?? "";
            }
            else if (reader.Exists(prefix + "Name"))
            {
                user.UserName = reader.GetStringNullAsEmpty(prefix + "Name") ?? "";
            }

            if (user.UserName == String.Empty)
            {
                user.UserName = "******" + user.UserId.ToString();
            }
            /* NO NO not emails
             * if (reader.Exists(prefix + "Email"))
            {
                user.Email = reader.GetStringNullAsEmpty(prefix + "Email") ?? "";
            }
             */
            
            if (reader.Exists(prefix + "SiteSuffix"))
            {
                user.SiteSuffix = reader.GetStringNullAsEmpty(prefix + "SiteSuffix") ?? "";
            }
            if (reader.Exists(prefix + "Area"))
            {
                user.Area = reader.GetStringNullAsEmpty(prefix + "Area") ?? "";
            }
            if (reader.Exists(prefix + "Title"))
            {
                user.Title = reader.GetStringNullAsEmpty(prefix + "Title") ?? "";
            }
            if (reader.Exists(prefix + "SubQuota"))
            {
                user.SubQuota = reader.GetInt32NullAsZero(prefix + "SubQuota");
            }
            if (reader.Exists(prefix + "Allocations"))
            {
                user.Allocations = reader.GetInt32NullAsZero(prefix + "Allocations");
            }
            if (reader.Exists(prefix + "Journal"))
            {
                user.Journal = reader.GetInt32NullAsZero(prefix + "Journal");
            }
            if (reader.Exists(prefix + "Active") && !reader.IsDBNull(prefix + "Active"))
            {
                user.Active = reader.GetBoolean(prefix + "Active");
            }
            if (reader.Exists(prefix + "DateLastNotified") && reader.GetValue(prefix + "DateLastNotified") != DBNull.Value)
            {
                user.DateLastNotified = new DateElement(reader.GetDateTime(prefix + "DateLastNotified"));
            }
            if (reader.Exists(prefix + "DateJoined") && reader.GetValue(prefix + "DateJoined") != DBNull.Value)
            {
                user.DateJoined = new DateElement(reader.GetDateTime(prefix + "DateJoined"));
            }
            if (reader.Exists(prefix + "ForumPostedTo"))
            {
                user.ForumPostedTo = reader.GetInt32NullAsZero(prefix + "ForumPostedTo");
            }
            if (reader.Exists(prefix + "Masthead"))
            {
                user.MastHead = reader.GetInt32NullAsZero(prefix + "Masthead");
            }
            if (reader.Exists(prefix + "SinBin"))
            {
                user.SinBin = reader.GetInt32NullAsZero(prefix + "SinBin");
            }
            if (reader.Exists(prefix + "ForumID"))
            {
                user.ForumId = reader.GetInt32NullAsZero(prefix + "ForumID");
            }
            var siteId = 0;
            if (reader.Exists("SiteID"))
            {
                siteId = reader.GetInt32NullAsZero("SiteID");
            }
            
            
            if (siteId != 0 && user.UserId != 0)
            {
                var userGroups = (UserGroups)SignalHelper.GetObject(typeof(UserGroups));
                var groupList = userGroups.GetUsersGroupsForSite(user.UserId, siteId);
                foreach (var group in groupList)
                {
                    user.Groups.Add(new Group(){Name = group.Name.ToUpper()});
                }
            }
            else
            {

            }
             

            return (User)user;
        
        }
Esempio n. 11
0
 private void AddMessageXML(IDnaDataReader dataReader, XmlElement parent)
 {
     XmlElement message = AddElementTag(parent, "MESSAGE");
     AddAttribute(message, "MSGID", dataReader.GetInt32NullAsZero("MsgID"));
     AddAttribute(message, "SITEID", dataReader.GetInt32NullAsZero("SiteID"));
     AddTextTag(message, "BODY", dataReader.GetStringNullAsEmpty("MESSAGEBODY"));
     AddDateXml(dataReader, message, "DatePosted", "DATEPOSTED");
 }
        private void CreateFormXml(IDnaDataReader dataReader, string comments, bool acceptButton, bool rejectButton, bool cancelButton, bool fetchButton, bool byRecommendationID)
        {
            RootElement.RemoveAll();
            _processRecommendationForm = AddElementTag(RootElement, "PROCESS-RECOMMENDATION-FORM");

            int recommendationID = dataReader.GetInt32NullAsZero("recommendationID");
            int h2g2ID = dataReader.GetInt32NullAsZero("h2g2ID");
            int entryID = dataReader.GetInt32NullAsZero("entryID");
            string entrySubject = dataReader.GetStringNullAsEmpty("Subject");

            int editorID = dataReader.GetInt32NullAsZero("EditorID");
            string editorName = dataReader.GetStringNullAsEmpty("EditorName");
            User editor = new User(InputContext);

            int scoutID = dataReader.GetInt32NullAsZero("ScoutID");
            string scoutName = dataReader.GetStringNullAsEmpty("ScoutName");
            User scout = new User(InputContext);

            DateTime dateRecommended = dataReader.GetDateTime("DateRecommended");
            string retrievedComments = dataReader.GetStringNullAsEmpty("Comments");

            AddIntElement(_processRecommendationForm, "RECOMMENDATION-ID", recommendationID);
            AddIntElement(_processRecommendationForm, "H2G2-ID", h2g2ID);
            AddTextTag(_processRecommendationForm, "SUBJECT", entrySubject);
            AddTextTag(_processRecommendationForm, "COMMENTS", retrievedComments);

            XmlElement editorElement = AddElementTag(_processRecommendationForm, "EDITOR");
            editor.AddPrefixedUserXMLBlock(dataReader, editorID, "editor", editorElement);

            XmlElement scoutElement = AddElementTag(_processRecommendationForm, "SCOUT");
            scout.AddPrefixedUserXMLBlock(dataReader, scoutID, "scout", scoutElement);

            AddDateXml(dateRecommended, _processRecommendationForm, "DATE-RECOMMENDED");

            // if we know what the decision is going to be then create an appropriate
            // default email to send
            string scoutEmailSubject = String.Empty;
            string scoutEmailText = String.Empty;
            string authorEmailSubject = String.Empty;
            string authorEmailText = String.Empty;

            if (acceptButton && !rejectButton)
            {
                CreateScoutAcceptanceEmail(scoutName, entrySubject, h2g2ID, dateRecommended, ref scoutEmailSubject, ref scoutEmailText);
                if (byRecommendationID)
                {
                    CreateAuthorAcceptanceEmail(editorName, entrySubject, h2g2ID, dateRecommended, ref authorEmailSubject, ref authorEmailText);
                }
            }
            else if (rejectButton && !acceptButton)
            {
                CreateScoutRejectionEmail(scoutName, entrySubject, h2g2ID, dateRecommended, ref scoutEmailSubject, ref scoutEmailText);
            }

            if (byRecommendationID)
            {
                XmlElement scoutEmail = AddElementTag(_processRecommendationForm, "SCOUT-EMAIL");
                AddTextTag(scoutEmail, "SUBJECT", scoutEmailSubject);
                AddTextTag(scoutEmail, "TEXT", scoutEmailText);

                XmlElement authorEmail = AddElementTag(_processRecommendationForm, "AUTHOR-EMAIL");
                AddTextTag(authorEmail, "SUBJECT", authorEmailSubject);
                AddTextTag(authorEmail, "TEXT", authorEmailText);
            }
            else
            {
                AddTextTag(_processRecommendationForm, "EMAIL-SUBJECT", scoutEmailSubject);
                AddTextTag(_processRecommendationForm, "EMAIL-TEXT", scoutEmailText);
            }

            XmlElement functions = AddElementTag(_processRecommendationForm, "FUNCTIONS");
            if (acceptButton)
            {
                AddElementTag(functions, "ACCEPT");
            }
            if (rejectButton)
            {
                AddElementTag(functions, "REJECT");
            }
            if (cancelButton)
            {
                AddElementTag(functions, "CANCEL");
            }
            if (fetchButton)
            {
                AddElementTag(functions, "FETCH");
            }
        }
Esempio n. 13
0
        static public SiteEvent CreateUserModatedEventActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
        {
            SiteEvent siteEvent = null;
            try
            {
                siteEvent = new SiteEvent();
                siteEvent.SiteId = dataReader.GetInt32NullAsZero("siteid");
                siteEvent.Date = new Date(dataReader.GetDateTime("DateCreated"));

                var duration = "";
                var moderationStatus = "";
                switch ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("status"))
                {
                    case ModerationStatus.UserStatus.Postmoderated:
                        siteEvent.Type =  SiteActivityType.UserModeratedPostMod;
                        moderationStatus = "postmoderated";
                        break;

                    case ModerationStatus.UserStatus.Premoderated:
                        siteEvent.Type =  SiteActivityType.UserModeratedPremod;
                        moderationStatus = "premoderated";
                        break;

                    case ModerationStatus.UserStatus.Restricted:
                        siteEvent.Type =  SiteActivityType.UserModeratedBanned;
                        moderationStatus = "banned";
                        break;

                     case ModerationStatus.UserStatus.Deactivated:
                        siteEvent.Type =  SiteActivityType.UserModeratedDeactivated;
                        moderationStatus = "deactivated";
                        break;

                     case ModerationStatus.UserStatus.Standard:
                        siteEvent.Type = SiteActivityType.UserModeratedStandard;
                        moderationStatus = "returned to normal";
                        break;

                     case ModerationStatus.UserStatus.Trusted:
                        siteEvent.Type = SiteActivityType.UserModeratedTrusted;
                        moderationStatus = "trusted";
                        break;

                    default:
                        throw new Exception("Unknown moderation status: " + ((ModerationStatus.UserStatus)dataReader.GetInt32NullAsZero("status")).ToString());
                }

                switch(dataReader.GetInt32NullAsZero("prefduration"))
                {
                    case 1440: duration = " for 1 day";break;
                    case 10080: duration = " for 1 week";break;
                    case 20160: duration = " for 2 weeks";break;
                    case 40320: duration = " for 1 month";break;
                    default:
                        if (dataReader.GetInt32NullAsZero("prefduration") > 0)
                        {
                            duration = " for " + dataReader.GetInt32NullAsZero("prefduration").ToString() + " hours"; 
                        }
                        break;
                }

                siteEvent.ActivityData = XElement.Parse(
                          string.Format(DataFormat,
                            dataReader.GetInt32NullAsZero("user_userid"), dataReader.GetStringNullAsEmpty("user_username"),
                            dataReader.GetInt32NullAsZero("status"), moderationStatus, dataReader.GetInt32NullAsZero("siteid"),
                            dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                            duration, dataReader.GetStringNullAsEmpty("modreason"))
                           );
                siteEvent.UserId = dataReader.GetInt32NullAsZero("user_userid");

                if (siteEvent != null)
                {
                    siteEvent.SaveEvent(creator);
                }
                
            }
            catch(Exception e)
            {
                siteEvent = null;
                SiteEventsProcessor.SiteEventLogger.LogException(e);
            }

            return siteEvent;
        }
Esempio n. 14
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;
        }
Esempio n. 15
0
        /// <summary>
        /// Creates and adds the returned User Xml block to a given parent post node from the passed user parameters with a prefix
        /// ie the field name of OwnerUserName, OwnerFirstNames
        /// </summary>
        /// <param name="dataReader">Data reader object</param>
        /// <param name="userID">The users id</param>
        /// <param name="prefix">The prefix of the field names for a different user in the same result set</param>
        /// <param name="parent">The parent Node to add the user xml to</param>
        /// <returns>XmlNode Containing user XML from the stored procedure</returns>
        public void AddPrefixedUserXMLBlock(IDnaDataReader dataReader, int userID, string prefix, XmlNode parent)
        {
            string userName = "";
            if (dataReader.Exists(prefix + "UserName"))
            {
                userName = dataReader.GetStringNullAsEmpty(prefix + "UserName");
            }
            else if (dataReader.Exists(prefix + "Name"))
            {
                userName = dataReader.GetStringNullAsEmpty(prefix + "Name");
            }

            if (userName == String.Empty)
            {
                userName = "******" + userID.ToString();
            }

            string identityUserId = "";
            if (dataReader.Exists(prefix + "identityUserId"))
            {
                identityUserId = dataReader.GetStringNullAsEmpty(prefix + "identityUserId");
            }

            string emailAddress = "";
            if (dataReader.Exists(prefix + "Email"))
            {
                emailAddress = dataReader.GetStringNullAsEmpty(prefix + "Email");
            }

            double zeigeistScore = 0.0;
            if (dataReader.DoesFieldExist(prefix + "ZeitgeistScore"))
            {
                zeigeistScore = dataReader.GetDoubleNullAsZero(prefix + "ZeitgeistScore");
            }

            string siteSuffix = "";
            if (dataReader.Exists(prefix + "SiteSuffix"))
            {
                siteSuffix = dataReader.GetStringNullAsEmpty(prefix + "SiteSuffix");
            }

            string area = "";
            if (dataReader.Exists(prefix + "Area"))
            {
                area = dataReader.GetStringNullAsEmpty(prefix + "Area");
            }

            string title = "";
            if (dataReader.Exists(prefix + "Title"))
            {
                title = dataReader.GetStringNullAsEmpty(prefix + "Title");
            }

            int subQuota = 0;
            if (dataReader.Exists(prefix + "SubQuota"))
            {
                subQuota = dataReader.GetInt32NullAsZero(prefix + "SubQuota");
            }

            int allocations = 0;
            if (dataReader.Exists(prefix + "Allocations"))
            {
                allocations = dataReader.GetInt32NullAsZero(prefix + "Allocations");
            }
            

            int journal = 0;
            if (dataReader.Exists(prefix + "Journal"))
            {
                journal = dataReader.GetInt32NullAsZero(prefix + "Journal");
            }

            bool isActive = false;
            if (dataReader.Exists(prefix + "Active") && !dataReader.IsDBNull(prefix + "Active"))
            {
                isActive = dataReader.GetBoolean(prefix + "Active");
            }

            DateTime dateLastNotified = DateTime.MinValue;
            if (dataReader.Exists(prefix + "DateLastNotified") && dataReader.GetValue(prefix + "DateLastNotified") != DBNull.Value)
            {
                dateLastNotified = dataReader.GetDateTime(prefix + "DateLastNotified");
            }

            DateTime dateJoined = DateTime.MinValue;
            if (dataReader.Exists(prefix + "DateJoined") && dataReader.GetValue(prefix + "DateJoined") != DBNull.Value)
            {
                dateJoined = dataReader.GetDateTime(prefix + "DateJoined");
            }
            int forumPostedTo = -1;
            if (dataReader.Exists(prefix + "ForumPostedTo"))
            {
                forumPostedTo = dataReader.GetInt32NullAsZero(prefix + "ForumPostedTo");
            }
            int masthead = -1;
            if (dataReader.Exists(prefix + "Masthead"))
            {
                masthead = dataReader.GetInt32NullAsZero(prefix + "Masthead");
            }
            int sinbin = -1;
            if (dataReader.Exists(prefix + "SinBin"))
            {
                sinbin = dataReader.GetInt32NullAsZero(prefix + "SinBin");
            }
            int forumID = -1;
            if (dataReader.Exists(prefix + "ForumID"))
            {
                forumID = dataReader.GetInt32NullAsZero(prefix + "ForumID");
            }

            XmlNode userXML = GenerateUserXml(userID,
                                                userName,
                                                emailAddress,
                                                dataReader.GetStringNullAsEmpty(prefix + "FirstNames"),
                                                dataReader.GetStringNullAsEmpty(prefix + "LastName"),
                                                dataReader.GetInt32NullAsZero(prefix + "Status"),
                                                dataReader.GetInt32NullAsZero(prefix + "TaxonomyNode"),
                                                isActive,
                                                zeigeistScore,
                                                siteSuffix,
                                                area,
                                                title,
                                                journal,
                                                dateLastNotified,
                                                subQuota, 
                                                allocations,
                                                dateJoined,
                                                forumID,
                                                forumPostedTo,
                                                masthead,
                                                sinbin,
                                                identityUserId);


            if (userXML != null)
            {
                XmlNode importxml = parent.OwnerDocument.ImportNode(userXML, true);
                parent.AppendChild(importxml);
            }
        }
Esempio n. 16
0
        private User DmUserFromReader(IDnaDataReader reader, ISite site)
        {
            var user = new User
            {
                UserId = reader.GetInt32NullAsZero("DmUserID"),
                DisplayName = reader.GetStringNullAsEmpty("DmUserName"),
                Editor = (reader.GetInt32NullAsZero("DmUserIsEditor") == 1),
                Status = reader.GetInt32NullAsZero("DmStatus"),

            };
            if (reader.DoesFieldExist("DmIdentityUserId"))
            {
                user.BbcId = reader.GetStringNullAsEmpty("DmIdentityUserId");
            }
            user.SiteSpecificDisplayName = string.Empty;
            if (SiteList.GetSiteOptionValueBool(site.SiteID, "User", "UseSiteSuffix"))
            {
                if (reader.DoesFieldExist("DmSiteSpecificDisplayName"))
                {
                    user.SiteSpecificDisplayName = reader.GetStringNullAsEmpty("SiteSpecificDisplayName");
                }
            }
            return user;
        }
Esempio n. 17
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. 18
0
        /// <summary>
        /// Generates the individual Comment CommentBoxForum Xml within the Comment CommentBoxForum List xml page
        /// </summary>
        /// <param name="dataReader">SP containing the comment forums</param>
        /// <param name="commentForumList">Parent node to attach to</param>
        private void AddCommentForumListXML(IDnaDataReader dataReader, XmlNode commentForumList)
        {
            // start creating the comment forum structure
            XmlNode commentForum = CreateElementNode("COMMENTFORUM");
            AddAttribute(commentForum, "UID", dataReader.GetStringNullAsEmpty("uid"));
            AddAttribute(commentForum, "FORUMID", dataReader.GetInt32NullAsZero("forumID").ToString());
            AddAttribute(commentForum, "FORUMPOSTCOUNT", dataReader.GetInt32NullAsZero("forumpostcount").ToString());
            AddAttribute(commentForum, "FORUMPOSTLIMIT", InputContext.GetSiteOptionValueInt("Forum", "PostLimit"));
            AddAttribute(commentForum, "CANWRITE", dataReader.GetByteNullAsZero("CanWrite").ToString());
            AddAttribute(commentForum, "NOTSIGNEDINUSERID", dataReader.GetInt32NullAsZero("NotSignedInUserID").ToString());

            AddTextTag(commentForum, "HOSTPAGEURL", dataReader.GetStringNullAsEmpty("url"));
            AddTextTag(commentForum, "TITLE", dataReader.GetStringNullAsEmpty("title"));
            AddTextTag(commentForum, "MODSTATUS", dataReader.GetByteNullAsZero("ModerationStatus"));
            AddTextTag(commentForum, "SITEID", dataReader.GetInt32NullAsZero("siteid"));
            AddTextTag(commentForum, "FASTMOD", dataReader.GetInt32NullAsZero("fastmod"));

            if (dataReader.DoesFieldExist("DateCreated") && !dataReader.IsDBNull("DateCreated"))
            {
                DateTime dateCreated = dataReader.GetDateTime("DateCreated");
                AddElement(commentForum, "DATECREATED", DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, dateCreated));
            }

            if (dataReader.DoesFieldExist("ForumCloseDate") && !dataReader.IsDBNull("ForumCloseDate"))
            {
                DateTime closeDate = dataReader.GetDateTime("ForumCloseDate");
                AddElement(commentForum, "CLOSEDATE", DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, closeDate));
            }

            if (dataReader.DoesFieldExist("LastUpdated") && !dataReader.IsDBNull("LastUpdated"))
            {
                DateTime dateLastUpdated = dataReader.GetDateTime("LastUpdated");
                AddElement(commentForum, "LASTUPDATED", DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, dateLastUpdated));
            }

            int forumId = dataReader.GetInt32NullAsZero("forumID");
            //get terms admin object
            TermsFilterAdmin termsAdmin = TermsFilterAdmin.CreateForumTermAdmin(InputContext.CreateDnaDataReaderCreator(), _cache, forumId);
            XmlDocument termNodeDoc = SerialiseToXmlDoc(termsAdmin);
            string termNodeText = termNodeDoc.DocumentElement.InnerXml.ToString();
            AddXmlTextTag(commentForum, "TERMS", termNodeText);

            commentForumList.AppendChild(commentForum);
        }
Esempio n. 19
0
        private void AddCommentForumListXML(IDnaDataReader dataReader, XmlNode commentForumList)
        {
            // start creating the comment forum structure
            XmlNode commentForum = CreateElementNode("COMMENTFORUM");
            AddAttribute(commentForum, "UID", dataReader.GetStringNullAsEmpty("uid"));
            AddAttribute(commentForum, "FORUMID", dataReader.GetInt32NullAsZero("forumID").ToString());
            AddAttribute(commentForum, "FORUMPOSTCOUNT", dataReader.GetInt32NullAsZero("forumpostcount").ToString());
            AddAttribute(commentForum, "FORUMPOSTLIMIT", InputContext.GetSiteOptionValueInt("Forum", "PostLimit"));
            AddAttribute(commentForum, "CANWRITE", dataReader.GetByteNullAsZero("CanWrite").ToString());
            AddAttribute(commentForum, "NOTSIGNEDINUSERID", dataReader.GetInt32NullAsZero("NotSignedInUserID").ToString());

            AddTextTag(commentForum, "HOSTPAGEURL", dataReader.GetStringNullAsEmpty("url"));
            AddTextTag(commentForum, "TITLE", dataReader.GetStringNullAsEmpty("title"));
            AddTextTag(commentForum, "MODSTATUS", dataReader.GetByteNullAsZero("ModerationStatus"));
            AddTextTag(commentForum, "SITEID", dataReader.GetInt32NullAsZero("siteid"));
            AddTextTag(commentForum, "FASTMOD", dataReader.GetInt32NullAsZero("fastmod"));
            AddTextTag(commentForum, "CONTACTEMAIL", dataReader.GetStringNullAsEmpty("encryptedcontactemail"));

            if (dataReader.DoesFieldExist("DateCreated") && !dataReader.IsDBNull("DateCreated"))
            {
                DateTime dateCreated = dataReader.GetDateTime("DateCreated");
                AddElement(commentForum, "DATECREATED", DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, dateCreated));
            }

            if (dataReader.DoesFieldExist("ForumCloseDate") && !dataReader.IsDBNull("ForumCloseDate"))
            {
                DateTime closeDate = dataReader.GetDateTime("ForumCloseDate");
                AddElement(commentForum, "CLOSEDATE", DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, closeDate));
            }

            if (dataReader.DoesFieldExist("LastUpdated") && !dataReader.IsDBNull("LastUpdated"))
            {
                DateTime dateLastUpdated = dataReader.GetDateTime("LastUpdated");
                AddElement(commentForum, "LASTUPDATED", DnaDateTime.GetDateTimeAsElement(RootElement.OwnerDocument, dateLastUpdated));
            }

            int forumId = dataReader.GetInt32NullAsZero("forumID");
 
            AddXmlTextTag(commentForum, "TERMS", "");

            commentForumList.AppendChild(commentForum);
        }
Esempio n. 20
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. 21
0
        private MostCommentedCommentForum MostCommentedCommentForumCreateFromReader(IDnaDataReader reader)
        {
            var mostCommentedCommentForum = new MostCommentedCommentForum();
            mostCommentedCommentForum.UID = reader.GetStringNullAsEmpty("Uid");

            var site = SiteList.GetSite(reader.GetInt32NullAsZero("SiteID"));
            mostCommentedCommentForum.SiteName = (site != null) && (false == string.IsNullOrEmpty(site.SiteName)) ? site.SiteName : string.Empty;
            
            mostCommentedCommentForum.ForumId = reader.GetInt32NullAsZero("ForumID");
            mostCommentedCommentForum.Url = reader.GetStringNullAsEmpty("Url");
            mostCommentedCommentForum.Title = reader.GetStringNullAsEmpty("Title");
            mostCommentedCommentForum.CanWrite = reader.GetByteNullAsZero("CanWrite") == 1;
            mostCommentedCommentForum.ForumPostCount = reader.GetInt32NullAsZero("ForumPostCount");
            mostCommentedCommentForum.DateCreated = reader.GetDateTime("DateCreated");
            mostCommentedCommentForum.ForumCloseDate = reader.GetDateTime("ForumCloseDate");
            mostCommentedCommentForum.CommentForumListCount = reader.GetInt32NullAsZero("CommentForumListCount");
            mostCommentedCommentForum.LastPosted = reader.GetDateTime("LastPosted");
            return mostCommentedCommentForum;
        }
Esempio n. 22
0
        static public List<SiteEvent> CreatePostModerationDecisionActivity(IDnaDataReader dataReader, IDnaDataReaderCreator creator)
        {
            List<SiteEvent> siteEventList = new List<SiteEvent>();
            try
            {
                SiteEvent siteEvent1 = null;    
                siteEvent1 = new SiteEvent();
                siteEvent1.SiteId = dataReader.GetInt32NullAsZero("siteid");
                siteEvent1.Date = new Date(dataReader.GetDateTime("DateCreated"));
            
                var statusId = dataReader.GetInt32NullAsZero("status");

                var type = "post";
                if (!string.IsNullOrEmpty(dataReader.GetStringNullAsEmpty("parenturl")))
                {
                    type = "comment";
                }
                
                switch ((ModerationDecisionStatus)statusId)
                {
                    case ModerationDecisionStatus.Fail:
                        siteEvent1.Type = SiteActivityType.ModeratePostFailed;
                        siteEvent1.ActivityData = XElement.Parse(
                          string.Format(DataFormatFailed,
                            dataReader.GetInt32NullAsZero("forumid"), dataReader.GetInt32NullAsZero("postid"),
                            dataReader.GetInt32NullAsZero("threadid"), dataReader.GetStringNullAsEmpty("parenturl"), type,
                            dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                            dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                            dataReader.GetStringNullAsEmpty("ModReason"))
                            );
                        siteEvent1.UserId = dataReader.GetInt32NullAsZero("author_userid");
                        siteEventList.Add(siteEvent1);

                        if (dataReader.GetInt32NullAsZero("complainantid") != 0)
                        {//complaint upheld event
                            var siteEvent2 = new SiteEvent();
                            siteEvent2.SiteId = dataReader.GetInt32NullAsZero("siteid");
                            siteEvent2.Date = new Date(dataReader.GetDateTime("DateCreated"));
                            siteEvent2.Type = SiteActivityType.ComplaintPostUpHeld;
                            siteEvent2.ActivityData = XElement.Parse(
                              string.Format(DataFormatUpHeld,
                                dataReader.GetInt32NullAsZero("forumid"), dataReader.GetInt32NullAsZero("postid"),
                                dataReader.GetInt32NullAsZero("threadid"), dataReader.GetStringNullAsEmpty("parenturl"), type,
                                dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                                dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                                dataReader.GetStringNullAsEmpty("ModReason"))
                                );
                            siteEvent2.UserId = dataReader.GetInt32NullAsZero("complainantid");
                            siteEventList.Add(siteEvent2);
                        }
                        break;


                    case ModerationDecisionStatus.Referred:
                        siteEvent1.Type = SiteActivityType.ModeratePostReferred;
                        siteEvent1.ActivityData = XElement.Parse(
                         string.Format(DataFormatReferred,
                            dataReader.GetInt32NullAsZero("forumid"), dataReader.GetInt32NullAsZero("postid"),
                            dataReader.GetInt32NullAsZero("threadid"), dataReader.GetStringNullAsEmpty("parenturl"), type,
                            dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                            dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                            dataReader.GetStringNullAsEmpty("Notes"))
                           );
                        siteEvent1.UserId = dataReader.GetInt32NullAsZero("author_userid");
                        siteEventList.Add(siteEvent1);
                        break;

                    case ModerationDecisionStatus.Passed:
                        if (dataReader.GetInt32NullAsZero("complainantid") != 0)
                        {//complaint rejected
                            if (dataReader.GetStringNullAsEmpty("complainttext").IndexOf(ComplaintStringPrefix) < 0)
                            {
                                siteEvent1.Type = SiteActivityType.ComplaintPostRejected;
                                siteEvent1.ActivityData = XElement.Parse(
                                 string.Format(DataFormatReject,
                                    dataReader.GetInt32NullAsZero("forumid"), dataReader.GetInt32NullAsZero("postid"),
                                    dataReader.GetInt32NullAsZero("threadid"), dataReader.GetStringNullAsEmpty("parenturl"), type,
                                    dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                                    dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                                    dataReader.GetStringNullAsEmpty("Notes"))
                                   );
                                siteEvent1.UserId = dataReader.GetInt32NullAsZero("complainantid");
                                siteEventList.Add(siteEvent1);
                            }
                            else
                            {//is a reinstate so add that event
                                siteEvent1.Type = SiteActivityType.ModeratePostFailedReversal;
                                siteEvent1.ActivityData = XElement.Parse(string.Format(DataFormatReversed,
                                    dataReader.GetInt32NullAsZero("forumid"), dataReader.GetInt32NullAsZero("postid"),
                                    dataReader.GetInt32NullAsZero("threadid"), dataReader.GetStringNullAsEmpty("parenturl"), type,
                                    dataReader.GetInt32NullAsZero("author_userid"), dataReader.GetStringNullAsEmpty("author_username"),
                                    dataReader.GetInt32NullAsZero("mod_userid"), dataReader.GetStringNullAsEmpty("mod_username"),
                                    dataReader.GetStringNullAsEmpty("Notes"))
                                    );
                                siteEvent1.UserId = dataReader.GetInt32NullAsZero("author_userid");
                                siteEventList.Add(siteEvent1);
                            }
                            
                        }
                        break;
                    default:
                        siteEventList = null;
                        break;
                }

                if (siteEventList != null)
                {
                    foreach (var siteEvent in siteEventList)
                    {
                        siteEvent.SaveEvent(creator);
                    }
                }
            }
            catch(Exception e)
            {
                siteEventList = null;
                SiteEventsProcessor.SiteEventLogger.LogException(e);
            }



            return siteEventList;
        }
Esempio n. 23
0
        /// <summary>
        /// Creates the commentforumdata from a given reader
        /// </summary>
        /// <param name="reader">The database reaser</param>
        /// <returns>A Filled comment forum object</returns>
        private CommentForum CommentForumCreateFromReader(IDnaDataReader reader)
        {
            var closingDate = reader.GetDateTime("forumclosedate");
            //if (closingDate == null)
            //{
            //    closingDate = DateTime.MaxValue;
            //}
            var site = SiteList.GetSite(reader.GetStringNullAsEmpty("sitename"));

            var commentForum = new CommentForum();

            commentForum.Title = reader.GetStringNullAsEmpty("Title");
            commentForum.Id = reader.GetStringNullAsEmpty("UID");
            commentForum.CanRead = reader.GetByteNullAsZero("canRead") == 1;
            commentForum.CanWrite = reader.GetByteNullAsZero("canWrite") == 1;
            commentForum.ParentUri = reader.GetStringNullAsEmpty("Url");
            commentForum.SiteName = reader.GetStringNullAsEmpty("sitename");
            commentForum.CloseDate = closingDate;
            commentForum.LastUpdate = reader.GetDateTime("LastUpdated");
            if (reader.GetDateTime("lastposted") > commentForum.LastUpdate)
            {
//use last posted as it is newer
                commentForum.LastUpdate = reader.GetDateTime("lastposted");
            }
            commentForum.Updated = new DateTimeHelper(commentForum.LastUpdate);
            commentForum.Created = new DateTimeHelper(reader.GetDateTime("DateCreated"));
            commentForum.commentSummary = new CommentsSummary
                                              {
                                                  Total = reader.GetInt32NullAsZero("ForumPostCount"),
                                                  EditorPicksTotal = reader.GetInt32NullAsZero("editorpickcount")
                                              };
            commentForum.ForumID = reader.GetInt32NullAsZero("forumid");
            commentForum.isClosed = !commentForum.CanWrite || site.IsEmergencyClosed ||
                                    site.IsSiteScheduledClosed(DateTime.Now) ||
                                    (DateTime.Now > closingDate);
            //MaxCharacterCount = siteList.GetSiteOptionValueInt(site.SiteID, "CommentForum", "'MaxCommentCharacterLength")
            var replacements = new Dictionary<string, string>();
            replacements.Add("commentforumid", reader.GetStringNullAsEmpty("uid"));
            replacements.Add("sitename", site.SiteName);

            if (reader.Exists("IsContactForm") && !reader.IsDBNull("IsContactForm"))
            {
                commentForum.isContactForm = true;
                commentForum.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                            UriDiscoverability.UriType.ContactFormById,
                                                                            replacements);
                commentForum.commentSummary.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                                           UriDiscoverability.UriType.ContactFormById,
                                                                                           replacements);
            }
            else
            {
                commentForum.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                            UriDiscoverability.UriType.CommentForumById,
                                                                            replacements);
                commentForum.commentSummary.Uri = UriDiscoverability.GetUriWithReplacments(BasePath,
                                                                                           UriDiscoverability.UriType.CommentsByCommentForumId,
                                                                                           replacements);
            }

            //get moderation status
            commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Unknown;
            if (!reader.IsDBNull("moderationstatus"))
            {
//if it is set for the specific forum
                commentForum.ModerationServiceGroup =
                    (ModerationStatus.ForumStatus) (reader.GetTinyIntAsInt("moderationstatus"));
            }
            if (commentForum.ModerationServiceGroup == ModerationStatus.ForumStatus.Unknown)
            {
//else fall back to site moderation status
                switch (site.ModerationStatus)
                {
                    case ModerationStatus.SiteStatus.UnMod:
                        commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive;
                        break;
                    case ModerationStatus.SiteStatus.PreMod:
                        commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.PreMod;
                        break;
                    case ModerationStatus.SiteStatus.PostMod:
                        commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.PostMod;
                        break;
                    default:
                        commentForum.ModerationServiceGroup = ModerationStatus.ForumStatus.Reactive;
                        break;
                }
            }

            commentForum.NotSignedInUserId = reader.GetInt32NullAsZero("NotSignedInUserId");
            commentForum.allowNotSignedInCommenting = commentForum.NotSignedInUserId != 0;

            return commentForum;
        }
Esempio n. 24
0
        /// <summary>
        /// Loads the field from the database
        /// </summary>
        /// <param name="dataReader">dataReader with the field info</param>
        public void LoadFieldFromDatabase(IDnaDataReader dataReader)
        {
            _UIFieldID = dataReader.GetInt32NullAsZero("UIFieldID");
            _name = dataReader.GetStringNullAsEmpty("Name");
            _label = dataReader.GetStringNullAsEmpty("Label");

            _type = (UIFieldType)Enum.Parse(typeof(UIFieldType), dataReader.GetStringNullAsEmpty("Type"));

            _description = dataReader.GetStringNullAsEmpty("Description");
            _isKeyPhrase = dataReader.GetBoolean("IsKeyPhrase");
            _keyPhraseNamespace = dataReader.GetStringNullAsEmpty("KeyPhraseNamespace");
            _required = dataReader.GetBoolean("Required");
            _defaultValue = dataReader.GetStringNullAsEmpty("DefaultValue");
            _escape = dataReader.GetBoolean("Escape");
            _rawInput = dataReader.GetBoolean("RawInput");
            _includeInGuideEntry = dataReader.GetBoolean("IncludeInGuideEntry");
            _validateEmpty = dataReader.GetBoolean("ValidateEmpty");
            _validateNotEqualTo = dataReader.GetBoolean("ValidateNotEqualTo");
            _validateParsesOK = dataReader.GetBoolean("ValidateParsesOK");
            _notEqualToValue = dataReader.GetStringNullAsEmpty("NotEqualToValue");
            _validateCustom = dataReader.GetBoolean("ValidateCustom");
            _step = dataReader.GetInt32NullAsZero("Step");

            _permissions = (UIFieldPermissions)Enum.Parse(typeof(UIFieldPermissions), dataReader.GetStringNullAsEmpty("Permissions"));
        }
Esempio n. 25
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;
        }
Esempio n. 26
0
        public static ArticleSummary CreateArticleSummaryFromReader(IDnaDataReader reader)
        {

            ArticleSummary articleSummary = new ArticleSummary();

            articleSummary.H2G2ID = reader.GetInt32NullAsZero("h2g2id");
            articleSummary.Name = reader.GetStringNullAsEmpty("subject");
            articleSummary.StrippedName = StringUtils.StrippedName(reader.GetStringNullAsEmpty("subject"));

            if (reader.DoesFieldExist("Type"))
            {
                articleSummary.Type = Article.GetArticleTypeFromInt(reader.GetInt32NullAsZero("Type"));
            }

            if (reader.DoesFieldExist("editor"))
            {
                articleSummary.Editor = new UserElement() { user = User.CreateUserFromReader(reader, "editor") };
            }
                        
            articleSummary.DateCreated = new DateElement(reader.GetDateTime("datecreated"));

            if (reader.DoesFieldExist("lastupdated"))
            {
                articleSummary.LastUpdated = new DateElement(reader.GetDateTime("lastupdated")); ;
            }

            articleSummary.Status = ArticleStatus.GetStatus(reader.GetInt32NullAsZero("status"));

            return articleSummary;
        }
Esempio n. 27
0
        /// <summary>
        /// Fills the userData Dictionary with User DB data
        /// </summary>
        /// <param name="sp">Stored Procedure Data Reader object</param>
        /// <returns>True if sucessful or false</returns>
        private bool FillUserDataDictionary(IDnaDataReader sp)
        {
			// Set member variables that are useful as values
            _userID = sp.GetInt32NullAsZero("userid");
            _identityUserId = sp.GetStringNullAsEmpty("identityuserid");
            _status = (UserStatus)sp.GetInt32NullAsZero("Status");
			_userName = sp.GetStringNullAsEmpty("UserName");
			_firstNames = sp.GetStringNullAsEmpty("FirstNames");
            _lastName = sp.GetStringNullAsEmpty("LastName");
            _userEmail = sp.GetStringNullAsEmpty("Email");
			_password = sp.GetStringNullAsEmpty("Password");
         
			if (_loginName.Length == 0)
			{
				_loginName = sp.GetStringNullAsEmpty("LoginName");
			}
            _preferredSkin = sp.GetStringNullAsEmpty("PrefSkin");
			_masthead = sp.GetInt32NullAsZero("Masthead");
			_journalID = sp.GetInt32NullAsZero("Journal");
			_title = sp.GetStringNullAsEmpty("Title");
			_siteSuffix = sp.GetStringNullAsEmpty("SiteSuffix");
            _acceptSubscriptions = sp.GetBoolean("AcceptSubscriptions");
            _prefStatus = sp.GetInt32NullAsZero("PrefStatus");
            _teamID = sp.GetInt32NullAsZero("TeamID");
            _lastUpdated = DateTime.Now;
            _lastUpdated = sp.GetDateTime("LastUpdatedDate");

            bool success = false;
            if (_gotUserData)
            {
                //AddUserDataObject("UserID", sp);
                //AddUserDataObject("UserName", sp);
                AddUserDataObject("Postcode", sp);
                AddUserDataObject("Region", sp);
                AddUserDataObject("PrefUserMode", sp);
                //AddUserDataObject("Status", sp);
                AddUserDataObject("Area", sp);
                AddUserDataObject("Title", sp);
                //AddUserDataObject("FirstNames", sp);
                //AddUserDataObject("LastName", sp);
                AddUserDataObject("SiteSuffix", sp);
                AddUserDataObject("TeamID", sp);
                AddUserDataObject("UnreadPublicMessageCount", sp);
                AddUserDataObject("UnreadPrivateMessageCount", sp);
                AddUserDataObject("TaxonomyNode", sp);
                AddUserDataObject("HideLocation", sp);
                AddUserDataObject("HideUserName", sp);
                //AddUserDataObject("AcceptSubscriptions", sp);

                if (ShowFullDetails)
                {
                    AddUserDataObject("PrefXML", sp);
                    //AddUserDataObject("Email", sp);

                    //AddUserDataObject("LoginName", sp);
                    AddUserDataObject("BBCUID", sp);
                    AddUserDataObject("Cookie", sp);
                    //AddUserDataObject("Password", sp);
                    AddUserDataObject("Masthead", sp);
                    AddUserDataObject("Journal", sp);
                    AddUserDataObject("PrivateForum", sp);
                    AddUserDataObject("DateJoined", sp);
                    AddUserDataObject("DateReleased", sp);
                    AddUserDataObject("Active", sp);
                    AddUserDataObject("Anonymous", sp);

                    AddUserDataObject("SinBin", sp);
                    AddUserDataObject("Latitude", sp);
                    AddUserDataObject("Longitude", sp);
                    AddUserDataObject("PrefSkin", sp);

                    AddUserDataObject("IsModClassMember", sp);
                    AddUserDataObject("PrefForumStyle", sp);
                    AddUserDataObject("AgreedTerms", sp);
                    AddUserDataObject("PrefStatus", sp); 
                    AddUserDataObject("AutoSinBin", sp);
                }

                success = true;
            }
            return success;
        }
Esempio n. 28
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. 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
         /// <summary>
        /// Makes the XML for a Media Asset from the datareader and attache it to the parent element
        /// </summary>
        /// <param name="dataReader"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public XmlNode MakeXml(IDnaDataReader dataReader, XmlElement parent)
        {
            _mediaAssetID = dataReader.GetInt32NullAsZero("mediaassetid");
            if (_mediaAssetID == 0)
            {
                return null;
            }

            int ownerID = dataReader.GetInt32NullAsZero("ownerid");
            int hidden = dataReader.GetInt32NullAsZero("hidden");
            int contentType = dataReader.GetInt32NullAsZero("contentType");
            int siteID = dataReader.GetInt32NullAsZero("siteID");

            string caption = dataReader.GetStringNullAsEmpty("caption");
            string filename = dataReader.GetStringNullAsEmpty("filename");
            string mediaassetdescription = dataReader.GetStringNullAsEmpty("description");
            string mimeType = dataReader.GetStringNullAsEmpty("mimetype");
            string externalLinkURL = dataReader.GetStringNullAsEmpty("externallinkurl");

            XmlElement assetXML = AddElementTag(parent, "MEDIAASSET");
            AddAttribute(assetXML, "MEDIAASSETID", _mediaAssetID);

            AddTextElement(assetXML, "FTPPATH", GenerateFTPDirectoryString());
            AddIntElement(assetXML, "SITEID", siteID);
            AddTextElement(assetXML, "CAPTION", caption);
            AddTextElement(assetXML, "FILENAME", filename);
            AddTextElement(assetXML, "MIMETYPE", mimeType);
            AddIntElement(assetXML, "CONTENTTYPE", contentType);

            //TODO : Need to add the keyphrases for the media asset here

            //Extra extendedable element stuff removed for time being
            XmlDocument extraelementinfo = new XmlDocument();
            extraelementinfo.LoadXml("<EXTRAELEMENTXML>" + dataReader.GetStringNullAsEmpty("EXTRAELEMENTXML") + "</EXTRAELEMENTXML>");
            assetXML.AppendChild(ImportNode(extraelementinfo.FirstChild));

            XmlNode owner = AddElementTag(assetXML,"OWNER");
            User user = new User(InputContext);
            user.AddUserXMLBlock(dataReader, ownerID, owner);
            assetXML.AppendChild(owner);

            AddTextElement(assetXML, "MEDIAASSETDESCRIPTION", mediaassetdescription);

            AddDateXml(dataReader, assetXML, "MADateCreated", "DATECREATED");
            AddDateXml(dataReader, assetXML, "MALastUpdated", "LASTUPDATED");

            AddIntElement(assetXML, "HIDDEN", hidden);

            string externalLinkID = String.Empty;
            string externalLinkType = String.Empty;
            string flickrFarmPath = String.Empty;
            string flickrServer = String.Empty;
            string flickrID = String.Empty;
            string flickrSecret = String.Empty;
            string flickrSize = String.Empty;

            GetIDFromLink(externalLinkURL, 
                ref externalLinkID, 
                ref externalLinkType,
                ref flickrFarmPath,
                ref flickrServer,
                ref flickrID,
                ref flickrSecret,
                ref flickrSize);

            AddTextElement(assetXML, "EXTERNALLINKURL", externalLinkURL);
            AddTextElement(assetXML, "EXTERNALLINKID", externalLinkID);
            AddTextElement(assetXML, "EXTERNALLINKTYPE", externalLinkType);

            if (externalLinkType == "Flickr")
            {
                XmlElement flickr = AddElementTag(assetXML, "FLICKR");
                AddTextElement(flickr, "FARMPATH", flickrFarmPath);
                AddTextElement(flickr, "SERVER", flickrServer);
                AddTextElement(flickr, "ID", flickrID);
                AddTextElement(flickr, "SECRET", flickrSecret);
                AddTextElement(flickr, "SIZE", flickrSize);
                assetXML.AppendChild(flickr);
            }

            AddPollXml(dataReader, assetXML);

            return assetXML;

        }