<?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>Simon Hartcher</title>
	<atom:link href="http://www.simonhartcher.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.simonhartcher.com</link>
	<description>{ "dev", "music", "more" } # No Guarantees</description>
	<lastBuildDate>Wed, 27 Jan 2010 01:04:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Serious Sam HD &#8211; Kleer Skeleton Surfing</title>
		<link>http://www.simonhartcher.com/?p=191&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=191#comments</comments>
		<pubDate>Wed, 27 Jan 2010 01:04:39 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=191</guid>
		<description><![CDATA[


Something funny I discovered while playing Serious Sam HD – The First Encounter. A bit of a bug I guess.
  tweetmeme_url='http://www.simonhartcher.com/?p=191'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; ]]></description>
			<content:encoded><![CDATA[<div style="padding-bottom: 0px; margin: 0px auto; padding-left: 0px; width: 425px; padding-right: 0px; display: block; float: none; padding-top: 0px" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:a2844cb5-45e1-4cf3-a043-85b88e2a761a" class="wlWriterEditableSmartContent">
<div><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/75e7CSapztU&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1&amp;hl=en"></param><embed src="http://www.youtube.com/v/75e7CSapztU&amp;hl=en_US&amp;fs=1&amp;rel=0&amp;hd=1&amp;hl=en" type="application/x-shockwave-flash" width="425" height="355"></embed></object></div>
</div>
<p>Something funny I discovered while playing Serious Sam HD – The First Encounter. A bit of a bug I guess.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=191&amp;t=Serious+Sam+HD+%26ndash%3B+Kleer+Skeleton+Surfing&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=191'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=191</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Caching for a WPF Desktop Application</title>
		<link>http://www.simonhartcher.com/?p=187&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=187#comments</comments>
		<pubDate>Sat, 12 Dec 2009 11:49:03 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[image-caching]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=187</guid>
		<description><![CDATA[WPF is a great technology and in my opinion is miles better than WinForms. Unfortunately, like any technology there are always going to be shortfalls that you have to work around yourself. My company is presently developing a WPF Desktop Application that fetches images from a web server. One of the shortfalls of WPF is [...]]]></description>
			<content:encoded><![CDATA[<p>WPF is a great technology and in my opinion is miles better than WinForms. Unfortunately, like any technology there are always going to be shortfalls that you have to work around yourself. My company is presently developing a WPF Desktop Application that fetches images from a web server. One of the shortfalls of WPF is that client side caching is not implemented, but you can do it yourself using custom bindings.</p>
<p>Consider the following code where the binding <em>ImageAddress </em>points to an image on some web server (www.someserver.com/image.jpg):</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9bc2a626-4292-4f6e-92ac-b7d0c3ebd434" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">&lt;</span><span style="color: #a31515">Image</span><span style="color: #ff0000"> Source</span><span style="color: #0000ff">=&quot;{</span><span style="color: #a31515">Binding</span><span style="color: #ff0000"> ImageAddress}</span><span style="color: #0000ff">&quot;/&gt;</span> </li>
</ol></div>
</p></div>
</p></div>
<p>Each time the Window in which this code resides is loaded the image will be fetched from the web server.</p>
<p><font size="4"><strong>Every time you say?!</strong> <em>Every time…</em> </font></p>
<p>Considering the application we are working on will be displaying a lot of images, this is just not acceptable. I kept thinking that there has to be a way to turn on caching, but after Googling (the good kind) until my hands were sore I discovered there was no switch I could just turn on. I <a href="http://stackoverflow.com/questions/1878060/how-do-i-cache-images-on-the-client-for-a-wpf-application">asked a question</a> on StackOverflow and it was suggested that I just save the images to a local directory. Unfortunately that was all he said.</p>
<p>After some searching I discovered that using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.binding.converter.aspx">Binding.Converter</a> attribute I could pass the value of the Source attribute to a Converter and then back again. To create a converter you create a class that implements <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx">IValueConverter</a>. IValueConverter requires that you implement two methods:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1165ea22-ae97-40aa-aafa-15b764da90d9" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> Convert(<span style="color: #0000ff">object</span> value, <span style="color: #2b91af">Type</span> targetType, <span style="color: #0000ff">object</span> parameter, <span style="color: #2b91af">CultureInfo</span> culture) </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> ConvertBack(<span style="color: #0000ff">object</span> value, <span style="color: #2b91af">Type</span> targetType, <span style="color: #0000ff">object</span> parameter, <span style="color: #2b91af">CultureInfo</span> culture) </li>
</ol></div>
</p></div>
</p></div>
<p><strong>Convert </strong>will be used to convert the data you pass to it into the desired format to display on the form. <strong>ConvertBack</strong> is the reverse, where any changes the user makes to the data displayed on the form may need to be converted back to a format that you require for processing (eg. to send to a database). Here is an example as provided on msdn:</p>
<blockquote><p>The following example shows the implementation of a date converter that converts the date value passed in so that it only shows the year, the month, and the day. When implementing the IValueConverter interface, it is a good practice to decorate the implementation with a <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.valueconversionattribute.aspx">ValueConversionAttribute</a> attribute to indicate to development tools the data types involved in the conversion, as in the following example:</p>
</blockquote>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a92a93ab-4bea-47fc-a2ae-5ac0dc669059" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2.5em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li>[<span style="color: #2b91af">ValueConversion</span>(<span style="color: #0000ff">typeof</span>(<span style="color: #2b91af">DateTime</span>), <span style="color: #0000ff">typeof</span>(<span style="color: #2b91af">String</span>))] </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> <span style="color: #2b91af">DateConverter</span> : <span style="color: #2b91af">IValueConverter</span> </li>
<li>{ </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> Convert(<span style="color: #0000ff">object</span> value, <span style="color: #2b91af">Type</span> targetType, <span style="color: #0000ff">object</span> parameter, <span style="color: #2b91af">CultureInfo</span> culture) </li>
<li>&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">DateTime</span> date = (<span style="color: #2b91af">DateTime</span>)value; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">return</span> date.ToShortDateString(); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; } </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> ConvertBack(<span style="color: #0000ff">object</span> value, <span style="color: #2b91af">Type</span> targetType, <span style="color: #0000ff">object</span> parameter, <span style="color: #2b91af">CultureInfo</span> culture) </li>
<li>&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">string</span> strValue = value <span style="color: #0000ff">as</span> <span style="color: #0000ff">string</span>; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">DateTime</span> resultDateTime; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">if</span> (<span style="color: #2b91af">DateTime</span>.TryParse(strValue, <span style="color: #0000ff">out</span> resultDateTime)) </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">return</span> resultDateTime; </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #0000ff">return</span> <span style="color: #2b91af">DependencyProperty</span>.UnsetValue; </li>
<li>&#160;&#160;&#160; } </li>
<li style="background: #f3f3f3">} </li>
</ol></div>
</p></div>
</p></div>
<p>As you can see, in Convert <em>value </em>is cast to a DateTime object and then returned as a string using <em>ToShortDateString()</em>. Then in ConvertBack (which will be passed a string from the form) the string is parsed into a date using <em>DateTime.TryParse() </em>and then returned if it completes successfully.</p>
<p>So, onto the specific problem of caching an image on the local machine. I start with an empty class called <em>ImageCacher</em> implementing stub methods from IValueConverter. As we are grabbing the web address from a database, we are not interested in sending the local address back to the database, so we can simply complete ConvertBack returning a null value.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d8eb8c21-04bf-4ece-8988-141d845dfaae" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #008000">//Not needed &#8211; return null</span> </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> ConvertBack(<span style="color: #0000ff">object</span> value, <span style="color: #2b91af">Type</span> targetType, <span style="color: #0000ff">object</span> parameter, <span style="color: #2b91af">CultureInfo</span> culture) </li>
<li>{ </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>; </li>
<li>} </li>
</ol></div>
</p></div>
</p></div>
<p>We then add the ValueConversionAttribute to indicate to development tools the data types involved in the conversion. This is not compulsory, but I think it also makes understanding what the converter is doing easier in a single glance. Our goal is to grab the string from the Source attribute and then pass one back with the updated image location (after we save it locally). So in this case, we are converting from a string to a string.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:757f8f2e-4ad0-4705-94f0-2fdfaa800560" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li>[<span style="color: #2b91af">ValueConversion</span>(<span style="color: #0000ff">typeof</span>(<span style="color: #0000ff">string</span>), <span style="color: #0000ff">typeof</span>(<span style="color: #0000ff">string</span>))] </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">class</span> <span style="color: #2b91af">ImageCacher</span> : <span style="color: #2b91af">IValueConverter</span> </li>
<li>{ </li>
</ol></div>
</p></div>
</p></div>
<p>Let us define where our images will be saved.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f2829dee-2d5f-4c8b-bf6f-1f26166072dc" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">static</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">readonly</span> <span style="color: #0000ff">string</span> AppDataDirectory = <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0}/ImageCacher/&quot;</span>, <span style="color: #2b91af">Environment</span>.GetFolderPath(<span style="color: #2b91af">Environment</span>.<span style="color: #2b91af">SpecialFolder</span>.ApplicationData)); </li>
</ol></div>
</p></div>
</p></div>
<p>Here we use the Environment class to return the path to the Application Data folder on the local machine via the GetFolderPath method with the SpecialFolder.ApplicationData enum. I have simply appended that directory with the directory ImageCacher, as that is where we will store our images.</p>
<p>First thing in Convert is to check to see if our directory already exists, and create it if it doesn’t.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:64fef7ac-4306-4888-80bf-82da7e893086" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> Convert(<span style="color: #0000ff">object</span> value, <span style="color: #2b91af">Type</span> targetType, <span style="color: #0000ff">object</span> parameter, <span style="color: #2b91af">CultureInfo</span> culture) </li>
<li style="background: #f3f3f3">{ </li>
<li>&#160;&#160;&#160; <span style="color: #008000">//Check to see if the directory in AppData has been created</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">if</span> (!<span style="color: #2b91af">Directory</span>.Exists(AppDataDirectory)) </li>
<li>&#160;&#160;&#160; { </li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #008000">//Create it</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Directory</span>.CreateDirectory(AppDataDirectory); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; } </li>
</ol></div>
</p></div>
</p></div>
<p>Since we are working with a web address, we will create a Uri from our string. Once we have that, we can use the Segments property of the Uri class to grab the name of the image in the web address, and we’ll use that to define the local path where the image will be stored (or is already stored, if it has been downloaded before).</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd0ee557-8922-4870-b435-445e7d5098ef" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #008000">//Cast the string into a Uri so we can access the image name without regex</span> </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">var</span> uri = <span style="color: #0000ff">new</span> <span style="color: #2b91af">Uri</span>((<span style="color: #2b91af">String</span>)value); </li>
<li>&#160; </li>
<li style="background: #f3f3f3"><span style="color: #008000">//The full path of the image on the local computer</span> </li>
<li><span style="color: #0000ff">var</span> localFile = <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;{0}{1}&quot;</span>, AppDataDirectory, uri.Segments[uri.Segments.Length-<span style="color: #a52a2a">1</span>]); </li>
</ol></div>
</p></div>
</p></div>
<p>Next, we check to see if the image has been stored locally already, and if not, we fetch it using a HttpWebRequest and grab the response using HttpWebResponse.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7462f5de-098f-40e8-8226-e4d2a49783a8" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">if</span> (!<span style="color: #2b91af">File</span>.Exists(localFile)) </li>
<li style="background: #f3f3f3">{ </li>
<li>&#160;&#160;&#160; <span style="color: #0000ff">var</span> request = <span style="color: #2b91af">HttpWebRequest</span>.Create(uri); </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">var</span> response = (<span style="color: #2b91af">HttpWebResponse</span>)request.GetResponse(); </li>
</ol></div>
</p></div>
</p></div>
<p>Because we used the HttpWebResponse class, we can check the ContentType of the response to make sure that we are in fact fetching an image. If it isn’t, we throw an exception.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:998f9558-19ad-4269-95bb-43490140e2f7" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #008000">//check the content type to assert that the file in the uri is an image</span> </li>
<li style="background: #f3f3f3"><span style="color: #0000ff">if</span> (!response.ContentType.StartsWith(<span style="color: #a31515">&quot;image&quot;</span>)) </li>
<li>{ </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> <span style="color: #2b91af">FileFormatException</span>(uri, <span style="color: #2b91af">String</span>.Format(<span style="color: #a31515">&quot;Uri passed to ImageCacher does not return an image. Content is of type {0}.&quot;</span>, response.ContentType)); </li>
<li>} </li>
</ol></div>
</p></div>
</p></div>
<p>Now that we have asserted that the response is actually an image, we can load it from GetResponseStream into the Image class (System.Drawing) and then save it to the path we defined earlier.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f6e67ecc-0780-4239-920c-852e1b61b83f" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li>&#160;&#160;&#160; <span style="color: #008000">//load the image from the stream</span> </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #0000ff">var</span> image = <span style="color: #2b91af">Image</span>.FromStream(response.GetResponseStream()); </li>
<li>&#160; </li>
<li style="background: #f3f3f3">&#160;&#160;&#160; <span style="color: #008000">//save it</span> </li>
<li>&#160;&#160;&#160; image.Save(localFile); </li>
<li style="background: #f3f3f3">} </li>
</ol></div>
</p></div>
</p></div>
<p>Finally, return the path to the local file.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:de26dafd-18ec-4e60-8490-c295dc16572b" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li>&#160;&#160;&#160; <span style="color: #0000ff">return</span> localFile; </li>
<li style="background: #f3f3f3">} </li>
</ol></div>
</p></div>
</p></div>
<p>Then in XAML, reference our converter using an xmlns tag and add our converter in the resources area.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:35b72add-849a-425a-b0da-4875c90d4e93" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;">
<li><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;MyImageCacher.Window1&quot;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;<span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span></li>
<li>&#160;&#160;&#160;&#160;&#160;<span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;<span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">mc</span><span style="color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span> </li>
<li>&#160;&#160;&#160;&#160;&#160;<span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">d</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;<span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">con</span><span style="color:#0000ff">=&quot;clr-namespace:MyImageCacher.ImageCacher&quot;&gt;</span></li>
<li>&#160;&#160;&#160;&#160;<span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span></li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">con</span><span style="color:#0000ff">:</span><span style="color:#a31515">ImageCacher</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;imageCacher&quot;/&gt;</span></li>
</ol></div>
</p></div>
</p></div>
<p>Then we add the Converter attribute to the Binding of our original Image control.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:917ecc7c-05be-457a-b715-012a9dd0c5d0" class="wlWriterSmartContent">
<div style="border-bottom: #000080 1px solid; border-left: #000080 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; color: #000; font-size: 10pt; border-top: #000080 1px solid; border-right: #000080 1px solid">
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="padding-bottom: 0px; margin: 0px 0px 0px 2em; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px">
<li><span style="color: #0000ff">&lt;</span><span style="color: #a31515">Image</span><span style="color: #ff0000"> Source</span><span style="color: #0000ff">=&quot;{</span><span style="color: #a31515">Binding</span><span style="color: #ff0000"> ImageAddress</span><span style="color: #0000ff">,</span><span style="color: #ff0000"> Converter</span><span style="color: #0000ff">={</span><span style="color: #a31515">StaticResource</span><span style="color: #ff0000"> imageCacher}}</span><span style="color: #0000ff">&quot;/&gt;</span> </li>
</ol></div>
</p></div>
</p></div>
<p>And its as simple as that. Each time an address is passed to the control, it will run it through the converter first. It will check to see if the image exists locally, and download it if it hasn’t been. The solution could be more polished but this is working for us <strong>right now</strong>.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=187&amp;t=Image+Caching+for+a+WPF+Desktop+Application&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=187'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=187</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GrabIt &#8211; A Good Free Binary Newsreader</title>
		<link>http://www.simonhartcher.com/?p=184&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=184#comments</comments>
		<pubDate>Wed, 23 Sep 2009 04:03:35 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[usenet]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=184</guid>
		<description><![CDATA[I recently started using Usenet through Astraweb which has been great. Its a great way to get files…FAST! The problem was I couldn’t find a decent client that was free, supported binary downloads and had auto repair (PAR support).
I had been using a trial of Newsbin Pro which was great but I thought there surely [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started using Usenet through <a href="http://astraweb.com">Astraweb</a> which has been great. Its a great way to get files…FAST! The problem was I couldn’t find a decent client that was free, supported binary downloads and had auto repair (PAR support).</p>
<p>I had been using a trial of <a href="http://www.newsbin.com/">Newsbin Pro</a> which was great but I thought there surely must be a free alternative out there. After a bit of searching I found <a href="http://shemes.com/">GrabIt</a> – A free binary newsreader with all the features I mentioned above. Simply <a href="http://download.shemes.com/GrabIt172b4.exe">download</a> and install! No bloatware to be found. The only advertising is a menu item (<em>shown below) </em>which opens browser links to <a href="http://shemes.com">Shemes.com</a> Usenet Services.</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="GrabIt" src="http://www.simonhartcher.com/wp-content/uploads/2009/09/image.png" border="0" alt="GrabIt" width="644" height="468" /></p>
<p>They provide Usenet Search subscriptions which I guess seem like pretty good value but I find <a href="http://newzleech.com/">Newzleech</a> to be more than sufficient. There are also Sheme Usenet Server subscriptions but Astraweb is much better value.</p>
<p>The only tinkering I needed to do after installation was increase the number of server connections.<a href="http://www.simonhartcher.com/wp-content/uploads/2009/09/image1.png?source=rss"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" src="http://www.simonhartcher.com/wp-content/uploads/2009/09/image_thumb.png" border="0" alt="image" width="162" height="244" align="right" /></a></p>
<ol>
<li> Right-Click <em>Default Server</em> under <em>Subscribed groups</em></li>
<li>Click <em>server properties</em></li>
<li>Move the slider bar under <em>Maximum allowed connections </em>to the right to increase the value (up to a maximum of 32 connections)</li>
<li>Click <em>Ok</em></li>
</ol>
<p>Any downloaded files will automatically extract (and repair if needed) to a directory which you can specify in <em>Preferences</em> under <em>Edit</em>. GrabIt comes with nzb support and association, so the steps to downloading a file is simple:</p>
<ol>
<li> Start a Usenet search at <a href="http://newzleech.com">Newzleech</a></li>
<li>Download and open the nzb file for the desired file(s)</li>
</ol>
<p>Have fun!</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=184&amp;t=GrabIt+-+A+Good+Free+Binary+Newsreader&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=184'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=184</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HOWTO: Query MSSQL And Send HTML Email Using Powershell</title>
		<link>http://www.simonhartcher.com/?p=146&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=146#comments</comments>
		<pubDate>Thu, 13 Aug 2009 01:31:09 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[mssql]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=146</guid>
		<description><![CDATA[Before I start this tutorial I must preface this with a warning: The amount of coding in this tutorial is so minimal it is almost sexually exciting. I have found that Powershell is such a powerful scripting tool that you can accomplish tasks that would take 100’s of lines in a lot less. This tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>Before I start this tutorial I must preface this with a warning: <strong>The amount of coding in this tutorial is so minimal it is almost sexually exciting. </strong>I have found that <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx">Powershell</a> is such a powerful scripting tool that you can accomplish tasks that would take 100’s of lines in a lot less. This tutorial is an amalgamation of several different tutorials I found online when I wanted to have a crack at emailing a report to a client. As it turned out it is now run daily as part of our scheduled tasks.</p>
<p>Powershell is what you would call the successor of Command Prompt but more is akin to a *nix command line tool like bash. As it seems that <em>everything</em> is going .NET these days it should be no surprise that Powershell also leverages the <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET Framework</a>. If you have used C# or VB.NET before the kind of objects you will be working with will be quite familiar. I am running Powershell 2.0 on the Windows 7 RTM (which comes preinstalled) but Powershell 1.0 will also work with this tutorial.</p>
<p><strong>Getting A Working Connection String</strong></p>
<p>The first thing we want to do is form our SQL query which will be the data that we will email to our client. To do that in Powershell we are going to need a connection string. A handy little tool that I use to grab a connection string is the Data Link Properties file. You can just create a new file somewhere called:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> Test.udl</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>You will need to be able to <a href="http://www.fileinfo.com/help/windows-show-extensions.html">see all file extensions</a> to create the file. Open the file using Windows Explorer and go to the Provider tab. Once there you need to select “Microsoft OLE DB Provider for SQL Server”.<img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Data Link Properties - Provider Tab" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb1.png" border="0" alt="Data Link Properties - Provider Tab" width="381" height="477" /></p>
<p>Once that has been completed we need to go to the Connection tab and enter our server details. If you have entered the correct details (Server Name, User and Password) you should now be able to click the “Select the database on the server” checkbox which will show a dropdown list of available databases. For the purpose of this tutorial I have chosen the AdventureWorks database.</p>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image1.png?source=rss"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Data Link Properties - Connection" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb2.png" border="0" alt="Data Link Properties - Connection" width="381" height="477" /></a></p>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image15.png?source=rss"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Data Link Dialog Box" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb3.png" border="0" alt="Data Link Dialog Box" width="244" height="111" align="right" /></a></p>
<p>Please also note that I have checked “Allow saving password” that will make it so we don’t have to enter it manually later. In my case, since the script is sitting on a work server there is no risk in leaving the password as plain text in the file.</p>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image16.png?source=rss"></a></p>
<p>Once you have completed all of the above, click Ok. You will get a warning about saving the password to which you can just click yes. Obviously in a less secure environment on a production server you may want to consider other options for storing your password, but that is beyond the scope of this tutorial.</p>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image16.png?source=rss"></a></p>
<p>Now that the file (Test.udl) is saved if you open it in your favourite text editor you will see something like this (I have removed my server password for obvious reasons):</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> [oledb]</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> <span style="color: #008000">; Everything after this line is an OLE DB initstring</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span> Provider=SQLOLEDB.1<span style="color: #008000">;Password=*******;Persist Security Info=True;User ID=sa;Initial Catalog=AdventureWorks;Data Source=DEEVUS-PC\SQLEXPRESS</span></pre>
<p><!--CRLF--></p>
</div>
</div>
<p>All we actually need is the text on line 3 excluding the first segment “Provider=SQLOLEDB.1;” which gives us our working connection string!</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #006080">"Password=*******;Persist Security Info=True;User ID=sa;Initial Catalog=AdventureWorks;Data Source=DEEVUS-PC\SQLEXPRESS"</span></pre>
<p><!--CRLF--></p>
</div>
</div>
<p><strong>Querying SQL Using Powershell</strong></p>
<p>Now that we have a working connection string, we can begin coding our Powershell script. The first thing we need to do is create our connection object:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #008000">#Connection Object</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> $cn = New-Object System.Data.SqlClient.SqlConnection(</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span>         <span style="color: #006080">"Password=********;Persist Security Info=True;User ID=sa;Initial Catalog=AdventureWorks;Data Source=DEEVUS-PC\SQLEXPRESS"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span>     )</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Then we create our query string:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> $q = <span style="color: #006080">"SELECT TOP 50 * FROM HumanResources.vEmployee ORDER BY LastName"</span></pre>
<p><!--CRLF--></p>
</div>
</div>
<p>We also need an Adapter and a DataSet to gather and hold our data. Once you have gathered the data using the <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx">SqlDataAdapter</a> you put the results into the <a href="http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx">DataSet</a>:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #008000">#Data Adapter which will gather the data using our query</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> $da = New-Object System.Data.SqlClient.SqlDataAdapter($q, $cn)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span> <span style="color: #008000">#DataSet which will hold the data we have gathered</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span> $ds = New-Object System.Data.DataSet</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060">   5:</span> <span style="color: #008000">#Out-Null is used so the number of affected rows isn't printed</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060">   6:</span> $da.Fill($ds) | Out-Null</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060">   7:</span> <span style="color: #008000">#Close the database connection</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060">   8:</span> $cn.Close()</pre>
<p><!--CRLF--></p>
</div>
</div>
<p><strong>Creating The HTML Email</strong></p>
<p>So now we have the data that we want to email we need to format it into HTML. Powershell has an inbuilt function called <a href="http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/convertto-html.mspx">ConvertTo-HTML</a><strong> </strong>which automagically turns data into HTML! It is really quite simple:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> $emailbody = $ds.Tables[0] |</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span>     Select-Object LastName, FirstName, JobTitle, Phone, EmailAddress, AddressLine1, City, PostalCode |</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span>     ConvertTo-HTML</pre>
<p><!--CRLF--></p>
</div>
</div>
<p><strong><a href="http://technet.microsoft.com/en-us/library/dd315291.aspx">Select-Object</a></strong> will simply grab the members from the DataSet that we need. As you can see in the above snippet we have grabbed some general information about the employees at AdventureWorks. If you’ve gotten to this point and want to see what the outcome might look like, you can add <strong><a href="http://technet.microsoft.com/en-us/library/dd315303.aspx">Out-File</a> test.html</strong> to the end of the last line so that it looks like this:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> ConvertTo-HTML | Out-File test.html</pre>
<p><!--CRLF--></p>
</div>
</div>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image6.png?source=rss"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Output in browser" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb4.png" border="0" alt="Output in browser" width="244" height="196" align="right" /></a>This will save the results to a html file which you can freely view in your preferred browser.</p>
<p>As you can see from your html file (or the screenshot provided) it is not the prettiest markup on the internet. However, there are ways to improve the look and feel of the generated html via the <strong>–head</strong> parameter of ConvertTo-HTML. The head parameter will essential pass whatever you give it to the &lt;head&gt; tags of the HTML. The head of a HTML markup can be used to shape the look and feel of the body of the document, so this way we can pass it some information to make it look nicer.</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #008000">#HTML Email Styles</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> $style = <span style="color: #006080">"&lt;style type='text/css'&gt;"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span> $style = $style + <span style="color: #006080">"BODY{background-color:#FFFFFF;font-family:Verdana;}"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span> $style = $style + <span style="color: #006080">"TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;font-size:12px;}"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060">   5:</span> $style = $style + <span style="color: #006080">"TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#D3D3D3 }"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060">   6:</span> $style = $style + <span style="color: #006080">"TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFFFFF }"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060">   7:</span> $style = $style + <span style="color: #006080">"&lt;/style&gt;"</span></pre>
<p><!--CRLF--></p>
</div>
</div>
<p>And then the last line will look like this to implement the styles we just created:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> ConvertTo-HTML -head $style | Out-File test.html</pre>
<p><!--CRLF--></p>
</div>
</div>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image11.png?source=rss"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Output in browser with styles" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb5.png" border="0" alt="Output in browser with styles" width="604" height="484" /></a></p>
<p><strong>Sending The Email</strong></p>
<p>For the final stage of this tutorial we need to actually send the email. First things first we should create all the variables pertaining to sending an email – From, To and the Subject</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> $emailFrom = <span style="color: #006080">"deevus@isp.com.au"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> $emailTo = <span style="color: #006080">"someone@anotherisp.com"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span> $subject = <span style="color: #006080">"AdventureWorks - Current Employees"</span></pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Now we form the message using the <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx">Net.Mail.MailMessage</a> class.</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> $message = New-Object Net.Mail.MailMessage($emailFrom, $emailTo, $subject, $emailbody)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> <span style="color: #008000">#This is needed to make sure it interprets the email as HTML</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span> $message.IsBodyHTML = $true</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>And the SMTP server using the <a href="http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx">Net.Mail.SmtpClient</a> class.</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> $smtpServer = <span style="color: #006080">"smtp.isp.com.au"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> $smtp = New-Object Net.Mail.SmtpClient($smtpServer)</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Finally, like magic, we send the email!</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> $smtp.Send($message)</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Before we run the script, make sure you remove or comment out <strong>| Out-File test.html</strong> – otherwise the email will be blank.</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> ConvertTo-HTML -head $style #| Out-File test.html</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Then all you need to do is run the script from the Powershell console.</p>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image12.png?source=rss"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="Powershell console" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb6.png" border="0" alt="Powershell console" width="889" height="207" /></a></p>
<p>If all is well, your recipient should receive a nicely formatted email sent using Powershell with data from SQL.</p>
<p><strong>Great Success!</strong></p>
<p>Here is the Powershell script in its entirety:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060">   1:</span> <span style="color: #008000">#Connection Object</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060">   2:</span> $cn = New-Object System.Data.SqlClient.SqlConnection(</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060">   3:</span>         <span style="color: #006080">"Password=********;Persist Security Info=True;User ID=sa;Initial Catalog=AdventureWorks;Data Source=DEEVUS-PC\SQLEXPRESS"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060">   4:</span>     )</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060">   5:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060">   6:</span> $q = <span style="color: #006080">"SELECT TOP 50 * FROM HumanResources.vEmployee ORDER BY LastName"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060">   7:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060">   8:</span> <span style="color: #008000">#Data Adapter which will gather the data using our query</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum9" style="color: #606060">   9:</span> $da = New-Object System.Data.SqlClient.SqlDataAdapter($q, $cn)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum10" style="color: #606060">  10:</span> <span style="color: #008000">#DataSet which will hold the data we have gathered</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum11" style="color: #606060">  11:</span> $ds = New-Object System.Data.DataSet</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum12" style="color: #606060">  12:</span> <span style="color: #008000">#Out-Null is used so the number of affected rows isn't printed</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum13" style="color: #606060">  13:</span> $da.Fill($ds) | Out-Null</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum14" style="color: #606060">  14:</span> <span style="color: #008000">#Close the database connection</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum15" style="color: #606060">  15:</span> $cn.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum16" style="color: #606060">  16:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum17" style="color: #606060">  17:</span> <span style="color: #008000">#HTML Email Styles</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum18" style="color: #606060">  18:</span> $style = <span style="color: #006080">"&lt;style type='text/css'&gt;"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum19" style="color: #606060">  19:</span> $style = $style + <span style="color: #006080">"BODY{background-color:#FFFFFF;font-family:Verdana;}"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum20" style="color: #606060">  20:</span> $style = $style + <span style="color: #006080">"TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;font-size:12px;}"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum21" style="color: #606060">  21:</span> $style = $style + <span style="color: #006080">"TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#D3D3D3 }"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum22" style="color: #606060">  22:</span> $style = $style + <span style="color: #006080">"TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#FFFFFF }"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum23" style="color: #606060">  23:</span> $style = $style + <span style="color: #006080">"&lt;/style&gt;"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum24" style="color: #606060">  24:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum25" style="color: #606060">  25:</span> $emailbody = $ds.Tables[0] |</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum26" style="color: #606060">  26:</span>     Select-Object LastName, FirstName, JobTitle, Phone, EmailAddress, AddressLine1, City, PostalCode |</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum27" style="color: #606060">  27:</span>     ConvertTo-HTML -head $style <span style="color: #008000">#| Out-File test.html</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum28" style="color: #606060">  28:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum29" style="color: #606060">  29:</span> $emailFrom = <span style="color: #006080">"deevus@isp.com.au"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum30" style="color: #606060">  30:</span> $emailTo = <span style="color: #006080">"someone@anotherisp.com"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum31" style="color: #606060">  31:</span> $subject = <span style="color: #006080">"AdventureWorks - Current Employees"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum32" style="color: #606060">  32:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum33" style="color: #606060">  33:</span> $message = New-Object Net.Mail.MailMessage($emailFrom, $emailTo, $subject, $emailbody)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum34" style="color: #606060">  34:</span> <span style="color: #008000">#This is needed to make sure it interprets the email as HTML</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum35" style="color: #606060">  35:</span> $message.IsBodyHTML = $true</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum36" style="color: #606060">  36:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum37" style="color: #606060">  37:</span> $smtpServer = <span style="color: #006080">"smtp.isp.com.au"</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum38" style="color: #606060">  38:</span> $smtp = New-Object Net.Mail.SmtpClient($smtpServer)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum39" style="color: #606060">  39:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum40" style="color: #606060">  40:</span> $smtp.Send($message)</pre>
<p><!--CRLF--></p>
</div>
</div>
<p><a href="http://www.simonhartcher.com/?attachment_id=163&source=rss">Download</a></p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=146&amp;t=HOWTO%3A+Query+MSSQL+And+Send+HTML+Email+Using+Powershell&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=146'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=146</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Windows 7 Upgrade Path</title>
		<link>http://www.simonhartcher.com/?p=138&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=138#comments</comments>
		<pubDate>Tue, 11 Aug 2009 01:02:11 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[windows]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[windows7]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=138</guid>
		<description><![CDATA[As part of my daily news crawl I came across a post on iTNews by Iain Thomson regarding the Windows 7 Upgrade Path:
Data released from Microsoft on the upgrade methods for Windows XP and Vista users makes it look as though users will have a tough time installing the new operating system.    [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my daily news crawl I came across a post on <a href="http://itnews.com.au/">iTNews</a> by Iain Thomson regarding the <a href="http://itnews.com.au/News/152480,windows-7-upgrade-path-looks-rocky.aspx">Windows 7 Upgrade Path</a>:</p>
<blockquote><p>Data released from Microsoft on the upgrade methods for Windows XP and Vista users makes it look as though users will have a tough time installing the new operating system.      <br />A chart released to the Wall Street Journal shows that very few of the upgrade option open to users will be possible without serious changes.       <br />Most, in fact, will require the complete wiping of the hard drive and an installation from scratch.</p>
</blockquote>
<p>To paraphrase my comment on that post:</p>
<blockquote><p>To be perfectly honest I don&#8217;t feel like Microsoft SHOULD provide an easy upgrade path from XP (a 10 year old OS!).      <br />The amount of crap that would be accumulated over time on a PC running XP since its inception would be ridiculous. Anyone who knows anything about Windows XP would have done periodic clean installs anyway to get the best out of the operating system. They would have to be used to a backup scheme anyway, except now Microsoft will make it easier with [Windows Easy Transfer].</p>
</blockquote>
<p>So what if people will have to do a clean install to move to Windows 7? As said above, unless you do regular clean installs with Windows XP you’re not getting the most out of it. It does not take long (6 months is usually the magic number) for slow boot times and visual performance issues to appear. <a href="http://www.simonhartcher.com/wp-content/uploads/2009/08/image.png?source=rss"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Windows 7 Ultimate" border="0" alt="Windows 7 Ultimate" align="right" src="http://www.simonhartcher.com/wp-content/uploads/2009/08/image_thumb.png" width="244" height="213" /></a></p>
<p>I am currently running the Windows 7 RTM which I upgraded on two of my home machines from Vista Ultimate and clean installed on my Home Theatre PC. The in-place upgrade process was quite simple and in the case of my laptop and HTPC I <a href="http://kmwoley.com/blog/?p=345">installed from a flash drive</a>. Upgrading does take considerably longer than a clean install (about an hour in total on a fast machine compared to 30 minutes for a clean install) but all your programs, settings and documents are carried across in the upgrade. In all cases I have had only minor issues with program compatibility pertaining to <a href="http://www.daemon-tools.cc/">image mounting software</a> which can be solved by installing the latest version. </p>
<p>One thing I’m really excited about with Windows 7 is the performance on a lowspec machine like a netbook. A close friend of mine purchased a <a href="http://www.kogan.com.au/shop/kogan-agora-netbook-pro/">very competitively priced netbook</a> that came with linux preinstalled. As much as I would be happy to use linux on a netbook due to my previous experience with it, my friend was not enjoying it as much as he should due to <em>“Office Envy”</em>. I helped him install Windows 7 on it using a flash drive (as his netbook does not have a DVD drive) and after failing the first time with the x64 version (he doesn’t have the hardware) we got 7 installed successfully in x86. It was really surprising (and gratifying) to see how well it ran on such a lowspec machine. The difference in boot and general reaction time between the netbook and my main machine at home was negligible. A job well done and a happy friend. </p>
<p>If you have stumbled here and want some help “upgrading” to Windows 7 from XP, take a look at this post on Scott Hanselman’s blog called <a href="http://www.hanselman.com/blog/StepByStepHowToUpgradeFromWindowsXPToWindows7.aspx">Step-By-Step: How To &quot;Upgrade&quot; from Windows XP to Windows 7</a>.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=138&amp;t=The+Windows+7+Upgrade+Path&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=138'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=138</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Reader in Firefox Sidebar</title>
		<link>http://www.simonhartcher.com/?p=124&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=124#comments</comments>
		<pubDate>Thu, 28 May 2009 10:59:12 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[google reader]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=124</guid>
		<description><![CDATA[I really love Google Reader. For me it is to the Naughties (2000&#8217;s) as The News was to the Nineties (1990&#8217;s). I love reading my news items in the morning, and they&#8217;re all items I actually want to read.
There&#8217;s a couple of ways that you can use Google Reader other than the regular site. Google have provided [...]]]></description>
			<content:encoded><![CDATA[<p>I really love <a href="http://www.google.com/reader/view/" target="_blank">Google Reader</a>. For me it is to the Naughties (2000&#8217;s) as The News was to the Nineties (1990&#8217;s). I love reading my news items in the morning, and they&#8217;re all items I actually <em>want</em> to read.</p>
<p>There&#8217;s a couple of ways that you can use Google Reader other than the regular site. Google have provided a &#8216;goodie&#8217; bookmarklet which brings up each unread item sequentially but within the context of the item. That is, it takes you to the actual item on the parent site. Recently, Google have released a brand new <a href="http://googlereader.blogspot.com/2008/05/brand-new-google-reader-for-iphone.html" target="_blank">Google Reader for iPhone</a>. Their intention was to give a better experience on mobile browsers, but since its just a webpage, you can access it from any browser (at least for the moment).</p>
<div id="attachment_126" class="wp-caption alignnone" style="width: 710px"><a href="http://www.simonhartcher.com/wp-content/uploads/2009/05/googlereadersidebar1.jpg?source=rss"><img class="size-full wp-image-126" src="http://www.simonhartcher.com/wp-content/uploads/2009/05/googlereadersidebar1.jpg" alt="Google Reader Sidebar" width="700" height="554" /></a><p class="wp-caption-text">Google Reader in the Sidebar</p></div>
<p>To get Google Reader in your Firefox sidebar, simply do the following:</p>
<ol>
<li>Open Bookmarks -&gt; Organise Bookmarks (Ctrl+Shift+B)</li>
<li>Right Click &#8220;Bookmarks Toolbar&#8221; -&gt; New Bookmark (You don&#8217;t have to put it in your toolbar but it seemed the logical choice for me)</li>
<li>Create a bookmark with the address &#8211; <a href="http://www.google.com/reader/i/">http://www.google.com/reader/i/</a></li>
<li>
<div class="mceTemp">Tick &#8220;Load this bookmark in the sidebar&#8221;</div>
</li>
</ol>
<div id="attachment_128" class="wp-caption alignnone" style="width: 387px"><a href="http://www.simonhartcher.com/wp-content/uploads/2009/05/addbookmark.jpg?source=rss"><img class="size-full wp-image-128" src="http://www.simonhartcher.com/wp-content/uploads/2009/05/addbookmark.jpg" alt="Make sure you tick &quot;Load this bookmark in the sidebar&quot;" width="377" height="249" /></a><p class="wp-caption-text">Make sure you tick &quot;Load this bookmark in the sidebar&quot;</p></div>
<p>And you&#8217;re done. Its as simple as clicking the bookmark which will open Google Reader in your sidebar.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=124&amp;t=Google+Reader+in+Firefox+Sidebar&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=124'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=124</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>All I need is a Flux Capacitor&#8230;</title>
		<link>http://www.simonhartcher.com/?p=114&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=114#comments</comments>
		<pubDate>Thu, 28 May 2009 06:01:51 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[proof-reading]]></category>
		<category><![CDATA[road-work]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=114</guid>
		<description><![CDATA[Today I found a letter which had been placed on the windscreen of my car under a wiper blade. According to the letter there is going to be some work in my street to complete some work they did a few months back. Everything seemed nominal except the date in which they are going to [...]]]></description>
			<content:encoded><![CDATA[<p>Today I found a letter which had been placed on the windscreen of my car under a wiper blade. According to the letter there is going to be some work in my street to complete some work they did a few months back. Everything seemed nominal except the date in which they are going to do the work:</p>
<div id="attachment_115" class="wp-caption alignnone" style="width: 792px"><a href="http://www.simonhartcher.com/wp-content/uploads/2009/05/roadworknoticeweb.jpg?source=rss"><img class="size-full wp-image-115" src="http://www.simonhartcher.com/wp-content/uploads/2009/05/roadworknoticeweb.jpg" alt="In the past?" width="782" height="517" /></a><p class="wp-caption-text">In the past?</p></div>
<p>They must be a bit behind schedule&#8230; and that&#8217;s not surprising. The hard part about it is that I am required to move my car from the work area to make their job easier, which is fine. But when are they <em>actually doing the work?</em> Obviously, the date is wrong. They must have scheduled the work for the previous date and in true government fashion have had to delay and reschedule.</p>
<p>So, I called the number they provided, and after a bout of confusion as to why the letter stated the wrong date, it was confirmed that the work is happening <em>tonight</em>. It also turns out that the work is not going to be as far as my apartment, so I shouldn&#8217;t be affected.</p>
<p>No harm done in the end, but people really should proof read letters before they send them out&#8230;</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=114&amp;t=All+I+need+is+a+Flux+Capacitor...&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=114'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=114</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Curious Case of Post-Release Maintenance</title>
		<link>http://www.simonhartcher.com/?p=99&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=99#comments</comments>
		<pubDate>Wed, 20 May 2009 10:02:56 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=99</guid>
		<description><![CDATA[Generally, the Software Development Process is pretty clear cut.

Requirements
Specification
Architecture
Design
Construction/Testing/Documentation
Release and Maintenance

When it comes to post-release maintenance, it is an iterative process that goes over all these steps in a smaller scale.  This is often referred to as iterative and incremental development. As a developer that has only been part of my current project post-release, its [...]]]></description>
			<content:encoded><![CDATA[<p>Generally, the <strong>Software Development Process </strong>is pretty clear cut.</p>
<ul>
<li>Requirements</li>
<li>Specification</li>
<li>Architecture</li>
<li>Design</li>
<li>Construction/Testing/Documentation</li>
<li>Release and Maintenance</li>
</ul>
<p>When it comes to post-release maintenance, it is an iterative process that goes over all these steps in a smaller scale.  This is often referred to as <a href="http://en.wikipedia.org/wiki/Iterative_development">iterative and incremental development</a>. As a developer that has only been part of my current project post-release, its hard to say what the process was prior to the initial release,  but I can only imagine, and it isn&#8217;t good. </p>
<p>The code is riddled with 1000 line routines and little gems like this:</p>
<pre class="brush: pascal;">
try
	//Hah, try to debug this code!
	//Nice try, schmuck.
except end;
</pre>
<p>Database connection dropped out? This exception code will handle it&#8230;NOT. You&#8217;ll just be plugging away doing some work and for some reason it will stop working. Its not as bad as it used to be though.</p>
<p>Or this:</p>
<pre class="brush: pascal;">
if (someExpression) then begin
	if (anotherExpression) then begin
		if (yetAnotherExpression) then begin
			//and so on!
		end;
	end;
end;
</pre>
<p>Nothing beats debugging some arrowhead code in the morning. I&#8217;d even go on to wager that my example above has better variable names than the code I&#8217;m trying to imitate. Its always fun trying to debug an aforementioned 1000 line routine that uses a boolean named DataOK about 17 times. In DataOK&#8217;s defence, it has probably had a longer life that I have.</p>
<p>As you can imagine, that&#8217;s not all. There are things like ADOTable objects that load all the data in a table and aren&#8217;t even used in the code, and I don&#8217;t even want to go into how the business logic and data access is done all in the form code&#8230;</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=99&amp;t=The+Curious+Case+of+Post-Release+Maintenance&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=99'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=99</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vimpress &#8211; Edit your Wordpress posts using vim</title>
		<link>http://www.simonhartcher.com/?p=73&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=73#comments</comments>
		<pubDate>Tue, 19 May 2009 12:51:32 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[meta-blogging]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[vimpress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=73</guid>
		<description><![CDATA[I have just discovered Vimpress which is a plugin for vim, a great text editor which I have been using/learning for the last few months. The plugin requires Python 2.4 to be installed to work and here are some plugin install instructions to get you going.


Once setup your next post is only a :BlogSend away!
On [...]]]></description>
			<content:encoded><![CDATA[<p>I have just discovered <a href="http://friggeri.net/blog/2007/07/13/vimpress">Vimpress</a> which is a plugin for <a href="http://www.vim.org">vim</a>, a great text editor which I have been using/learning for the last few months. The plugin requires <a href="http://www.python.org/download/releases/2.4.4/">Python 2.4</a> to be installed to work and here are some <a href="http://phorolinux.com/vimpress-publish-wordpress-blog-posts-from-vim.html">plugin install instructions</a> to get you going.</p>
<p><a href="http://www.simonhartcher.com/wp-content/uploads/2009/05/vimpress.png?source=rss"><a href="http://www.simonhartcher.com/wp-content/uploads/2009/05/vimpress1.png"><img class="alignnone size-full wp-image-97" title="vimpress1" src="http://www.simonhartcher.com/wp-content/uploads/2009/05/vimpress1.png" alt="vimpress1" width="677" height="490" /></a><br />
</a></p>
<p>Once setup your next post is only a :BlogSend away!</p>
<p>On a vim related note, I have recently been reading <a href="http://vim.runpaint.org/">Vim Recipes</a>, a &#8220;free cookbook for the vim text editor&#8221;. I have already learnt a few new things which is always welcome to make my vim experience that much better.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=73&amp;t=Vimpress+-+Edit+your+Wordpress+posts+using+vim&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=73'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=73</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New blog. New domain. Many thanks.</title>
		<link>http://www.simonhartcher.com/?p=70&source=rss</link>
		<comments>http://www.simonhartcher.com/?p=70#comments</comments>
		<pubDate>Tue, 19 May 2009 12:39:40 +0000</pubDate>
		<dc:creator>Simon Hartcher</dc:creator>
				<category><![CDATA[introduction]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[domain-name]]></category>

		<guid isPermaLink="false">http://www.simonhartcher.com/?p=70</guid>
		<description><![CDATA[So I&#8217;ve now migrated from my crappy Blogger account to Wordpress. Goodbye crappy 800&#215;600 themes and lackluster customisation options! I am so impressed in how easy Wordpress was to setup and to use:

FTP to server
Point to database
Run installation

Another biggy is that I have a shiny new domain name. What better way to represent myself than [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve now migrated from my crappy Blogger account to Wordpress. Goodbye crappy 800&#215;600 themes and lackluster customisation options! I am so impressed in how easy Wordpress was to setup and to use:</p>
<ol>
<li>FTP to server</li>
<li>Point to database</li>
<li>Run installation</li>
</ol>
<p>Another biggy is that I have a shiny new domain name. What better way to represent myself than a domain name which is&#8230;my name? I was surprised when I found out how cheap it was as well.</p>
<p>Last but not least, I would like to thank <a href="http://dancenode.com" target="_blank">Dancenode</a> for the hosting. Thanks guys!</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://www.simonhartcher.com/?p=70&amp;t=New+blog.+New+domain.+Many+thanks.&amp;s=compact' height='18' width='120' frameborder='0' scrolling='no'></iframe></td> <td><script type="text/javascript">tweetmeme_url='http://www.simonhartcher.com/?p=70'; tweetmeme_style = 'compact';tweetmeme_source = 'deevus'; </script><script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js" ></script></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://www.simonhartcher.com/?feed=rss2&amp;p=70</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
