<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>VibrantCode</title>
  <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/" />
  <link rel="self" href="http://blog.andrewnurse.net/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2008-05-05T09:32:52.2229217-07:00</updated>
  <author>
    <name>Andrew Nurse</name>
  </author>
  <subtitle>Oooh...pretty code</subtitle>
  <id>http://blog.andrewnurse.net/</id>
  <generator uri="http://www.dasblog.net" version="2.0.7180.0">DasBlog</generator>
  <entry>
    <title>Off to Redmond</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/05/05/OffToRedmond.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,5d9a79fc-6354-4534-b8c5-ab4259667975.aspx</id>
    <published>2008-05-05T09:32:52.2229217-07:00</published>
    <updated>2008-05-05T09:32:52.2229217-07:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">Phew, I've been posting a lot of forum posts
and blogs today trying to tidy up loose ends, because I'm off to Redmond today! I'll
be going back to Microsoft for another summer internship, and I'm really excited!<br /><br />
I'll try to post more later in the week (because I really have to shutdown my computer
and pack it up now :P) so keep an eye here, and on my Twitter feed: <a href="http://twitter.com/anurse">http://twitter.com/anurse</a> (follow
me?).<br /><p></p><img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=5d9a79fc-6354-4534-b8c5-ab4259667975" /></div>
    </content>
  </entry>
  <entry>
    <title>Playing with IE8: Reports Module as a WebSlice</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/03/06/PlayingWithIE8ReportsModuleAsAWebSlice.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,e608612d-51d2-4bee-94cf-53366df772d9.aspx</id>
    <published>2008-03-06T12:51:51.554-07:00</published>
    <updated>2008-03-06T13:00:41.9792847-07:00</updated>
    <category term="DNN" label="DNN" scheme="http://blog.andrewnurse.net/CategoryView,category,DNN.aspx" />
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
So, I downloaded and installed the IE8 Beta yesterday and decided to play around with <a href="http://www.microsoft.com/windows/products/winfamily/ie/ie8/features.mspx">WebSlices</a>.
I found it really easy to create a simple WebSlice (just apply some CSS Classes) and
I decided to try and do this with the Reports Module.
</p>
        <p>
I was suprised with just how easy it was! I have already created a replacement ViewReports.ascx
file that turns every Reports Module into a WebSlice. I've attached the new file here,
just replace your existing DesktopModules/Reports/ViewReports.ascx file with it if
you want to check it out. Any Visualizer should work, but I've only tried the Grid.
</p>
        <p>
CAUTION: This is for preview purposes ONLY! This replacement file has NOT been tested
in ANY SIGNIFICANT WAY (other than trying it out once). Back up your existing ViewReports.ascx
file BEFORE using this!
</p>
        <p>
Here's the popup you see when you view a report
</p>
        <img border="0" src="http://blog.andrewnurse.net/content/binary/webslice_popup_screenshot.png" />
        <p>
And here's a screenshot of the WebSlice in action:
</p>
        <p>
          <img border="0" src="http://blog.andrewnurse.net/content/binary/webslice_screenshot.png" />
        </p>
        <p>
Anyway, the file is attached. Try it out on one of your test sites! I'll probably
integrate this into an upcoming version in a more configurable way, since it's so
easy :).
</p>
        <p>
          <a href="http://blog.andrewnurse.net/content/binary/ViewReports.zip">ViewReports.zip
(.54 KB)</a>
        </p>
        <p>
UPDATE: Changed to a ZIP file
</p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=e608612d-51d2-4bee-94cf-53366df772d9" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Developing an RSS Data Source - Part III</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/03/02/DevelopingAnRSSDataSourcePartIII.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,195f9774-95f7-49dc-a21a-3f32f1f8c31b.aspx</id>
    <published>2008-03-02T10:23:00.885-07:00</published>
    <updated>2008-03-02T10:23:00.8858213-07:00</updated>
    <category term="DNN" label="DNN" scheme="http://blog.andrewnurse.net/CategoryView,category,DNN.aspx" />
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
In this series of blogs, I'm going to follow the development of an RSS Data Source.
I'm going to use Visual Studio 2008, but I'll be using .Net 2.0 features so you should
be able to follow along in Visual Studio 2005. You can also use the Express editions
of Visual Web Developer (both 2005 and 2008 versions should work). All the code will
be in VB.Net, but it should be straightforward enough for C# developers to understand
(after all, its all .Net)
</p>
        <p>
Continued from <a href="http://blog.andrewnurse.net/2008/02/29/DevelopingAnRSSDataSourcePartII.aspx"><font color="#547699">Part
II</font></a>.
</p>
        <h2>Part III - Settings
</h2>
        <p>
In this part, we're going to add a setting page so that we can change the RSS feed
that our Data Source downloads.
</p>
        <p>
In current versions of the Reports Module, Data Source settings are stored in the
ModuleSettings table provided by DotNetNuke. This ensures that all copies of the same
module instance will share the same Data Source settings (Visualizer settings are <strong>not</strong> shared
between copies). However, Data Source developers need not (and <strong>should</strong><strong>not</strong>)
access these directly. Instead, the Reports Module provides a layer on top of the
ModuleSettings table called "Data Source Settings". When the Data Source is executed,
the Reports Module passes a Dictionary containing these settings (inside the ReportInfo
object). To allow users to edit the settings, we go back to the Settings.ascx file
we created in <a href="Part1.htm">Part I</a>.
</p>
        <p>
Let's start with the user interface for our settings page. All we need for now is
a place for the user to enter a feed URL. When we're done, it should look like the
screenshot below
</p>
        <div class="captioned_image">
          <img alt="The finished settings UI" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/IE-FullFinishedSettings.png" />
          <p class="caption">
Figure 1 - The finished settings UI
</p>
        </div>
        <p>
So, open up the <em>Settings.ascx</em> file and make sure you are in <kbd>Design</kbd> mode.
First we need to add a label, so users know what they should type in our text box.
In the Solution Explorer, find the file: <em>controls/labelcontrol.ascx</em> and drag
it on to the design surface.
</p>
        <div class="captioned_image">
          <img alt="Locating the LabelControl.ascx file" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/VS-LabelControl.png" />
          <p class="caption">
Figure 2 - Locating the LabelControl.ascx file
</p>
        </div>
        <p>
Next drag an ASP.Net TextBox control, from the Toolbox, on to the surface. You should
have something that looks like this:
</p>
        <div class="captioned_image">
          <img alt="Locating the LabelControl.ascx file" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/VS-DesignSurface.png" />
          <p class="caption">
Figure 3 - Locating the LabelControl.ascx file
</p>
        </div>
        <p>
Now, set the properties of the controls to the following values:
</p>
        <table>
          <thead>
            <tr>
              <th>
Property</th>
              <th>
Value for Label</th>
              <th>
Value for Text Box</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <kbd>ID</kbd>
              </td>
              <td>
feedUrlLabel</td>
              <td>
feedUrlTextBox</td>
            </tr>
            <tr>
              <td>
                <kbd>ControlName</kbd>
              </td>
              <td>
feedUrlTextBox</td>
              <td>
N/A</td>
            </tr>
            <tr>
              <td>
                <kbd>Width</kbd>
              </td>
              <td>
N/A</td>
              <td>
100%</td>
            </tr>
          </tbody>
        </table>
        <p>
Save your changes, and open up the code file: <em>Settings.ascx.vb</em>. Here, we
need to add code to connect our text box to the Data Source settings. The key to this
is the <kbd>LoadSettings</kbd> and <kbd>SaveSettings</kbd> methods provided by <kbd>ReportsSettingsBase</kbd>.
First, we need to import some extra namespaces:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red204\green120\blue50;\red0\green0\blue0;\red255\green255\blue255;}??\fs26 \cf1\cb2\highlight2 {\b Imports}\cf3 {\b  DotNetNuke.Modules.Reports}\par ??\cf1 {\b Imports}\cf3 {\b  System.Collections.Generic}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Imports</span> DotNetNuke.Modules.Reports
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Imports</span> System.Collections.Generic
</p>
        </div>
        <p>
