Пример #1
0
        public HtmlItem GetHtmlItemById(string fileName, string listCode, string itemId)
        {
            string      xmlFileName = GetXmlFileName(fileName);
            XmlDocument doc         = GetXmlDocumentByFileName(xmlFileName);
            HtmlItem    thisItem    = null;
            XmlNodeList nodeList    = doc.GetElementsByTagName("Htmls");

            if (nodeList.Count > 0)
            {
                XmlNode root = nodeList[0];
                foreach (XmlNode node in root.ChildNodes)
                {
                    HtmlItem item = HtmlItem.LoadByXmlNode(node);
                    if (item.Id.Equals(itemId, StringComparison.OrdinalIgnoreCase))
                    {
                        thisItem = item;
                        break;
                    }
                }
            }
            if (thisItem != null)
            {
                string titleFileName = string.Format(@"Contents\{0}\{1}.Title.txt"
                                                     , listCode ?? "_None"
                                                     , itemId);
                thisItem.Title = GetFileContent(titleFileName);

                string contentFileName = string.Format(@"Contents\{0}\{1}.Content.txt"
                                                       , listCode ?? "_None"
                                                       , itemId);
                thisItem.Content = GetFileContent(contentFileName);
            }
            return(thisItem);
        }
Пример #2
0
        public IList <HtmlItem> GetHtmlItemsByParent(string fileName, int pageIndex, int pageSize)
        {
            string           xmlFileName = GetXmlFileName(fileName);
            XmlDocument      doc         = GetXmlDocumentByFileName(xmlFileName);
            IList <HtmlItem> list        = new List <HtmlItem>();
            XmlNodeList      nodeList    = doc.GetElementsByTagName("Htmls");

            if (nodeList.Count > 0)
            {
                XmlNode root = nodeList[0];
                for (int i = 0;
                     i < root.ChildNodes.Count &&
                     i >= pageIndex * pageSize &&
                     i < (pageIndex + 1) * pageSize;
                     i++)
                {
                    XmlNode node = root.ChildNodes[i];
                    list.Add(HtmlItem.LoadByXmlNode(node));
                }
            }
            return(list);
        }