<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>Chris Risner . Com</title><link>http://chrisrisner.com</link><description>Chris Risner . Com</description><ttl>60</ttl><item><title><![CDATA[ Veritas – Error Logging – Part 8 ]]></title><link>http://chrisrisner.com/Veritas-–-Error-Logging-–-Part-8</link><guid isPermaLink="true">http://chrisrisner.com/Veritas-–-Error-Logging-–-Part-8</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/634003144233522332.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Veritas" border="0" alt="Veritas" align="right" src="http://chrisrisner.com/upload/634003144233522332.jpg" width="195" height="36" /></a> Today’s short article is about error handling.&#160; In addition to recording errors to our BlogLog table which we <a title="Veritas DB Design" href="http://chrisrisner.com/Veritas--Database-Design-%E2%80%93-Part-2">discussed previously</a>, we’ll also program in the capability to log to both email and a text file.&#160; If you controlled the server you were going to host on, you could look at other options (writing to the event log, logging through a MSMQ) but since we’re writing this to work on a shared host, we’ll only use the options that we know (should) work.&#160; To begin with we’ll add some settings to the BlogConfig class to control whether or not we log to each source:</p>  <div class="csharpcode">   <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">string</span> LogEmailAddress { get; set; }</pre>

  <pre><span class="lnum">   2:  </span><span class="kwrd">public</span> <span class="kwrd">string</span> LogFilePath { get; set; }</pre>

  <pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">public</span> <span class="kwrd">bool</span> LogToDb { get; set; }</pre>

  <pre><span class="lnum">   4:  </span><span class="kwrd">public</span> <span class="kwrd">bool</span> LogToEmail { get; set; }</pre>

  <pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">public</span> <span class="kwrd">bool</span> LogToFile { get; set; }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style><style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>3 of these will just control where we’re going to log to and the other two just control to what file or email address we log to.&#160; We’ll also add those fields into all of the load and build xml methods in our BlogConfig class.&#160; Once that’s done, we’ll add a new Logging Handler class into our Business Layer.&#160; The first thing we need is a property to check and see if each type of logging is enabled.&#160; These getters will just reach into our BlogConfig to see if the property above is set to true or false:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsDbLoggingEnabled</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>     get</pre>

  <pre><span class="lnum">   4:  </span>     {</pre>

  <pre class="alt"><span class="lnum">   5:  </span>          <span class="kwrd">return</span> CacheHandler.GetBlogConfig().LogToDb;</pre>

  <pre><span class="lnum">   6:  </span>     }</pre>

  <pre class="alt"><span class="lnum">   7:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p>We’re going to create two methods for each type of logging.&#160; One that takes in an exception and one that takes in individual details (in case we’re not logging a specific exception).&#160; Both of these methods will also take in the “logging source” (the method or file calling the logging method).&#160; Before we create those, we’ll create our helper methods to take in those details and create a BlogLog object:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">private</span> <span class="kwrd">static</span> BlogLog GetBlogLog(<span class="kwrd">string</span> message, <span class="kwrd">string</span> details, <span class="kwrd">string</span> level, <span class="kwrd">string</span> logger)</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>    BlogLog log = <span class="kwrd">new</span> BlogLog()</pre>

  <pre><span class="lnum">   4:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   5:  </span>        BlogConfigId = CacheHandler.BlogConfigId,</pre>

  <pre><span class="lnum">   6:  </span>        CreateDate = DateTime.Now,</pre>

  <pre class="alt"><span class="lnum">   7:  </span>        EventLevel = level,</pre>

  <pre><span class="lnum">   8:  </span>        Exception = details,</pre>

  <pre class="alt"><span class="lnum">   9:  </span>        Message = message,</pre>

  <pre><span class="lnum">  10:  </span>        Url = HttpContext.Current.Request.Url.ToString(),</pre>

  <pre class="alt"><span class="lnum">  11:  </span>        Logger = logger</pre>

  <pre><span class="lnum">  12:  </span>    };</pre>

  <pre class="alt"><span class="lnum">  13:  </span>    <span class="kwrd">return</span> log;</pre>

  <pre><span class="lnum">  14:  </span>}</pre>

  <pre class="alt"><span class="lnum">  15:  </span>&#160;</pre>

  <pre><span class="lnum">  16:  </span><span class="kwrd">private</span> <span class="kwrd">static</span> BlogLog GetBlogLog(Exception ex, <span class="kwrd">string</span> logger)</pre>

  <pre class="alt"><span class="lnum">  17:  </span>{</pre>

  <pre><span class="lnum">  18:  </span>    BlogLog log = <span class="kwrd">new</span> BlogLog()</pre>

  <pre class="alt"><span class="lnum">  19:  </span>    {</pre>

  <pre><span class="lnum">  20:  </span>        BlogConfigId = CacheHandler.BlogConfigId,</pre>

  <pre class="alt"><span class="lnum">  21:  </span>        CreateDate = DateTime.Now,</pre>

  <pre><span class="lnum">  22:  </span>        EventLevel = <span class="str">&quot;Error&quot;</span>,</pre>

  <pre class="alt"><span class="lnum">  23:  </span>        Exception = GetInfoFromException(ex),</pre>

  <pre><span class="lnum">  24:  </span>        Message = ex.Message,</pre>

  <pre class="alt"><span class="lnum">  25:  </span>        Url = HttpContext.Current.Request.Url.ToString(),</pre>

  <pre><span class="lnum">  26:  </span>        Logger = logger</pre>

  <pre class="alt"><span class="lnum">  27:  </span>    };</pre>

  <pre><span class="lnum">  28:  </span>    <span class="kwrd">return</span> log;</pre>

  <pre class="alt"><span class="lnum">  29:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>One last item before we get to the logging methods is the GetInfoFromException method we see called above.&#160; It will simply concatenate a few of the details of the exception:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">string</span> GetInfoFromException(Exception ex)</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">string</span> stackTrace = ex.StackTrace + <span class="str">&quot;\n\n&quot;</span>;</pre>

  <pre><span class="lnum">   4:  </span>    <span class="kwrd">if</span> (ex.InnerException != <span class="kwrd">null</span>)</pre>

  <pre class="alt"><span class="lnum">   5:  </span>        stackTrace += LoggingHandler.GetInfoFromException(ex.InnerException);</pre>

  <pre><span class="lnum">   6:  </span>    <span class="kwrd">return</span> stackTrace;</pre>

  <pre class="alt"><span class="lnum">   7:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p>Finally we’ll create our two actual logging methods.&#160; As you’ll see, these will both make use of our GetBlogLog methods above:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> LogToDb(<span class="kwrd">string</span> message, <span class="kwrd">string</span> details, <span class="kwrd">string</span> level, <span class="kwrd">string</span> logger)</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsDbLoggingEnabled)</pre>

  <pre><span class="lnum">   4:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   5:  </span>        BlogLog log = LoggingHandler.GetBlogLog(message, details, level, logger);</pre>

  <pre><span class="lnum">   6:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   7:  </span>        var repo = VeritasRepository.GetInstance();</pre>

  <pre><span class="lnum">   8:  </span>        repo.Add(log);</pre>

  <pre class="alt"><span class="lnum">   9:  </span>        repo.Save();</pre>

  <pre><span class="lnum">  10:  </span>    }</pre>

  <pre class="alt"><span class="lnum">  11:  </span>}</pre>

  <pre><span class="lnum">  12:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  13:  </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> LogToDb(Exception ex, <span class="kwrd">string</span> logger)</pre>

  <pre><span class="lnum">  14:  </span>{</pre>

  <pre class="alt"><span class="lnum">  15:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsDbLoggingEnabled)</pre>

  <pre><span class="lnum">  16:  </span>    {</pre>

  <pre class="alt"><span class="lnum">  17:  </span>        BlogLog log = LoggingHandler.GetBlogLog(ex, logger);</pre>

  <pre><span class="lnum">  18:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  19:  </span>        var repo = VeritasRepository.GetInstance();</pre>

  <pre><span class="lnum">  20:  </span>        repo.Add(log);</pre>

  <pre class="alt"><span class="lnum">  21:  </span>        repo.Save();</pre>

  <pre><span class="lnum">  22:  </span>    }</pre>

  <pre class="alt"><span class="lnum">  23:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>That’s it for logging to the database.&#160; We've got two additional methods that will log to email and log to a file but we won’t show those for brevity’s sake.&#160; If you want, you can check out the code attached to see what those look like.&#160; We’re now able to log any errors or information we might want to from anywhere else in the code and we can do it in several different ways.&#160; However, we need a method that will handle figuring out where and what to log to so we don’t have to pick and choose in other locations:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Log(<span class="kwrd">string</span> message, <span class="kwrd">string</span> details, <span class="kwrd">string</span> level, <span class="kwrd">string</span> logger)</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsDbLoggingEnabled)</pre>

  <pre><span class="lnum">   4:  </span>        LogToDb(message, details, level, logger);</pre>

  <pre class="alt"><span class="lnum">   5:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsEmailLoggingEnabled)</pre>

  <pre><span class="lnum">   6:  </span>        LogToEmail(message, details, level, logger);</pre>

  <pre class="alt"><span class="lnum">   7:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsFileLoggingEnabled)</pre>

  <pre><span class="lnum">   8:  </span>        LogToFile(message, details, level, logger);</pre>

  <pre class="alt"><span class="lnum">   9:  </span>}</pre>

  <pre><span class="lnum">  10:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  11:  </span><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Log(Exception ex, <span class="kwrd">string</span> logger)</pre>

  <pre><span class="lnum">  12:  </span>{</pre>

  <pre class="alt"><span class="lnum">  13:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsDbLoggingEnabled)</pre>

  <pre><span class="lnum">  14:  </span>        LogToDb(ex, logger);</pre>

  <pre class="alt"><span class="lnum">  15:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsEmailLoggingEnabled)</pre>

  <pre><span class="lnum">  16:  </span>        LogToEmail(ex, logger);</pre>

  <pre class="alt"><span class="lnum">  17:  </span>    <span class="kwrd">if</span> (LoggingHandler.IsFileLoggingEnabled)</pre>

  <pre><span class="lnum">  18:  </span>        LogToFile(ex, logger);</pre>

  <pre class="alt"><span class="lnum">  19:  </span>}</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>