Then, we can implement the <kbd>LoadSettings</kbd> and <kbd>SaveSettings</kbd> methods.
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;\red165\green194\blue92;}??\fs26 \cf1\cb2\highlight2 {\b     }\cf3 {\b Public}\cf1 {\b  }\cf3 {\b Overrides}\cf1 {\b  }\cf3 {\b Sub}\cf1 {\b  LoadSettings(}\cf3 {\b ByVal}\cf1 {\b  Settings }\cf3 {\b As}\cf1 {\b  Dictionary(}\cf3 {\b Of}\cf1 {\b  }\cf3 {\b String}\cf1 {\b , }\cf3 {\b String}\cf1 {\b ))}\par ??{\b         }\cf3 {\b MyBase}\cf1 {\b .LoadSettings(Settings)}\par ??{\b         feedUrlTextBox.Text = SettingsUtil.GetDictionarySetting(Settings, _}\par ??{\b                                                                 }\cf4 "FeedUrl"\cf1 {\b , _}\par ??{\b                                                                 }\cf3 {\b String}\cf1 {\b .Empty)}\par ??{\b     }\cf3 {\b End}\cf1 {\b  }\cf3 {\b Sub}\par ??\par ??\cf1 {\b     }\cf3 {\b Public}\cf1 {\b  }\cf3 {\b Overrides}\cf1 {\b  }\cf3 {\b Sub}\cf1 {\b  SaveSettings(}\cf3 {\b ByVal}\cf1 {\b  Settings }\cf3 {\b As}\cf1 {\b  Dictionary(}\cf3 {\b Of}\cf1 {\b  }\cf3 {\b String}\cf1 {\b , }\cf3 {\b String}\cf1 {\b ))}\par ??{\b         }\cf3 {\b MyBase}\cf1 {\b .SaveSettings(Settings)}\par ??{\b         Settings(}\cf4 "FeedUrl"\cf1 {\b ) = feedUrlTextBox.Text}\par ??{\b     }\cf3 {\b End}\cf1 {\b  }\cf3 {\b Sub}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Public</span>
            <span style="COLOR: #cc7832">Overrides</span>
            <span style="COLOR: #cc7832">Sub</span> LoadSettings(<span style="COLOR: #cc7832">ByVal</span> Settings <span style="COLOR: #cc7832">As</span> Dictionary(<span style="COLOR: #cc7832">Of</span><span style="COLOR: #cc7832">String</span>, <span style="COLOR: #cc7832">String</span>))
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">MyBase</span>.LoadSettings(Settings)
</p>
          <p style="MARGIN: 0px">
    feedUrlTextBox.Text = SettingsUtil.GetDictionarySetting(Settings,
_
</p>
          <p style="MARGIN: 0px">
                   
                   
                    <span style="FONT-WEIGHT: normal; COLOR: #a5c25c">"FeedUrl"</span>,
_
</p>
          <p style="MARGIN: 0px">
                   
                   
                    <span style="COLOR: #cc7832">String</span>.Empty)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">End</span>
            <span style="COLOR: #cc7832">Sub</span>
          </p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Public</span>
            <span style="COLOR: #cc7832">Overrides</span>
            <span style="COLOR: #cc7832">Sub</span> SaveSettings(<span style="COLOR: #cc7832">ByVal</span> Settings <span style="COLOR: #cc7832">As</span> Dictionary(<span style="COLOR: #cc7832">Of</span><span style="COLOR: #cc7832">String</span>, <span style="COLOR: #cc7832">String</span>))
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">MyBase</span>.SaveSettings(Settings)
</p>
          <p style="MARGIN: 0px">
    Settings(<span style="FONT-WEIGHT: normal; COLOR: #a5c25c">"FeedUrl"</span>)
= feedUrlTextBox.Text
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">End</span>
            <span style="COLOR: #cc7832">Sub</span>
          </p>
        </div>
        <p>
The <kbd>LoadSettings</kbd> method is provided with a <kbd>System.Collections.Generic.Dictionary(Of
String, String)</kbd> containing the current settings saved for the Data Source. Our
implementation uses the <kbd>SettingsUtil</kbd> helper class (provided with the Reports
Module) to retrieve a value from the dictionary, or return a default value if it doesn't
exist (in this case, an empty string).
</p>
        <p>
The <kbd>SaveSettings</kbd> method is also provided with the current settings. However,
this method is responsible for retrieving the values entered by the user and updating
the settings.
</p>
        <p>
Save the file, and navigate to the Settings page on your test module. You should see
our new Settings control displayed, as in the screenshot below:
</p>
        <div class="captioned_image">
          <img alt="Settings page so far" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/IE-EmptySettings.png" />
          <p class="caption">
Figure 4 - Settings page so far
</p>
        </div>
        <p>
Oops, we still need to put the label text in! We're going to support the DotNetNuke
Localization Framework, so we need to put the text in two places.
</p>
        <p>
First, lets add the localized text. Create a Resource File called<em> Settings.ascx.resx </em>in <em>/DesktopModules/Reports/DataSources/RSS/App_LocalResources</em> file
and open it. In Visual Studio, you get a nice table interface for editing resource
strings. Add the following entries to the table (feel free to tweak the values as
you want, just keep the name the same):
</p>
        <table>
          <thead>
            <tr>
              <th>
Name</th>
              <th>
Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <kbd>feedUrlLabel.Text</kbd>
              </td>
              <td>
RSS Feed URL</td>
            </tr>
            <tr>
              <td>
                <kbd>feedUrlLabel.Help</kbd>
              </td>
              <td>
Enter the URL to an RSS feed to retrieve data from</td>
            </tr>
          </tbody>
        </table>
        <p>
Your resource file should look like this after making those changes
</p>
        <div class="captioned_image">
          <img alt="Resource File after entering values" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/VS-ResourceFile.png" />
          <p class="caption">
Figure 5 - Resource File after entering values
</p>
        </div>
        <p>
Now, go back to <em>Settings.ascx</em> and set the following properties on the label
we created earlier:
</p>
        <table>
          <thead>
            <tr>
              <th>
Property</th>
              <th>
Value</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <kbd>Text</kbd>
              </td>
              <td>
RSS Feed URL</td>
            </tr>
            <tr>
              <td>
                <kbd>Suffix</kbd>
              </td>
              <td>
:</td>
            </tr>
            <tr>
              <td>
                <kbd>CssClass</kbd>
              </td>
              <td>
SubHead</td>
            </tr>
          </tbody>
        </table>
        <p>
Note: That's a colon (':') in the Suffix property. Also, <kbd>CssClass</kbd> is case
sensitive.
</p>
        <p>
Now, save and refresh your page. You should see something like the screen shot below:
</p>
        <div class="captioned_image">
          <img alt="Finished Settings UI" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/IE-FinishedSettingsUI.png" />
          <p class="caption">
Figure 6 - The finished Feed URL text box
</p>
        </div>
        <p>
Now, to change our Data Source code to use this new setting. Let's go back to the <em>/App_Code/RSSDataSource/RSSDataSource.vb</em> file
and take a look at the signature for the <kbd>ExecuteReport</kbd> method:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;}??\fs26 \cf1\cb2\highlight2 {\b     }\cf3 {\b Public}\cf1 {\b  }\cf3 {\b Overrides}\cf1 {\b  }\cf3 {\b Function}\cf1 {\b  ExecuteReport(}\cf3 {\b ByVal}\cf1 {\b  report }\cf3 {\b As}\cf1 {\b  ReportInfo, _}\par ??{\b                                             }\cf3 {\b ByVal}\cf1 {\b  hostModule }\cf3 {\b As}\cf1 {\b  PortalModuleBase, _}\par ??{\b                                             }\cf3 {\b ByVal}\cf1 {\b  inputParameters }\cf3 {\b As}\cf1 {\b  IDictionary(}\cf3 {\b Of}\cf1 {\b  }\cf3 {\b String}\cf1 {\b , }\cf3 {\b Object}\cf1 {\b )) }\cf3 {\b As}\cf1 {\b  System.Data.DataView}\par ??}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Public</span>
            <span style="COLOR: #cc7832">Overrides</span>
            <span style="COLOR: #cc7832">Function</span> ExecuteReport(<span style="COLOR: #cc7832">ByVal</span> report <span style="COLOR: #cc7832">As</span> ReportInfo,
_
</p>
          <p style="MARGIN: 0px">
                   
                    <span style="COLOR: #cc7832">ByVal</span> hostModule <span style="COLOR: #cc7832">As</span> PortalModuleBase,
_
</p>
          <p style="MARGIN: 0px">
                   
                    <span style="COLOR: #cc7832">ByVal</span> inputParameters <span style="COLOR: #cc7832">As</span> IDictionary(<span style="COLOR: #cc7832">Of</span><span style="COLOR: #cc7832">String</span>, <span style="COLOR: #cc7832">Object</span>)) <span style="COLOR: #cc7832">As</span> System.Data.DataView
</p>
        </div>
        <p>
