Friday, September 28, 2007

[ By Tom Hearn, Developer]

RSSBus is about accessing and customizing your data, your way, easily. You can use any of the hundreds of connectors that we have to connect to various systems or create your own to access systems that are proprietary to you. You can use the RSSBus Admin Console to easily configure and publish RSS with data extensions or use RSBScript for even more control.  You can automatically serve your feed in any of the supported formats (ATOM, RSS, HTML, JSON, XLS) by simply changing an input parameter or format the feed your way using a custom feed formatter.

Custom feed formatters change how an entire feed is formatted upon execution of a script. As items are pushed from a script, they are passed to the chosen feed formatter, and the results are sent to the client.

Consider the following scenario:

You work at a construction company,  and each month you compile sales reports for 10 different employees.  Each of these employees stores their sales data in a different place: Excel, SQL Server, MySQL, and so forth.  Your boss does not know how to access all of these different technologies, and more importantly, does not want or need to know how.  He wants to see all of this data, each month, problem-free, in CSV format.  RSSBus to the rescue.

With RSSBus, you configure a feed using the connectors already provided in RSSBus for Excel, SQL Server, and MySQL to access the data from those systems. Then you create a custom CSV feed formatter to format those feeds as CSV, and finally, send your boss the URL.  All the other pieces are already available, so let's get started with writing a custom CSV formatter.

All RSSBus feed formatters need to implement the interface RSBFeedFormatter.

        public interface RSBFeedFormatter

        {

            string FeedStart(RSBItem metaItem, string[] param);

            string FormatItem(RSBItem item);

            string FeedEnd();

            string Info();

        }


These methods are fairly straightforward, but a quick explanation might help. 

  • Info() describes the formatter and is invoked when meta-data is requested about the formatter.
  • FeedStart() is invoked before iterating through the feed items and is used to start the feed.
  • FormatItem() is invoked for each item in the feed and is used to format each item.
  • FeedEnd() is invoked after all of the items have been formatted and is used to finalize the feed.

In our example, the primary underlying functionality of our class is contained in FeedStart() and FormatItem().

FeedStart() will retrieve the current HttpContext, set the ContentType to Excel so the users will not view the data as a normal webpage, and then set the Content-Disposition header so the file is automatically downloaded when a user visits the URL.

        public string FeedStart(RSBItem metaItem, string[] param)

        {

            // Set the Content-type so the browser knows it isn't HTML

            System.Web.HttpContext http = System.Web.HttpContext.Current;

            http.Response.ContentType = "Content-type: application/vnd.ms-excel";

            http.Response.AddHeader("Content-Disposition", "inline; filename=" +

                metaItem.GetAttr("rss:title", 1) + ".csv");

            return "";

        }

FormatItem() will loop through each of the items in the feed and process them as a csv file would be formatted.  FormatItem() will first go through the initial row to retrieve the actual attribute names before any items are processed, to place at the top of our csv file.  Next, all of the items in the feed will be processed and added to our output.

        public string FormatItem(RSBItem item) {

 

            processFirstItem ...

           

            for (int i = 0; i < attrnames.Length; i++) {

                string val = item.GetAttr(attrnames[i]);

                if (val == null) val = "";

                else val = val.Replace("\n", "").Replace("\r", "");

                text.Append("\"" + val + "\"");

                if (i < attrnames.Length - 1) text.Append(",");

            }

            text.Append("\r\n");

            return text.ToString();

        }

That concludes our task. Simply compile the formatter and place the resulting assembly in the bin folder of your RSSBus installation. The formatter will automatically be detected and you can now use it by specifying the format tag at the end of a url, such as http://www.mywebsite.com/rssbus/examplescript.rsb?@format=csv. 

For the complete code listing, download the zip file below. It includes a project that can be used with either RSSBus Feed Server or RSSBus Desktop.


Downloads: CSVFormatter.zip
#   
Thursday, September 06, 2007

It’s official - The RSSBus Feed Server is feature complete! If you have been waiting for the release candidate to start integrating data with feeds, the time is now.

Since the previous Beta RSSBus has been updated with significant performance enhancements, updates for security and scalability, and functional enhancements to the admin console to makes feed creation, publishing, and integration easier than ever.

New in RC1

  • Feed Creation Wizard – The RSSBus Admin UI has been enhanced with a new Feed creation wizard that takes all of the guesswork out of creating and exposing feeds. The wizard walks you through the process of exposing input and output parameters as well as configuring security for your feeds.
  • Enhanced Logging – RSSBus has been improved with fully customizable logging facilities to monitor feed info, feed access, and connector errors.
  • Caching and Improved Performance – Caching has been available in RSSBus for some time, however this release includes support for Etag and if-modified-since for cached feeds reducing bandwidth and increasing performance.
  • RSSBus Users Guide – Need a better overview of RSSBus? The new RSSBus users guide includes everything you neet to know about setting up RSSBus including installation of the Feed Server, administration, security, and development. To receive a copy of the user’s guide, download the latest RC1 release of RSSBus Feed Server.
  • New Connectors & Connector Updates - All RSSBus Connectors have bee updated with new enhancements in accessibility and performance for this release.  New connectors are also available targeting new technologies such as BiztalkOps, DbaseOps, OledbOps, PgsqlOps, TwitterOps, and more!

Thank you

We could not have achieved this milestone without the support and feedback of all of our beta testers. The quality of feedback that we have received has been instrumental, guiding our development efforts towards important enhancements in security, usability, and scalability.  Stay tuned for the RTM announcement in the next few weeks!

To check out RSSBus RC1 download: RSSBus Feed Server.

#