So that’s it for our logging.&#160; If you want to download the latest code with all of the unit tests, <a title="Veritas Part 8" href="http://chrisrisner.com/upload/Veritas Part 8.zip">you can do so here</a>.&#160; You may notice that they’re missing tests for the email logging.&#160; I haven’t decided on the best way to handle those yet so they aren’t there.&#160;  ]]></description><pubDate>Thu, 19 Aug 2010 02:00:00 GMT</pubDate></item><item><title><![CDATA[ Running in the Free Press Half Marathon and Raising Money for the American Cancer Society ]]></title><link>http://chrisrisner.com/Running-in-the-Free-Press-Half-Marathon-and-Raising-Money-for-the-American-Cancer-Society</link><guid isPermaLink="true">http://chrisrisner.com/Running-in-the-Free-Press-Half-Marathon-and-Raising-Money-for-the-American-Cancer-Society</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/americancancersociety.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="American Cancer Society" border="0" alt="American Cancer Society" align="right" src="http://chrisrisner.com/upload/americancancersociety.jpg" width="244" height="148" /></a> Last year, instead of running any half marathons, I took part in the <a title="Freep Marathon" href="http://www.freepmarathon.com/">Detroit Freepress Marathon</a> Relay along with 4 other people from work.&#160; After that, people started to get more motivated and wanted to run the Half this year.&#160; So along with 4 or 5 other people, I’m going to run the <a title="Free Press Half Marathon" href="http://www.freepmarathon.com/">Free Press Half Marathon</a> this year in October.&#160; In addition to running the Half, I’m raising money for the <a title="American Cancer Society" href="http://www.cancer.org/">American Cancer Society</a>.&#160; </p>  <p>I think we’ve all been touched by Cancer in one way or another.&#160; Even if not a direct relative, you probably know someone that’s had it or have a friend that’s known someone that does.&#160; Every little bit helps as we try to find a cure.&#160; As of writing this, I’ve raised $100 and need to hit at least $500.&#160; If you’d like to donate (and any donation would be greatly appreciated by both myself and ACS) you can do so <a title="Donate to ACS" href="http://main.acsevents.org/goto/risner">here</a>. </p> ]]></description><pubDate>Wed, 04 Aug 2010 14:15:00 GMT</pubDate></item><item><title><![CDATA[ How do you Play Monopoly? ]]></title><link>http://chrisrisner.com/How-do-you-Play-Monopoly-</link><guid isPermaLink="true">http://chrisrisner.com/How-do-you-Play-Monopoly-</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/MonopolyGuy.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Monopoly Guy" border="0" alt="Monopoly Guy" align="right" src="http://chrisrisner.com/upload/MonopolyGuy.jpg" width="244" height="225" /></a> Last week a friend of mine from Arizona was visiting Michigan and had we had a chance to hang out with him for a couple of nights.&#160; While he was here, he purchased for Erin and I our first edition of Monopoly.&#160; Erin and I have of course played before but WE have never owned it.&#160; Having few people willing to play the fast-paced property-trading game in the overly warm state of Arizona, he relished the opportunity to sucker Erin and I into a game (or two).&#160; After purchasing a copy from the local store, we got everything out and started playing.&#160; I quickly learned that there are a couple rules that he is use to that I wasn’t.&#160; </p>  <p>First and foremost, he doesn’t put any money in the middle.&#160; <strong>No $500 to start and no tax money or money from Chance or Community Chest.</strong>&#160; Growing up, I always put a fresh $500 in there and replaced that every time someone landed on Free Parking (who then took all the money).&#160; I was ok with this one but the next one was just ridiculous.&#160; <strong>If you have multiple railroads and someone lands on one of them, even if the others are mortgaged, you still collect the amount for having that many railroads.</strong>&#160; This is just crazy.&#160; He was pretty adamant that this was “the rule” but I had to overrule and call a “House Rule” to block him.&#160; In my mind, if you have two railroads and someone lands on one, they owe you $50.&#160; If however, the other railroad is mortgaged, it’s $25.&#160; Period.&#160; There’s no way around this one.&#160; Thankfully, <a title="Monopoly Rules" href="http://www.hasbro.com/common/instruct/monins.pdf">Hasbro’s official rules agree with me</a>!&#160; </p>  <p>So the question is, how do you play Monopoly?&#160; Are there any weird rules you follow in your house?&#160; Any idea why you have these rules? </p> ]]></description><pubDate>Tue, 27 Jul 2010 23:58:00 GMT</pubDate></item><item><title><![CDATA[ Veritas – Site Configuration – Part 7 ]]></title><link>http://chrisrisner.com/Veritas-–-Site-Configuration-–-Part-7</link><guid isPermaLink="true">http://chrisrisner.com/Veritas-–-Site-Configuration-–-Part-7</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/634003144233522332.jpg"><img style="border-right-width: 0px; margin: 0px 0px 10px 5px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Veritas" border="0" alt="Veritas" align="right" src="http://chrisrisner.com/upload/634003144233522332.jpg" width="195" height="36"></a> To continue with the scheme of the <a title="Last Veritas Entry" href="http://chrisrisner.com/Veritas-%E2%80%93-Data-Access-with-Entity-Framework-4-0-%E2%80%93-Part-6">last entry</a>, we’re going to again depart from our <a title="Veritas Series" href="http://chrisrisner.com/Veritas--Creating-a-Blog-Engine-with-MVC-2-and--Net-4-0-%E2%80%93-Part-1">originally planned series</a>.&nbsp; Today we’re going to talk about our Blog Configuration.&nbsp; As we discussed in the <a title="Initial Database Design" href="http://chrisrisner.com/Veritas--Database-Design-%E2%80%93-Part-2">initial database design entry</a>, our blog config database table primarily consists of an XML column.&nbsp; Instead of creating a column for each setting we might want, we’ll store it all dynamically as XML.&nbsp; Furthermore, there is no way I’m going to think of all the config settings we’ll want while I’m writing this.&nbsp; Rather then trying to update this entry every time I think of something new, we’ll just outline what we’re going to do in our BlogConfig object so when we decide to add something else down the road, you’ll understand.&nbsp; First we’ll add a BlogConfig class to the Models folder in our DataLayer.&nbsp; This will be a partial class and will expand on our already created BlogConfig object (it was created as part of our Entity Framework EDMX):</p> <div class="csharpcode"><pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">namespace</span> Veritas.DataLayer.Models</pre><pre><span class="lnum">   2:  </span>{</pre><pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> BlogConfig</pre><pre><span class="lnum">   4:  </span>    {</pre><pre class="alt"><span class="lnum">   5:  </span>        </pre><pre><span class="lnum">   6:  </span>    }</pre><pre class="alt"><span class="lnum">   7:  </span>}</pre></div>
<p>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
We’re probably going to end up with dozens of settings (at least) but we’re only going to handle three of them for now.&nbsp; We’ll add a boolean that will control if comments are allowed on the site, a string to contain the “about” information of the blog, and an int to store the number of posts:</p>
<div class="csharpcode"><pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">namespace</span> Veritas.DataLayer.Models</pre><pre><span class="lnum">   2:  </span>{</pre><pre class="alt"><span class="lnum">   3:  </span>    <span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> BlogConfig</pre><pre><span class="lnum">   4:  </span>    {</pre><pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> <span class="kwrd">bool</span> AllowComments { get; set; }</pre><pre><span class="lnum">   6:  </span>        <span class="kwrd">public</span> <span class="kwrd">string</span> BlogAbout { get; set; }        </pre><pre class="alt"><span class="lnum">   7:  </span>        <span class="kwrd">public</span> <span class="kwrd">int</span> PostCount { get; set; }</pre><pre><span class="lnum">   8:  </span>    }</pre><pre class="alt"><span class="lnum">   9:  </span>}</pre></div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>