The important parameter here is the <kbd>report</kbd> parameter. There is a property
called <kbd>DataSourceSettings</kbd> on that object which contains the same dictionary
we created in <kbd>SaveSettings</kbd>. First, delete the FeedUrl constant we were
using before. Then add following code to the beginning of the <kbd>ExecuteReport</kbd> method
to get the Feed URL from the settings:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;\red165\green194\blue92;}??\fs26 \cf1\cb2\highlight2 {\b         }\cf3 {\b If}\cf1 {\b  }\cf3 {\b Not}\cf1 {\b  report.DataSourceSettings.ContainsKey(}\cf4 "FeedUrl"\cf1 {\b ) }\cf3 {\b Then}\par ??\cf1 {\b             }\cf3 {\b Throw}\cf1 {\b  }\cf3 {\b New}\cf1 {\b  RequiredSettingMissingException(}\cf4 "FeedUrl"\cf1 {\b , }\cf3 {\b MyBase}\cf1 {\b .ExtensionContext)}\par ??{\b         }\cf3 {\b End}\cf1 {\b  }\cf3 {\b If}\par ??\cf1 {\b         }\cf3 {\b Dim}\cf1 {\b  feedUrl }\cf3 {\b As}\cf1 {\b  Uri = }\cf3 {\b Nothing}\par ??\cf1 {\b         }\cf3 {\b If}\cf1 {\b  }\cf3 {\b Not}\cf1 {\b  Uri.TryCreate(report.DataSourceSettings(}\cf4 "FeedUrl"\cf1 {\b ), UriKind.Absolute, feedUrl) }\cf3 {\b Then}\par ??\cf1 {\b             }\cf3 {\b Throw}\cf1 {\b  }\cf3 {\b New}\cf1 {\b  RequiredSettingMissingException(}\cf4 "FeedUrl"\cf1 {\b , }\cf3 {\b MyBase}\cf1 {\b .ExtensionContext)}\par ??{\b         }\cf3 {\b End}\cf1 {\b  }\cf3 {\b If}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">If</span>
            <span style="COLOR: #cc7832">Not</span> report.DataSourceSettings.ContainsKey(<span style="FONT-WEIGHT: normal; COLOR: #a5c25c">"FeedUrl"</span>) <span style="COLOR: #cc7832">Then</span></p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">Throw</span><span style="COLOR: #cc7832">New</span> RequiredSettingMissingException(<span style="FONT-WEIGHT: normal; COLOR: #a5c25c">"FeedUrl"</span>, <span style="COLOR: #cc7832">MyBase</span>.ExtensionContext)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">End</span>
            <span style="COLOR: #cc7832">If</span>
          </p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Dim</span> feedUrl <span style="COLOR: #cc7832">As</span> Uri
= <span style="COLOR: #cc7832">Nothing</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">If</span>
            <span style="COLOR: #cc7832">Not</span> Uri.TryCreate(report.DataSourceSettings(<span style="FONT-WEIGHT: normal; COLOR: #a5c25c">"FeedUrl"</span>),
UriKind.Absolute, feedUrl) <span style="COLOR: #cc7832">Then</span></p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">Throw</span><span style="COLOR: #cc7832">New</span> RequiredSettingMissingException(<span style="FONT-WEIGHT: normal; COLOR: #a5c25c">"FeedUrl"</span>, <span style="COLOR: #cc7832">MyBase</span>.ExtensionContext)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">End</span>
            <span style="COLOR: #cc7832">If</span>
          </p>
        </div>
        <p>
This code checks for the setting, and if it isn't present or if it isn't a valid URL
we throw an exception provided by the Reports Module: <kbd>RequiredSettingMissingException</kbd>.
We pass it the name of our setting and some contextual information about our Data
Source (which is provided automatically by our base class. If the setting isn't present,
the Reports Module will automatically display a useful error message indicating that
the setting is missing.
</p>
        <p>
While we're in the code, let's add HTML Decoding directly to the Data Source, so we
don't have to use the HTML Decode converter in the Module Settings. To do that, we
change the line that adds entries to the output table so that it automatically HTML
Decodes the description:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;}??\fs26 \cf1\cb2\highlight2 {\b dt.Rows.Add(title, }\cf3 {\b New}\cf1 {\b  Uri(link), HttpUtility.HtmlDecode(description))}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
dt.Rows.Add(title, <span style="COLOR: #cc7832">New</span> Uri(link), HttpUtility.HtmlDecode(description))
</p>
        </div>
        <p>
Make sure everything is saved and go back to the website. You should probably go back
to the home page, just to make sure everything is properly recompiled. Go back to
the settings page for the Reports Module, and make sure the RSS Data Source is selected.
Then configure it with your favourite RSS feed. This time, I'll use my personal blog's
RSS feed (WARNING: Shameless plug alert!).
</p>
        <div class="captioned_image">
          <img alt="Testing the Settings UI" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/IE-SettingsUITest.png" />
          <p class="caption">
Figure 7 - Testing the Settings UI
</p>
        </div>
        <p>
Once you've done that, make sure the HTML Decode property is set and the HTML Visualizer
is properly configured, just like in part 2 and click Update. You should see the RSS
feed displayed just like in Part 2, only now we can change the URL!
</p>
        <div class="captioned_image">
          <img alt="Final Results" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part3/IE-Final.png" />
          <p class="caption">
Figure 8 - The Final Results
</p>
          <h3>Conclusion
</h3>
        </div>
        <p>
At this point, we have a working RSS Data Source! You can stop here if you want, but
in the next part I'll cover packaging the Data Source up so that it can be installed
in any Reports Module installation.
</p>
        <p>
          <a href="http://blog.andrewnurse.net/content/binary/RSSDataSource/Files/Part3.zip">Download
the code so far.</a>
        </p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=195f9774-95f7-49dc-a21a-3f32f1f8c31b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Developing an RSS Data Source - Part II</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/02/29/DevelopingAnRSSDataSourcePartII.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,fd4a2728-3346-4256-ac28-2e99875145e3.aspx</id>
    <published>2008-02-29T13:30:07.242-07:00</published>
    <updated>2008-03-02T10:24:39.6208282-07:00</updated>
    <category term="DNN" label="DNN" scheme="http://blog.andrewnurse.net/CategoryView,category,DNN.aspx" />
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
UPDATE: <a href="http://blog.andrewnurse.net/2008/03/02/DevelopingAnRSSDataSourcePartIII.aspx">Part
III</a> is now available.
</p>
        <p>
In this series of blogs, I'm going to follow the development of an RSS Data Source.
I'm going to use Visual Studio 2008, but I'll be using .Net 2.0 features so you should
be able to follow along in Visual Studio 2005. You can also use the Express editions
of Visual Web Developer (both 2005 and 2008 versions should work). All the code will
be in VB.Net, but it should be straightforward enough for C# developers to understand
(after all, its all .Net)
</p>
        <p>
Continued from <a href="http://blog.andrewnurse.net/2008/02/29/DevelopingAnRSSDataSourcePartI.aspx">Part
I</a>.
</p>
        <h2>Part II - WebRequests, XPath, and Data Tables, oh my!
</h2>
        <p>
In this part, we're going to add the code to retrieve data from the RSS feed. First,
we need to create a folder to hold our code. We're going to put our code in the <em>App_Code</em> folder,
so it will be compiled automatically by ASP.Net. That way we can save a few extra
steps and get straight to the point. You could also put this code in a separate .Net
Class Library, and put that library in the Bin folder of your website.
</p>
        <p>
We'll create a sub-folder inside the App_Code folder for our code and call it <em>RSSDataSource</em>:
</p>
        <div class="captioned_image">
          <img alt="Creating an App_Code folder" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part2/VS-AppCodeFolder.png" />
          <p class="caption">
Figure 1 - Creating an App_Code folder
</p>
        </div>
        <p>
Next, we need to tell ASP.Net to compile code found in this folder. Open the <em>web.config</em> file,
in the root of the website, and find the <em>&lt;codeSubDirectories&gt;</em> section
(its inside the <em>&lt;system.web&gt;</em> section). In my version of DotNetNuke
it looks like this, but yours may have different <em>&lt;add&gt;</em> entries:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;\red165\green194\blue92;}??\fs26 \cf1\cb2\highlight2 {\b       &lt;}\cf3 {\b codeSubDirectories}\cf1 {\b &gt;}\par ??{\b         &lt;}\cf3 {\b add}\cf1 {\b  directoryName="}\cf4 {\b HTML}\cf1 {\b " /&gt;}\par ??{\b       &lt;/}\cf3 {\b codeSubDirectories}\cf1 {\b &gt;}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas, monospace">
          <p style="MARGIN: 0px">
