Ok finally got time to work on this project today. I think the only problem i have is splitting out reoccuring events. My category filter and such works fine and i can get the data from the tables but i cant help but think one of your eventsget stored procedures has to have all this reoccuring events stuff handled. here is what i have so far...
Sadly the data comes up blank. what is the easiest way to get a list of the next 30 events, starting from today's day, filtered by the category selected. (i have the selection and passing the value stuff handled. Just need @category in the storedprocedure. Just dont want to recreate the wheel if this has already been done.
*I am happy to contribute the finished product to the team if you are interested. I can convert it to VB if necessary.
using
System;
using
System.Configuration;
/* Add these namespaces */
using
System.Data;
using
System.Data.SqlClient;
using
System.Text;
using
System.Xml;
using
DotNetNuke;
using
DotNetNuke.Entities.Portals;
public
partial class _RSS2 : System.Web.UI.Page
{
{
protected void Page_Load(object sender, EventArgs e)// find out if the query string parameter is present
{
{
{
if (Request.QueryString["category"] != null && Request.QueryString["category"] != "")using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ToString()))using (SqlCommand cm = new SqlCommand())// get the CategoryId from the query string
int qsCategory = Convert.ToInt32(Request.QueryString["category"]);int qsPortalID = Convert.ToInt32(Request.QueryString["PortalID"]);// set the conenction and query string
cm.Connection = cn;
cm.CommandText =
"SELECT [Category], [CategoryName], [PortalID] FROM [EventsCategory] WHERE ([Category] = @Category) And ([PortalID] = @PortalID)";// create parameter for our command and give it a value
parmCategories.Value = qsCategory;
parmPortalID.Value = qsPortalID;
SqlParameter parmCategories = new SqlParameter("@Category", SqlDbType.Int);SqlParameter parmPortalID = new SqlParameter("@PortalID", SqlDbType.Int);// add the parameter to the command object
// and open the connection
cm.Parameters.Add(parmCategories);
cm.Parameters.Add(parmPortalID);
cn.Open();
// execute the query and return the results to a SqlDataReader
{
SqlDataReader dr = cm.ExecuteReader();if (dr.Read())// clear out the buffer
Response.Clear();
// set response content type
Response.ContentType =
"text/xml";// delcare and instantiate XMLTextWriter object
XmlTextWriter xtw = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);// write out the XML declaration and version 1.0 info
xtw.WriteStartDocument();
// write out the rss xml element "rss" (required)
xtw.WriteStartElement(
xtw.WriteAttributeString(
"rss");"version", "2.0");// write out "channel" element (required)
xtw.WriteStartElement(
"channel");// write out title, link, and description based on the feed being requested,
// all three elements are required
xtw.WriteElementString(
xtw.WriteElementString(
xtw.WriteElementString(
xtw.WriteElementString(
"title", dr["CategoryName"].ToString());"link", "http://www.example.com/");"description", dr["CategoryName"].ToString());"copyright", "Copyright " + DateTime.Now.Year.ToString() + ". All rights reserved.");// close the connection and clear the existing parameters
dr.Close();
cm.Parameters.Clear();
// prepare new query
cm.Connection = cn;
cm.CommandText =
cm.CommandType =
"EventsGetByRange";CommandType.StoredProcedure;// add parameter and execute query to return article details
parmArticles.Value = qsCategory;
cm.Parameters.Add(parmArticles);
parmstartdate.Value =
cm.Parameters.Add(parmstartdate);
parmenddate.Value =
cm.Parameters.Add(parmenddate);
parmmodules.Value =
cm.Parameters.Add(parmmodules);
dr = cm.ExecuteReader();
SqlParameter parmArticles = new SqlParameter("@Category", SqlDbType.Int);SqlParameter parmstartdate = new SqlParameter("@BeginDate", SqlDbType.DateTime);DateTime.Today;SqlParameter parmenddate = new SqlParameter("@EndDate", SqlDbType.DateTime);"01.01.2010";SqlParameter parmmodules = new SqlParameter("@Modules", SqlDbType.Int);"0";// Loop through the content of the database and add them to the RSS feed
{
xtw.WriteStartElement(
xtw.WriteElementString(
xtw.WriteElementString(
xtw.WriteElementString(
xtw.WriteEndElement();
}
dr.Close();
while (dr.Read())"item");"title", dr["EventName"].ToString());"description", dr["EventDesc"].ToString());"link", "http://www.example.com/default.aspx?articleid=" + dr["EventName"]);// Close all tags
xtw.WriteEndElement();
xtw.WriteEndElement();
xtw.WriteEndDocument();
xtw.Flush();
xtw.Close();
}
else
{
Response.Write(
}
}
}
}
"Non valid RSS feed URL.");else
{
Response.Write(
}
}
}
"Non valid RSS feed URL.");