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

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

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

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

                        count++;

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

            AddAttribute(soloGuideEntriesUserList, "COUNT", count);
        }
 /// <summary>
 /// Find user from email.
 /// </summary>
 /// <param name="foundUsers"></param>
 /// <param name="email"></param>
 private int FindUserFromEmail(XmlElement foundUsers, String email)
 {
     int userId = 0;
     using (IDnaDataReader reader = InputContext.CreateDnaDataReader("finduserfromemail"))
     {
         reader.AddParameter("email", email);
         reader.Execute();
         while (reader.Read())
         {
             User find = new User(InputContext);
             find.AddUserXMLBlock(reader, reader.GetInt32NullAsZero("userid"), foundUsers);
             userId = reader.GetInt32NullAsZero("userid");
         }
     }
     return userId;
 }
        /// <summary>
        /// Generates XML for ModeratorManagement page.
        /// </summary>
        public void GenerateXml(  string groupName, int foundUserid )
        {
            XmlElement modList = AddElementTag(RootElement,"MODERATOR-LIST");
            AddAttribute(modList, "GROUPNAME", groupName);
            XmlElement sites = null;
            XmlElement classes = null;
            using ( IDnaDataReader dataReader = InputContext.CreateDnaDataReader("getfullmoderatorlist") )
            {
                dataReader.AddParameter("groupname", groupName);
                dataReader.AddParameter("userid", InputContext.ViewingUser.UserID);
                dataReader.AddParameter("founduserid", foundUserid);
                dataReader.Execute();

                int userId = 0;
                int classId = -1;
                int siteId = -1;
                while ( dataReader.Read() )
                {
                    if ( userId != dataReader.GetInt32NullAsZero("userid") )
                    {
                        userId = dataReader.GetInt32NullAsZero("userid");

                        XmlElement moderator = AddElementTag(modList, "MODERATOR");
                        User user = new User(InputContext);
                        user.AddUserXMLBlock(dataReader, userId,moderator);

                        sites = AddElementTag(moderator, "SITES");
                        classes = AddElementTag(moderator, "CLASSES");
                        classId = -1;
                        siteId = -1;
                    }

                    if ( !dataReader.IsDBNull("modclassid") )
                    {
                        // User is assigned to moderation class
                        if (classId != dataReader.GetInt32NullAsZero("modclassid"))
                        {
                            classId = dataReader.GetInt32NullAsZero("modclassid");
                            AddIntElement(classes, "CLASSID", classId);
                        }
                    }
                    else if ( !dataReader.IsDBNull("siteid") && siteId != dataReader.GetInt32NullAsZero("siteid") )
                    {
                        // User is assigned to a specific site
                        siteId = dataReader.GetInt32NullAsZero("siteid");
                        XmlElement site = AddElementTag(sites, "SITE");
                        AddAttribute(site, "SITEID", siteId);
                    }
                }
            }

            AddModerationClasses();
        }
        /// <summary>
        /// Find a user from userid.
        /// </summary>
        /// <param name="foundUsers"></param>
        /// <param name="email"></param>
        private int FindUserFromUserId(XmlElement foundUsers, String email)
        {
            int userId;
            //Search for user by userid.
            using (IDnaDataReader reader = InputContext.CreateDnaDataReader("finduserfromidwithorwithoutmasthead"))
            {
                
                if (Int32.TryParse(email, out userId))
                {
                    reader.AddParameter("userid", userId);
                    reader.AddParameter("siteid", InputContext.CurrentSite.SiteID);
                    reader.Execute();

                    while (reader.Read())
                    {
                        User find = new User(InputContext);
                        find.AddUserXMLBlock(reader, userId, foundUsers);
                        userId = reader.GetInt32NullAsZero("userid");
                    }
                }
            }
            return userId;
        }