&lt;<span style="COLOR: #cc7832">codeSubDirectories</span>&gt;
</p>
          <p style="MARGIN: 0px">
  &lt;<span style="COLOR: #cc7832">add</span> directoryName="<span style="COLOR: #a5c25c">HTML</span>"
/&gt;
</p>
          <p style="MARGIN: 0px">
&lt;/<span style="COLOR: #cc7832">codeSubDirectories</span>&gt;
</p>
        </div>
        <p>
We need to add an entry to this list for our new subfolder. On my system, it looks
like this (again, yours may vary slightly):
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;\red165\green194\blue92;}??\fs26 \cf1\cb2\highlight2 {\b       &lt;}\cf3 {\b codeSubDirectories}\cf1 {\b &gt;}\par ??{\b         &lt;}\cf3 {\b add}\cf1 {\b  directoryName="}\cf4 {\b HTML}\cf1 {\b " /&gt;}\par ??{\b         &lt;}\cf3 {\b add}\cf1 {\b  directoryName="}\cf4 {\b RSSDataSource}\cf1 {\b "/&gt;}\par ??{\b       &lt;/}\cf3 {\b codeSubDirectories}\cf1 {\b &gt;}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas, monospace">
          <p style="MARGIN: 0px">
&lt;<span style="COLOR: #cc7832">codeSubDirectories</span>&gt;
</p>
          <p style="MARGIN: 0px">
  &lt;<span style="COLOR: #cc7832">add</span> directoryName="<span style="COLOR: #a5c25c">HTML</span>"
/&gt;
</p>
          <p style="MARGIN: 0px">
  &lt;<span style="COLOR: #cc7832">add</span> directoryName="<span style="COLOR: #a5c25c">RSSDataSource</span>"/&gt;
</p>
          <p style="MARGIN: 0px">
&lt;/<span style="COLOR: #cc7832">codeSubDirectories</span>&gt;
</p>
        </div>
        <p>
Now that we have somewhere to put our code, let's create our Data Source! We'll create
a class inside our nice new <em>App_Code</em> folder called <em>RSSDataSource</em>.
</p>
        <p>
I'm not going to list the code for the Data Source in this post, because I've attached
it to this post. However, I'll go over the general steps.
</p>
        <ol>
          <li>
First, we use the <em>System.Net.WebClient</em> class to download the RSS feed. For
now, I've hardcoded it to one of my favourite blogs: <a href="http://www.hanselman.com/blog/">Scott
Hanselman's Computer Zen</a></li>
          <li>
Next we create an ADO.Net <em>DataTable</em> with three columns: <em>Title</em>, <em>Link</em> and <em>Description</em></li>
          <li>
Then, we use the classes in the <em>System.Xml.XPath</em> namespace to add a row for
each item in the feed to the <em>DataTable</em>. 
</li>
          <li>
Finally, we wrap the DataTable in a DataView. The Reports Module expects us to return
a DataView in order to allow us to do filtering and sorting if we wanted to. We aren't
using that feature, so we just create a simple DataView to wrap our table.</li>
        </ol>
        <p>
There's only one last step to hook everything up. We need to tell the Reports Module
how to find our Data Source code. To do that, open the code-behind file for <em>DesktopModules/Reports/DataSources/RSS/Settings.ascx</em> and
change the <em>DataSourceClass</em> property to the following code:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red204\green120\blue50;}??\fs26 \cf1\cb2\highlight2 {\b     }\cf3 {\b Public}\cf1 {\b  }\cf3 {\b ReadOnly}\cf1 {\b  }\cf3 {\b Property}\cf1 {\b  DataSourceClass() }\cf3 {\b As}\cf1 {\b  }\cf3 {\b String}\cf1 {\b  }\cf3 {\b Implements}\cf1 {\b  IDataSourceSettingsControl.DataSourceClass}\par ??{\b         }\cf3 {\b Get}\par ??\cf1 {\b             }\cf3 {\b Return}\cf1 {\b  }\cf3 {\b GetType}\cf1 {\b (RSSDataSource).FullName}\par ??{\b         }\cf3 {\b End}\cf1 {\b  }\cf3 {\b Get}\par ??\cf1 {\b     }\cf3 {\b End}\cf1 {\b  }\cf3 {\b Property}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Public</span>
            <span style="COLOR: #cc7832">ReadOnly</span>
            <span style="COLOR: #cc7832">Property</span> DataSourceClass() <span style="COLOR: #cc7832">As</span><span style="COLOR: #cc7832">String</span><span style="COLOR: #cc7832">Implements</span> IDataSourceSettingsControl.DataSourceClass
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">Get</span></p>
          <p style="MARGIN: 0px">
        <span style="COLOR: #cc7832">Return</span><span style="COLOR: #cc7832">GetType</span>(RSSDataSource).FullName
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">End</span><span style="COLOR: #cc7832">Get</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">End</span>
            <span style="COLOR: #cc7832">Property</span>
          </p>
        </div>
        <p>
And with that, we have a working RSS Data Source! Go back to your browser and go to
the Settings page for the Reports Module instance we created in Part 1. Select the
RSS Data Source as the <em>Active Data Source</em>, and click update. You should see
a very wide grid containing the data from the RSS feed (assuming you are using the
Grid Visualizer, which is the default):
</p>
        <div class="captioned_image">
          <img alt="Simple Grid View" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part2/IE-GridNoDecode.png" />
          <p class="caption">
Figure 2 - Simple Grid View
</p>
        </div>
        <p>
Well, that doesn't look very useful does it? Let's start by getting rid of that HTML
junk in the Description field. To get rid of that, go back to the Settings page, and
add "Description" to the list of columns to HTML Decode.
</p>
        <div class="captioned_image">
          <img alt="HTML Decode Converter" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part2/IE-HtmlDecodeSetting.png" />
          <p class="caption">
Figure 3 - HTML Decode Converter
</p>
        </div>
        <p>
That should clean up the HTML, but it's still a big grid. Let's use the HTML Visualizer
to clean it up a bit. Put the following code in an HTML file and place it in your <em>Portals/[PortalID]</em> folder:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red255\green255\blue255;\red0\green0\blue0;\red232\green188\blue100;\red165\green194\blue92;}??\fs26 \cf1\cb2\highlight2 {\b &lt;}\cf3 {\b h1}\cf1 {\b &gt;&lt;}\cf3 {\b a}\cf1 {\b  href=}\cf4 {\b "[Link]"}\cf1 {\b &gt;[Title]&lt;/}\cf3 {\b a}\cf1 {\b &gt;&lt;/}\cf3 {\b h1}\cf1 {\b &gt;}\par ??{\b [Description]}\par ??{\b &lt;}\cf3 {\b hr}\cf1 {\b  /&gt;}}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
&lt;<span style="COLOR: #e8bc64">h1</span>&gt;&lt;<span style="COLOR: #e8bc64">a</span> href=<span style="COLOR: #a5c25c">"[Link]"</span>&gt;[Title]&lt;/<span style="COLOR: #e8bc64">a</span>&gt;&lt;/<span style="COLOR: #e8bc64">h1</span>&gt;
</p>
          <p style="MARGIN: 0px">
[Description]
</p>
          <p style="MARGIN: 0px">
&lt;<span style="COLOR: #e8bc64">hr</span> /&gt;
</p>
        </div>
        <p>
Then, go back to the Settings page, select the HTML Template Visualizer and the HTML
file you just uploaded:
</p>
        <div class="captioned_image">
          <img alt="Configuring the HTML Visualizer" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part2/IE-HtmlTemplate.png" />
          <p class="caption">
Figure 4 - Configuring the HTML Visualizer
</p>
        </div>
        <p>
Click Update and you should see a much more readable display. It's almost like a real
RSS Reader!
</p>
        <div class="captioned_image">
          <img alt="A Reports Module-powered RSS Reader?" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part2/IE-RSSReader.png" />
          <p class="caption">
Figure 5 - A Reports Module-powered RSS Reader!
</p>
        </div>
        <h3>Conclusion
</h3>
        <p>
Well, that's all for part two. Next, we'll cover Data Source settings so that we can
point our Data Source at any RSS feed we want, rather than hard coding it. Then, we
add an HTML Decoding feature directly into the Data Source so we don't have to configure
the module to decode the Description field. Finally, we'll package it all up so that
others can download and install it.
</p>
        <p>
          <a href="http://blog.andrewnurse.net/content/binary/RSSDataSource/Files/Part2.zip">Download
