<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Philip Hendry&#039;s Blog</title>
	<atom:link href="http://philiphendry.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://philiphendry.wordpress.com</link>
	<description>One day there&#039;ll be enough time...</description>
	<lastBuildDate>Mon, 22 Apr 2013 09:13:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='philiphendry.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Philip Hendry&#039;s Blog</title>
		<link>http://philiphendry.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://philiphendry.wordpress.com/osd.xml" title="Philip Hendry&#039;s Blog" />
	<atom:link rel='hub' href='http://philiphendry.wordpress.com/?pushpress=hub'/>
		<item>
		<title>A Facebook AngularJS Directive</title>
		<link>http://philiphendry.wordpress.com/2013/04/22/a-facebook-angularjs-directive/</link>
		<comments>http://philiphendry.wordpress.com/2013/04/22/a-facebook-angularjs-directive/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 08:39:15 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[AngularJS]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/?p=373</guid>
		<description><![CDATA[I’ve been developing a dashboard for the application I’m working on and one of the things it needed to include were Social Media controls such as Twitter, LinkedIN, Google +1 and Facebook. Integrating them into ASP.NET WebForms and MVC was mostly a painless experience but that was because of the predominant PostBack mechanism. I’ve recently [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=373&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve been developing a dashboard for the application I’m working on and one of the things it needed to include were Social Media controls such as Twitter, LinkedIN, Google +1 and Facebook. Integrating them into ASP.NET WebForms and MVC was mostly a painless experience but that was because of the predominant PostBack mechanism. I’ve recently chosen to look at <a href="http://angularjs.org/">AngularJS</a> since it’s two-way binding is spectacular and looked instantly better than <a href="http://knockoutjs.com/">KnockoutJS</a> which seemed to require to much boilerplate code.</p>
<p>Most of the problems I experienced when initially trying to integrate the Facebook code revolved around AngularJS binding variables not resolving and javascript code not executing at the right time. The steps below highlight how I resolved each of these issues.</p>
<p>First up was initialising the Facebook SDK. I’ve placed the code below at the top of my aspx page that delivers my dashboard. The Facebook application ID is currently being fetched by .Net code at line 6. The <a href="https://developers.facebook.com/docs/reference/javascript/">Facebook documentation</a> describes how to set this up as an async process and therefore does not disrupt the loading of the rest of the page.</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="overflow:visible;font-size:8pt;">
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="overflow:visible;font-size:8pt;">
<pre style="overflow:visible;font-size:8pt;"><span id="lnum1" style="color:#606060;">   1:</span> &lt;%-- Facebook Javascript SDK --%&gt;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum2" style="color:#606060;">   2:</span> &lt;div id=<span style="color:#006080;">"fb-root"</span>&gt;&lt;/div&gt;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum3" style="color:#606060;">   3:</span> &lt;script&gt;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum4" style="color:#606060;">   4:</span>     window.fbAsyncInit = <span style="color:#0000ff;">function</span>() {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum5" style="color:#606060;">   5:</span>         FB.init({</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum6" style="color:#606060;">   6:</span>             appId: <span style="color:#006080;">'&lt;%=ConfigurationHelper.GetMandatorySetting&lt;String&gt;("facebookApplicationId")%&gt;'</span>,</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum7" style="color:#606060;">   7:</span>             status: <span style="color:#0000ff;">true</span>, <span style="color:#008000;">// check login status</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum8" style="color:#606060;">   8:</span>             cookie: <span style="color:#0000ff;">true</span>, <span style="color:#008000;">// enable cookies to allow the server to access the session</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum9" style="color:#606060;">   9:</span>             xfbml: <span style="color:#0000ff;">true</span>,  <span style="color:#008000;">// parse XFBML</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum10" style="color:#606060;">  10:</span>             oauth: <span style="color:#0000ff;">true</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum11" style="color:#606060;">  11:</span>         });</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum12" style="color:#606060;">  12:</span>     };</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum13" style="color:#606060;">  13:</span>     (<span style="color:#0000ff;">function</span> (d, s, id) {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum14" style="color:#606060;">  14:</span>         <span style="color:#0000ff;">var</span> js, fjs = d.getElementsByTagName(s)[0];</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum15" style="color:#606060;">  15:</span>         <span style="color:#0000ff;">if</span> (d.getElementById(id)) <span style="color:#0000ff;">return</span>;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum16" style="color:#606060;">  16:</span>         js = d.createElement(s); js.id = id;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum17" style="color:#606060;">  17:</span>         js.src = <span style="color:#006080;">"//connect.facebook.net/en_GB/all.js"</span>;</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum18" style="color:#606060;">  18:</span>         fjs.parentNode.insertBefore(js, fjs);</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum19" style="color:#606060;">  19:</span>     }(document, <span style="color:#006080;">'script'</span>, <span style="color:#006080;">'facebook-jssdk'</span>));</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum20" style="color:#606060;">  20:</span> &lt;/script&gt;</pre>
<p><!--CRLF--></p>
</div>
</div>
</div>
</div>
<p>The next step is to define the AngularJS directive. There are three things to note :</p>
<ol>
<li>The template includes the binding {{urlToLike}} on line 5 which is resolved during the linking phase and must appear on the scope of the containing controller.</li>
<li>The template would never turn into a Facebook plugin unless we tell it to change and therefore on line 13 I call the Facebook SDK to <a href="https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/">parse</a> the element just added. Thanks to <a href="https://gist.github.com/echong/3856847">echong</a> for that hint. The check for the existence of FB is required because sometimes the SDK hasn’t been configured yet and if that’s the case the SDK will render the like button itself.</li>
<li>The final trick on line 11 was to make the call to parse inside a $timeout() – this adds it to the javascript queue and is processed when everything else has finished. This particular change solved problems for me when I refreshed the entire page by pressing F5 – the refresh caused the SDK to be loaded after the directive and therefore the $timeout() sorts the ordering out nicely. I’ve used this trick before to render Highcharts after the rest of the AngularJS digest loop has completed.</li>
</ol>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="overflow:visible;font-size:8pt;">
<pre style="overflow:visible;font-size:8pt;"></pre>
<p>&nbsp;</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="overflow:visible;font-size:8pt;">
<pre style="overflow:visible;font-size:8pt;"><span id="lnum1" style="color:#606060;">   1:</span> .directive(<span style="color:#006080;">'facebookLike'</span>, [<span style="color:#006080;">'$timeout'</span>, <span style="color:#0000ff;">function</span> ($timeout) {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum2" style="color:#606060;">   2:</span>     <span style="color:#0000ff;">return</span> {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum3" style="color:#606060;">   3:</span>         template:</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum4" style="color:#606060;">   4:</span>             <span style="color:#006080;">'&lt;div class="fb-like" '</span> +</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum5" style="color:#606060;">   5:</span>                 <span style="color:#006080;">'data-href="{{marketingSiteUrl}}" '</span> +</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum6" style="color:#606060;">   6:</span>                 <span style="color:#006080;">'data-send="false" '</span> +</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum7" style="color:#606060;">   7:</span>                 <span style="color:#006080;">'data-layout="button_count" '</span> +</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum8" style="color:#606060;">   8:</span>                 <span style="color:#006080;">'data-width="450" '</span> +</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum9" style="color:#606060;">   9:</span>                 <span style="color:#006080;">'data-show-faces="false"&gt;&lt;/div&gt;'</span>,</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum10" style="color:#606060;">  10:</span>         link: <span style="color:#0000ff;">function</span> (scope, element, attributes) {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum11" style="color:#606060;">  11:</span>             $timeout(<span style="color:#0000ff;">function</span> () {</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum12" style="color:#606060;">  12:</span>                 <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">typeof</span> FB !== <span style="color:#006080;">"undefined"</span> &amp;&amp; FB !== <span style="color:#0000ff;">null</span></pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum13" style="color:#606060;">  13:</span>                     ? FB.XFBML.parse(element.parent()[0])</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum14" style="color:#606060;">  14:</span>                     : <span style="color:#0000ff;">void</span> 0; });</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum15" style="color:#606060;">  15:</span>         }</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum16" style="color:#606060;">  16:</span>     };</pre>
<p><!--CRLF--></p>
<pre style="overflow:visible;font-size:8pt;"><span id="lnum17" style="color:#606060;">  17:</span> }])</pre>
<p><!--CRLF--></p>
</div>
</div>
</div>
</div>
<p>This same technique above can be used for LinkedIN, Twitter and Google +1 but the parse functions are slighty different (IN.init(), twttr.widgets.load() and gapi.plusone.go() respectively.)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/373/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/373/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=373&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2013/04/22/a-facebook-angularjs-directive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>Create a contents page with page numbers from html input using Websupergoo Abcpdf</title>
		<link>http://philiphendry.wordpress.com/2011/12/23/create-a-contents-page-with-page-numbers-from-html-input-using-websupergoo-abcpdf/</link>
		<comments>http://philiphendry.wordpress.com/2011/12/23/create-a-contents-page-with-page-numbers-from-html-input-using-websupergoo-abcpdf/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 09:25:35 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/?p=370</guid>
		<description><![CDATA[I’ve created a report pdf from an html page output from our ASP.NET based product but I needed to change a contents list that was rendered as a hyperlink list on the page into a list of section headings and page number since the pdf was primarily for printing. The solution wasn’t immediately obvious but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=370&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve created a report pdf from an html page output from our ASP.NET based product but I needed to change a contents list that was rendered as a hyperlink list on the page into a list of section headings and page number since the pdf was primarily for printing. The solution wasn’t immediately obvious but I’ve come up with the following which I was running in a unit test for simple quick prototyping. The key is using the HtmlOptions.AddTags property in ABCpdf which allows areas of the HTML to be retrieve during pdf rendering and modified.</p>
<p>&#160;</p>
<div id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">using</span> System.Diagnostics;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#0000ff;">using</span> System.IO;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> <span style="color:#0000ff;">using</span> System.Collections.Generic;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#0000ff;">using</span> System.Linq;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> <span style="color:#0000ff;">using</span> Microsoft.VisualStudio.TestTools.UnitTesting;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span> <span style="color:#0000ff;">using</span> WebSupergoo.ABCpdf8;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> <span style="color:#0000ff;">namespace</span> TestPdfFormFields</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>    [TestClass]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span>    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> PdfPrototyping</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>    {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>       <span style="color:#0000ff;">struct</span> Tag</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span>       {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>          <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> name;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>          <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> rectString;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>          <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> pagenumber;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>       }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>          </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>       [TestMethod]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>       <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> testCreatingAPdfWithContentsPageFromHtml()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>       {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>          <span style="color:#008000;">// Create Websupergoo ABCpdf document and set up the page size</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>          var theDoc = <span style="color:#0000ff;">new</span> Doc();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>          theDoc.Rect.Inset(100, 100);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>          theDoc.Rect.Top = 700;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>          <span style="color:#008000;">// The following HtmlOption instructs ABCpdf to interpret the style tags 'abcpdf-tag-visible' and</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>          <span style="color:#008000;">// create a array of the id's take from the html and the rectangles representing the size of the </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>          <span style="color:#008000;">// html element. </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span>          theDoc.HtmlOptions.AddTags = <span style="color:#0000ff;">true</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum33">  33:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum34">  34:</span>          <span style="color:#008000;">// The basis of this solution therefore is to create placeholders where page numbers will be rendered</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum35">  35:</span>          <span style="color:#008000;">// in the contents page and back-fill them once we know where the sections/chapters have been rendered</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum36">  36:</span>          <span style="color:#008000;">// since it won't be known until ABCpdf has chained pages together.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum37">  37:</span>          var theID = theDoc.AddImageHtml(</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum38">  38:</span>                   <span style="color:#006080;">@&quot;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum39">  39:</span>                      &lt;h1&gt;Contents&lt;/h1&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum40">  40:</span>                      &lt;ul&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum41">  41:</span>                         &lt;li&gt;&lt;span id='contents1' style='abcpdf-tag-visible: true; width: 20px;'&gt;&lt;/span&gt;.......First paragraph&lt;/li&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum42">  42:</span>                         &lt;li&gt;&lt;span id='contents2' style='abcpdf-tag-visible: true; width: 20px;'&gt;&lt;/span&gt;.......Second paragraph&lt;/li&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum43">  43:</span>                         &lt;li&gt;&lt;span id='contents3' style='abcpdf-tag-visible: true; width: 20px;'&gt;&lt;/span&gt;.......Third paragraph&lt;/li&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum44">  44:</span>                      &lt;/ul&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum45">  45:</span>                      &lt;h1 id='heading1' style='abcpdf-tag-visible: true; page-break-before:always;'&gt;Section One&lt;/h1&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum46">  46:</span>                      &lt;h1 id='heading2' style='abcpdf-tag-visible: true; page-break-before:always;'&gt;Section Two&lt;/h1&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum47">  47:</span>                      &lt;h1 id='heading3' style='abcpdf-tag-visible: true; page-break-before:always;'&gt;Section Three&lt;/h1&gt;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum48">  48:</span>                   &quot;</span>);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum49">  49:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum50">  50:</span>          var tagCache = <span style="color:#0000ff;">new</span> List&lt;Tag&gt;();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum51">  51:</span>          var pagenumber = 1;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum52">  52:</span>          <span style="color:#0000ff;">while</span> (<span style="color:#0000ff;">true</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum53">  53:</span>          {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum54">  54:</span>             <span style="color:#008000;">// Fetch all the tags and rectangles and add them to a tagCache for the current theID. Chaining</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum55">  55:</span>             <span style="color:#008000;">// creates a new theID which will contain more tags to add</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum56">  56:</span>             var tags = theDoc.HtmlOptions.GetTagIDs(theID);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum57">  57:</span>             var tagRects = theDoc.HtmlOptions.GetTagRects(theID);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum58">  58:</span>             tagCache.AddRange(tags.Select((t, i) =&gt; <span style="color:#0000ff;">new</span> Tag {name = t, pagenumber = pagenumber, rectString = tagRects[i].String}));</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum59">  59:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum60">  60:</span>             <span style="color:#0000ff;">if</span> (!theDoc.Chainable(theID))</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum61">  61:</span>                <span style="color:#0000ff;">break</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum62">  62:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum63">  63:</span>             theDoc.Page = theDoc.AddPage();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum64">  64:</span>             theID = theDoc.AddImageToChain(theID);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum65">  65:</span>             pagenumber++;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum66">  66:</span>          }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum67">  67:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum68">  68:</span>          <span style="color:#008000;">// Now we have a cache of all contents and heading tags we can iterate through the</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum69">  69:</span>          <span style="color:#008000;">// contents tags, find the smallest page number of the corresponding section then</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum70">  70:</span>          <span style="color:#008000;">// render the page number into the contents.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum71">  71:</span>          theDoc.HPos = 1.0;   <span style="color:#008000;">// Right justify</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum72">  72:</span>          theDoc.VPos = 0.5;   <span style="color:#008000;">// Centre vertically</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum73">  73:</span>          theDoc.FontSize = 8;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum74">  74:</span>          <span style="color:#0000ff;">foreach</span> (var tag <span style="color:#0000ff;">in</span> tagCache.Where(t =&gt; t.name.StartsWith(<span style="color:#006080;">&quot;contents&quot;</span>)))</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum75">  75:</span>          {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum76">  76:</span>             var paragraphName = <span style="color:#006080;">&quot;heading&quot;</span> + tag.name.Substring(<span style="color:#006080;">&quot;contents&quot;</span>.Length);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum77">  77:</span>             var paragraphPageNumber = tagCache.Where(t =&gt; t.name == paragraphName).Select(t =&gt; t.pagenumber).Min();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum78">  78:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum79">  79:</span>             theDoc.PageNumber = tag.pagenumber;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum80">  80:</span>             theDoc.Rect.String = tag.rectString;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum81">  81:</span>             theDoc.AddText(paragraphPageNumber.ToString());</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum82">  82:</span>          }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum83">  83:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum84">  84:</span>          <span style="color:#008000;">// Now iterate through all the pages, add page numbers and flatten the layers.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum85">  85:</span>          theDoc.Rect.String = <span style="color:#006080;">&quot;100 70 500 150&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum86">  86:</span>          var pageCount = theDoc.PageCount;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum87">  87:</span>          <span style="color:#0000ff;">for</span> (var pageNumber = 1; pageNumber &lt;= pageCount; pageNumber++)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum88">  88:</span>          {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum89">  89:</span>             theDoc.PageNumber = pageNumber;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum90">  90:</span>             theDoc.AddText(<span style="color:#006080;">&quot;Page &quot;</span> + pageNumber + <span style="color:#006080;">&quot; of &quot;</span> + pageCount);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum91">  91:</span>             theDoc.Flatten();</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum92">  92:</span>          }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum93">  93:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum94">  94:</span>          <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">string</span> testFilename = <span style="color:#006080;">@&quot;c:\temp\HtmlOptionsGetTagRects.pdf&quot;</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum95">  95:</span>          <span style="color:#0000ff;">if</span> (File.Exists(testFilename))</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum96">  96:</span>             File.Delete(testFilename);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum97">  97:</span>          theDoc.Save(testFilename);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum98">  98:</span>          Process.Start(testFilename);</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum99">  99:</span>       }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum100"> 100:</span>    }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum101"> 101:</span> }</pre>
<p><!--CRLF--></div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/370/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/370/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=370&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/12/23/create-a-contents-page-with-page-numbers-from-html-input-using-websupergoo-abcpdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>User Interface progress?</title>
		<link>http://philiphendry.wordpress.com/2011/07/25/user-interface-progress/</link>
		<comments>http://philiphendry.wordpress.com/2011/07/25/user-interface-progress/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 10:59:37 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/07/25/user-interface-progress/</guid>
		<description><![CDATA[I really feel the need to rant… I’ve just seen the following interface design: So, you tell me… does this mean Column Guides is already turned on or when you flick the switch you are turning it on? Now I would assume it’s already turned on but the trouble I have here is what is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=368&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I really feel the need to rant… I’ve just seen the following interface design:</p>
<p><a href="http://philiphendry.files.wordpress.com/2011/07/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://philiphendry.files.wordpress.com/2011/07/image_thumb.png?w=179&#038;h=50" width="179" height="50" /></a></p>
<p>So, you tell me… does this mean Column Guides is already turned on or when you flick the switch you are turning it on? Now I would assume it’s already turned on but the trouble I have here is what is wrong with using old-fashioned interface elements like the ones below? Aren’t they obvious? They may not be pretty but at least you know exactly what it means. Mind you… I have a gripe about the check box control too – sometimes it contains an ‘x’! You know it means the Column Guides are turned on but and ‘x’!!!!</p>
<p><a href="http://philiphendry.files.wordpress.com/2011/07/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://philiphendry.files.wordpress.com/2011/07/image_thumb1.png?w=236&#038;h=43" width="236" height="43" /></a></p>
<p><a href="http://philiphendry.files.wordpress.com/2011/07/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://philiphendry.files.wordpress.com/2011/07/image_thumb2.png?w=154&#038;h=42" width="154" height="42" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/368/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=368&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/07/25/user-interface-progress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>

		<media:content url="http://philiphendry.files.wordpress.com/2011/07/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://philiphendry.files.wordpress.com/2011/07/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://philiphendry.files.wordpress.com/2011/07/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Highlighting Selected Text automatically in Visual Studio</title>
		<link>http://philiphendry.wordpress.com/2011/07/20/highlighting-selected-text-automatically-in-visual-studio/</link>
		<comments>http://philiphendry.wordpress.com/2011/07/20/highlighting-selected-text-automatically-in-visual-studio/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 13:40:53 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[Dev Tools]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/07/20/highlighting-selected-text-automatically-in-visual-studio/</guid>
		<description><![CDATA[I’ve used Eclipse and always loved the way that any selected text is automatically discovered elsewhere in the current file and highlighted – this is also available in Notepad++. Plugins to the rescue! There’s WordLight for Visual Studio 2008 and another called Highlight all occurrences of selected word.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=361&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve used Eclipse and always loved the way that any selected text is automatically discovered elsewhere in the current file and highlighted – this is also available in Notepad++.</p>
<p>Plugins to the rescue! There’s <a href="http://visualstudiogallery.msdn.microsoft.com/ad686131-47d4-4c13-ada2-5b1a9019fb6f">WordLight</a> for Visual Studio 2008 and another called <a href="http://visualstudiogallery.msdn.microsoft.com/4b92b6ad-f563-4705-8f7b-7f85ba3cc6bb">Highlight all occurrences of selected word</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/361/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=361&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/07/20/highlighting-selected-text-automatically-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>Problems Compiling Android Project After Importing Into A New Workspace</title>
		<link>http://philiphendry.wordpress.com/2011/06/13/problems-compiling-android-project-after-importing-into-a-new-workspace/</link>
		<comments>http://philiphendry.wordpress.com/2011/06/13/problems-compiling-android-project-after-importing-into-a-new-workspace/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 18:34:49 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Eclipse]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/06/13/problems-compiling-android-project-after-importing-into-a-new-workspace/</guid>
		<description><![CDATA[A couple of times now I’ve had compilation problems trying to compile an Android project after having just imported it into a new Workspace – and usually it seems to concern references to system packages. The solution seems to be: Checking Windows –&#62; Preferences –&#62; Android –&#62; SDK location which has blanked out. By resetting [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=360&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A couple of times now I’ve had compilation problems trying to compile an Android project after having just imported it into a new Workspace – and usually it seems to concern references to system packages. The solution seems to be:</p>
<ul>
<li>Checking Windows –&gt; Preferences –&gt; Android –&gt; SDK location which has blanked out. By resetting the path to the SDK then the SDK Targets re-appear.</li>
<li>Selecting Package Explorer –&gt; &lt;project&gt; –&gt; Android Tools –&gt; Fix Project Properties. I can’t remember the exact reason this helped but it certainly did when loading source code that had accompanied a book.</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/360/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/360/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=360&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/06/13/problems-compiling-android-project-after-importing-into-a-new-workspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>Internet Explorer Developer Toolbar Formatting Javascript</title>
		<link>http://philiphendry.wordpress.com/2011/06/01/internet-explorer-developer-toolbar-formatting-javascript/</link>
		<comments>http://philiphendry.wordpress.com/2011/06/01/internet-explorer-developer-toolbar-formatting-javascript/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 15:19:31 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[Dev Tools]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/06/01/internet-explorer-developer-toolbar-formatting-javascript/</guid>
		<description><![CDATA[I’ve seen screens like this all the time: Jumbles of javascript spewd out by the ASP.NET AJAX and the like. However I’ve just noticed this very handy toolbar menu option: Which produces formatted code like this: I wish I had found that months and months ago!!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=359&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve seen screens like this all the time:</p>
<p><a href="http://philiphendry.files.wordpress.com/2011/06/image.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://philiphendry.files.wordpress.com/2011/06/image_thumb.png?w=644&#038;h=219" width="644" height="219" /></a></p>
<p>Jumbles of javascript spewd out by the ASP.NET AJAX and the like. However I’ve just noticed this very handy toolbar menu option:</p>
<p><a href="http://philiphendry.files.wordpress.com/2011/06/image1.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://philiphendry.files.wordpress.com/2011/06/image_thumb1.png?w=644&#038;h=228" width="644" height="228" /></a></p>
<p>Which produces formatted code like this:</p>
<p><a href="http://philiphendry.files.wordpress.com/2011/06/image2.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="image" border="0" alt="image" src="http://philiphendry.files.wordpress.com/2011/06/image_thumb2.png?w=637&#038;h=484" width="637" height="484" /></a></p>
<p>I wish I had found that months and months ago!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/359/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=359&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/06/01/internet-explorer-developer-toolbar-formatting-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>

		<media:content url="http://philiphendry.files.wordpress.com/2011/06/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://philiphendry.files.wordpress.com/2011/06/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://philiphendry.files.wordpress.com/2011/06/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Create SQL Scripts for Data in a table</title>
		<link>http://philiphendry.wordpress.com/2011/04/08/create-sql-scripts-for-data-in-a-table/</link>
		<comments>http://philiphendry.wordpress.com/2011/04/08/create-sql-scripts-for-data-in-a-table/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 11:58:55 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/04/08/create-sql-scripts-for-data-in-a-table/</guid>
		<description><![CDATA[On occasion I want to get data from a table and into a script – particularly when I want to create a deployment script for standing data that needs to be migrated between servers. Rather than hand-craft it this last time I’ve created the script below which, when given the name of a table, generates [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=352&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>On occasion I want to get data from a table and into a script – particularly when I want to create a deployment script for standing data that needs to be migrated between servers. Rather than hand-craft it this last time I’ve created the script below which, when given the name of a table, generates a union’d list of select statements that represent the data. With a slight modification this list can then be selected into a temporary table then joined back to the original in an update/insert to create a script that automatically maintains the data.</p>
<p>There are some caveats to this script though :</p>
<ul>
<li>You have to delete the first ‘union’ in the resulting SQL.</li>
<li>It doesn’t handle dates correctly and potentially some other data types – I did write this in a hurry!</li>
</ul>
<p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:1420a8a3-42a3-4712-aceb-d367b5e01571" class="wlWriterEditableSmartContent">
<pre style="width:942px;height:613px;background-color:White;overflow:auto;"><div><span style="color:#008080;"> 1</span> <span style="color:#0000FF;">declare</span><span style="color:#000000;"> </span><span style="color:#008000;">@tablename</span><span style="color:#000000;"> </span><span style="color:#0000FF;">nvarchar</span><span style="color:#000000;">(</span><span style="color:#FF00FF;">max</span><span style="color:#000000;">)
</span><span style="color:#008080;"> 2</span> <span style="color:#000000;"></span><span style="color:#0000FF;">set</span><span style="color:#000000;"> </span><span style="color:#008000;">@tablename</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">testtable</span><span style="color:#FF0000;">'</span><span style="color:#000000;">
</span><span style="color:#008080;"> 3</span> <span style="color:#000000;">
</span><span style="color:#008080;"> 4</span> <span style="color:#000000;"></span><span style="color:#0000FF;">if</span><span style="color:#000000;"> </span><span style="color:#808080;">not</span><span style="color:#000000;"> </span><span style="color:#808080;">exists</span><span style="color:#000000;"> ( </span><span style="color:#0000FF;">select</span><span style="color:#000000;"> </span><span style="color:#FF0000;">[</span><span style="color:#FF0000;">TABLE_NAME</span><span style="color:#FF0000;">]</span><span style="color:#000000;"> </span><span style="color:#0000FF;">from</span><span style="color:#000000;"> INFORMATION_SCHEMA.TABLES </span><span style="color:#0000FF;">where</span><span style="color:#000000;"> </span><span style="color:#FF0000;">[</span><span style="color:#FF0000;">TABLE_NAME</span><span style="color:#FF0000;">]</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#008000;">@tablename</span><span style="color:#000000;"> )
</span><span style="color:#008080;"> 5</span> <span style="color:#000000;"></span><span style="color:#0000FF;">begin</span><span style="color:#000000;">
</span><span style="color:#008080;"> 6</span> <span style="color:#000000;">    </span><span style="color:#0000FF;">declare</span><span style="color:#000000;"> </span><span style="color:#008000;">@message</span><span style="color:#000000;"> </span><span style="color:#0000FF;">nvarchar</span><span style="color:#000000;">(</span><span style="color:#FF00FF;">max</span><span style="color:#000000;">)
</span><span style="color:#008080;"> 7</span> <span style="color:#000000;">    </span><span style="color:#0000FF;">set</span><span style="color:#000000;"> </span><span style="color:#008000;">@message</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">The table </span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#008000;">@tablename</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;"> does not exist</span><span style="color:#FF0000;">'</span><span style="color:#000000;">
</span><span style="color:#008080;"> 8</span> <span style="color:#000000;">    </span><span style="color:#0000FF;">raiserror</span><span style="color:#000000;"> ( </span><span style="color:#008000;">@message</span><span style="color:#000000;">, </span><span style="color:#800000;font-weight:bold;">18</span><span style="color:#000000;">, </span><span style="color:#800000;font-weight:bold;">0</span><span style="color:#000000;"> );
</span><span style="color:#008080;"> 9</span> <span style="color:#000000;">    </span><span style="color:#0000FF;">return</span><span style="color:#000000;">;
</span><span style="color:#008080;">10</span> <span style="color:#000000;"></span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">11</span> <span style="color:#000000;">
</span><span style="color:#008080;">12</span> <span style="color:#000000;"></span><span style="color:#0000FF;">declare</span><span style="color:#000000;"> </span><span style="color:#008000;">@sql</span><span style="color:#000000;"> </span><span style="color:#0000FF;">nvarchar</span><span style="color:#000000;">(</span><span style="color:#FF00FF;">max</span><span style="color:#000000;">)
</span><span style="color:#008080;">13</span> <span style="color:#000000;"></span><span style="color:#0000FF;">set</span><span style="color:#000000;"> </span><span style="color:#008000;">@sql</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;">
</span><span style="color:#008080;">14</span> <span style="color:#000000;">
</span><span style="color:#008080;">15</span> <span style="color:#000000;"></span><span style="color:#0000FF;">declare</span><span style="color:#000000;"> </span><span style="color:#008000;">@newline</span><span style="color:#000000;"> </span><span style="color:#0000FF;">nvarchar</span><span style="color:#000000;">(</span><span style="color:#800000;font-weight:bold;">2</span><span style="color:#000000;">)
</span><span style="color:#008080;">16</span> <span style="color:#000000;"></span><span style="color:#0000FF;">set</span><span style="color:#000000;"> </span><span style="color:#008000;">@newline</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">char</span><span style="color:#000000;">(</span><span style="color:#800000;font-weight:bold;">13</span><span style="color:#000000;">) </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#0000FF;">char</span><span style="color:#000000;">(</span><span style="color:#800000;font-weight:bold;">10</span><span style="color:#000000;">)
</span><span style="color:#008080;">17</span> <span style="color:#000000;">
</span><span style="color:#008080;">18</span> <span style="color:#000000;"></span><span style="color:#0000FF;">select</span><span style="color:#000000;"> </span><span style="color:#008000;">@sql</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#008000;">@sql</span><span style="color:#000000;"> 
</span><span style="color:#008080;">19</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> ORDINAL_POSITION </span><span style="color:#808080;">&gt;</span><span style="color:#000000;"> </span><span style="color:#800000;font-weight:bold;">1</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;"> + </span><span style="color:#FF0000;">''</span><span style="color:#FF0000;">, </span><span style="color:#FF0000;">''</span><span style="color:#FF0000;"> + </span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;"> 
</span><span style="color:#008080;">20</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> IS_NULLABLE </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">YES</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">isnull(</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">21</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> NUMERIC_SCALE </span><span style="color:#0000FF;">is</span><span style="color:#000000;"> </span><span style="color:#808080;">not</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;"> </span><span style="color:#808080;">or</span><span style="color:#000000;"> DATA_TYPE </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">bit</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">convert(nvarchar, </span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">22</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> CHARACTER_MAXIMUM_LENGTH </span><span style="color:#0000FF;">is</span><span style="color:#000000;"> </span><span style="color:#808080;">not</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;"> </span><span style="color:#FF0000;">''''''''</span><span style="color:#FF0000;"> + </span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">23</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">[</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> isc.COLUMN_NAME </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">]</span><span style="color:#FF0000;">'</span><span style="color:#000000;">
</span><span style="color:#008080;">24</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> CHARACTER_MAXIMUM_LENGTH </span><span style="color:#0000FF;">is</span><span style="color:#000000;"> </span><span style="color:#808080;">not</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;"> + </span><span style="color:#FF0000;">'''''''''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">25</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> NUMERIC_SCALE </span><span style="color:#0000FF;">is</span><span style="color:#000000;"> </span><span style="color:#808080;">not</span><span style="color:#000000;"> </span><span style="color:#0000FF;">null</span><span style="color:#000000;"> </span><span style="color:#808080;">or</span><span style="color:#000000;"> DATA_TYPE </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">bit</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">)</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">26</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">case</span><span style="color:#000000;"> </span><span style="color:#0000FF;">when</span><span style="color:#000000;"> IS_NULLABLE </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">YES</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">then</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">, </span><span style="color:#FF0000;">''</span><span style="color:#FF0000;">null</span><span style="color:#FF0000;">''</span><span style="color:#FF0000;">)</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#0000FF;">else</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''</span><span style="color:#000000;"> </span><span style="color:#0000FF;">end</span><span style="color:#000000;">
</span><span style="color:#008080;">27</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;"> + </span><span style="color:#FF0000;">''</span><span style="color:#FF0000;"> as [</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> COLUMN_NAME </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">]</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">''''</span><span style="color:#000000;">
</span><span style="color:#008080;">28</span> <span style="color:#000000;">    </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#008000;">@newline</span><span style="color:#000000;">
</span><span style="color:#008080;">29</span> <span style="color:#000000;"></span><span style="color:#0000FF;">from</span><span style="color:#000000;"> INFORMATION_SCHEMA.COLUMNS isc
</span><span style="color:#008080;">30</span> <span style="color:#000000;"></span><span style="color:#0000FF;">where</span><span style="color:#000000;">
</span><span style="color:#008080;">31</span> <span style="color:#000000;">    isc.TABLE_NAME </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#008000;">@tablename</span><span style="color:#000000;">
</span><span style="color:#008080;">32</span> <span style="color:#000000;"></span><span style="color:#0000FF;">order</span><span style="color:#000000;"> </span><span style="color:#0000FF;">by</span><span style="color:#000000;">
</span><span style="color:#008080;">33</span> <span style="color:#000000;">    ORDINAL_POSITION
</span><span style="color:#008080;">34</span> <span style="color:#000000;">
</span><span style="color:#008080;">35</span> <span style="color:#000000;"></span><span style="color:#0000FF;">set</span><span style="color:#000000;"> </span><span style="color:#008000;">@sql</span><span style="color:#000000;"> </span><span style="color:#808080;">=</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">select </span><span style="color:#FF0000;">''</span><span style="color:#FF0000;">union select </span><span style="color:#FF0000;">''</span><span style="color:#FF0000;"> + </span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#008000;">@sql</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;"> from [</span><span style="color:#FF0000;">'</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#008000;">@tablename</span><span style="color:#000000;"> </span><span style="color:#808080;">+</span><span style="color:#000000;"> </span><span style="color:#FF0000;">'</span><span style="color:#FF0000;">]</span><span style="color:#FF0000;">'</span><span style="color:#000000;">
</span><span style="color:#008080;">36</span> <span style="color:#000000;"></span><span style="color:#0000FF;">exec</span><span style="color:#000000;"> sp_executesql </span><span style="color:#008000;">@sql</span></div></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/352/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/352/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=352&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/04/08/create-sql-scripts-for-data-in-a-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>Configuring Event Log Permission for Asp.net applications</title>
		<link>http://philiphendry.wordpress.com/2011/03/23/configuring-event-log-permission-for-asp-net-applications/</link>
		<comments>http://philiphendry.wordpress.com/2011/03/23/configuring-event-log-permission-for-asp-net-applications/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 14:40:25 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/03/23/configuring-event-log-permission-for-asp-net-applications/</guid>
		<description><![CDATA[I’ve been having some problems with writing to a custom event log as well as the standard ‘Application’ event log where it failed with the following error : Stack Trace: [Win32Exception (0x80004005): Access is denied] [InvalidOperationException: Cannot open log for source 'Application'. You may not have write access.] System.Diagnostics.EventLog.OpenForWrite(String currentMachineName) +1008783 System.Diagnostics.EventLog.InternalWriteEvent(UInt32 eventID, UInt16 category, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=350&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I’ve been having some problems with writing to a custom event log as well as the standard ‘Application’ event log where it failed with the following error :</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:b62ec1fa-7038-4209-addd-5926fdc77a25" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:auto;"><span style="color:#000000;">    Stack Trace: 
    
    
    [Win32Exception (0x80004005): Access is denied]
    
    [InvalidOperationException: Cannot open log for source 'Application'. You may not have write access.]
    System.Diagnostics.EventLog.OpenForWrite(String currentMachineName) +1008783
    System.Diagnostics.EventLog.InternalWriteEvent(UInt32 eventID, UInt16 category, EventLogEntryType type, String[] strings, Byte[] rawData, String currentMachineName) +216
    System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +264
    System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) +87
    System.Diagnostics.EventLog.WriteEntry(String source, String message, EventLogEntryType type) +14
    ASP.test_testeventlogaccess_aspx.WriteToApplication(Object sender, EventArgs e) in c:\Inetpub\wwwroot\connect\Test\TestEventLogAccess.aspx:20
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>What made this harder to figure was it worked in one environment but not another! The difference was impersonation was turned on in the web.config for the failing web site :</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:80faabe3-1029-4dc4-806c-2a0e1f6c31c3" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:auto;"><span style="color:#000000;">
  </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">system.web</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">identity </span><span style="color:#FF0000;">impersonate</span><span style="color:#0000FF;">="true"</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;">
  </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">system.web</span><span style="color:#0000FF;">&gt;</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>This meant that the user being used to access the event log was not the AppPool identity but rather the ASP.NET IUSR_ identity (which has not been overridden with the optional username/password attributes above in the config above.)</p>
<p>Microsoft has a knowledge base article describing <a href="http://support.microsoft.com/kb/2028427" target="_blank">how to configure event log permissions</a> but there were two extra steps I had to perform before I could add the IUSR identity to the event log permissions :</p>
<h3>Fetching the SID for an account</h3>
<p>The SDDL string that needs to be added according to the knowledge base article referenced above requires the SID for the IUSR account. There are a couple of ways to do this listed below. Either script block should be saved to a .vbs file and run as a parameter to cscript.exe from a command line :</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:bf55031b-4163-4f14-9c74-62965b53b0d6" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:auto;"><span style="color:#000000;">    strComputer </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">.</span><span style="color:#800000;">"</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">Set</span><span style="color:#000000;"> objWMIService </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">GetObject</span><span style="color:#000000;">(</span><span style="color:#800000;">"</span><span style="color:#800000;">winmgmts:\\</span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> strComputer </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">\root\cimv2</span><span style="color:#800000;">"</span><span style="color:#000000;">)
    </span><span style="color:#0000FF;">Set</span><span style="color:#000000;"> objAccount </span><span style="color:#000000;">=</span><span style="color:#000000;"> objWMIService.Get(</span><span style="color:#800000;">"</span><span style="color:#800000;">Win32_UserAccount.Name='IUSR_&lt;COMPUTER NAME&gt;',Domain='&lt;COMPUTER NAME&gt;'</span><span style="color:#800000;">"</span><span style="color:#000000;">)
    Wscript.Echo objAccount.SID
    
    
    </span><span style="color:#0000FF;">On</span><span style="color:#000000;"> </span><span style="color:#0000FF;">Error</span><span style="color:#000000;"> </span><span style="color:#0000FF;">Resume</span><span style="color:#000000;"> </span><span style="color:#0000FF;">Next</span><span style="color:#000000;">
    strComputer </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">.</span><span style="color:#800000;">"</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">Set</span><span style="color:#000000;"> objWMIService </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">GetObject</span><span style="color:#000000;">(</span><span style="color:#800000;">"</span><span style="color:#800000;">winmgmts:\\</span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> strComputer </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> </span><span style="color:#800000;">"</span><span style="color:#800000;">\root\cimv2</span><span style="color:#800000;">"</span><span style="color:#000000;">)
    </span><span style="color:#0000FF;">Set</span><span style="color:#000000;"> colItems </span><span style="color:#000000;">=</span><span style="color:#000000;"> objWMIService.ExecQuery(</span><span style="color:#800000;">"</span><span style="color:#800000;">Select * from Win32_UserAccount</span><span style="color:#800000;">"</span><span style="color:#000000;">,,</span><span style="color:#800080;">48</span><span style="color:#000000;">)
    </span><span style="color:#0000FF;">For</span><span style="color:#000000;"> </span><span style="color:#0000FF;">Each</span><span style="color:#000000;"> objItem in colItems
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">AccountType: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.AccountType
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Caption: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Caption
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Description: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Description
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Disabled: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Disabled
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Domain: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Domain
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">FullName: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.FullName
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">InstallDate: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.InstallDate
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Lockout: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Lockout
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Name: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Name
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">PasswordChangeable: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.PasswordChangeable
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">PasswordExpires: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.PasswordExpires
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">PasswordRequired: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.PasswordRequired
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">SID: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.SID
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">SIDType: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.SIDType
        Wscript.Echo </span><span style="color:#800000;">"</span><span style="color:#800000;">Status: </span><span style="color:#800000;">"</span><span style="color:#000000;"> </span><span style="color:#000000;">&amp;</span><span style="color:#000000;"> objItem.Status
    </span><span style="color:#0000FF;">Next</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<h3>Remove the IUSR Identity from the Guest Users Group</h3>
<p>The last modification which is not mentioned in the knowledge base article is that the Guest Users group is already explicitly denied access to the event log (at least on my Windows Server 2003 machine) and therefore adding the SID for this account will not have an account. To solve this I removed the IUSR account from the Guest Users group and everything worked.</p>
<h3>Debugging</h3>
<p>As an aside to be able to test and debug this on both a production and test server I created an .aspx file with no code-behind with the following code :</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:1de16956-6c9d-4d11-8826-a7151b5a6b5a" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:auto;"><span style="color:#000000;">    </span><span style="background-color:#FFFF00;color:#000000;">&lt;%</span><span style="background-color:#F5F5F5;color:#000000;">@ Page Language</span><span style="background-color:#F5F5F5;color:#000000;">=</span><span style="background-color:#F5F5F5;color:#800000;">"</span><span style="background-color:#F5F5F5;color:#800000;">C#</span><span style="background-color:#F5F5F5;color:#800000;">"</span><span style="background-color:#F5F5F5;color:#000000;"> </span><span style="background-color:#FFFF00;color:#000000;">%&gt;</span><span style="color:#000000;">
    </span><span style="background-color:#FFFF00;color:#000000;">&lt;%</span><span style="background-color:#F5F5F5;color:#000000;">@ Import Namespace</span><span style="background-color:#F5F5F5;color:#000000;">=</span><span style="background-color:#F5F5F5;color:#800000;">"</span><span style="background-color:#F5F5F5;color:#800000;">System.Diagnostics</span><span style="background-color:#F5F5F5;color:#800000;">"</span><span style="background-color:#FFFF00;color:#000000;">%&gt;</span><span style="color:#000000;">
    
    
    </span><span style="color:#0000FF;">&lt;!</span><span style="color:#FF00FF;">DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
    
    </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">html </span><span style="color:#FF0000;">xmlns</span><span style="color:#0000FF;">="http://www.w3.org/1999/xhtml"</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">head </span><span style="color:#FF0000;">runat</span><span style="color:#0000FF;">="server"</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
        </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">title</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">Test Event Log Access</span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">title</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
        
        </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">script </span><span style="color:#FF0000;">runat</span><span style="color:#0000FF;">="server"</span><span style="color:#0000FF;">&gt;</span><span style="background-color:#F5F5F5;color:#000000;">
        
        protected </span><span style="background-color:#F5F5F5;color:#0000FF;">void</span><span style="background-color:#F5F5F5;color:#000000;"> WriteToMyEventLog(object sender, EventArgs e)
        {
            EventLog.WriteEntry(</span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">MyEventLog</span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">, </span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">This is a test</span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">, EventLogEntryType.Error);
        }
    
        protected </span><span style="background-color:#F5F5F5;color:#0000FF;">void</span><span style="background-color:#F5F5F5;color:#000000;"> WriteToApplication(object sender, EventArgs e)
        {
            EventLog.WriteEntry(</span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">Application</span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">, </span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">This is a test</span><span style="background-color:#F5F5F5;color:#000000;">"</span><span style="background-color:#F5F5F5;color:#000000;">, EventLogEntryType.Error);
        }        
        </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">script</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
        
    </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">head</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">body</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
        </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">form </span><span style="color:#FF0000;">id</span><span style="color:#0000FF;">="form"</span><span style="color:#FF0000;"> runat</span><span style="color:#0000FF;">="server"</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
        </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">div</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
            </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">asp:Button </span><span style="color:#FF0000;">runat</span><span style="color:#0000FF;">="server"</span><span style="color:#FF0000;"> ID</span><span style="color:#0000FF;">="btnWriteToMyEventLog"</span><span style="color:#FF0000;"> Text</span><span style="color:#0000FF;">="Write to My Event Log"</span><span style="color:#FF0000;"> OnClick</span><span style="color:#0000FF;">="WriteToMyEventLog"</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;">
            </span><span style="color:#0000FF;">&lt;</span><span style="color:#800000;">asp:Button </span><span style="color:#FF0000;">runat</span><span style="color:#0000FF;">="server"</span><span style="color:#FF0000;"> ID</span><span style="color:#0000FF;">="btnWriteToApplication"</span><span style="color:#FF0000;"> Text</span><span style="color:#0000FF;">="Write to Application"</span><span style="color:#FF0000;"> OnClick</span><span style="color:#0000FF;">="WriteToApplication"</span><span style="color:#FF0000;"> </span><span style="color:#0000FF;">/&gt;</span><span style="color:#000000;">
        </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">div</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
        </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">form</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">body</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
    </span><span style="color:#0000FF;">&lt;/</span><span style="color:#800000;">html</span><span style="color:#0000FF;">&gt;</span><span style="color:#000000;">
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/350/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/350/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=350&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/03/23/configuring-event-log-permission-for-asp-net-applications/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>Randomising data in a table using T-sql</title>
		<link>http://philiphendry.wordpress.com/2011/03/08/randomising-data-in-a-table-using-t-sql/</link>
		<comments>http://philiphendry.wordpress.com/2011/03/08/randomising-data-in-a-table-using-t-sql/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 08:48:08 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/03/08/randomising-data-in-a-table-using-t-sql/</guid>
		<description><![CDATA[I needed to obfuscate some data for a demo server but rather than re-invent all the data I simply wanted to randomly swap data so associations could not be made between a store and pay rates for example. After a bit of head scratching I came to the conclusion that I simply needed to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=349&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I needed to obfuscate some data for a demo server but rather than re-invent all the data I simply wanted to randomly swap data so associations could not be made between a store and pay rates for example. After a bit of head scratching I came to the conclusion that I simply needed to be able to correlate one set of data with a random set. The simplest way I thought of was to use a row_number() to correlate one list of data with another where one set of row numbers were ordered by a primary key whilst the other used a little trick of ordering by newid() which is recalculated for each row and therefore randomly distributes the data. Here’s the code :</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:5aee3d80-c54f-4b52-9301-3e7f99120497" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:auto;font-family:Courier New;font-size:7.8px;"><span style="color:#0000FF;">select</span><span style="color:#000000;"> </span><span style="color:#808080;">*</span><span style="color:#000000;">
</span><span style="color:#008080;">--</span><span style="color:#008080;">update s1 set s1.StoreName = s2.StoreName, s1.StoreAddress1 = s2.StoreAddress1, s1.County = s2.County, s1.Town = s2.Town, s1.PostCode = s2.PostCode, s1.Telephone = s2.Telephone</span><span style="color:#008080;">
</span><span style="color:#0000FF;">from</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">select</span><span style="color:#000000;"> row_number() </span><span style="color:#0000FF;">over</span><span style="color:#000000;">(</span><span style="color:#0000FF;">order</span><span style="color:#000000;"> </span><span style="color:#0000FF;">by</span><span style="color:#000000;"> StoreID) </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> RowNumber, StoreId, StoreName, StoreAddress1, County, Town, PostCode, Telephone </span><span style="color:#0000FF;">from</span><span style="color:#000000;"> Stores s1) </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> s1 
</span><span style="color:#808080;">join</span><span style="color:#000000;"> (</span><span style="color:#0000FF;">select</span><span style="color:#000000;"> row_number() </span><span style="color:#0000FF;">over</span><span style="color:#000000;">(</span><span style="color:#0000FF;">order</span><span style="color:#000000;"> </span><span style="color:#0000FF;">by</span><span style="color:#000000;"> </span><span style="color:#FF00FF;">newid</span><span style="color:#000000;">()) </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> RowNumber, StoreId, StoreName, StoreAddress1, County, Town, PostCode, Telephone </span><span style="color:#0000FF;">from</span><span style="color:#000000;"> Stores s2) </span><span style="color:#0000FF;">as</span><span style="color:#000000;"> s2 </span><span style="color:#0000FF;">on</span><span style="color:#000000;"> s1.RowNumber </span><span style="color:#808080;">=</span><span style="color:#000000;"> s2.RowNumber 
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/349/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/349/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=349&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/03/08/randomising-data-in-a-table-using-t-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
		<item>
		<title>Mapping SkyDrive as a Network drive in windows</title>
		<link>http://philiphendry.wordpress.com/2011/03/07/mapping-skydrive-as-a-network-drive-in-windows/</link>
		<comments>http://philiphendry.wordpress.com/2011/03/07/mapping-skydrive-as-a-network-drive-in-windows/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 21:06:00 +0000</pubDate>
		<dc:creator>philiphendry</dc:creator>
				<category><![CDATA[Tip]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">https://philiphendry.wordpress.com/2011/03/07/mapping-skydrive-as-a-network-drive-in-windows/</guid>
		<description><![CDATA[I didn’t realise you could do it until I found an article describing exactly how to do it and it works a treat! I’m thinking of using my SkyDrive account to backup photos off a NetGear ReadyNAS Duo storage device onto the cloud so they’re all doubly safe!!<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=348&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I didn’t realise you could do it until I found an <a href="http://www.nirmaltv.com/2010/02/02/how-to-map-skydrive-as-network-drive-in-windows/" target="_blank">article</a> describing exactly how to do it and it works a treat! I’m thinking of using my SkyDrive account to backup photos off a NetGear ReadyNAS Duo storage device onto the cloud so they’re all doubly safe!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/philiphendry.wordpress.com/348/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/philiphendry.wordpress.com/348/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=philiphendry.wordpress.com&#038;blog=3012011&#038;post=348&#038;subd=philiphendry&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://philiphendry.wordpress.com/2011/03/07/mapping-skydrive-as-a-network-drive-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3214cb235f3cd7a089cee75182f0976b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Phil</media:title>
		</media:content>
	</item>
	</channel>
</rss>
