4-11-2009 22:2:18
sử dụng các chức năng có sẵn của DNN thì không biết nó cụ thể thế nào, nhưng tự viết ra 1 cái là hoàn toàn trong tầm tay.
Nó na ná thế này.
------------
private XmlElement CreateItem(XmlDocument doc, DataRow row, string deskname)
{
XmlElement news = doc.CreateElement("item");
DateTime d = Convert.ToDateTime(row["ModifyDate"]);
string pubdate = d.DayOfWeek.ToString().Substring(0, 3) + ", " + d.ToString("dd MMM yyyy HH:mm:ss") + " GMT";
string lnk = "http://" + PortalUtils.HostName + UrlProvider.DesktopUrl(deskname, row["ID"].ToString());
CommonFunction.AddNode(doc, news, "link", lnk);
CommonFunction.AddNode(doc, news, "title", row["Headline"].ToString());
CommonFunction.AddNode(doc, news, "description", row["Description"].ToString());
CommonFunction.AddNode(doc, news, "pubDate", pubdate);
return news;
}
private XmlDocument GenDoc(int id)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<rss version=\"2.0\"></rss>");
XmlDeclaration xmlDecl = doc.CreateXmlDeclaration("1.0", "utf-8", "yes");
XmlElement root = doc.DocumentElement;
doc.InsertBefore(xmlDecl, root);
CategoryController db = new CategoryController();
CategoryInfo cat = db.Load(id);
if (cat.Ids == "") cat.Ids = cat.CatID.ToString();
XmlElement channel = doc.CreateElement("channel");
root.AppendChild(channel);
CommonFunction.AddNode(doc, channel, "title", PortalUtils.HostName);
CommonFunction.AddNode(doc, channel, "link", "http://" + PortalUtils.HostName);
CommonFunction.AddNode(doc, channel, "description", PortalUtils.HostName);
CommonFunction.AddNode(doc, channel, "copyright", "VSP - AWAS");
CommonFunction.AddNode(doc, channel, "generator", "VSP Generator");
string strSQL = "SELECT ID, Description, Headline, ModifyDate FROM PRESS_News "
+ " (WHERE CatID IN (" + cat.Ids + ")) AND (PublishedStatus=5) ORDER BY ModifyDate DESC ";
DataTable dt = DataFactory.LoadPage(strSQL, 0, PAGESIZE);
for (int i = 0; i < dt.Rows.Count; i++)
{
XmlElement item = CreateItem(doc, dt.Rows, cat.DesktopViewID);
channel.AppendChild(item);
}
return doc;
}
---
http://coder.awas.vnhttp://mobile.awas.vnhttp://vtv.awas.vnhttp://baihatviet.awas.vn