<p></p>
<p></p>
<p>Now, since we’re not making columns for any of these, we’re going to need to load them from the xml column whenever we load our BlogConfig object and pull them into the xml when we save it.&nbsp; Lastly we’ll add methods to load our xml from the properties and to load the properties from the xml:</p>
<div class="csharpcode"><pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> LoadConfigFromXml()</pre><pre><span class="lnum">   2:  </span>{</pre><pre class="alt"><span class="lnum">   3:  </span>    XmlDocument doc = <span class="kwrd">new</span> XmlDocument();</pre><pre><span class="lnum">   4:  </span>    doc.LoadXml(<span class="kwrd">this</span>.ConfigXml);            </pre><pre class="alt"><span class="lnum">   5:  </span>    <span class="kwrd">if</span> (doc.DocumentElement[<span class="str">"AllowComments"</span>] != <span class="kwrd">null</span>)</pre><pre><span class="lnum">   6:  </span>        <span class="kwrd">this</span>.AllowComments = Convert.ToBoolean(doc.DocumentElement[<span class="str">"AllowComments"</span>].InnerText);</pre><pre class="alt"><span class="lnum">   7:  </span>    <span class="kwrd">if</span> (doc.DocumentElement[<span class="str">"BlogAbout"</span>] != <span class="kwrd">null</span>)</pre><pre><span class="lnum">   8:  </span>        <span class="kwrd">this</span>.BlogAbout = doc.DocumentElement[<span class="str">"BlogAbout"</span>].InnerText;</pre><pre class="alt"><span class="lnum">   9:  </span>    <span class="kwrd">if</span> (doc.DocumentElement[<span class="str">"PostCount"</span>] != <span class="kwrd">null</span>)</pre><pre><span class="lnum">  10:  </span>        <span class="kwrd">this</span>.PostCount = Convert.ToInt32(doc.DocumentElement[<span class="str">"PostCount"</span>].InnerText);</pre><pre class="alt"><span class="lnum">  11:  </span>}</pre><pre><span class="lnum">  12:  </span>&nbsp;</pre><pre class="alt"><span class="lnum">  13:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> BuildXmlFromConfig()</pre><pre><span class="lnum">  14:  </span>{</pre><pre class="alt"><span class="lnum">  15:  </span>    XElement blogConfigXml = </pre><pre><span class="lnum">  16:  </span>        <span class="kwrd">new</span> XElement(<span class="str">"BlogConfig"</span>,</pre><pre class="alt"><span class="lnum">  17:  </span>            <span class="kwrd">new</span> XElement(<span class="str">"AllowComments"</span>, <span class="kwrd">this</span>.AllowComments),</pre><pre><span class="lnum">  18:  </span>            <span class="kwrd">new</span> XElement(<span class="str">"BlogAbout"</span>, <span class="kwrd">this</span>.BlogAbout),</pre><pre class="alt"><span class="lnum">  19:  </span>            <span class="kwrd">new</span> XElement(<span class="str">"PostCount"</span>, <span class="kwrd">this</span>.PostCount)</pre><pre><span class="lnum">  20:  </span>            );            </pre><pre class="alt"><span class="lnum">  21:  </span>    <span class="kwrd">this</span>.ConfigXml = blogConfigXml.ToString().Replace(<span class="str">"\r\n  "</span>, <span class="str">""</span>).Replace(<span class="str">"\r\n"</span>, <span class="str">""</span>);            </pre><pre><span class="lnum">  22:  </span>}</pre></div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>

<p>As we add (many) more config settings, we’ll have to alter these methods but you get the basic idea of how we’re storing and reading our configuration xml.&nbsp; I added in unit tests for both of these methods as well.&nbsp; You can <a title="Veritas Part 7" href="http://chrisrisner.com/upload/Veritas Part 7.zip">get the latest here</a>.</p><pre>&nbsp;</pre> ]]></description><pubDate>Thu, 22 Jul 2010 23:42:00 GMT</pubDate></item><item><title><![CDATA[ Veritas – Data Access with Entity Framework 4.0 – Part 6 ]]></title><link>http://chrisrisner.com/Veritas-–-Data-Access-with-Entity-Framework-4-0-–-Part-6</link><guid isPermaLink="true">http://chrisrisner.com/Veritas-–-Data-Access-with-Entity-Framework-4-0-–-Part-6</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/634003144233522332.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Veritas Blog Engine" border="0" alt="Veritas" align="right" src="http://chrisrisner.com/upload/634003144233522332.jpg" width="195" height="36" /></a> If you were paying attention, you know that part 6 in our <a title="Veritas Blog Engine" href="http://chrisrisner.com/Veritas--Creating-a-Blog-Engine-with-MVC-2-and--Net-4-0-%E2%80%93-Part-1">Veritas Blog Engine series</a> was supposed to be about Error Logging.&#160; Well, we’re going to go a bit out of order and do Data Access first.&#160; The reason for this is that we’re going to use a lot of our data access methods in the sections I originally thought we’d write first.&#160; I ran into quite a bit of <a title="Entity Framework 3.5" href="http://chrisrisner.com/MVC2-%E2%80%93-Adding-Data-Annotation-Validation-for-Entity-Framework-Entities">trouble the last time I played with Entity Framework</a> when it was 3.5.&#160; Thankfully, they made quite a few improvements with 4.0 so we’re going to give it another try.</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/VeritasEDMX.jpg"><img style="border-right-width: 0px; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Veritas EDMX" border="0" alt="Veritas EDMX" align="left" src="http://chrisrisner.com/upload/VeritasEDMX.jpg" width="239" height="244" /></a> First things first, if you haven’t already done so, add a Models folder to your DataLayer project.&#160; All of our database objects and any extensions will sit in this folder and namespace.&#160; After that, we’ll add a “ADO .Net Entity Data Model” which is the Entity Framework file that we generate all of our database classes and connections in.&#160; Like every past version of Microsoft’s “This is the way to do database access”, we get to generate the majority of our code straight from the database.&#160; Included in this is the same functionality we had with the Linq2Sql generator for pluralizing / singularizing object names (though now it’s optional) as well as including foreign key columns in the models (which will hopefully fix the FK problems that plagued 3.5 (seriously it was like they designed it to be hard to have foreign key constraints).&#160; Once we’ve selected all of our tables and tell it to generate we’re given an EDMX file and presented with a fantastic database diagram view.&#160; Now, technically, we’ve generated our database access.&#160; We could call it a day.&#160; However, since we’re using the <a title="repository" href="http://chrisrisner.com/Veritas-%E2%80%93-Base-Objects-%E2%80%93-Part-5">repository pattern</a> and we want all of our data access methods to be in one place, we’ll go ahead and create all of those methods in the repository class we made in the last entry.</p>  <p>Before we can add any data access methods we need to add a instance of our Entities object (EDMX) to our repository like so:</p>  <div class="csharpcode">   <pre class="alt"><span class="kwrd">private</span> VeritasBlogDBV3Entities db = <span class="kwrd">new</span> VeritasBlogDBV3Entities();</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p>So inside of our repository class we’ll use db. to do all our database interaction.&#160; The first method we’ll create is our Save method.&#160; This method handles saving any inserts, updates, and deletes after they’re done:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="rem">/// &lt;summary&gt;</span></pre>

  <pre><span class="lnum">   2:  </span><span class="rem">/// Saves all DB changes and then accepts the changes.</span></pre>

  <pre class="alt"><span class="lnum">   3:  </span><span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre><span class="lnum">   4:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> Save()</pre>

  <pre class="alt"><span class="lnum">   5:  </span>{</pre>

  <pre><span class="lnum">   6:  </span>    db.SaveChanges(System.Data.Objects.SaveOptions.AcceptAllChangesAfterSave);</pre>

  <pre class="alt"><span class="lnum">   7:  </span>}</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>We’ll call this method after doing any DB changes (or after any group of DB changes if we’re not doing them individually).&#160; After this, we’ll add entries (separated out into regions) for each of our objects for adding and deleting.&#160; So for example, here are the methods for the BlogConfig object:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="preproc">#region</span> BlogConfig</pre>

  <pre><span class="lnum">   2:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   3:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> Add(BlogConfig blogConfig)</pre>

  <pre><span class="lnum">   4:  </span>{</pre>

  <pre class="alt"><span class="lnum">   5:  </span>    db.BlogConfigs.AddObject(blogConfig);</pre>

  <pre><span class="lnum">   6:  </span>}</pre>

  <pre class="alt"><span class="lnum">   7:  </span>&#160;</pre>

  <pre><span class="lnum">   8:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> Delete(BlogConfig blogConfig)</pre>

  <pre class="alt"><span class="lnum">   9:  </span>{</pre>

  <pre><span class="lnum">  10:  </span>    db.BlogConfigs.DeleteObject(blogConfig);</pre>

  <pre class="alt"><span class="lnum">  11:  </span>}</pre>

  <pre><span class="lnum">  12:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  13:  </span><span class="preproc">#endregion</span></pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>These are pretty simple methods and just handle telling our entity object that we want to insert or delete something.&#160; The Save method still has to be called after each of these.&#160; A quick note on the delete methods:&#160; we may or may not end up ever using them.&#160; Typically I don’t like deleting data as much as “marking it inactive” for historical purposes.&#160; We’re going to write some unit tests in a second so we’re going to write a method to pull all our BlogConfigs from the DB.&#160; We won’t end up using this anywhere but in our unit test.</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> IEnumerable&lt;BlogConfig&gt; GetAllBlogConfigs()</pre>

  <pre><span class="lnum">   2:  </span>{</pre>

  <pre class="alt"><span class="lnum">   3:  </span>     <span class="kwrd">return</span> db.BlogConfigs;</pre>

  <pre><span class="lnum">   4:  </span>}</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Now, before we can actually write some unit tests, we need to implement the StartTransaction and RollbackTransaction methods we made in the last entry.&#160; These methods will be called before and after any unit tests so we’re not actually putting anything in the database.&#160; </p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> DbTransaction Transaction { get; set; }</pre>

  <pre><span class="lnum">   2:  </span><span class="rem">/// &lt;summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">   3:  </span><span class="rem">/// Will create a new transation.  </span></pre>

  <pre><span class="lnum">   4:  </span><span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> StartTransaction()</pre>

  <pre><span class="lnum">   6:  </span>{</pre>

  <pre class="alt"><span class="lnum">   7:  </span>    db.Connection.Open();</pre>

  <pre><span class="lnum">   8:  </span>    DbTransaction trans = db.Connection.BeginTransaction();</pre>

  <pre class="alt"><span class="lnum">   9:  </span>    <span class="kwrd">this</span>.Transaction = trans;</pre>

  <pre><span class="lnum">  10:  </span>}</pre>

  <pre class="alt"><span class="lnum">  11:  </span>&#160;</pre>

  <pre><span class="lnum">  12:  </span><span class="rem">/// &lt;summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  13:  </span><span class="rem">/// Rolls back a transation. </span></pre>

  <pre><span class="lnum">  14:  </span><span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  15:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> RollbackTransaction()</pre>

  <pre><span class="lnum">  16:  </span>{</pre>

  <pre class="alt"><span class="lnum">  17:  </span>    <span class="kwrd">this</span>.Transaction.Rollback();</pre>

  <pre><span class="lnum">  18:  </span>}</pre>
