예제 #1
0
        /// <summary>
        /// Gets all the information to do with a given list.
        /// This is mainly called by the FastCategoryList Builder
        /// </summary>
        /// <param name="GUID">The GUID for the list you want to look at</param>
        public void GetCategoryListForGUID(string GUID)
        {
            RootElement.RemoveAll();
            // Get the cache Category list date
            DateTime lastUpdated = CacheGetCategoryListDate(GUID);

            // Set the cache expiry time default to 5 mins ago. 
            DateTime expiryDate = DateTime.Now.AddMinutes(-5);
            if (lastUpdated > expiryDate)
		    {
                expiryDate = lastUpdated;
		    }

            // Check to see if the Category list is cached
            _cachedFileName = "categorylist" + GUID + ".txt";
            string cachedCategoryList = String.Empty;
            /*if (InputContext.FileCacheGetItem("List", _cachedFileName, ref expiryDate, ref cachedCategoryList) && cachedCategoryList.Length > 0)
            {
                // Create the object from the cache
                CreateAndInsertCachedXML(cachedCategoryList, "CATEGORYLIST", true);

                // Finally update the relative dates and return
                UpdateRelativeDates();
                return;
            }
            */
            XmlElement categoryList = AddElementTag(RootElement, "CATEGORYLIST");
            AddTextTag(categoryList, "GUID", GUID);

            // Get the category list details from the database
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("getcategorylistforguid"))
            {
                Guid categoryListID = new Guid(GUID);
                dataReader.AddParameter("categorylistid", categoryListID);
                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    AddAttribute(categoryList, "LISTWIDTH", dataReader.GetInt32NullAsZero("LISTWIDTH"));
                    do
                    {
                        // Now get the details
                        int nodeID = 0;
                        bool isRoot = false;
                        Category category = new Category(InputContext);

                        // Get the Node Info
                        XmlElement hierarchyDetails = AddElementTag(categoryList, "HIERARCHYDETAILS");
                        nodeID = dataReader.GetInt32NullAsZero("NODEID");
                        AddAttribute(hierarchyDetails, "NODEID", nodeID);

                        isRoot = (dataReader.GetInt32NullAsZero("PARENTID") == 0);

                        AddAttribute(hierarchyDetails, "ISROOT", isRoot);
                        AddAttribute(hierarchyDetails, "USERADD", dataReader.GetTinyIntAsInt("USERADD"));
                        AddAttribute(hierarchyDetails, "TYPE", dataReader.GetInt32NullAsZero("TYPE"));

                        AddTextTag(hierarchyDetails, "DISPLAYNAME", dataReader.GetStringNullAsEmpty("DISPLAYNAME"));
                        if (nodeID > 0)
                        {
                            AddTextTag(hierarchyDetails, "DESCRIPTION", dataReader.GetStringNullAsEmpty("DESCRIPTION"));
                            AddTextTag(hierarchyDetails, "SYNONYMS", dataReader.GetStringNullAsEmpty("SYNONYMS"));
                            AddIntElement(hierarchyDetails, "H2G2ID", dataReader.GetInt32NullAsZero("H2G2ID"));
                        }

                        // Open the members tag and add all the members for the hierarchy node
                        XmlElement members = AddElementTag(hierarchyDetails, "MEMBERS");

                        // Get the Subject Members for the Node
                        members.AppendChild(ImportNode(category.GetSubjectMembersForNodeID(nodeID)));

                        // Get the Article Members for this node
                        //members.AppendChild(ImportNode(category.GetArticleMembersForNodeID(nodeID)));

                        // Get the Club Members for this node
                        //members.AppendChild(ImportNode(category.GetClubMembersForNodeID(nodeID)));

                        // Get the NodeAliases for this node
                        members.AppendChild(ImportNode(category.GetNodeAliasMembersForNodeID(nodeID)));

                        // Get the Notices for this node
                        //members.AppendChild(ImportNode(category.GetNoticesForNodeID(nodeID)));
                    } while (dataReader.Read());

                    // We now need to set the sort order for the member of each node
                    XmlNodeList hierarchyNodes = categoryList.SelectNodes("HIERARCHYDETAILS");
                    foreach (XmlElement hierarchyNode in hierarchyNodes)
                    {
                        Category category = new Category(InputContext);
                        //category.SetSortOrderForNodeMembers(hierarchyNode, "MEMBERS");
                    }
                }
                FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "List", _cachedFileName, categoryList.OuterXml);
            }
        }