the code so far.</a>
        </p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=fd4a2728-3346-4256-ac28-2e99875145e3" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Developing an RSS Data Source - Part I</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/02/29/DevelopingAnRSSDataSourcePartI.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,155560d2-8873-4fd5-9b6a-df2b23b1a851.aspx</id>
    <published>2008-02-28T23:03:39.282-07:00</published>
    <updated>2008-02-29T13:34:52.9632738-07:00</updated>
    <category term="DNN" label="DNN" scheme="http://blog.andrewnurse.net/CategoryView,category,DNN.aspx" />
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
UPDATE: <a href="http://blog.andrewnurse.net/2008/02/29/DevelopingAnRSSDataSourcePartII.aspx">Part
II</a> is now available.
</p>
        <p>
In this series of blogs, I'm going to follow the development of an RSS Data Source.
I'm going to use Visual Studio 2008, but I'll be using .Net 2.0 features so you should
be able to follow along in Visual Studio 2005. You can also use the Express editions
of Visual Web Developer (both 2005 and 2008 versions should work). All the code will
be in VB.Net, but it should be straightforward enough for C# developers to understand
(after all, its all .Net)
</p>
        <h3>Part I - Setting Up
</h3>
        <p>
First things first, you'll need to install a Source distribution of DotNetNuke. I'm
not going to cover that here because there are some other resources out there. You'll
also need to install the Source package of the Reports Module. Once you've done this,
open your DotNetNuke website up in Visual Studio
</p>
        <div class="captioned_image">
          <img alt="Open Website Dialog" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part1/VS-OpenWebsite.png" />
          <p class="caption">
Figure 1 - Open Website Dialog
</p>
        </div>
        <p>
After opening it, expand the <em>DesktopModules/Reports/DataSources</em> folder. You
should see something similar to the following
</p>
        <div class="captioned_image">
          <img alt="Data Sources Folder" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part1/VS-DataSourcesFolder.png" />
          <p class="caption">
Figure 2 - Data Sources Folder
</p>
        </div>
        <p>
Each of the folder under the <em>DataSources</em> folder represents a different Data
Source. So, lets get started and create a folder for our Data Source and call it <em>RSS</em>.
Inside that folder, we need to create an <em>App_LocalResources</em> folder. Visual
Studio provides a special menu option to do that:
</p>
        <div class="captioned_image">
          <img alt="Add App_LocalResources Folder menu item" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part1/VS-AddAppLRFolder.png" />
          <p class="caption">
Figure 3 - Add App_LocalResources Folder menu item
</p>
        </div>
        <p>
Inside there, we must create a Resource file. Even if you aren't planning to translate
your Data Source into different languages, the Reports Module uses this file to determine
the name of your Data Source, so you must create it. In this sample, we aren't going
to use the DotNetNuke Localization framework, so this is the only time we'll need
to delve into Resource files. Add a new Resource file to the <em>App_LocalResources </em>folder
called "DataSource.ascx.resx".
</p>
        <div class="captioned_image">
          <img alt="Adding a Resource File" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part1/VS-AddResourceFile.png" />
          <p class="caption">
Figure 4 - Adding a Resource File
</p>
        </div>
        <p>
Open this file and add a new resource key called "DataSourceName.Text" with a value
of "RSS".
</p>
        <div class="captioned_image">
          <img alt="Editing the Resource File" src="http://blog.andrewnurse.net/content/binary/RSSDataSource/Images/Part1/VS-ResourceFileEditor.png" />
          <p class="caption">
Figure 5 - Editing the Resource File
</p>
        </div>
        <p>
We've almost got a running, albeit useless, Data Source. There's only one more file
to add. Back in the "RSS" folder, add a Web User Control called "Settings.ascx". Open
the Code-behind file (Settings.ascx.vb) and replace the contents with the following
code:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red204\green120\blue50;\red0\green0\blue0;\red255\green255\blue255;}??\fs26 \cf1\cb2\highlight2 {\b Imports}\cf3 {\b  DotNetNuke.Modules.Reports.Extensions}\par ??\cf1 {\b Imports}\cf3 {\b  DotNetNuke.Modules.Reports.DataSources}\par ??\par ??\cf1 {\b Partial}\cf3 {\b  }\cf1 {\b Class}\cf3 {\b  DesktopModules_Reports_DataSources_RSS_Settings}\par ??{\b     }\cf1 {\b Inherits}\cf3 {\b  ReportsSettingsBase}\par ??{\b     }\cf1 {\b Implements}\cf3 {\b  IDataSourceSettingsControl}\par ??\par ??\par ??{\b     }\cf1 {\b Public}\cf3 {\b  }\cf1 {\b ReadOnly}\cf3 {\b  }\cf1 {\b Property}\cf3 {\b  DataSourceClass() }\cf1 {\b As}\cf3 {\b  }\cf1 {\b String}\cf3 {\b  }\cf1 {\b Implements}\cf3 {\b  IDataSourceSettingsControl.DataSourceClass}\par ??{\b         }\cf1 {\b Get}\par ??\cf3 {\b             }\cf1 {\b Return}\cf3 {\b  }\cf1 {\b String}\cf3 {\b .Empty}\par ??{\b         }\cf1 {\b End}\cf3 {\b  }\cf1 {\b Get}\par ??\cf3 {\b     }\cf1 {\b End}\cf3 {\b  }\cf1 {\b Property}\par ??{\b End}\cf3 {\b  }\cf1 {\b Class}\par ??}
-->
        <div style="FONT-WEIGHT: bold; FONT-SIZE: 13pt; BACKGROUND: black; COLOR: white; FONT-FAMILY: Consolas">
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Imports</span> DotNetNuke.Modules.Reports.Extensions
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Imports</span> DotNetNuke.Modules.Reports.DataSources
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Partial</span>
            <span style="COLOR: #cc7832">Class</span> DesktopModules_Reports_DataSources_RSS_Settings
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">Inherits</span> ReportsSettingsBase
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">Implements</span> IDataSourceSettingsControl
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
 
</p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">Public</span><span style="COLOR: #cc7832">ReadOnly</span><span style="COLOR: #cc7832">Property</span> DataSourceClass() <span style="COLOR: #cc7832">As</span><span style="COLOR: #cc7832">String</span><span style="COLOR: #cc7832">Implements </span>IDataSourceSettingsControl.DataSourceClass
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: #cc7832">Get</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">Return</span><span style="COLOR: #cc7832">String</span>.Empty
</p>
          <p style="MARGIN: 0px">
        <span style="COLOR: #cc7832">End</span><span style="COLOR: #cc7832">Get</span></p>
          <p style="MARGIN: 0px">
    <span style="COLOR: #cc7832">End</span><span style="COLOR: #cc7832">Property</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #cc7832">End</span>
            <span style="COLOR: #cc7832">Class</span>
          </p>
        </div>
        <p>
Save everything and open your Web Browser. Add an instance of the Reports Module to
a page and open the Settings page. You should now see the "RSS Data Source" in the
Active Data Source drop-down. You can select it, but it doesn't do anything, so don't
click Update.
</p>
        <h3>Conclusion
</h3>
        <p>
That's all for part one. I know there isn't anything really useful yet, but I want
to keep these parts short. Tomorrow, we'll add the code to retrieve data from an RSS
feed.
</p>
        <p>
          <a href="http://blog.andrewnurse.net/content/binary/RSSDataSource/Files/Part1.zip">Download
