<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Caffeinated Geek.ca</title>
	<atom:link href="http://caffeinatedgeek.ca/feed" rel="self" type="application/rss+xml" />
	<link>http://caffeinatedgeek.ca</link>
	<description>A cup of caffeine each day keeps the coder at play</description>
	<lastBuildDate>Sat, 10 Dec 2011 00:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Waste&#8230;.</title>
		<link>http://caffeinatedgeek.ca/2011/12/09/waste/%</link>
		<comments>http://caffeinatedgeek.ca/2011/12/09/waste/%#comments</comments>
		<pubDate>Sat, 10 Dec 2011 00:09:08 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Waste]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=42</guid>
		<description><![CDATA[I talked about it in my last post, and it still permeates. The Kanban board I have pushed for at work is still not up. The CIO has even approved it. And you&#8217;d think a $100 purchase of a whiteboard and some post-its would be a trivially simple task. However, after a couple weeks, still [...]]]></description>
			<content:encoded><![CDATA[<p>I talked about it in my last post, and it still permeates.  The Kanban board I have pushed for at work is still not up.  The CIO has even approved it.  And you&#8217;d think a $100 purchase of a whiteboard and some post-its would be a trivially simple task.  However, after a couple weeks, still nothing.  We ran a trial on a whiteboard in another workers office while they were away on vacation for a week.  And you could quickly see where our bottlenecks were.  But the team seeing them, and the people who can actually institute change are two different things.  Maybe in another couple weeks we&#8217;ll finally get it up.  Maybe not.  </p>
<p>Another fun part of the past few weeks was taking a week to decide on the font for the title of a corporate report.  You&#8217;d think we would have a standard format.  And you&#8217;d be right.  We do.  I followed it initially.  Was asked to change it twice since then.  Finally had enough and got a PM, BA, and two other employees, and a member of Senior Management.  And yet it took that long for someone to explain what the font should be.  Turns out, it was exactly like the corporate standard&#8230;but no italics.  That was it.  A week and probably 10-15 man hours between several people to say &#8220;No italics&#8221;.</p>
<p>Next topic is going to be about UI&#8230;and why you don&#8217;t let the users design them.  Not that they aren&#8217;t critical to the process.  After all, they&#8217;re the owner of the product!</p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2011/12/09/waste/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eliminating Waste</title>
		<link>http://caffeinatedgeek.ca/2011/11/23/eliminating-waste/%</link>
		<comments>http://caffeinatedgeek.ca/2011/11/23/eliminating-waste/%#comments</comments>
		<pubDate>Thu, 24 Nov 2011 00:26:36 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=35</guid>
		<description><![CDATA[Like too many projects we start in life, this site became forgotten. Barely started, and with good intentions, I just didn&#8217;t find the time to follow through. I have many ideas in my head for projects I want to start&#8230;but sadly, that&#8217;s how I think of them. As things I want to start. Not as [...]]]></description>
			<content:encoded><![CDATA[<p>Like too many projects we start in life, this site became forgotten.  Barely started, and with good intentions, I just didn&#8217;t find the time to follow through.  I have many ideas in my head for projects I want to start&#8230;but sadly, that&#8217;s how I think of them.  As things I want to start.  Not as things I want to finish.  </p>
<p>A recent talk by <a href="http://www.joelfromcanada.com/" target="_blank">Joel Semeniuk</a> at the <a href="http://www.prairiedevcon.com/">Prairie Developer Conference</a> in Winnipeg, MB got me thinking about waste.  The talk at the time was about Kanban, and how anything started, and not finished, is waste.  Unmerged branches, projects not yet deployed, or anything else that&#8217;s not &#8220;Done.  Done.&#8221;</p>
<p>I remembered this site.  This thing I started a couple years ago.  And I realized&#8230;it was waste.  It&#8217;s unfinished.  I read and enjoy great blogs by other developers.  They help provide insight, solutions, and sometimes a spark.  A spark that puts you in the zone.  Even if only for a little while, but it motivates you.  It makes you strive for perfection.</p>
<p>Which ties into reviews.  I, like most developers, find reviews pointless.  Along with timesheets, but that&#8217;s another rant.  This review, in my mind was a giant waste of time.  It wasn&#8217;t long, it was basically a quick survey where you evaluate yourself.  Then later you sit with your boss and go over it.  However, what I consider &#8220;meets job expectations&#8221; and what my boss may consider &#8220;meets job expectations&#8221; are likely different.  And it has been pointed out before that they are, that I was &#8220;above average&#8221; or &#8220;exceeding&#8221;.  But how is this helping either of us?  Should I do less?  No&#8230;that&#8217;s probably not the point.  Does it actually help me become better?  No.  I strive to improve on my own.  And if you&#8217;re in IT and not striving to learn and improve, you&#8217;re in the wrong industry.  So if our views were so different, and he already knew how he would rank my work, why were we going through exercise?  I really don&#8217;t know.  Seems like a lot of waste when you calculate the number of employees doing this, and their bosses time, and what could be getting done during it.  It seems we only do these because HR says we should.  Because they help some employees&#8230;so it must help everyone right?  Or at the very least, not hurt.  All wasted time and effort for little to no business value.  At best it breaks even, more thank likely it&#8217;s a cost to perform and store these that never provides any overall benefit to the company.</p>
<p>Ultimately, I&#8217;m hoping in the next couple days the team and I get a Kanban board up on the wall, with WIP limits (that&#8217;s going to be a hard sell) and that we use and enforce the proper flow of tasks through it.  I guess we&#8217;ll see how it goes.</p>
<p>To sum up, the point of this 500 word rant is that we need to eliminate waste, even if it&#8217;s one small step at a time.  And I&#8217;m going to try and turn this waste of a site into something that can provide me value.  Somewhere that I can reflect, and hopefully as a tool to better myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2011/11/23/eliminating-waste/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BB Tips</title>
		<link>http://caffeinatedgeek.ca/2009/10/27/bb-tips/%</link>
		<comments>http://caffeinatedgeek.ca/2009/10/27/bb-tips/%#comments</comments>
		<pubDate>Tue, 27 Oct 2009 22:46:00 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[BlackBerry]]></category>
		<category><![CDATA[Shortcuts]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/uncategorized/bb-tips/</guid>
		<description><![CDATA[ALT-CAP-H will bring up your &#8220;Help Me!&#8221; page with pin, platform, version, mac, signal, etc Typing &#8220;MYPIN&#8221; in a message will enter your pin for you. ALT-&#8221;NMLL&#8221; will toggle between signal strength bars and numbers ALT-CAP-DEL will reboot your blackberry]]></description>
			<content:encoded><![CDATA[<p>ALT-CAP-H will bring up your &#8220;Help Me!&#8221; page with pin, platform, version, mac, signal, etc<br />
Typing &#8220;MYPIN&#8221; in a message will enter your pin for you.<br />
ALT-&#8221;NMLL&#8221; will toggle between signal strength bars and numbers<br />
ALT-CAP-DEL will reboot your blackberry</p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/10/27/bb-tips/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gone Mobile</title>
		<link>http://caffeinatedgeek.ca/2009/06/12/gone-mobile/%</link>
		<comments>http://caffeinatedgeek.ca/2009/06/12/gone-mobile/%#comments</comments>
		<pubDate>Fri, 12 Jun 2009 05:14:27 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[BlackBerry]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=27</guid>
		<description><![CDATA[The site has gone mobile. It&#8217;s looking good on the BB, in fact, that&#8217;s where this post is being written. How&#8217;s it work from your mobile device?]]></description>
			<content:encoded><![CDATA[<p>The site has gone mobile.  It&#8217;s looking good on the BB, in fact, that&#8217;s where this post is being written. How&#8217;s it work from your mobile device?</p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/06/12/gone-mobile/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wrap existing .NET site in a Portal/Theme</title>
		<link>http://caffeinatedgeek.ca/2009/06/11/wrap-existing-net-site-in-a-portaltheme/%</link>
		<comments>http://caffeinatedgeek.ca/2009/06/11/wrap-existing-net-site-in-a-portaltheme/%#comments</comments>
		<pubDate>Thu, 11 Jun 2009 23:17:29 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[App_Browsers]]></category>
		<category><![CDATA[Page Adapter]]></category>
		<category><![CDATA[Portal]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=23</guid>
		<description><![CDATA[Recently I ran into the problem where we were attempting to have all of our websites run inside of a portal. Where you could easily jump from one app to another, without having to go back and forth, or always back to a home page with links. What we wanted was a header menu added [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I ran into the problem where we were attempting to have all of our websites run inside of a portal.  Where you could easily jump from one app to another, without having to go back and forth, or always back to a home page with links.</p>
<p>What we wanted was a header menu added to ALL of our websites that handled some authentication, and showed what websites you had access to, and allowed you to easily navigate between them, as though they were one large application.</p>
<p>Now, rewriting all these applications would be a nightmare.  There was no time.  Even if the goal was simply to modify the master pages of each app&#8230;some of which were very dated, and didn&#8217;t have the luxury of master pages.</p>
<p>So with a little research on the Page Adapter Class and some creative use of the .browsers file, I came up with an unobtrusive method to easily add our new portal to all existing applications, without any recompiling.</p>
<p>First, lets create our Portal Page Adapter project.  Add a new class file named PortalPageAdapter.cs</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">namespace</span> PortalPageAdapter
<span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.UI</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.UI.HtmlControls</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Xml</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web.UI.WebControls</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Security.Principal</span><span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Xml.Linq</span><span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> PortalPageAdapter <span style="color: #008000;">:</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UI</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Adapters</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PageAdapter</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnInit<span style="color: #008000;">&#40;</span>EventArgs e<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #008080; font-style: italic;">// Do whatever security checks you need to do...</span>
			<span style="color: #6666cc; font-weight: bold;">string</span> user <span style="color: #008000;">=</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">LogonUserIdentity</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span><span style="color: #008000;">;</span>
&nbsp;
			List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> roles <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #008080; font-style: italic;">//populate your roles</span>
&nbsp;
			<span style="color: #008080; font-style: italic;">// Setup Context</span>
			HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> GenericPrincipal<span style="color: #008000;">&#40;</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Identity</span>, roles<span style="color: #008000;">.</span><span style="color: #0000FF;">Distinct</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OnInit</span><span style="color: #008000;">&#40;</span>e<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span>
&nbsp;
		<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> CreateChildControls<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0600FF; font-weight: bold;">base</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CreateChildControls</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #008080; font-style: italic;">// Inject portal onto page</span>
			HtmlForm html <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Page</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OfType</span><span style="color: #008000;">&lt;</span>HtmlForm<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">First</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			html<span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">AddAt</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #008000;">new</span> LiteralControl<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;br/&gt;PORTAL GOES HERE&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #008080; font-style: italic;">// Hide WebControls based on their Role Attribute</span>
			<span style="color: #008080; font-style: italic;">// 	This allows the portal, to handle the rendering of any websites </span>
			<span style="color: #008080; font-style: italic;">//	you have, it can show/hide items at the control level</span>
&nbsp;
			List<span style="color: #008000;">&lt;</span>WebControl<span style="color: #008000;">&gt;</span> controls <span style="color: #008000;">=</span> html<span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</span><span style="color: #008000;">.</span><span style="color: #0000FF;">OfType</span><span style="color: #008000;">&lt;</span>WebControl<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
				<span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>c <span style="color: #008000;">=&gt;</span> <span style="color: #008000;">!</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>c<span style="color: #008000;">.</span><span style="color: #0000FF;">Attributes</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;role&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
				<span style="color: #008000;">.</span><span style="color: #0000FF;">ToList</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
			<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>WebControl control <span style="color: #0600FF; font-weight: bold;">in</span> controls<span style="color: #008000;">&#41;</span>
			<span style="color: #008000;">&#123;</span>
				control<span style="color: #008000;">.</span><span style="color: #0000FF;">Visible</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
				<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> role <span style="color: #0600FF; font-weight: bold;">in</span> control<span style="color: #008000;">.</span><span style="color: #0000FF;">Attributes</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;role&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Split</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">' '</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
				<span style="color: #008000;">&#123;</span>
					<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">User</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsInRole</span><span style="color: #008000;">&#40;</span>role<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
					<span style="color: #008000;">&#123;</span>
						control<span style="color: #008000;">.</span><span style="color: #0000FF;">Visible</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
						<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
					<span style="color: #008000;">&#125;</span>
				<span style="color: #008000;">&#125;</span>				
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Now that we have our portal written, with a trick up it&#8217;s sleeve to hide/show content based upon the users roles, let&#8217;s look at how we add it to an existing website.</p>
<p>In the App_Browsers folder, add a file called default.browsers</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;browsers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;browser</span> <span style="color: #000066;">refID</span>=<span style="color: #ff0000;">&quot;Default&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;controlAdapters<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;adapter</span> <span style="color: #000066;">controlType</span>=<span style="color: #ff0000;">&quot;System.Web.UI.Page&quot;</span> <span style="color: #000066;">adapterType</span>=<span style="color: #ff0000;">&quot;PortalPageAdapter.PortalPageAdapter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/controlAdapters<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/browser<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/browsers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>And add the compiled dll of our PortalPageAdapter class to the bin folder.</p>
<p>Navigate to your website and the first thing you see should be the line &#8220;PORTAL GOES HERE&#8221;, which you can modify in the Portal Page Adapter class to create whatever content you would like.  How you generate the html is up to you.  Be it includes, databases, xml/xsl, whatever.  Get creative.</p>
<p>Now, the last thing, is, the &#8216;trick&#8217; that has been programmed in, on any aspx page, you can add the &#8220;role&#8221; attribute to any WebControl (asp:whatever) and it will be rendered (or not) based upon the roles loaded by the PortalPageAdapter class.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Default.aspx.cs&quot; Inherits=&quot;PageAdapter._Default&quot; %&gt;
&nbsp;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head runat=&quot;server&quot;&gt;
	&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt;
	&lt;div&gt;
		&lt;asp:Panel runat=&quot;server&quot;&gt;
			Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum imperdiet justo id sem. Aenean convallis mi sed ipsum. Donec semper dapibus erat. Suspendisse consequat libero quis felis feugiat aliquam. Sed nec elit. Fusce sapien tellus, vestibulum id, pharetra in, scelerisque sit amet, lectus. Vivamus eu turpis at nunc elementum ultricies. Morbi feugiat fringilla est. Fusce urna diam, accumsan vitae, ultrices non, varius vitae, quam. Vivamus vitae enim vel nulla mattis aliquam. Suspendisse lacinia arcu non urna. Praesent convallis ante ut sapien. Nunc sit amet mauris ornare mauris accumsan ultricies. Praesent venenatis tellus id quam. Fusce vel enim a est malesuada venenatis.
			&lt;p /&gt;
		&lt;/asp:Panel&gt;
		&lt;asp:Panel runat=&quot;server&quot; role=&quot;ADMIN&quot;&gt;
			Sed eget mauris vitae libero imperdiet malesuada. Suspendisse feugiat semper erat. Duis sit amet odio ultricies dui ultrices volutpat. Sed id risus vitae odio bibendum varius. Nam rutrum consectetur felis. Donec vitae velit. Phasellus facilisis ornare mi. Etiam quis dui id leo bibendum vehicula. Proin egestas, neque quis pulvinar malesuada, odio tellus porta orci, nec dictum est nunc id diam. Integer eu dui. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut nec ante ut pede ornare ornare. Mauris eget mauris et urna tincidunt tincidunt. Suspendisse sit amet lacus in dui fermentum aliquam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse odio. Phasellus orci. Aliquam erat volutpat. Nam eget ligula id arcu fermentum lobortis. Sed vel leo.
			&lt;p /&gt;
		&lt;/asp:Panel&gt;
		&lt;asp:Panel runat=&quot;server&quot; Role=&quot;USER ADMIN&quot;&gt;
			Suspendisse pulvinar. Etiam ipsum. Proin vulputate nibh et purus. Nunc hendrerit. Morbi consequat nibh id tortor. In mollis rhoncus velit. Pellentesque magna ipsum, cursus sit amet, viverra eu, porttitor et, dolor. Cras quis sem. Ut interdum nisi quis magna. Donec mauris erat, consequat id, gravida eu, scelerisque ac, nisi. Nulla ante purus, dignissim nec, mollis quis, euismod quis, arcu. In vel arcu. Duis enim erat, accumsan vel, blandit vel, ultricies id, pede. Nulla luctus, nisi at faucibus tincidunt, orci sapien ornare erat, vitae iaculis justo risus ut magna.
			&lt;p /&gt;
		&lt;/asp:Panel&gt;
		&lt;asp:Panel runat=&quot;server&quot; Role=&quot;MANAGER&quot;&gt;
			Etiam imperdiet lacus at dui fringilla dictum. Etiam condimentum, diam vitae fringilla faucibus, ante ante facilisis nulla, at porttitor diam ipsum vel odio. Aliquam sollicitudin neque et diam. Aenean feugiat, justo ut imperdiet cursus, sem risus ultrices ligula, eget rutrum orci leo tempor enim. Nunc eget velit. Pellentesque dictum, odio a tempor aliquet, ipsum justo lacinia mauris, sed posuere metus enim vel ipsum. Donec dolor. Aliquam semper, eros vitae vehicula lacinia, dolor massa suscipit libero, a molestie enim justo tincidunt sem. Praesent eget mi ut purus interdum vehicula. Nulla a leo. Morbi lacinia, ligula id pharetra vulputate, sapien arcu dignissim tortor, ac condimentum velit libero at purus.
			&lt;p /&gt;
		&lt;/asp:Panel&gt;
		&lt;asp:Panel runat=&quot;server&quot;&gt;
			Donec adipiscing lacus ac sapien. Nulla ac quam. Sed enim. Curabitur magna. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras viverra, libero quis molestie cursus, justo lacus semper nisl, in fringilla enim pede ac elit. Pellentesque facilisis. Etiam fringilla adipiscing mauris. Vivamus bibendum nibh nec massa. Maecenas risus. Cras tempus accumsan pede. Cras dictum hendrerit dolor. Curabitur et tortor ullamcorper elit mattis lacinia. Cras tempus euismod velit. Donec feugiat nunc quis dui. Vivamus nisi urna, bibendum et, imperdiet sit amet, facilisis in, libero. Maecenas lobortis velit at ante. Aenean in lacus et massa fringilla molestie. Praesent mollis nibh ut nunc.
			&lt;p /&gt;
		&lt;/asp:Panel&gt;
		&lt;asp:Button runat=&quot;server&quot; role=&quot;ADMIN&quot; Text=&quot;Admin Button&quot; /&gt;
		&lt;asp:Button runat=&quot;server&quot; role=&quot;USER MANAGER&quot; Text=&quot;User Button&quot; /&gt;
	&lt;/div&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>This would also be a simple way to add an embeded IM client to a series of websites.</p>
<p>Happy coding.  </p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/06/11/wrap-existing-net-site-in-a-portaltheme/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The C# ?? null coalescing operator</title>
		<link>http://caffeinatedgeek.ca/2009/06/10/the-c-null-coalescing-operator/%</link>
		<comments>http://caffeinatedgeek.ca/2009/06/10/the-c-null-coalescing-operator/%#comments</comments>
		<pubDate>Thu, 11 Jun 2009 04:09:12 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[??]]></category>
		<category><![CDATA[Null]]></category>
		<category><![CDATA[Operator]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=18</guid>
		<description><![CDATA[A simple tip to save typing and increase your codes readability is the &#8220;double question mark operator&#8221;, more accurately called the &#8220;null coalescing operator&#8221;. Instead of using this to set defaults in a function function void test&#40;int aVar&#41; &#123; int myVar = aVar; if &#40;aVar == null&#41; &#123; myVar = 42; &#125; &#125; or function [...]]]></description>
			<content:encoded><![CDATA[<p>A simple tip to save typing and increase your codes readability is the &#8220;double question mark operator&#8221;, more accurately called the &#8220;null coalescing operator&#8221;.</p>
<p>Instead of using this to set defaults in a function</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">function <span style="color: #6666cc; font-weight: bold;">void</span> test<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> aVar<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #6666cc; font-weight: bold;">int</span> myVar <span style="color: #008000;">=</span> aVar<span style="color: #008000;">;</span>
	<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>aVar <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		myVar <span style="color: #008000;">=</span> <span style="color: #FF0000;">42</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">function <span style="color: #6666cc; font-weight: bold;">void</span> test<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> aVar<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #6666cc; font-weight: bold;">int</span> myVar <span style="color: #008000;">=</span> aVar <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">?</span> <span style="color: #FF0000;">42</span> <span style="color: #008000;">:</span> aVar<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>You can simply use</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">function <span style="color: #6666cc; font-weight: bold;">void</span> test<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> aVar<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #6666cc; font-weight: bold;">int</span> myVar <span style="color: #008000;">=</span> aVar <span style="color: #008000;">??</span> <span style="color: #FF0000;">42</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Granted, you&#8217;d likely find much better ways to use this than simply defaults in a function call, but hey, this is just an example, let your imagination do the work.</p>
<p>MSDN reference: <a href="http://msdn.microsoft.com/en-us/library/ms173224.aspx">http://msdn.microsoft.com/en-us/library/ms173224.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/06/10/the-c-null-coalescing-operator/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Validation with XSDs</title>
		<link>http://caffeinatedgeek.ca/2009/06/10/xml-validation-with-xsds/%</link>
		<comments>http://caffeinatedgeek.ca/2009/06/10/xml-validation-with-xsds/%#comments</comments>
		<pubDate>Thu, 11 Jun 2009 00:31:42 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Validate]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSD]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=11</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of work with excel uploads lately to allow clients to easily upload data to their systems.  Not the best approach mind you, but they know how to use excel&#8230;so what can you do? What I have worked out is a multi step process to import the excel file to the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of work with excel uploads lately to allow clients to easily upload data to their systems.  Not the best approach mind you, but they know how to use excel&#8230;so what can you do?</p>
<p>What I have worked out is a multi step process to import the excel file to the database and validate the contents to a reasonable degree.  I have these all written into some custom classes and use IOC and DI to handle workflow so that writing subsequent uploads is a trivial task, and the majority of code is simply the validation and transformation files (XSDs, XSLs, and Stored Procs)</p>
<p>First, you have to retrieve the contents of the excel sheet(s)</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">protected</span> XElement GetWorksheetXML<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> sheetNumber, <span style="color: #6666cc; font-weight: bold;">string</span> xsltPath<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">// Create working file</span>
  <span style="color: #6666cc; font-weight: bold;">string</span> workingFilePath <span style="color: #008000;">=</span> Path<span style="color: #008000;">.</span><span style="color: #0000FF;">GetTempFileName</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  File<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteAllBytes</span><span style="color: #008000;">&#40;</span>workingFilePath, <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">filebytes</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Read the worksheet</span>
  DataSet myDataSet <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> DataSet<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #6666cc; font-weight: bold;">string</span> strConn <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot;</span> <span style="color: #008000;">+</span> workingFilePath <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;;Extended Properties='Excel 8.0;HDR=No;IMEX=1;'&quot;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Fill the Dataset</span>
  OleDbDataAdapter myCommand <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> OleDbDataAdapter<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;SELECT * FROM [&quot;</span> <span style="color: #008000;">+</span> GetExcelSheetNames<span style="color: #008000;">&#40;</span>strConn<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#91;</span>sheetNumber<span style="color: #008000;">&#93;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;]&quot;</span>, strConn<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  myCommand<span style="color: #008000;">.</span><span style="color: #0000FF;">Fill</span><span style="color: #008000;">&#40;</span>myDataSet<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Clean up</span>
  File<span style="color: #008000;">.</span><span style="color: #0000FF;">Delete</span><span style="color: #008000;">&#40;</span>workingFilePath<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// Return transformed XML</span>
  <span style="color: #0600FF; font-weight: bold;">return</span> XElement<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>Utility<span style="color: #008000;">.</span><span style="color: #0000FF;">Transform</span><span style="color: #008000;">&#40;</span>myDataSet<span style="color: #008000;">.</span><span style="color: #0000FF;">GetXml</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, xsltPath, <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Secondly, convert it to a better XML format with an XSLT.  You should also merge any sheets here so you have one XML file from the XSL.  I&#8217;m not going to bother showing this, as it&#8217;s hardly the point of the article, though, if you are unsure how to do this, feel free to ask</p>
<p>Third, and the whole point of this article, verify data types with XSD.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">protected</span> XElement ValidateXSD<span style="color: #008000;">&#40;</span>XElement item, <span style="color: #6666cc; font-weight: bold;">string</span> xsdPath<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  XElement errors <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Errors&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>File<span style="color: #008000;">.</span><span style="color: #0000FF;">Exists</span><span style="color: #008000;">&#40;</span>xsdPath<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// Reference: http://msdn.microsoft.com/en-us/library/bb358456.aspx</span>
    XDocument xsd <span style="color: #008000;">=</span> XDocument<span style="color: #008000;">.</span><span style="color: #0000FF;">Load</span><span style="color: #008000;">&#40;</span>xsdPath<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    XDocument xml <span style="color: #008000;">=</span> XDocument<span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    XmlSchemaSet schemas <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlSchemaSet<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    schemas<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span>, XmlReader<span style="color: #008000;">.</span><span style="color: #0000FF;">Create</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> StringReader<span style="color: #008000;">&#40;</span>xsd<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    xml<span style="color: #008000;">.</span><span style="color: #0000FF;">Document</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Validate</span><span style="color: #008000;">&#40;</span>schemas,
      <span style="color: #008080; font-style: italic;">// Validation Event/Error Handling</span>
      <span style="color: #008000;">&#40;</span>sender, e<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&amp;</span>gt<span style="color: #008000;">;</span>
      <span style="color: #008000;">&#123;</span>
        errors<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">new</span> XElement<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Error&quot;</span>, e<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #008080; font-style: italic;">// If there were errors return them, otherwise return null</span>
  <span style="color: #0600FF; font-weight: bold;">return</span> errors<span style="color: #008000;">.</span><span style="color: #0000FF;">Elements</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;</span> <span style="color: #FF0000;">0</span> <span style="color: #008000;">?</span> errors <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Fourth, at this point, if there are no errors, you should pass the XML file as input to a stored procedure to further validate the data (if there are IDs and Codes that need to be verified with other systems), and assuming all has gone well, pass the XML file to a stored procedure which writes the data into your database&#8230;or whatever you need to do.  By this point your XML should be clean, and valid.</p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/06/10/xml-validation-with-xsds/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s scary because it&#8217;s true&#8230;</title>
		<link>http://caffeinatedgeek.ca/2009/06/03/its-scary-because-its-true/%</link>
		<comments>http://caffeinatedgeek.ca/2009/06/03/its-scary-because-its-true/%#comments</comments>
		<pubDate>Thu, 04 Jun 2009 02:57:37 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Relationship]]></category>
		<category><![CDATA[Vendor]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=7</guid>
		<description><![CDATA[The Vendor-Client Relationship http://www.youtube.com/watch?v=R2a8TRSgzZY]]></description>
			<content:encoded><![CDATA[<p>The Vendor-Client Relationship</p>
<p><a title="http://www.youtube.com/watch?v=R2a8TRSgzZY" href="http://www.youtube.com/watch?v=R2a8TRSgzZY" target="_blank">http://www.youtube.com/watch?v=R2a8TRSgzZY</a></p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/06/03/its-scary-because-its-true/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Painlessly Audit Your SQL2005 Schema &amp; DDL Information</title>
		<link>http://caffeinatedgeek.ca/2009/04/04/painlessly-audit-your-sql2005-schema-ddl-information/%</link>
		<comments>http://caffeinatedgeek.ca/2009/04/04/painlessly-audit-your-sql2005-schema-ddl-information/%#comments</comments>
		<pubDate>Sat, 04 Apr 2009 06:51:19 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=5</guid>
		<description><![CDATA[I recently stumbled across the following page Painlessly Audit Your SQL2005 Schema &#38; DDL Information. We all know about SQL DML (Data Manipulation Language) triggers, these are the kind we use  occassionally when data is manipulated. What you may not know about are DDL (Data Definition Language) triggers. In short, you can write a trigger [...]]]></description>
			<content:encoded><![CDATA[<p>I recently stumbled across the following page</p>
<p><a href="http://www.clanmonroe.com/Blog/archive/2007/10/04/painlessly-audit-your-sql2005-schema-amp-ddl-information.aspx">Painlessly Audit Your SQL2005 Schema &amp; DDL Information</a>.</p>
<p>We all know about SQL DML (Data Manipulation Language) triggers, these are the kind we use  occassionally when data is manipulated.</p>
<p>What you may not know about are DDL (Data Definition Language) triggers.</p>
<p>In short, you can write a trigger to fire whenever tables, stored procedures, views, etc change.</p>
<p>So with the following table and trigger (code stolen from link above) you can audit your stored proc and table changes</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">&#91;</span>dbo<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">.</span><span style="color: #66cc66;">&#91;</span>DBChangeLog<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span>
    <span style="color: #66cc66;">&#91;</span>LogId<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">IDENTITY</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>DatabaseName<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>EventType<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>ObjectName<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>ObjectType<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>SqlCommandXml<span style="color: #66cc66;">&#93;</span> XML <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>EventDate<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span>datetime<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> <span style="color: #66cc66;">&#91;</span>DF_EventsLog_EventDate<span style="color: #66cc66;">&#93;</span>  <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #66cc66;">&#40;</span>getdate<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">&#91;</span>LoginName<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
<span style="color: #66cc66;">&#41;</span> 
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TRIGGER</span> <span style="color: #66cc66;">&#91;</span>LOG_DB_OBJECT_CHANGE<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">DATABASE</span>
<span style="color: #993333; font-weight: bold;">FOR</span> create_procedure<span style="color: #66cc66;">,</span> alter_procedure<span style="color: #66cc66;">,</span> drop_procedure
    <span style="color: #66cc66;">,</span> create_table<span style="color: #66cc66;">,</span> alter_table<span style="color: #66cc66;">,</span> drop_table
    <span style="color: #66cc66;">,</span> create_function<span style="color: #66cc66;">,</span> alter_function<span style="color: #66cc66;">,</span> drop_function
<span style="color: #993333; font-weight: bold;">AS</span>
&nbsp;
    <span style="color: #993333; font-weight: bold;">SET</span> NOCOUNT <span style="color: #993333; font-weight: bold;">ON</span>
&nbsp;
    <span style="color: #993333; font-weight: bold;">DECLARE</span> @<span style="color: #993333; font-weight: bold;">DATA</span> XML
    <span style="color: #993333; font-weight: bold;">SET</span> @<span style="color: #993333; font-weight: bold;">DATA</span> <span style="color: #66cc66;">=</span> EVENTDATA<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
    <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> DBChangeLog<span style="color: #66cc66;">&#40;</span>databasename<span style="color: #66cc66;">,</span> eventtype<span style="color: #66cc66;">,</span> objectname<span style="color: #66cc66;">,</span>
                            objecttype<span style="color: #66cc66;">,</span> sqlcommandxml<span style="color: #66cc66;">,</span> loginname<span style="color: #66cc66;">&#41;</span>
    <span style="color: #993333; font-weight: bold;">SELECT</span> @<span style="color: #993333; font-weight: bold;">DATA</span><span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'(/EVENT_INSTANCE/DatabaseName)[1]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'varchar(256)'</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">,</span> @<span style="color: #993333; font-weight: bold;">DATA</span><span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'(/EVENT_INSTANCE/EventType)[1]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'varchar(50)'</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">,</span> @<span style="color: #993333; font-weight: bold;">DATA</span><span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'(/EVENT_INSTANCE/ObjectName)[1]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'varchar(256)'</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">,</span> @<span style="color: #993333; font-weight: bold;">DATA</span><span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'(/EVENT_INSTANCE/ObjectType)[1]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'varchar(25)'</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">,</span> @<span style="color: #993333; font-weight: bold;">DATA</span><span style="color: #66cc66;">.</span>query<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'(/EVENT_INSTANCE/TSQLCommand)[1]'</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">,</span> @<span style="color: #993333; font-weight: bold;">DATA</span><span style="color: #66cc66;">.</span><span style="color: #993333; font-weight: bold;">VALUE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'(/EVENT_INSTANCE/LoginName)[1]'</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'varchar(256)'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #993333; font-weight: bold;">GO</span>
<span style="color: #993333; font-weight: bold;">SET</span> ANSI_NULLS OFF
<span style="color: #993333; font-weight: bold;">GO</span>
<span style="color: #993333; font-weight: bold;">SET</span> QUOTED_IDENTIFIER OFF
<span style="color: #993333; font-weight: bold;">GO</span>
ENABLE <span style="color: #993333; font-weight: bold;">TRIGGER</span> <span style="color: #66cc66;">&#91;</span>LOG_DB_OBJECT_CHANGE<span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">DATABASE</span></pre></div></div>

<p>And that&#8217;s all there is to it.</p>
<p>You could now easily write a webpage to search and filter this table, and perform diffs on different versions.  And never again have a stored procedure get changed on you, clobbering a fix you did the day before&#8230;without having a backup of your fix!</p>
<p>And you can log who made the change, so you can exact some revenge.</p>
<p>-c</p>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/04/04/painlessly-audit-your-sql2005-schema-ddl-information/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regexes and Named Capture Groups</title>
		<link>http://caffeinatedgeek.ca/2009/04/04/regexes-and-named-capture-groups/%</link>
		<comments>http://caffeinatedgeek.ca/2009/04/04/regexes-and-named-capture-groups/%#comments</comments>
		<pubDate>Sat, 04 Apr 2009 06:40:40 +0000</pubDate>
		<dc:creator>gibble</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[capture groups]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://caffeinatedgeek.ca/?p=3</guid>
		<description><![CDATA[Not everyone knows about named capture groups, not everyone knows about regexes for that matter, but for those that do, capture groups are great, they allow us to grab portions of our regular expression match, and use them in our application.  The problem is, as your regex gets more and more complicated, if you still [...]]]></description>
			<content:encoded><![CDATA[<div class="snap_preview">
<p>Not everyone knows about named capture groups, not everyone knows about regexes for that matter, but for those that do, capture groups are great, they allow us to grab portions of our regular expression match, and use them in our application.  The problem is, as your regex gets more and more complicated, if you still rely on the index of the capture group, to get the data you want, it can change as we make modifications, and be hard to find, and introduce undesired behaviours when you set a variable to capture group 7, when it’s now capture group 8…but you didn’t notice.  Yeah, it should be caught in testing, but it’s nearly 2009, we shouldn’t be referencing data by numbers when we can reference it by name.</p>
<p>So let’s say we have a flat file that we are parsing, it’s an old data file from a legacy system that we are trying to read in the format</p>
<p>id[tab]name[tab]position</p>
<p>And we’d write a simple regex to match and capture the 3 parts /^(\w+)\t(\w+)\t(\w+)$/</p>
<p>so</p>
<p>var id =  match.Group[1];</p>
<p>var name =  match.Group[2];</p>
<p>var position =  match.Group[3];</p>
<p>But, let’s say that the file changes slightly and we insert extension between name and position, our regex would change to /^(\w+)\t(\w+)\t(\w+)\t(\w+)$/ and we’d have to change position to use group 4.</p>
<p>A small inconvenience, but unnecessary.</p>
<p>if our matches are named /^(?&lt;id&gt;\w+)\t(?&lt;name&gt;\w+)\t(?&lt;extension&gt;\w+)\t(?&lt;position&gt;\w+)$/</p>
<p>We can use match.Group["id"] to get the name, match.Group["name"], etc</p>
<p>In more complex scenarios this saves a LOT of time and headaches.  Not only that, it comments your regex making it easier to maintain and read in the future!</p>
<p>-c</p></div>
]]></content:encoded>
			<wfw:commentRss>http://caffeinatedgeek.ca/2009/04/04/regexes-and-named-capture-groups/%/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