</div>

<p><style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>Now that these methods are implemented, we just need to make a base test class to handle calling these.</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span>[TestClass()]</pre>

  <pre><span class="lnum">   2:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> TestBase</pre>

  <pre class="alt"><span class="lnum">   3:  </span>{</pre>

  <pre><span class="lnum">   4:  </span>    <span class="kwrd">public</span> VeritasRepository repo = VeritasRepository.GetInstance();</pre>

  <pre class="alt"><span class="lnum">   5:  </span>&#160;</pre>

  <pre><span class="lnum">   6:  </span>    <span class="rem">//Use TestInitialize to run code before running each test</span></pre>

  <pre class="alt"><span class="lnum">   7:  </span>    [TestInitialize()]</pre>

  <pre><span class="lnum">   8:  </span>    <span class="kwrd">public</span> <span class="kwrd">void</span> MyTestInitialize()</pre>

  <pre class="alt"><span class="lnum">   9:  </span>    {</pre>

  <pre><span class="lnum">  10:  </span>        repo.StartTransaction();</pre>

  <pre class="alt"><span class="lnum">  11:  </span>        repo.Save();</pre>

  <pre><span class="lnum">  12:  </span>    }</pre>

  <pre class="alt"><span class="lnum">  13:  </span>&#160;</pre>

  <pre><span class="lnum">  14:  </span>    <span class="rem">//Use TestCleanup to run code after each test has run</span></pre>

  <pre class="alt"><span class="lnum">  15:  </span>    [TestCleanup()]</pre>

  <pre><span class="lnum">  16:  </span>    <span class="kwrd">public</span> <span class="kwrd">void</span> MyTestCleanup()</pre>

  <pre class="alt"><span class="lnum">  17:  </span>    {</pre>

  <pre><span class="lnum">  18:  </span>        repo.RollbackTransaction();</pre>

  <pre class="alt"><span class="lnum">  19:  </span>    }</pre>

  <pre><span class="lnum">  20:  </span>}</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p></p>

<p>Now we have everything we need to actually write a unit test to test adding a new BlogConfig:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="rem">/// &lt;summary&gt;</span></pre>

  <pre><span class="lnum">   2:  </span><span class="rem">///A test for Add BlogConfig</span></pre>

  <pre class="alt"><span class="lnum">   3:  </span><span class="rem">///&lt;/summary&gt;</span></pre>

  <pre><span class="lnum">   4:  </span>[TestMethod()]</pre>

  <pre class="alt"><span class="lnum">   5:  </span><span class="kwrd">public</span> <span class="kwrd">void</span> AddBlogConfigTest()</pre>

  <pre><span class="lnum">   6:  </span>{</pre>

  <pre class="alt"><span class="lnum">   7:  </span>    BlogConfig blogConfig = <span class="kwrd">new</span> BlogConfig()</pre>

  <pre><span class="lnum">   8:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   9:  </span>        Host = <span class="str">&quot;test.com&quot;</span>,</pre>

  <pre><span class="lnum">  10:  </span>        LastUpdateDate = DateTime.Now,</pre>

  <pre class="alt"><span class="lnum">  11:  </span>        CreateDate = DateTime.Now,</pre>

  <pre><span class="lnum">  12:  </span>        ConfigXml = <span class="str">&quot;&lt;BlogConfig&gt;&lt;/BlogConfig&gt;&quot;</span></pre>

  <pre class="alt"><span class="lnum">  13:  </span>    };</pre>

  <pre><span class="lnum">  14:  </span>    repo.Add(blogConfig);</pre>

  <pre class="alt"><span class="lnum">  15:  </span>    repo.Save();</pre>

  <pre><span class="lnum">  16:  </span>    <span class="rem">//Check the db for changes</span></pre>

  <pre class="alt"><span class="lnum">  17:  </span>    var configs = repo.GetAllBlogConfigs().ToArray();</pre>

  <pre><span class="lnum">  18:  </span>    var testConfig = configs.Where(p =&gt; p.Host == <span class="str">&quot;test.com&quot;</span>).SingleOrDefault();</pre>

  <pre class="alt"><span class="lnum">  19:  </span>    Assert.IsNotNull(testConfig);            </pre>

  <pre><span class="lnum">  20:  </span>}</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p></p>

