public SpaceShortPostInfo[] GetSpacePostList(string nodeName) { SpaceShortPostInfo[] array = (nodeName == "Website") ? __spacePostListForWebSite : __spacePostListForSpaceIndex; if (array != null) { return(array); } XmlNodeList xmlNodeList = AggregationData.xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/" + nodeName + "_spacearticlelist/Article"); array = new SpaceShortPostInfo[xmlNodeList.Count]; int num = 0; foreach (XmlNode xmlnode in xmlNodeList) { array[num] = new SpaceShortPostInfo(); array[num].Postid = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "postid") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "postid"))); array[num].Author = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "author") == null) ? "" : AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "author").Trim()); array[num].Uid = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "uid") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "uid").Trim())); array[num].Postdatetime = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime") == null) ? DateTime.Now : Convert.ToDateTime(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime").Trim())); array[num].Title = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : Utils.RemoveHtml(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "title"))); array[num].Views = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "views") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "views").Trim())); array[num].Commentcount = ((AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "commentcount") == null) ? 0 : Convert.ToInt32(AggregationData.xmlDoc.GetSingleNodeValue(xmlnode, "commentcount"))); num++; } if (nodeName == "Website") { __spacePostListForWebSite = array; } else { __spacePostListForSpaceIndex = array; } return(array); }
/// <summary> /// 得到空间日志数组 /// </summary> /// <param name="nodename">节点名称</param> /// <returns></returns> public SpaceShortPostInfo[] GetSpacePostList(string nodeName) { SpaceShortPostInfo[] __spacePostList = (nodeName == "Website") ? __spacePostListForWebSite : __spacePostListForSpaceIndex; //当记录不为空时则直接反回数据 if (__spacePostList != null) { return(__spacePostList); } XmlNodeList xmlnodelist = xmlDoc.DocumentElement.SelectNodes("/Aggregationinfo/Aggregationpage/" + nodeName + "/" + nodeName + "_spacearticlelist/Article"); __spacePostList = new SpaceShortPostInfo[xmlnodelist.Count]; int rowcount = 0; foreach (XmlNode xmlnode in xmlnodelist) { __spacePostList[rowcount] = new SpaceShortPostInfo(); __spacePostList[rowcount].Postid = (xmlDoc.GetSingleNodeValue(xmlnode, "postid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "postid")); __spacePostList[rowcount].Author = (xmlDoc.GetSingleNodeValue(xmlnode, "author") == null) ? "" : xmlDoc.GetSingleNodeValue(xmlnode, "author").Trim(); __spacePostList[rowcount].Uid = (xmlDoc.GetSingleNodeValue(xmlnode, "uid") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "uid").Trim()); __spacePostList[rowcount].Postdatetime = (xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime") == null) ? DateTime.Now : Convert.ToDateTime(xmlDoc.GetSingleNodeValue(xmlnode, "postdatetime").Trim()); __spacePostList[rowcount].Title = (xmlDoc.GetSingleNodeValue(xmlnode, "title") == null) ? "" : Utils.RemoveHtml(xmlDoc.GetSingleNodeValue(xmlnode, "title")); __spacePostList[rowcount].Views = (xmlDoc.GetSingleNodeValue(xmlnode, "views") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "views").Trim()); __spacePostList[rowcount].Commentcount = (xmlDoc.GetSingleNodeValue(xmlnode, "commentcount") == null) ? 0 : Convert.ToInt32(xmlDoc.GetSingleNodeValue(xmlnode, "commentcount")); rowcount++; } if (nodeName == "Website") { __spacePostListForWebSite = __spacePostList; } else { __spacePostListForSpaceIndex = __spacePostList; } return(__spacePostList); }