the code so far.</a>
        </p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=155560d2-8873-4fd5-9b6a-df2b23b1a851" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Just signed my offer letter</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/02/13/JustSignedMyOfferLetter.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,3e42d7fa-c638-48d7-98e4-dc197ea50b14.aspx</id>
    <published>2008-02-12T23:54:27.5149799-07:00</published>
    <updated>2008-02-12T23:54:27.5149799-07:00</updated>
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <category term="Microsoft Internship" label="Microsoft Internship" scheme="http://blog.andrewnurse.net/CategoryView,category,Microsoft%2BInternship.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Well, I just signed my offer letter so I'm going back to Microsoft for another summer!
This time, I'll be working on the ASP.Net team, which is exciting. It's going to be
a lot of fun having a chance to contribute to a framework I've been using for the
past 2 years (I've almost forgotton what a Windows Form is :P).
</p>
        <p>
I just thought I'd share that exciting news with my readers. However, I do have a
few other updates:
</p>
        <ol>
          <li>
The Reports Module 5.0 User Guide is almost "content-complete" so I'll just need to
get it formatted properly and it should be ready to go live 
</li>
          <li>
I'm starting a Blog series on Developing for the Reports Module. For now, this is
going to have to stand in for a full Programming Guide, but hopefully it will be a
good starting point for those of you thinking of writing Visualizers or Data Sources.</li>
        </ol>
        <p>
Anyway, look for my first post in that series soon. I'll be crossposting it on my
DotNetNuke blog, so feel free to check it out there.
</p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=3e42d7fa-c638-48d7-98e4-dc197ea50b14" />
      </div>
    </content>
  </entry>
  <entry>
    <title>T-11 hours till my Interviews begin</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2008/01/18/T11HoursTillMyInterviewsBegin.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,fbda1ffb-799a-473f-a42f-c36eddf25166.aspx</id>
    <published>2008-01-17T22:50:11.205045-07:00</published>
    <updated>2008-01-17T22:50:11.205045-07:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">So, I'm chilling in my hotel in Redmond
watching MythBusters (best show ever!) while I await the start of my Microsoft Interviews
at 8am tomorrow morning.<br /><br />
Now, on to things my readers would be interested in :). I'm going to start a series
on Extending the Reports Module in the next few days that's going to start by developing
a custom Data Source for the module that extracts data from an RSS feed. I'll probably
move on to developing a custom Visualizer and even more tutorials.<br /><br />
I'm also going to try to set up a documentation Wiki for the module and pre-populate
it with some basic documentation for Reports 5.0.<br /><br />
Anyway, now that the holidays are over, I'll be getting back into blogging regularly,
so keep an eye on your RSS readers!<br /><p></p><img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=fbda1ffb-799a-473f-a42f-c36eddf25166" /></div>
    </content>
  </entry>
  <entry>
    <title>Using Parameters in the Reports Module</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2007/12/19/UsingParametersInTheReportsModule.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,aeb6fab5-6926-45f9-9dbc-c606d2ec8cc8.aspx</id>
    <published>2007-12-19T07:17:04-07:00</published>
    <updated>2007-12-19T00:14:10.2186474-07:00</updated>
    <category term="DNN" label="DNN" scheme="http://blog.andrewnurse.net/CategoryView,category,DNN.aspx" />
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A common question that comes up in the Reports Module forums is "How can I display
data relevant to the current User in the Reports Module?". So, I figured I should
write a blog post about a feature that has been in the Reports Module for a few versions.
When writing your SQL Scripts for the Reports Module, you automatically have access
to four parameters: <strong><em>@PortalID</em></strong>, <strong><u><em>@TabID</em></u></strong>, <strong><em>@ModuleID </em></strong>and <strong><em>@UserID</em></strong>.
When the SQL Script is executed, these are replaced by the ID of the current Portal,
Tab, Module and User (respectively).
</p>
        <p>
So, if you wanted to display a list of Roles for the currently logged in user you
could use this script:
</p>
        <div class="csharpcode" style="font-size: 11pt; background: black; color: white; font-family: consolas">
          <p style="margin: 0px">
            <span style="color: #ff8000">SELECT  </span>R.* 
</p>
          <p style="margin: 0px">
            <span style="color: #ff8000">FROM    </span>{oQ}UserRoles UR 
</p>
          <p style="margin: 0px">
    <span style="color: #ff8000">INNER JOIN </span>dnn_Roles R 
</p>
          <p style="margin: 0px">
    <span style="color: #ff8000">ON    </span>    
UR.RoleID = R.RoleID 
</p>
          <p style="margin: 0px">
            <span style="color: #ff8000">WHERE   </span>UR.UserID = @UserID
</p>
        </div>
        <p>
When you run this script, the current user's ID will be substituted in the place of
the <strong><em>@UserID</em></strong> parameter. (Note: This is done by SQL Server
itself, which avoids SQL Injection attacks). Also, the <strong><em>{oQ}</em></strong> token
is replaced with the Object Qualifier configured for your database (if you configured
one in your web.config file)
</p>
        <p>
Here's another example. It's a script that retrieves the <strong><em>Website</em></strong> profile
property for each user in the current portal.
</p>
        <div style="font-size: 11pt; background: black; color: white; font-family: consolas">
          <p style="margin: 0px">
            <span style="color: #ff8000">SELECT     </span>U.Username,
</p>
          <p style="margin: 0px">
          <em>(<span style="color: #ff8000">SELECT     </span>PropertyValue</em></p>
          <p style="margin: 0px">
            <em>           <span style="color: #ff8000">FROM    </span>  
{oQ}UserProfile <span style="color: #ff8000">AS </span>UP</em>
          </p>
          <p style="margin: 0px">
            <em>           <span style="color: #ff8000">INNER
JOIN </span>{oQ}ProfilePropertyDefinition <span style="color: #ff8000">AS </span>PPD </em>
          </p>
          <p style="margin: 0px">
            <em>           <span style="color: #ff8000">ON    </span>    
PPD.PropertyDefinitionID = UP.PropertyDefinitionID</em>
          </p>
          <p style="margin: 0px">
            <em>
              <span style="color: #ff8000">          
WHERE    </span>  UP.UserId = U.UserId</em>
          </p>
          <p style="margin: 0px">
            <em>           <span style="color: #ff8000">AND        </span>PropertyName
= <span style="color: lime">'Website'</span></em>
          </p>
          <p style="margin: 0px">
            <em>           <span style="color: #ff8000">AND    </span>   
PropertyCategory = <span style="color: lime">'Contact Info'</span>) <span style="color: #ff8000">AS </span><span style="color: lime">'Website'</span></em>
          </p>
          <p style="margin: 0px">
            <span style="color: #ff8000">FROM    </span>   {oQ}UserPortals <span style="color: #ff8000">AS </span>UP
</p>
          <p style="margin: 0px">
            <span style="color: #ff8000">INNER JOIN </span>{oQ}Users <span style="color: #ff8000">AS </span>U 
</p>
          <p style="margin: 0px">
            <span style="color: #ff8000">ON    </span>    
UP.UserId = U.UserId
</p>
          <p style="margin: 0px">
            <span style="color: #ff8000">WHERE    </span>  PortalID = @PortalID
</p>
        </div>
        <p>
The <em>italicized</em> section is the part that actually retrieves the property value,
you can replace the <strong><em>PropertyName</em></strong> and <strong><em>PropertyCategory</em></strong> values
as you like and repeat this section multiple times to bring back multiple profile
properties.
</p>
        <p>
One of the planned future features for the module is to support user-specified parameters.
This means you could place a text box, drop down, calendar or other control on the
view page for the module and the value of this control would be used as a parameter
to the Report. At the moment you're limited to these four parameters, but there's
still a lot you can do with them!
</p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=aeb6fab5-6926-45f9-9dbc-c606d2ec8cc8" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Reports Module v5.0 Released to Tracker</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2007/12/19/ReportsModuleV50ReleasedToTracker.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,615f5170-84bc-435c-ab99-a28ad5a792ce.aspx</id>
    <published>2007-12-19T06:42:02-07:00</published>
    <updated>2007-12-18T23:43:06.6947946-07:00</updated>
    <category term="DNN" label="DNN" scheme="http://blog.andrewnurse.net/CategoryView,category,DNN.aspx" />
    <category term="Reports Module" label="Reports Module" scheme="http://blog.andrewnurse.net/CategoryView,category,Reports%2BModule.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
After a few delays, version 5.0 of the Reports Module has been released to the Module
Release Process. This means that it should be released shortly (though given the time
of year, it may take a couple of weeks). I'll be posting some How-To screencasts walking
through the new features (and some old ones too) in the next week or so. I'm also
working on a full User's Guide to be released shortly.
</p>
        <p>
          <strong>One important note regarding Reports 5.0:</strong> The module <strong>requires
at least v4.6 of the DotNetNuke core</strong>, it will <strong>NOT</strong> run on
a previous version of the core. This is because of the new Visualizer and Data Source
installers which use the Package Installer introduced in v4.6. I hope to release a
version of the module with the installer portions removed which will be referred to
as "Version 4.9".
</p>
        <p>