<p>Since this class implements our TestBase class, before this unit test is called, we’re getting a new instance of VeritasRepository and calling StartTransaction on it.&#160; When the test is done, it will call the RollbackTransaction method on the repo.&#160; If everything goes well, it will create a new config object, insert it into the database, save that change, pull it back, and make sure it comes back from the DB.&#160; Since most of our tests (such as our DeleteConfig test) will rely on having a BlogConfig and a BlogUser (if not many more things) to already be in the DB, we’ll eventually insert all of these in the test initialize but for now, we can add all of our Add / Delete methods and create tests for them.&#160; Since we need to be able to pull records back from the database to make sure our tests are working, we’ll need to add more methods like the GetAllBlogConfigs seen above.&#160; There are a lot of methods that we’ll in our repository that we’re not going to list here so if you want to see them all, download the files and check out the repo.&#160; As of now, we’ve got what should be all the data access methods we’ll need as well as the unit tests for all of them.&#160; As always, you can <a title="Veritas Part 6" href="http://chrisrisner.com/upload/Veritas Part 6.zip">download the latest here</a>.</p> ]]></description><pubDate>Mon, 12 Jul 2010 22:51:00 GMT</pubDate></item><item><title><![CDATA[ Veritas – Base Objects – Part 5 ]]></title><link>http://chrisrisner.com/Veritas-–-Base-Objects-–-Part-5</link><guid isPermaLink="true">http://chrisrisner.com/Veritas-–-Base-Objects-–-Part-5</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/634003144233522332.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 5px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Veritas" border="0" alt="Veritas" align="right" src="http://chrisrisner.com/upload/634003144233522332.jpg" width="195" height="36" /></a> Now that we’ve established our <a title="Database" href="http://chrisrisner.com/Veritas--Database-Design-%E2%80%93-Part-2">database</a> and our <a title="Project Structure" href="http://chrisrisner.com/Veritas-%E2%80%93-Creating-the-Project-and-Solution-Structure-%E2%80%93-Part-4">initial project structure</a>, we can finally start coding.&#160; We’ll start our coding by creating some of the base objects we’re going to use throughout our application.&#160; I know, after 4 entries, can’t we actually make the site show something?&#160;&#160; We could but I don’t want to start showing stuff and then go back to refactor stuff if we can get some of it done ahead of time.</p>  <p>The first thing we’ll create is our repository class that' we’ll be using for Data Access.&#160; We won’t actually handle our data access quite yet, but we’re going to create our interface for accessing that data.&#160; We’ll add a new class to the DataLayer named “VeritasRepository”.&#160; For now, we’ll just implement the repository pattern inside this class:   <br /></p>  <div class="csharpcode">   <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> VeritasRepository</pre>

  <pre><span class="lnum">   2:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">internal</span> <span class="kwrd">const</span> <span class="kwrd">string</span> CACHE_KEY = <span class="str">&quot;_VeritasRepository_Cache_Key&quot;</span>;</pre>

  <pre><span class="lnum">   4:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">private</span> VeritasRepository() { }</pre>

  <pre><span class="lnum">   6:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   7:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre><span class="lnum">   8:  </span>        <span class="rem">/// Static method to get an instance of our Veritas Repostiory.  </span></pre>

  <pre class="alt"><span class="lnum">   9:  </span>        <span class="rem">/// Checks to see if we have a context in case we're using </span></pre>

  <pre><span class="lnum">  10:  </span>        <span class="rem">/// this in a unit test.</span></pre>

  <pre class="alt"><span class="lnum">  11:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre><span class="lnum">  12:  </span>        <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

  <pre class="alt"><span class="lnum">  13:  </span>        <span class="kwrd">public</span> <span class="kwrd">static</span> VeritasRepository GetInstance()</pre>

  <pre><span class="lnum">  14:  </span>        {</pre>

  <pre class="alt"><span class="lnum">  15:  </span>            <span class="kwrd">if</span> (HttpContext.Current == <span class="kwrd">null</span>)</pre>

  <pre><span class="lnum">  16:  </span>                <span class="kwrd">return</span> <span class="kwrd">new</span> VeritasRepository();</pre>

  <pre class="alt"><span class="lnum">  17:  </span>&#160;</pre>

  <pre><span class="lnum">  18:  </span>            <span class="kwrd">if</span> (HttpContext.Current.Items.Contains(CACHE_KEY))</pre>

  <pre class="alt"><span class="lnum">  19:  </span>                <span class="kwrd">return</span> (VeritasRepository)HttpContext.Current.Items[CACHE_KEY];</pre>

  <pre><span class="lnum">  20:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  21:  </span>            VeritasRepository repo = <span class="kwrd">new</span> VeritasRepository();</pre>

  <pre><span class="lnum">  22:  </span>            HttpContext.Current.Items[CACHE_KEY] = repo;</pre>

  <pre class="alt"><span class="lnum">  23:  </span>            <span class="kwrd">return</span> repo;</pre>

  <pre><span class="lnum">  24:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  25:  </span>&#160;</pre>

  <pre><span class="lnum">  26:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  27:  </span>        <span class="rem">/// Forces us to get a new instace for testing purposes</span></pre>

  <pre><span class="lnum">  28:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  29:  </span>        <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

  <pre><span class="lnum">  30:  </span>        <span class="kwrd">public</span> <span class="kwrd">static</span> VeritasRepository ForceNewInstance()</pre>

  <pre class="alt"><span class="lnum">  31:  </span>        {</pre>

  <pre><span class="lnum">  32:  </span>            VeritasRepository repo = <span class="kwrd">new</span> VeritasRepository();</pre>

  <pre class="alt"><span class="lnum">  33:  </span>            <span class="kwrd">if</span> (HttpContext.Current.Items.Contains(CACHE_KEY))</pre>

  <pre><span class="lnum">  34:  </span>                HttpContext.Current.Items[CACHE_KEY] = repo;</pre>

  <pre class="alt"><span class="lnum">  35:  </span>            <span class="kwrd">else</span></pre>

  <pre><span class="lnum">  36:  </span>                HttpContext.Current.Items.Add(CACHE_KEY, repo);</pre>

  <pre class="alt"><span class="lnum">  37:  </span>            <span class="kwrd">return</span> repo;</pre>

  <pre><span class="lnum">  38:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  39:  </span>&#160;</pre>

  <pre><span class="lnum">  40:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  41:  </span>        <span class="rem">/// Will create a new transation.  Not implemented now but will be later.</span></pre>

  <pre><span class="lnum">  42:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  43:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> StartTransaction()</pre>

  <pre><span class="lnum">  44:  </span>        {</pre>

  <pre class="alt"><span class="lnum">  45:  </span>            <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException();</pre>

  <pre><span class="lnum">  46:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  47:  </span>&#160;</pre>

  <pre><span class="lnum">  48:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  49:  </span>        <span class="rem">/// Rolls back a transation.  Not implemented now but will be later.</span></pre>

  <pre><span class="lnum">  50:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  51:  </span>        <span class="kwrd">public</span> <span class="kwrd">void</span> RollbackTransaction()</pre>

  <pre><span class="lnum">  52:  </span>        {</pre>

  <pre class="alt"><span class="lnum">  53:  </span>            <span class="kwrd">throw</span> <span class="kwrd">new</span> NotImplementedException();</pre>

  <pre><span class="lnum">  54:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  55:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>That’s pretty much it for our data layer for now.&#160; No we’ll do a couple things in our Business Layer.&#160; We’ll start by adding a new folder named “Screens”.&#160; To that folder we’ll add a new class named “ScreenBase”.&#160; For all of our views (to be created later) we’ll create a strongly typed Screen that we’ll tie to that view. Our ScreenBase is going to be an abstract class that will contain an instance of our repository class (so all of our child Screens will have access to it) and a few abstract properties and methods:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> ScreenBase</pre>

  <pre><span class="lnum">   2:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">protected</span> VeritasRepository repo = VeritasRepository.GetInstance();</pre>

  <pre><span class="lnum">   4:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">public</span> ScreenBase()  {  }</pre>

  <pre><span class="lnum">   6:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   7:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre><span class="lnum">   8:  </span>        <span class="rem">/// Determines if the entites associated with the view </span></pre>

  <pre class="alt"><span class="lnum">   9:  </span>        <span class="rem">/// are valid or not.</span></pre>

  <pre><span class="lnum">  10:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre class="alt"><span class="lnum">  11:  </span>        <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">bool</span> IsValid { get; }</pre>

  <pre><span class="lnum">  12:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">  13:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre><span class="lnum">  14:  </span>        <span class="rem">/// Loads up whatever entities this screen may need.</span></pre>

  <pre class="alt"><span class="lnum">  15:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre><span class="lnum">  16:  </span>        <span class="kwrd">protected</span> <span class="kwrd">abstract</span> <span class="kwrd">void</span> LoadScreen();        </pre>

  <pre class="alt"><span class="lnum">  17:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>The last thing we’ll create today are some base objects in our UI project.&#160; Specifically we’ll create a Form class (to override some of the functionality of the html helpers) and some overrides of the ViewPages, ViewUserControl, and ViewMasterPage.&#160; We’ll start by adding a new class named “VeritasForm” to the Views folder:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> VeritasForm</pre>

  <pre><span class="lnum">   2:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">private</span> VeritasRepository repo = VeritasRepository.GetInstance();</pre>

  <pre><span class="lnum">   4:  </span>        <span class="kwrd">internal</span> <span class="kwrd">const</span> <span class="kwrd">string</span> CACHE_KEY = <span class="str">&quot;_VeritasForm_Cache_Key&quot;</span>;</pre>

  <pre class="alt"><span class="lnum">   5:  </span>        <span class="kwrd">internal</span> HtmlHelper Helper { get; set; }</pre>

  <pre><span class="lnum">   6:  </span>&#160;</pre>

  <pre class="alt"><span class="lnum">   7:  </span>        <span class="rem">/// &lt;summary&gt;</span></pre>

  <pre><span class="lnum">   8:  </span>        <span class="rem">/// Our static accessor so we can easily access this from the views.</span></pre>

  <pre class="alt"><span class="lnum">   9:  </span>        <span class="rem">/// &lt;/summary&gt;</span></pre>

  <pre><span class="lnum">  10:  </span>        <span class="rem">/// &lt;param name=&quot;helper&quot;&gt;&lt;/param&gt;</span></pre>

  <pre class="alt"><span class="lnum">  11:  </span>        <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

  <pre><span class="lnum">  12:  </span>        <span class="kwrd">public</span> <span class="kwrd">static</span> VeritasForm GetInstance(HtmlHelper helper)</pre>

  <pre class="alt"><span class="lnum">  13:  </span>        {</pre>

  <pre><span class="lnum">  14:  </span>            <span class="kwrd">if</span> (helper.ViewContext.HttpContext.Items.Contains(CACHE_KEY))</pre>

  <pre class="alt"><span class="lnum">  15:  </span>                <span class="kwrd">return</span> (VeritasForm)helper.ViewContext.HttpContext.Items[CACHE_KEY];</pre>

  <pre><span class="lnum">  16:  </span>            VeritasForm form = <span class="kwrd">new</span> VeritasForm(helper);</pre>

  <pre class="alt"><span class="lnum">  17:  </span>            helper.ViewContext.HttpContext.Items.Add(CACHE_KEY, form);</pre>

  <pre><span class="lnum">  18:  </span>            <span class="kwrd">return</span> form;</pre>

  <pre class="alt"><span class="lnum">  19:  </span>        }</pre>

  <pre><span class="lnum">  20:  </span>       </pre>

  <pre class="alt"><span class="lnum">  21:  </span>        <span class="kwrd">private</span> VeritasForm(HtmlHelper helper)</pre>

  <pre><span class="lnum">  22:  </span>        {</pre>

  <pre class="alt"><span class="lnum">  23:  </span>            Helper = helper;</pre>

  <pre><span class="lnum">  24:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  25:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Later on we’ll put overrides on helper methods like ActionLink, DropdownList, and more here.&#160; Moving along, we’ll override the ViewMasterPage and create the “VeritasViewMasterPage”:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> VeritasViewMasterPage : ViewMasterPage</pre>

  <pre><span class="lnum">   2:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> VeritasForm VeritasForm</pre>

  <pre><span class="lnum">   4:  </span>        {</pre>

  <pre class="alt"><span class="lnum">   5:  </span>            get</pre>

  <pre><span class="lnum">   6:  </span>            {</pre>

  <pre class="alt"><span class="lnum">   7:  </span>                <span class="kwrd">return</span> VeritasForm.GetInstance(Html);</pre>

  <pre><span class="lnum">   8:  </span>            }</pre>

  <pre class="alt"><span class="lnum">   9:  </span>        }</pre>

  <pre><span class="lnum">  10:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p>We’re just adding the VeritasForm as a member of our overridden Master Page.&#160;&#160; The reason for this is so that later on when we have master pages, we’ll change what they inherit to the VeritasViewMasterPage and we’ll have easy access to VeritasForm.&#160; We’re going to do the same thing for the ViewPage and the ViewUserControl, though one thing to note is that for both of these, we have to override both the version that takes in a templated type and the version that does not.</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> VeritasViewPage&lt;T&gt; : ViewPage&lt;T&gt; <span class="kwrd">where</span> T : <span class="kwrd">class</span></pre>

  <pre><span class="lnum">   2:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> VeritasForm VeritasForm</pre>

  <pre><span class="lnum">   4:  </span>        {</pre>

  <pre class="alt"><span class="lnum">   5:  </span>            get</pre>

  <pre><span class="lnum">   6:  </span>            {</pre>

  <pre class="alt"><span class="lnum">   7:  </span>                <span class="kwrd">return</span> VeritasForm.GetInstance(Html);</pre>

  <pre><span class="lnum">   8:  </span>            }</pre>

  <pre class="alt"><span class="lnum">   9:  </span>        }</pre>

  <pre><span class="lnum">  10:  </span>    }</pre>

  <pre class="alt"><span class="lnum">  11:  </span>&#160;</pre>

  <pre><span class="lnum">  12:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> VeritasViewPage : ViewPage</pre>

  <pre class="alt"><span class="lnum">  13:  </span>    {</pre>

  <pre><span class="lnum">  14:  </span>        <span class="kwrd">public</span> VeritasForm VeritasForm</pre>

  <pre class="alt"><span class="lnum">  15:  </span>        {</pre>

  <pre><span class="lnum">  16:  </span>            get</pre>

  <pre class="alt"><span class="lnum">  17:  </span>            {</pre>

  <pre><span class="lnum">  18:  </span>                <span class="kwrd">return</span> VeritasForm.GetInstance(Html);</pre>

  <pre class="alt"><span class="lnum">  19:  </span>            }</pre>

  <pre><span class="lnum">  20:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  21:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>

<p>And here’s the VeritasViewUserControl:</p>

<div class="csharpcode">
  <pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">public</span> <span class="kwrd">class</span> VeritasViewUserControl&lt;T&gt; : ViewUserControl&lt;T&gt; <span class="kwrd">where</span> T : <span class="kwrd">class</span></pre>

  <pre><span class="lnum">   2:  </span>    {</pre>

  <pre class="alt"><span class="lnum">   3:  </span>        <span class="kwrd">public</span> VeritasForm VeritasForm</pre>

  <pre><span class="lnum">   4:  </span>        {</pre>

  <pre class="alt"><span class="lnum">   5:  </span>            get</pre>

  <pre><span class="lnum">   6:  </span>            {</pre>

  <pre class="alt"><span class="lnum">   7:  </span>                <span class="kwrd">return</span> VeritasForm.GetInstance(Html);</pre>

  <pre><span class="lnum">   8:  </span>            }</pre>

  <pre class="alt"><span class="lnum">   9:  </span>        }</pre>

  <pre><span class="lnum">  10:  </span>    }</pre>

  <pre class="alt"><span class="lnum">  11:  </span>&#160;</pre>

  <pre><span class="lnum">  12:  </span>    <span class="kwrd">public</span> <span class="kwrd">class</span> VeritasViewUserControl : ViewUserControl</pre>

  <pre class="alt"><span class="lnum">  13:  </span>    {</pre>

  <pre><span class="lnum">  14:  </span>        <span class="kwrd">public</span> VeritasForm VeritasForm</pre>

  <pre class="alt"><span class="lnum">  15:  </span>        {</pre>

  <pre><span class="lnum">  16:  </span>            get</pre>

  <pre class="alt"><span class="lnum">  17:  </span>            {</pre>

  <pre><span class="lnum">  18:  </span>                <span class="kwrd">return</span> VeritasForm.GetInstance(Html);</pre>

  <pre class="alt"><span class="lnum">  19:  </span>            }</pre>

  <pre><span class="lnum">  20:  </span>        }</pre>

  <pre class="alt"><span class="lnum">  21:  </span>    }</pre>
</div>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p></p>
Now, you might be wondering why we haven’t gone over any tests?&#160; Well unfortunately, most of the things we’ve done require us to do some mocking.&#160; Specifically, we need to be able to mock the ViewContext.&#160; Since we’re not ready to go over that yet, we won’t go over the tests for these methods (yet).&#160; The tests are there, we’re just not implementing them.&#160; You can <a title="Veritas Part 5" href="http://chrisrisner.com/upload/Veritas Part 5.zip">download the latest here</a>. ]]></description><pubDate>Wed, 23 Jun 2010 23:29:00 GMT</pubDate></item><item><title><![CDATA[ Veritas – Creating the Project and Solution Structure – Part 4 ]]></title><link>http://chrisrisner.com/Veritas-–-Creating-the-Project-and-Solution-Structure-–-Part-4</link><guid isPermaLink="true">http://chrisrisner.com/Veritas-–-Creating-the-Project-and-Solution-Structure-–-Part-4</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/634003144233522332.jpg"><img style="border-right-width: 0px; margin: 0px 0px 10px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Veritas" border="0" alt="Veritas" align="right" src="http://chrisrisner.com/upload/634003144233522332.jpg" width="195" height="36" /></a> So far we’ve covered the <a title="Veritas Project" href="http://chrisrisner.com/Veritas--Creating-a-Blog-Engine-with-MVC-2-and--Net-4-0-%E2%80%93-Part-1">basics of what this project is all about</a> and we’ve covered all of the <a title="Database Tables" href="http://chrisrisner.com/Veritas--Database-Design-%E2%80%93-Part-2">database tables</a> we’re going to need.&#160; Now it’s time to start getting into the Visual Studio Solutions and Projects.&#160; Just to clarify again, we’re doing this project in Visual Studio 2010.&#160; Later on we’ll get into stuff that is specific to VS 2010 and .Net 4 so if you’re trying to follow along in VS 2008, things won’t make complete sense down the road.&#160; </p>  <p>Because we want strict control over our project names, we’re going to create our Solution file separate from everything else.&#160; So in Visual Studio, go to New and then Project.&#160; Under “Other Project Types” (this won’t be beneath “Visual C#”) we’re going to select “Visual Studio Solutions” and then “Blank Solution”.&#160; This is going to give us a solution with no precreated projects inside of it which is just what we want.&#160; You might have a naming convention you want to follow but we’re just going to use “Veritas” for the name of our solution.&#160; Once that is done we can create our projects.</p>  <p>Anyone familiar with an <a title="N-Tier Architecture" href="http://en.wikipedia.org/wiki/N-tier">N-tier architecture</a> will understand why we’re going to add 4 different projects to our solution. First we’ll create our UI project.&#160; After going into “Add New Project” we’re going to choose a “ASP .Net MVC 2 Empty Web Application”.&#160; If you haven’t used the MVC project template before, I strongly suggest creating a “ASP .Net MVC 2 Web Application” and understandubg how things work before proceeding.&#160; We’ll name our project “Veritas.UI.Web”.&#160; </p>  <p>Next we need to create our Business Layer and our Data Layer projects.&#160; So go to “Add New Project” and under “Windows” add a “Class Library” named “Veritas.BusinessLayer” and “Veritas.DataLayer”.&#160; After we’ve created these, we can go and add some references we’ll need later.&#160; The BusinessLayer project should reference the DataLayer.&#160; The UI should reference both the BusinessLayer and the DataLayer.&#160; Lastly, we need to add a “Test Project” (located under “Test”) which we’ll use for all of our unit and integration tests.&#160; Go ahead and name it “Veritas.Tests”.</p>  <p>The last thing we’ll do for today is remove some of the default files that were created that we don’t need.&#160; In the business and data layer projects, there will be a “Class1.cs” file that is generated.&#160; Go ahead and delete that.&#160; Once you’re done with that, do the same thing with “UnitTest1.cs” in the tests project.</p>  <p>So now we’re done with our solution and projects.&#160; In the next entry we’ll actually start doing some coding.&#160; If you’d like a look at the project structure as it should be so far, you can <a title="Download Veritas Part 4" href="http://chrisrisner.com/upload/Veritas Part 4.zip">download what we’ve done here</a>.</p> ]]></description><pubDate>Tue, 15 Jun 2010 23:11:00 GMT</pubDate></item><item><title><![CDATA[ Veritas: Database Design Continued – Part 3 ]]></title><link>http://chrisrisner.com/Veritas--Database-Design-Continued-–-Part-3</link><guid isPermaLink="true">http://chrisrisner.com/Veritas--Database-Design-Continued-–-Part-3</guid><description><![CDATA[ <p>In the <a title="Veritas Database Design Part 1" href="http://chrisrisner.com/Veritas--Database-Design-%E2%80%93-Part-2">last entry in this series</a>, we went over the “non-blog” tables in our database.&#160; Now it’s time to cover the tables that store data specific to posts or entries.&#160; We’re going to dive right into it and take a look at the most important table, BlogEntry:     <br /><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlogEntry2.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="BlogEntry" border="0" alt="BlogEntry" src="http://chrisrisner.com/upload/BlogEntry2.jpg" width="244" height="201" /></a> </p>  <p>This table will contain the details specific to an entry.&#160; So Text will be the html or the text for the post.&#160; Keywords will fill the meta keywords for the entry.&#160; Short will be used if we only want to display a shortened version of the html (in order to get more click throughs on RSS feeds for example).&#160; Our entry name will match our title with the exception that it will be HTML encoded (mostly).&#160; Lastly, the BlogAuthorId has a Foreign Key (FK) constraint to the BlogUser table (as mentioned in the previous post).&#160; In addition, BlogConfigId is a FK back to the BlogConfig table as per usual.&#160; Finally, PostType is a value we might use down the road to distinguish between live posts, drafts, or anything else we might store in the table.&#160; Moving along, we’ll look at the BlogViewEntryCount table:</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/blogentryviewcount.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="BlogEntryViewCount" border="0" alt="BlogEntryViewCount" src="http://chrisrisner.com/upload/blogentryviewcount.jpg" width="244" height="104" /></a> </p>  <p></p>  <p>For now the only real point of this table is the WebCount column.&#160; This table just keeps track of the number of times this entry has been loaded via the web.&#160; Down the road, we might add additional columns to see how many times the entry was loaded from an RSS feed or linked from Facebook, or anything else we might want to track.&#160; Each entry will (hopefully) get some comments or feedback but before we can store the feedback, we need a table to store the author of each comment.&#160; Since we’ll likely have repeat commentators we don’t want to have to store their info for every comment, so we’ll have a BlogFeedbackAuthor table:</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlogFeedbackAuthor.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blog Feedback Author" border="0" alt="Blog Feedback Author" src="http://chrisrisner.com/upload/BlogFeedbackAuthor.jpg" width="244" height="134" /></a> </p>  <p>This table will store the name, email, URL fields that we’ll ask for in every comment.&#160; Then we’ll store a total number of feedbacks for the people that enter the same info repeatedly.&#160; Simple enough.&#160; Now we’ll go to the BlogFeedback table:</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlogFeedback2.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blog Feedback" border="0" alt="Blog Feedback" src="http://chrisrisner.com/upload/BlogFeedback2.jpg" width="244" height="233" /></a> </p>  <p>First we have FKs to the BlogEntry table and the BlogFeedbackAuthor table.&#160; From there we are storing details on the actual feedback such as the body, the IP address of the user that entered it, the status it’s in (we’ll tie this to an enum in the code), the title of the feedback, and the user agent of the user.&#160; The NotifyAuthorOnFeedback column will be used to figure out if we should email the feedback author when someone comments after them on the same entry.&#160; Lastly we have Feedback Type which we might use down the road to distinguish between types of feedback.&#160;&#160; Only 4 tables left (for now) so let’s go to the BlogCategory:</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlogCategory.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blog Category" border="0" alt="Blog Category" src="http://chrisrisner.com/upload/BlogCategory.jpg" width="244" height="118" /></a> </p>  <p>Nothing really special here.&#160; The important things are the Title and the IsActive field.&#160; Now we have our BlogEntryCategory table to tie entries to categories:</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlogEntryCategory.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blog Entry Category" border="0" alt="Blog Entry Category" src="http://chrisrisner.com/upload/BlogEntryCategory.jpg" width="244" height="75" /></a> </p>  <p>This table is straight FKs.&#160; Now we’ll get to BlogPage:</p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlogPage.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blog Page" border="0" alt="Blog Page" src="http://chrisrisner.com/upload/BlogPage.jpg" width="244" height="173" /></a> </p>  <p>This table will be used to store pages we might want to host on our site with any sort of static comment.&#160; In the PageContent column we can put any html or javascript we want.&#160; Late we’ll make a way to render this so the user can add any static pages they want without having to get into code or anything like that.&#160; We’re also allowing the user to enter the Meta Keywords and Description.&#160; Finally we’ve got the Page Title (what we’ll actually put in the Title tag) and the Encoded Title (what we’ll use for the URL).&#160; Our last table (for now) will be the Blacklist table: </p>  <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/BlackList.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blacklist" border="0" alt="Blacklist" src="http://chrisrisner.com/upload/BlackList.jpg" width="244" height="80" /></a> </p>  <p>This table will just be used to store the addresses of anyone that wants to opt out of emails.&#160; So if someone comments with a bad address and says they want to be emailed when someone comments after them, the original person has the ability to say “I don’t want these emails!”.&#160; So we’re done (again for now) with our Database Schema.&#160; WOOT!&#160;&#160; Coming up we’ll go over the base project structure.&#160; So that you don’t have to go and create all of these tables yourself, you can download a <a title="Create Veritas Blog DB Script" href="http://chrisrisner.com/upload/CreateVeritasBlogDBScript.zip">SQL script to create all of these tables here (the SQL file is in a ZIP)</a>.
<br /> <br />
<strong>Update 6-27-2010:<br /> BlogCategory's IsActive field should have been a bit field but was incorrectly shown as a nvarchar.</strong></p> ]]></description><pubDate>Thu, 10 Jun 2010 04:00:00 GMT</pubDate></item><item><title><![CDATA[ Where we’re going, we don’t need TVs ]]></title><link>http://chrisrisner.com/Where-we’re-going,-we-don’t-need-TVs</link><guid isPermaLink="true">http://chrisrisner.com/Where-we’re-going,-we-don’t-need-TVs</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/hp8100cinema.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 5px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="HP Cinema 8100" border="0" alt="HP Cinema 8100" align="right" src="http://chrisrisner.com/upload/hp8100cinema.jpg" width="244" height="164" /></a> After visiting <a title="AtomicInternet&#39;s Site" href="http://atomicinternet.homeip.net">AtomicInternet’s house</a> and enjoying / enduring the awesomeness of his projector one too many times, I decided to upgrade my entertainment value.&#160; After informing him of my plans, he immediately and repeatedly shared with me <a title="Projector Review" href="http://gizmodo.com/5381731/1000-1080p-projector-battlemodo-optoma-hd20-vs-vivitek-h1080fd">this review</a> which he in turn obtained from <a title="The Senator" href="http://www.detroitarchive.com/">the Senator</a>.&#160; While the prospect of spending an extra $600 not that appealing, I was convinced in the long run to pony up and get the <a title="Epson HC 8100" href="http://www.epson.com/cgi-bin/Store/jsp/Product.do?BV_UseBVCookie=yes&amp;sku=V11H336120">Epson HC 8100</a>.&#160; Deciding to just move from a TV to a projector wasn’t exactly an easy one.&#160; I couldn’t just move the TV out of a room and put the projector on a table in that room and call it a day.&#160; </p>  <p>To begin with, I wanted to put the projector on the middle floor (I have a tri-level) of my house.&#160; While this would have provided the widest viewing area, there would have been no way to contain and block the light in the room on the main floor.&#160; Outside of making the floor hideous with blackout curtains hanging everywhere, there wasn’t a way to make it work.&#160; Much to Erin’s pleasure, this meant I was back to putting the projector downstairs.&#160; Sadly this didn’t eliminate all of my problems.</p>  <p>Wanting to stream a lot of video, wireless wasn’t really an option.&#160; Unfortunately this meant I would need to run some network cable into the downstairs (to where the projector would be), to the main floor (where I would move the TV and Media Center), as well as into the bedroom so I could eventually stream to there.&#160; After ordering wire from <a title="MonoPrice" href="http://www.monoprice.com">Monoprice</a> I drilled some holes and climbed up into the attic.&#160; Running the wires ended up being almost too easy with the exception of one place.&#160; Downstairs, I needed to run the wires from the living room, into the ceiling, through a shaft about 6” tall (from the ceiling of bottom floor to the bottom of the top floor) and into the laundry room.&#160; I solved this problem by <a title="Wire Hangers" href="http://chrisrisner.com/upload/proj-hanger.JPG">taping together about 8 wire hangers</a> (after straightening them) and taping one wire to that hanger.&#160; After running that through the floorboards, I taped the <a title="hanging wires" href="http://chrisrisner.com/upload/proj-hanging-wires.JPG">other 5 wires</a> (I was running some speaker wire as well) to the wire that had already been run through and pulled them back to the <a title="Wires in Laundry Room" href="http://chrisrisner.com/upload/proj-wires-laundry-room.JPG">laundry room</a> where all my wires would meet.&#160; After this I just had to <a title="Splice and Test Wires" href="http://chrisrisner.com/upload/proj-wires-brad.JPG">splice and test the wires</a> I’d already <a title="Wires in walls" href="http://chrisrisner.com/upload/proj-wires-wall-1.JPG">pulled through the walls</a> to make sure they were working and then put some <a title="Face Plates" href="http://chrisrisner.com/upload/proj-wires-plate.JPG">nice looking plates in front of them</a>.&#160; The last step prior to mounting the projector was to <a title="Move a light Switch" href="http://chrisrisner.com/upload/proj-moveswitch.JPG">move a light switch</a> that would be right in the projector screens path on the wall downstairs.&#160; Despite having to cut our a gang box and having to connect and extend actual power lines, this step ended up being not too difficult.</p>  <p>After all this, I just needed to <a title="Unbox the Projector" href="http://chrisrisner.com/upload/proj-proj-unboxing2.JPG">unbox the projector</a>.&#160; Once that was done, Atomic and the Senator again helped me to drill in the projector mount and <a title="Hang the Projector" href="http://chrisrisner.com/upload/proj-mounted-proj.JPG">hang the projector downstairs</a>.&#160; When all was said and done, I cleaned up a few things and was left with a pretty good looking <a title="Projector" href="http://chrisrisner.com/upload/proj-mounted-proj-2.JPG">projector hanging from the ceiling</a>.&#160; I moved from a 42” screen up to a 106”.&#160; Quite the improvement and one hell of a way to watch movies and play video games.</p> ]]></description><pubDate>Wed, 09 Jun 2010 00:42:00 GMT</pubDate></item><item><title><![CDATA[ New Hosting at Last ]]></title><link>http://chrisrisner.com/New-Hosting-at-Last</link><guid isPermaLink="true">http://chrisrisner.com/New-Hosting-at-Last</guid><description><![CDATA[ <p><a onclick="return hs.expand(this)" class="highslide" href="http://chrisrisner.com/upload/arvixe.jpg"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Arvixe" border="0" alt="Arvixe" align="right" src="http://chrisrisner.com/upload/arvixe.jpg" width="244" height="61" /></a> After finally being <a title="Fed up with GoDaddy" href="http://chrisrisner.com/GoDaddy-and-the-Mysterious-Case-of-Spammed-Email">completely fed up with GoDaddy</a>, it was time to start looking for a new host.&#160; I spent a good amount of time (at least a few hours) looking at several different hosts as well as considering hosting my sites at home (using DYNDNS).&#160; In the end, hosting myself (while being the most flexible option) didn’t work out due to cost.&#160; After shopping around with several hosts I chose <a title="Arvixe" href="http://www.arvixe.com/">Arivxe</a> to host my and several other sites.</p>  <ul>   <li><strong>It’s cheap but offers the options I need       <br /></strong>For less than $80 I got a .Net hosting account that offered unlimited disk space, unlimited band width, hosting of unlimited domains, and unlimited SQL databases.&#160; Now I’m not a complete idiot.&#160; I’m aware that there is a point where “unlimited” isn’t unlimited.&#160; However, none of the sites I host will ever approach that limit.</li>    <li><strong>Upgrades quickly       <br /></strong>When I first signed up, Arvixe wasn’t supporting .Net 4.0 yet (it wasn’t out yet) but they assured me that once it dropped they would start.&#160; Days after .Net 4.0 was released, they were already supporting it.&#160; </li>    <li><strong>Great service</strong>      <br />This is where Arvixe has really shined so far (and I hope continues to do so).&#160; They have a web based support chat on their site that you can use to ask questions prior to ordering or support questions after you already have something.&#160; I’ve never waited more than a few minutes to talk to someone and they’re always helpful with problems.&#160; Instead of “some hosts” where they blame everything on your code and are unwilling to attempt to work with you, Arvixe is willing to do whatever they can to help you solve your problems. </li> </ul>  <p>The only negative point I could make about Arvixe is that some of the initial set up (restoring a database from a different host / your own server) and setting up your config file could be easier.&#160; That being said, under both of these circumstances, the support people were a great help with solving these problems.&#160; While I’ve only been using them for 2 months so far, they are already as easy (if not easier to use) than my previous host and their support is amazingly better.&#160; If you’re in the market for a new host or if you’re fed up with getting crappy support, I’d recommend taking a look at Arvixe.&#160; </p> ]]></description><pubDate>Tue, 08 Jun 2010 00:51:00 GMT</pubDate></item></channel></rss>