To give you an idea of what's coming, here's an excerpt from the release notes containing
a list of resolved issues in this version (The same list can be found here: <a title="http://support.dotnetnuke.com/project/RoadMap.aspx?PROJID=36" href="http://support.dotnetnuke.com/project/RoadMap.aspx?PROJID=36">http://support.dotnetnuke.com/project/RoadMap.aspx?PROJID=36</a>)
</p>
        <ul>
          <li>
            <strong>
              <em>RPT-5634</em> JavaScipt error when first configuring Reports DNN _04.05.01 
<br /></strong>    A JavaScript error was occuring on the main settings page,
this has been corrected 
</li>
          <li>
            <strong>
              <em>RPT-5676</em> HTML Decoding in XSL Visualizer 
<br /></strong>    Fix through RPT-6514 
</li>
          <li>
            <strong>
              <em>RPT-4698</em> Clean up interface for Reporting Services Visualizer 
<br /></strong>    Interface for Reporting Services Visualizer has been improved
significantly the Visualizer has also been renamed to the "Microsoft ReportViewer
Visualizer" 
</li>
          <li>
            <strong>
              <em>RPT-5715 </em>Include {databaseOwner} token in upgrade SQL scripts 
<br /></strong>    Scripts have been corrected 
</li>
          <li>
            <strong>
              <em>RPT-5791 </em>Run Reports on Demand 
<br /></strong>    Reports can now be run "on-demand" rather than
automatically on load 
</li>
          <li>
            <strong>
              <em>RPT-5806 </em>Support the EnableExternalImages property of ReportViewer
control 
<br /></strong>    The EnableExternalImages and EnableHyperlink properties
are now supported, along with many others (see RPT-4698) 
</li>
          <li>
            <strong>
              <em>RPT-3994 </em>Alternate Data Sources 
<br /></strong>    Data Sources Framework allows Reports to run queries against
other Databases (SQL Server, Access, Oracle, etc.) 
</li>
          <li>
            <strong>
              <em>RPT-6466 </em>Disable the Use of Parameters while Caching is enabled 
<br /></strong>    Paramaters are disabled when Caching is enabled due to
a serious privacy risk 
</li>
          <li>
            <strong>
              <em>RPT-6514 </em>HTML Decoding and Encoding of fields retrieved from database 
<br /></strong>    Fields can now be individually HTML Encoded and HTML Decoded
before being passed to the Visualizer 
</li>
          <li>
            <strong>
              <em>RPT-6516 </em>Report Info Pane 
<br /></strong>    An info pane displaying the title and description of the
report can now be displayed on the main screen 
</li>
          <li>
            <strong>
              <em>RPT-6454 </em>Allow Users to specify custom CSS Styles and Classes for
the Grid in the Grid Visualizer 
<br /></strong>    Users can use custom CSS to style the Grid Visualizer 
</li>
          <li>
            <strong>
              <em>RPT-6438 </em>Add a setting to enable/disable Grid Lines in Grid Visualizer 
<br /></strong>    Grid Lines can now be configured in the Grid Visualizer 
</li>
        </ul>
        <p>
Keep an eye on the blogs for more updates, I'll make sure to post here when the module
is released!
</p>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ddc7a729-54ea-4d20-9c15-6693fe547072" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati
Tags: <a href="http://technorati.com/tags/DotNetNuke" rel="tag">DotNetNuke</a>,<a href="http://technorati.com/tags/Reporting" rel="tag">Reporting</a>,<a href="http://technorati.com/tags/ASP.Net" rel="tag">ASP.Net</a></div>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=615f5170-84bc-435c-ab99-a28ad5a792ce" />
      </div>
    </content>
  </entry>
  <entry>
    <title>More Better Familiarize Yourself with a Toolkit? (Name in progress) - #1</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2007/12/15/MoreBetterFamiliarizeYourselfWithAToolkitNameInProgress1.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,20649618-126a-4943-b000-c7d8ff68ab42.aspx</id>
    <published>2007-12-15T02:04:40.7942268-07:00</published>
    <updated>2007-12-15T02:04:40.7942268-07:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
While attempting to avoid infringing on the name from a segment from a <a href="http://www.dotnetrocks.com">popular
internet audio talk</a> show, I had an idea for a "quick tip" when I was
reading a recent <a href="http://dotnettipoftheday.org/tips/ObsoleteAttribute.aspx?discussion=1">.Net
Tip of the Day</a>.
</p>
        <blockquote>
          <p>
Throughout the product development cycle, occasionally certain methods become obsolete.
If you can't modify those methods, will need to write another implementation of the
method using a slightly different name or signature. To maintain compatibility, you
do not want to remove the old method and break your code. This is where the .NET <a href="http://msdn2.microsoft.com/en-us/library/system.obsoleteattribute.aspx">Obsolete</a> attribute
comes in handy:
</p>
          <!-- code formatted by http://manoli.net/csharpformat/ -->
          <pre class="csharpcode">[Obsolete(<span class="str">"Use the new LogRequestEx
instead."</span>)] <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">void</span> LogRequest(<span class="kwrd">string</span> feedUrl, <span class="kwrd">string</span> referer)
{ ...</pre>
          <p>
Setting the Obsolete attribute as above makes a warning message appear in the Visual
Studio's Error List stating that the particular call to a method is obsolete. The
warning message also includes your personalized message that you pass as the attribute's
argument (such as, "Use the new LogRequestEx instead").
</p>
        </blockquote>
        <p>
So, I figured I'd start of this semi-frequently series of .Net tips with an extension
to this one :). Not only can you have Visual Studio display a warning, but if you
really don't want people using the method you can configure it to display an error
message if the user tries to use the method. For example, in the example above you
need only add a boolean value for the second constructor parameter "error":
</p>
        <!-- code formatted by http://manoli.net/csharpformat/ -->
        <pre class="csharpcode">[Obsolete(<span class="str">"You must use the new LogRequestEx
instead."</span>, <span class="kwrd">true</span>)] <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">void</span> LogRequest(<span class="kwrd">string</span> feedUrl, <span class="kwrd">string</span> referer)
{ }</pre>
        <p>
More details can be found on <a href="http://msdn2.microsoft.com/en-us/library/system.obsoleteattribute.aspx">MSDN</a></p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=20649618-126a-4943-b000-c7d8ff68ab42" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Applying the Single Responsibility Principle at a Product level</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2007/12/13/ApplyingTheSingleResponsibilityPrincipleAtAProductLevel.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,6fdf0656-af39-4248-9c0c-4aab370b50af.aspx</id>
    <published>2007-12-12T19:57:36.7357698-07:00</published>
    <updated>2007-12-12T19:57:36.7357698-07:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the big concepts in Object Oriented Programming, is the <strong><em><a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single
Responsibility Principle</a> (SRP)</em></strong>, which essentially states that every
object in a computer program should have a single responsibility. I recently started
thinking about where <a href="http://blog.andrewnurse.net/2007/12/11/OneQueryAFluentInterfaceToDatabaseQueries.aspx">OneQuery</a> fits
in to the whole ORM landscape. OneQuery is designed for a very singular purpose. It
is a Database-agnostic Query engine. That alone is its responsibility and I think
it should stay that way. So, in fact, OneQuery <strong>doesn't </strong>fit into the
ORM landscape, because it isn't an ORM. OneQuery is directly focused on the problem
of writing queries against any database and receiving <em>tabular</em> results (i.e.
IDataReader).
</p>
        <p>
Does this mean that you should ignore it if you are looking for an ORM? No, I don't
believe so. Just because OneQuery isn't an ORM, doesn't mean it can't work with ORM
tools. One of the ideas sitting at the back of my head is to create an ORM called
"OneMapper" which would sit on top of OneQuery and add ORM features. The
fundamental difference between the combination of OneMapper and OneQuery and other
ORM tools is that you could use OneQuery without OneMapper. Tools like SubSonic and
NHibernate have a tight coupling between their ORM components and their database query
components. The point is, I see OneQuery as being an example of SoC/SRP being applied
at a "Product" level, rather than at a Class level. I want OneQuery to be
a <strong>really good</strong> query engine, not a pretty good ORM and I think that
separating those concerns makes that much more possible.
</p>
        <p>
The main problem I was thinking about when I dreamt up OneQuery is how DotNetNuke
could achieve true Database-agnosticism in its Data Access Layer. One option would
be to use a tool like NHibernate or SubSonic to completely rewrite the Data and Business
Layers with a true ORM. However the problem there is that it would be a wholesale
change and would probably introduce some major breaking changes. 
</p>
        <p>
Another option would be to use something like SubSonic's Query Tool (which actually
inspired me to develop OneQuery), which allows you to build database-agnostic queries
and execute them, receiving tabular data in return (rather than objects). Then, the
existing DotNetNuke infrastructure could handle the ORM stuff. This would basically
mean replacing the existing "SqlDataProvider" with a "SubSonicDataProvider"
and basically avoiding any breaking changes by just scooping out the old SQL Server-specific
guts and injecting a tasty cream...oops, I mean Database-Agnostic...filling. 
</p>
        <p>
So, why not do that? Well, I realized that SubSonic is, first and foremost, an ORM
and it will always be focused on that. The Query Tool is a great feature, but it feels
like it's just tacked on to the main ORM component. This has two ramifications: First,
the ORM will be the primary focus of development and new features in the Query Tool
will be fewer and far between. And second, if you just want the Query Tool, you have
to bring along the entire ORM system as well (unless SubSonic does some refactoring).
At 644KB, SubSonic isn't huge but it isn't tiny either (though, I don't have exact
numbers on what portion of that is the ORM and what portion is the Query Tool).
</p>
        <p>
So, that leads me into the primary difference between OneQuery and other tools like
NHibernate and SubSonic: OneQuery is not actually an ORM! Its a query engine, and
hopefully it will be a darn good one too. That is its primary responsibility and any
other cool features (like ORM components or LINQ support) are totally separate concerns.
</p>
        <p>
Now, having said all that, this is just what I've been thinking about recently. Maybe
it's all crazy talk. Feel free to sound off in the comments and tell me that :).
</p>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=6fdf0656-af39-4248-9c0c-4aab370b50af" />
      </div>
    </content>
  </entry>
  <entry>
    <title>OneQuery - A Fluent Interface to Database Queries</title>
    <link rel="alternate" type="text/html" href="http://blog.andrewnurse.net/2007/12/11/OneQueryAFluentInterfaceToDatabaseQueries.aspx" />
    <id>http://blog.andrewnurse.net/PermaLink,guid,909ac400-c7d1-4d5f-912e-a74b63555408.aspx</id>
    <published>2007-12-11T07:21:19-07:00</published>
    <updated>2007-12-18T23:43:45.1015362-07:00</updated>
    <category term="OneQuery" label="OneQuery" scheme="http://blog.andrewnurse.net/CategoryView,category,OneQuery.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Aside from my school work and my work on the <a href="http://www.dotnetnuke.com/tabid/824/default.aspx">DotNetNuke
Reports Module</a> (very very close to release now), I've been tinkering with another
project over the past few months. It's called OneQuery and its yet another Data Access
Layer tool. OneQuery is designed to provide a "<a href="http://en.wikipedia.org/wiki/Fluent_interface">fluent
interface</a>" to database queries. 
</p>
        <p>
What is a fluent interface? Wikipedia defines it as "an object oriented construct
that defines a behaviour capable of relaying the instruction context of a subsequent
call". Essentially, it means that instead of writing code like this:
</p>
        <pre class="csharpcode">List&lt;<span class="kwrd">int</span>&gt; ints = <span class="kwrd">new</span> List&lt;<span class="kwrd">int</span>&gt;();
ints.Add(1); ints.Add(2); ints.Add(3);</pre>
        <p>
You can write code like this
</p>
        <pre class="csharpcode">List&lt;<span class="kwrd">int</span>&gt; ints = <span class="kwrd">new</span> List&lt;<span class="kwrd">int</span>&gt;().Add(1).Add(2).Add(3);</pre>
        <p>
That's quite a savings and, in my opinion, it's much more readable.
</p>
        <h4>So, what's the point?
</h4>
        <p>
Well, recently I've been thinking about the issue of database agnostic...ness (database
agnostivity? database agnosticism?). I really want to be able to write data access
code that will run on multiple database engines without having to manually translate
it. <a href="http://www.dotnetnuke.com/">DotNetNuke</a> provides a, theoretically,
database agnostic interface through Data Providers. However, to support another database
engine, the core DataProvider must be translated, Stored Procedures must be converted
and all sorts of "Porting" issues arise. Wouldn't it be nice if you could
WORA (Write Once, Run Anywhere... a Java term) your SQL Scripts?
</p>
        <h4>Wait, hasn't this been done?
</h4>
        <p>
Of course it has, and many many times. First, there's the elephant in the room, LINQ.
However, aside from requiring .Net 3.5, if you want to write database agnostic code,
you need to use something like the ADO.Net Entity Framework. OneQuery is designed
to work in .Net 2.0, and I'm planning to write a LINQ layer on top of it so that you
can write LINQ queries and run them on multiple database engines (not just SQL Server).
I think OneQuery could serve as a "migration path" where you can write OneQuery
syntax and then move to LINQ syntax when you're ready to move to .Net 3.5 while still
keeping the database-agnostic OneQuery core.
</p>
        <p>
There are a lot more database libraries out there as well. <a href="http://subsonicproject.com">SubSonic</a> provides
an excellent Object/Relational Mapper (ORM) that allows you to work directly with
objects, but sometimes you want a little more control. There are, of course, many
others such as NHibernate, IBATIS.Net, and EntitySpaces. However, I found that while
working with these tools I would find little things that would annoy me. For example,
SubSonic does provide a way for you to directly query the database and get an IDataReader
back, but it has an interface I found a little awkward (though it is a nice fluent
interface). There are also smaller annoying features such as a lack of support for
certain SQL statements (like "INSERT") and a lack of JOIN support. On the
other side, tools like NHibernate are really designed to allow you to ignore the database
completely, which is a nice feature, but sometimes I need that direct database control.
</p>
        <h4>
        </h4>
        <h4>
        </h4>
        <h4>So, what is OneQuery?
</h4>
        <p>
[Wow, I started two sub-headings off with 'so', perhaps that summer at Microsoft is
affecting my patterns of speech. They say Microsofties tend to start there sentences
with "so" and say "drinking from a firehose" and "super"
a lot]
</p>
        <p>
OneQuery is designed to let you focus on writing one query, and allows you to run
the query on multiple database systems. Instead of using strings, which the compiler
ignores, I wanted to provide a fluent interface and use operator overloading to make
the queries as readable as possible.
</p>
        <h4>Enough already, get to the code!
</h4>
        <p>
Ok, so here's a sample query using OneQuery's fluent syntax:
</p>
        <p>
          <a href="http://blog.andrewnurse.net/content/binary/WindowsLiveWriter/OneQueryAFluentInterfacetoDatabaseQuerie_1396C/query_4.png">
            <img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="88" alt="query" src="http://blog.andrewnurse.net/content/binary/WindowsLiveWriter/OneQueryAFluentInterfacetoDatabaseQuerie_1396C/query_thumb_1.png" width="658" border="0" />
          </a>
        </p>
        <p>
(I posted it as a screenshot to make sure the spacing worked out, I'll post the text
at the end if you want to copy it).
</p>
        <p>
There are a few things I want to do to let you clear that up even further. For example,
it would be much easier if you could write ".OrderBy(Product.ListPrice).Desc()",
or ".Where(Product.ListPrice.Between(10).And(100))"
</p>
        <p>
Behind the scenes, the only other code you need to "write" is a helper class
for the products table. I used quotes there because I'm planning on creating a code
generator to do that for you.
</p>
        <h4>CAN HAZ CODE?
</h4>
        <p>
Hopefully I've tantalized you a little bit and you'd like to check it out. You can
download a preview release from our <a href="http://www.codeplex.com/onequery">CodePlex
Project Site</a>, and discuss future features there as well. I'm planning a whole
bunch of new features including (but definitely NOT limited to): 
</p>
        <ul>
          <li>
Support for ALL SQL DML Statements (INSERT, UPDATE, DELETE) 
</li>
          <li>
Full support for SELECT (including JOIN, GROUP BY, HAVING, and sub-queries) 
</li>
          <li>
A Code Generator to create the helper classes 
</li>
          <li>
and more! 
</li>
        </ul>
        <p>
Please let me know what you think! I want to make sure this system solves problems
for as many people as possible, and the best way to do that is to get contributions
from the community as early as possible. The <a href="http://www.codeplex.com/onequery">CodePlex
site</a> has plenty of places to contribute, so please check it out!
</p>
        <h5>Sample Code in Text Form
</h5>
        <pre class="csharpcode">IDataReader rdr = Product.Query()
                         .Where(Product.ListPrice &gt; 10 &amp; Product.ListPrice &lt; 100)
                         .OrderBy(Product.ListPrice, SortDirection.Descending)
                         .ExecuteReader();</pre>
        <p>
        </p>
        <div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:72e27e42-13fc-4276-bae4-35c1cd2093a5" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati
Tags: <a href="http://technorati.com/tags/Data%20Access" rel="tag">Data Access</a>,<a href="http://technorati.com/tags/C#" rel="tag">C#</a>,<a href="http://technorati.com/tags/VB" rel="tag">VB</a>,<a href="http://technorati.com/tags/.Net" rel="tag">.Net</a>,<a href="http://technorati.com/tags/Fluent%20Interface" rel="tag">Fluent
Interface</a>,<a href="http://technorati.com/tags/ORM" rel="tag">ORM</a></div>
        <img width="0" height="0" src="http://blog.andrewnurse.net/aggbug.ashx?id=909ac400-c7d1-4d5f-912e-a74b63555408" />
      </div>
    </content>
  </entry>
</feed>