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

<channel>
	<title>freemind blogs &#187; Uncategorized</title>
	<atom:link href="http://blogs.freemind.net/index.php/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.freemind.net</link>
	<description></description>
	<lastBuildDate>Thu, 19 Nov 2009 04:49:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Microsoft Earns Freemind Certified Pardner Status for 2010</title>
		<link>http://blogs.freemind.net/index.php/microsoft-earns-freemind-certified-pardner-status-for-2010/84/</link>
		<comments>http://blogs.freemind.net/index.php/microsoft-earns-freemind-certified-pardner-status-for-2010/84/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 04:49:25 +0000</pubDate>
		<dc:creator>Ira Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=84</guid>
		<description><![CDATA[EAGAN, MN &#8211; Freemind Solutions is proud to announce that it has conveyed its &#8220;Certified Pardner&#8221; status upon the upstart software company, Microsoft Corporation. Microsoft, with its primary offices located in Redmond, Washington, has submitted three products to Freemind for its use and analysis. The results of arduous selection and review process has deemed Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blogs.freemind.net/wp-content/uploads/2009/11/pardner.png" alt="pardner.png" border="0" width="350" align="right" />EAGAN, MN &#8211; Freemind Solutions is proud to announce that it has conveyed its &#8220;Certified Pardner&#8221; status upon the upstart software company, Microsoft Corporation. Microsoft, with its primary offices located in Redmond, Washington, has submitted three products to Freemind for its use and analysis. The results of arduous selection and review process has deemed Microsoft worthy of the status of &#8220;Certified Pardner&#8221; for 2010.</p>
<p>A media representative for Microsoft has likely contacted Freemind Solutions to thank them for this honor and to express the desire for Freemind&#8217;s coveted &#8220;Gold Pardner Status&#8221; for 2011. &#8220;It&#8217;s a solid goal for a rather plucky outfit,&#8221; said James Swanson, one of the principals at Freemind Solutions on Microsoft&#8217;s 2011 ambitions. Ira Mitchell, another principal at the firm chimed in, &#8220;I think they&#8217;ve got a shot at it, but it won&#8217;t be because of Expression Studio or IE8.&#8221;</p>
<p>&#8220;I&#8217;m thinking that they probably shouldn&#8217;t submit the Entity Framework either,&#8221; said Swanson, &#8220;but that new Visual Studio and what they&#8217;re doing with Azure could be enough to put them over the top. It&#8217;s early though, we&#8217;ll have to take a closer look later next year.&#8221;</p>
<p>Congratulations to Microsoft Corporation for this momentous achievement! The lucite plaque is in the mail. </p>
<p><strong><br />
In related news, Freemind Solutions has qualified as a Microsoft Certified Partner for the third consecutive year.</strong></p>
<p><br/><br />
<br/></p>
<p><strong><br />
About the companies:<br />
</strong></p>
<p><em>Microsoft Corporation</em> is a multinational computer technology corporation that develops, manufactures, licenses, and supports a wide range of software products for computing devices.</p>
<p><em>Freemind Solutions</em>, an Eagan, Minnesota corporation is a highly regarded professional services firm. Their client background includes litigation support, finance, government services, commercial and retail. For more information, please contact them at (612) 424-9699 or my emailing them at <a href="mailto:info@freemind.net">info@freemind.net</a>.</p>
<p>&#8212;</p>
<p>A number of writers contributed to this release.</p>
<p>© 2009 The Freemind Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed. Learn more about our Privacy Policy.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/microsoft-earns-freemind-certified-pardner-status-for-2010/84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WCF REST Starter Kit to Constant Contact Sample Application</title>
		<link>http://blogs.freemind.net/index.php/wcf-rest-starter-kit-to-constant-contact-sample-application/73/</link>
		<comments>http://blogs.freemind.net/index.php/wcf-rest-starter-kit-to-constant-contact-sample-application/73/#comments</comments>
		<pubDate>Fri, 22 May 2009 17:23:21 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=73</guid>
		<description><![CDATA[I&#8217;ve had a few requests to get more details on how I used the WCF REST Starter Kit to integrate with the Constant Contact AtomPub API (posted here). It&#8217;s shamefully simple but here it is. If you are not satisfied I will give you your money back. Requires: .NET Framework 3.51 WCF REST Starter Kit [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a few requests to get more details on how I used the WCF REST Starter Kit to integrate with the Constant Contact AtomPub API (<a href="http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/">posted here</a>). It&#8217;s shamefully simple but here it is. If you are not satisfied I will give you your money back.</p>
<p>Requires:</p>
<ul>
<li>.NET Framework 3.51</li>
<li><a title="WCF REST Starter Kit Preview 2" href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644">WCF REST Starter Kit Preview 2</a></li>
<li>NUnit/Log4net (included)</li>
<li><a href="http://developer.constantcontact.com/DWSHome">Constant Contact Developer Account</a></li>
</ul>
<p><a href="http://freemind.net/downloads/ConstantContact WCF REST Sample.zip">Download Sample App</a></p>
<p>Notes:</p>
<ul>
<li>Update the app.config with your account settings from Constant Contact.</li>
<li>Sample is using Http Digest for authentication. If there is interest I can update for OAuth.</li>
</ul>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Configuration</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections.Generic</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Freemind.Domain.Email</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">namespace</span> Freemind<span style="color: #008000;">.</span><span style="color: #0000FF;">ConstantContactSample</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">class</span> Program<br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">try</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Begin loading Contact Lists&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Connect and list Contact Lists</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ContactListProvider provider <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ContactListProvider<span style="color: #008000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ConfigurationManager<span style="color: #008000;">.</span><span style="color: #0000FF;">AppSettings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;ConstantContactAccountName&quot;</span><span style="color: #008000;">&#93;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ConfigurationManager<span style="color: #008000;">.</span><span style="color: #0000FF;">AppSettings</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;ConstantContactPassword&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List lists <span style="color: #008000;">=</span> provider<span style="color: #008000;">.</span><span style="color: #0000FF;">GetContactLists</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>lists <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>ContactList list <span style="color: #0600FF; font-weight: bold;">in</span> lists<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot; &nbsp;list:{0} id:{1}&quot;</span>, list<span style="color: #008000;">.</span><span style="color: #0000FF;">Name</span>, list<span style="color: #008000;">.</span><span style="color: #0000FF;">id</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Completed loading Contact Lists&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Press any key to quit&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadKey</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception ex<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Error: {0}&quot;</span>,ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/wcf-rest-starter-kit-to-constant-contact-sample-application/73/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using WCF REST Starter Kit to Access Constant Contact API</title>
		<link>http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/</link>
		<comments>http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/#comments</comments>
		<pubDate>Fri, 01 May 2009 19:30:37 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[atompub]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[wcf]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=57</guid>
		<description><![CDATA[Problem: Allow customers to sign up for email newsletters and synchronize those accounts with Constant Contact. Constant Contact is a company that provides Email Marketing services. You can use their editor to create nice looking emails and then configure a list of contacts. Constant Contact handles all the email sending, bounces, and unsubscribe activities. They [...]]]></description>
			<content:encoded><![CDATA[<p>Problem: Allow customers to sign up for email newsletters and synchronize those accounts with Constant Contact.</p>
<p><a title="Constant Contact" href="http://constantcontact.com" target="_blank">Constant Contact</a> is a company that provides Email Marketing services. You can use their editor to create nice looking emails and then configure a list of contacts. Constant Contact handles all the email sending, bounces, and unsubscribe activities. They also provide excellent reporting features to track how many people actually view your emails or click on the contained links.</p>
<p>The nice folks at Constant Contact provide a set of <a href="http://developer.constantcontact.com/doc" target="_blank">web services </a>for accessing account data. These interfaces are implemented as REST services utilizing the Atom Publication Protocol (AtomPub) and Atom Syndication Format. At first it might seem odd to be accessing data objects via a <em>blogging</em> protocol but it actually works quite naturally. So well that Google&#8217;s GData and Microsoft&#8217;s ADO.NET Data Services also support this technique.</p>
<p>Writing all the HTTP, Auth, and XML parsing code can be a real drag. Luckily Microsoft is releasing a <a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24644" target="_blank">WCF REST Starter Kit</a>. From the CodePlex summary:</p>
<blockquote><p><span id="ctl00_ctl00_MasterContent_Content_wikiSourceLabel">The WCF REST Starter Kit is a set of .Net Framework classes and Visual Studio features and templates that enable users to create and access REST-style Windows Communication Foundation (WCF) services. These services are based on the WCF web programming model available in .Net 3.5 SP1. The starter kit also contains the full source code for all features, detailed code samples, and unit tests.</span></p></blockquote>
<p>This starter kit makes accessing the Constant Contact API quite simple. Call GetEntry or GetFeed with a URI and get back a SyndicationItem or SyndicationFeed (collection of items). Similar methods exist for adding and updating data (AddEntry and UpdateEntry).</p>
<p>The following is one method from my ContactListProvider class:</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> ContactList GetContactList<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> id<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;AtomPubClient client <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> AtomPubClient<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;client<span style="color: #008000;">.</span><span style="color: #0000FF;">TransportSettings</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Credentials</span> <span style="color: #008000;">=</span> GetLoginCredentials<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// Place in a try block to ensure that any errors are caught</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">try</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; SyndicationItem item <span style="color: #008000;">=</span> client<span style="color: #008000;">.</span><span style="color: #0000FF;">GetEntry</span><span style="color: #008000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Uri<span style="color: #008000;">&#40;</span>id<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; ContactList list <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ContactList<span style="color: #008000;">&#40;</span>item<span style="color: #008000;">.</span><span style="color: #0000FF;">Content</span> <span style="color: #0600FF; font-weight: bold;">as</span> XmlSyndicationContent<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> list<span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>WebException ex<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; _log<span style="color: #008000;">.</span><span style="color: #0000FF;">Error</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;WebException: &quot;</span> <span style="color: #008000;">+</span> ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Status</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; &quot;</span> <span style="color: #008000;">+</span> ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span>, ex<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#40;</span>Exception ex<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Get the exception type</span><br />
&nbsp; &nbsp; &nbsp; _log<span style="color: #008000;">.</span><span style="color: #0000FF;">Error</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Exception: &quot;</span> <span style="color: #008000;">+</span> ex<span style="color: #008000;">.</span><span style="color: #0000FF;">Message</span>, ex<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Contact me via comments if you want a copy of all the providers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/using-wcf-rest-starter-kit-to-access-constant-contact-api/57/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to convert UPC-A to zero-compressed UPC-E</title>
		<link>http://blogs.freemind.net/index.php/how-to-convert-upc-a-to-zero-compressed-upc-e/56/</link>
		<comments>http://blogs.freemind.net/index.php/how-to-convert-upc-a-to-zero-compressed-upc-e/56/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 22:59:32 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[upc]]></category>
		<category><![CDATA[yucky]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=56</guid>
		<description><![CDATA[Universal Product Codes (UPCs) should be a very straight-forward topic. You give a product a number and that is the end of the story. Unfortunately it turns out to be a bit more complicated than that. There is a great (well I guess that&#8217;s subjective) page on Wikipedia that does an excellent job explaining all [...]]]></description>
			<content:encoded><![CDATA[<p>Universal Product Codes (UPCs) should be a very straight-forward topic. You give a product a number and that is the end of the story. Unfortunately it turns out to be a bit more complicated than that.</p>
<p>There is a great (well I guess that&#8217;s subjective) page on Wikipedia that does an excellent job explaining all the variations: <a title="Universal Product Codes" href="http://en.wikipedia.org/wiki/Universal_Product_Code" target="_blank">Universal Product Codes</a>. There are 14, 13, 12, 11, 10, 8, and 6 digit types of UPCs. There is also an interesting algorithm to convert from a fairly standard 12-digit UPC-A code into a zero-compressed UPC-E. This is a most uninteresting fact. Until the day comes when you actually have to convert some of these codes.</p>
<p>Here is some C# code to:</p>
<ul>
<li>Convert UPC-A codes to UPC-E</li>
<li>Convert UPC-E codes to UPC-A</li>
<li>Calculate check digits</li>
</ul>
<p>If google brought you here because you need these conversions then bask is it&#8217;s yucky goodness! If not, then just move right along (basically it&#8217;s a cup with dirt in it).</p>
<div class="codecolorer-container csharp default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> ConvertUPCAToUPCE<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> UPCa<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">string</span> UPCe <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">//Must be 12 digits</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>UPCa<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">12</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">string</span> mfg <span style="color: #008000;">=</span> UPCa<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span> <span style="color: #FF0000;">1</span>, <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">string</span> prod <span style="color: #008000;">=</span> UPCa<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">6</span>, <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;000&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> <span style="color: #008000;">&#40;</span>mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;100&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span><span style="color: #008000;">&#40;</span>mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;200&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXNNN0 &nbsp;0XX000-00NNN + check</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXNNN1 &nbsp;0XX100-00NNN + check</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXNNN2 &nbsp;0XX200-00NNN + check</span><br />
&nbsp; &nbsp; &nbsp; UPCe <span style="color: #008000;">=</span> mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> prod<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3</span>,<span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;00&quot;</span><span style="color: #008000;">&#41;</span> &nbsp; <br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXXNN3 &nbsp;0XXX00-000NN + check</span><br />
&nbsp; &nbsp; &nbsp; UPCe <span style="color: #008000;">=</span> mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>,<span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> prod<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3</span>,<span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;3&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;0&quot;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;4 &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XXXXN4 &nbsp;0XXXX0-0000N + check</span><br />
&nbsp; &nbsp; &nbsp; UPCe <span style="color: #008000;">=</span> mfg<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">4</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> prod<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">4</span>,<span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;4&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXXXX5 &nbsp;0XXXXX-00005 + check</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXXXX6 &nbsp;0XXXXX-00006 + check</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXXXX7 &nbsp;0XXXXX-00007 + check</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXXXX8 &nbsp;0XXXXX-00008 + check</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// &nbsp;9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XXXXX9 &nbsp;0XXXXX-00009 + check</span><br />
&nbsp; &nbsp; &nbsp; UPCe <span style="color: #008000;">=</span> mfg <span style="color: #008000;">+</span> prod<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">4</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">return</span> UPCe<span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> ConvertUPCEToUPCA<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> UPCe<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">//Must be 12 digits</span><br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span> <span style="color: #008000;">!=</span> <span style="color: #FF0000;">6</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">string</span> mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">string</span> prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;0&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;000&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;00&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;1&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;100&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;00&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;2&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;200&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;00&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">2</span>, <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;3&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;00&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;000&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3</span>, <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;4&quot;</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">4</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;0&quot;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0000&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">4</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mfg <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">5</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;prod <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;0000&quot;</span> <span style="color: #008000;">+</span> UPCe<span style="color: #008000;">.</span><span style="color: #0000FF;">Substring</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">5</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">return</span> mfg <span style="color: #008000;">+</span> prod <span style="color: #008000;">+</span> CalculateCheckDigit<span style="color: #008000;">&#40;</span>mfg <span style="color: #008000;">+</span> prod<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span><br />
<br />
<span style="color: #008080; font-style: italic;">//In the UPC-A system, the check digit is calculated as follows:</span><br />
<span style="color: #008080; font-style: italic;">//</span><br />
<span style="color: #008080; font-style: italic;">// &nbsp;1. Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.</span><br />
<span style="color: #008080; font-style: italic;">// &nbsp;2. Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result.</span><br />
<span style="color: #008080; font-style: italic;">// &nbsp;3. Find the result modulo 10 (i.e. the remainder when the result is divided by 10).</span><br />
<span style="color: #008080; font-style: italic;">// &nbsp;4. If the result is not zero, subtract the result from ten.</span><br />
<span style="color: #008080; font-style: italic;">//</span><br />
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> CalculateCheckDigit<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> upc<span style="color: #008000;">&#41;</span><br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">int</span> check <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #6666cc; font-weight: bold;">char</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> chars <span style="color: #008000;">=</span> upc<span style="color: #008000;">.</span><span style="color: #0000FF;">ToCharArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// process string from right to left</span><br />
&nbsp; &nbsp;Array<span style="color: #008000;">.</span><span style="color: #0000FF;">Reverse</span><span style="color: #008000;">&#40;</span>chars<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>i<span style="color: #008000;">&lt;</span>chars<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>i <span style="color: #008000;">%</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">!=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// even</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;check <span style="color: #008000;">+=</span> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>chars<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0600FF; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// odd</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;check <span style="color: #008000;">+=</span> <span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3</span> <span style="color: #008000;">*</span> <span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Parse</span><span style="color: #008000;">&#40;</span>chars<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp;check <span style="color: #008000;">=</span> check <span style="color: #008000;">%</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>check <span style="color: #008000;">!=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; check <span style="color: #008000;">=</span> <span style="color: #FF0000;">10</span> <span style="color: #008000;">-</span> check<span style="color: #008000;">;</span><br />
&nbsp; &nbsp;<span style="color: #008000;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #0600FF; font-weight: bold;">return</span> check<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><br />
<span style="color: #008000;">&#125;</span></div></div>
<p>Update: CheckDigit right to left processing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/how-to-convert-upc-a-to-zero-compressed-upc-e/56/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Beware of Windows Server 2008 Network Optimization</title>
		<link>http://blogs.freemind.net/index.php/beware-of-windows-server-2008-network-optimization/53/</link>
		<comments>http://blogs.freemind.net/index.php/beware-of-windows-server-2008-network-optimization/53/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 15:48:03 +0000</pubDate>
		<dc:creator>james</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=53</guid>
		<description><![CDATA[Problem: Recently I was migrating some Windows Server 2003 applications to new hardware and Windows Server 2008. The applications were mostly simple ASP.NET applications using either NHibernate or ADO.NET to communicate to a Windows Server 2003 x64 box running Sql Server 2005sp3. Each of the new Win2k8 machines were having performance issue retrieving data from [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Recently I was migrating some Windows Server 2003 applications to new hardware and Windows Server 2008. The applications were mostly simple ASP.NET applications using either NHibernate or ADO.NET to communicate to a Windows Server 2003 x64 box running Sql Server 2005sp3.</p>
<p>Each of the new Win2k8 machines were having performance issue retrieving data from the database. After firing up Sql Profiler I was able to see that executing a simple statement like &#8220;SELECT * FROM Store&#8221; was taking over 5sec to return 40 rows. The slowness was the same in both ADO.NET and NHibernate apps. More research from that the WinForms apps running as admin were having the same issues. And executing the queries in SSMS showed same behavior.</p>
<p><a href="http://blogs.freemind.net/wp-content/uploads/2009/03/db_slow.jpg"><img class="alignnone size-medium wp-image-54" title="db_slow" src="http://blogs.freemind.net/wp-content/uploads/2009/03/db_slow-300x137.jpg" alt="" width="300" height="137" /></a></p>
<p>So Win2k3 servers talking to the same database are running fast. Blowing my mind I found that using the Win2k8 servers to connect to a different Sql Server 2005sp2 on 32bit runs just fine (no delays). That&#8217;s right I can load the data onto a different server and see no delays!</p>
<p>If you are reading this you might be starting to form some theories. Both the Win2k3 and Win2k8 servers are on the same subnet.</p>
<p>At this point I requested help from the smart support guys from Microsoft. We verified that the Sql execution plans were not changing. We also verified the network settings on the database, Win2k3, and Win2k8 servers.</p>
<p>Next step netmon. After capturing and reviewing the netnom logs we were able to see that there were packets getting fragmented and there were long delays in sending the secondary packets. There are many newer features in Win2k8 to optimize the network performance (receive side scaling, tcp chimney offload, network direct memory access, and autotuning). Learn more here: <a href="http://support.microsoft.com/kb/951037" target="_blank">http://support.microsoft.com/kb/951037</a></p>
<p><strong>Root Cause:</strong></p>
<p>In my situation the autotuning feature was trying to adjust the tcp receive window (RWIN) and was timing out waiting for an acknowledgment from the database server. It is possible that the router was holding onto the response packet, I wasn&#8217;t able to completely correlate all the send/receives.</p>
<p>Learn more about RWIN behavior here: <a href="http://www.nerdgrind.com/speed-up-windows-vista-network-performance-with-tcp-windows-tuning/2/" target="_blank">http://www.nerdgrind.com/speed-up-windows-vista-network-performance-with-tcp-windows-tuning/2/</a></p>
<p><strong>Resolution:</strong></p>
<p>It is possible that we could have reconfigured the router to increase the frame sizes to prevent the packet fragmentation. It is also possible that change could have hidden the delays</p>
<p>The way I choose to resolve the issue was to turn off the autotuning with the following statement:</p>
<p><strong>netsh interface tcp set global autotuning=disabled</strong></p>
<p>Some network card drivers have the ability to control this setting via the advanced properties.</p>
<p><a href="http://blogs.freemind.net/wp-content/uploads/2009/03/db_fixed.jpg"><img class="alignnone size-medium wp-image-55" title="db_fixed" src="http://blogs.freemind.net/wp-content/uploads/2009/03/db_fixed-300x137.jpg" alt="" width="300" height="137" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/beware-of-windows-server-2008-network-optimization/53/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why the hell am I still forced to type runat=&#8221;server&#8221; after all these years?</title>
		<link>http://blogs.freemind.net/index.php/why-the-hell-am-i-still-forced-to-type-runatserver-after-all-these-years/45/</link>
		<comments>http://blogs.freemind.net/index.php/why-the-hell-am-i-still-forced-to-type-runatserver-after-all-these-years/45/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 19:46:32 +0000</pubDate>
		<dc:creator>Ira Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=45</guid>
		<description><![CDATA[We&#8217;ve all seen the Microsoft guys stumble over this time and time again in demos. Why are we still forced to add this? I mean, if it&#8217;s a server control (the control starts with &#8220;&#60;asp:&#8221;) it should be assumed &#8212; or added automatically by the Visual Studio IDE. What is this, the fourth version of [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all seen the Microsoft guys stumble over this time and time again in demos. Why are we still forced to add this? I mean, if it&#8217;s a server control (the control starts with &#8220;&lt;asp:&#8221;) it should be assumed &#8212; or added automatically by the Visual Studio IDE. What is this, the fourth version of Visual Studio for .NET?</p>
<p><strong>Why is runat=&#8221;server&#8221; not the default condition?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/why-the-hell-am-i-still-forced-to-type-runatserver-after-all-these-years/45/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minnebar 2008</title>
		<link>http://blogs.freemind.net/index.php/minnebar-2008/19/</link>
		<comments>http://blogs.freemind.net/index.php/minnebar-2008/19/#comments</comments>
		<pubDate>Sat, 10 May 2008 21:21:41 +0000</pubDate>
		<dc:creator>Ira Mitchell</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blogs.freemind.net/?p=19</guid>
		<description><![CDATA[Jim and I went to Minnebar this morning at Coffman Union on the campus of the University of Minnesota &#8212; 398 geeks and us. We hit three sessions and then went to the &#8220;State of the State&#8221; panel discussion with Jamie Thingelstad (former Dow Jones), Robert Stephens (Geek Squad), Dan Grigsby (Unpossible), Matthew Downquast (Crashplan), [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://barcamp.org/MinneBar"><img class="alignright size-full wp-image-20" title="minnebar-logo-small" src="http://blogs.freemind.net/wp-content/uploads/2008/05/minnebar-logo-small.png" alt="" width="250" height="60" /></a>Jim and I went to Minnebar this morning at Coffman Union on the campus of the University of Minnesota &#8212; 398 geeks and us. We hit three sessions and then went to the &#8220;State of the State&#8221; panel discussion with Jamie Thingelstad (former Dow Jones), Robert Stephens (Geek Squad), Dan Grigsby (Unpossible), Matthew Downquast (Crashplan), Douglas Olson (Microsoft), and Michael Gorman (Split Rock Partners).</p>
<p>They&#8217;re all really smart guys who are uniquely qualified to speak on the state of software in Minnesota, even if they did contradict themselves on one key point. They were all in agreement that Minnesota is a great place to build a development team &#8212; that it has a great community of developers and that our Midwestern work-ethic and loyalty are things that contribute to that, that we tend to be more thoughtful and risk-adverse. Only moments later, talk shifted to the need for developers as entrepreneurs to take the chances to start the next start-ups. Apparently our weakness needs to be our strength. All that considered, I could have listened to these guys for two or three hours.</p>
<p>It&#8217;s been many years since I first sat in a room listening to Robert Stephens talk about geek squad &#8212; back when they had the place in the Warehouse district. If you ever get a chance to hear him speak, take it. Actually, if you ever get a chance to hang out with any of these guys and listen to them, drop what you&#8217;re doing and make it happen.</p>
<p>One more point that hit home with me is that the University of Minnesota is a great school, but that it&#8217;s our duty collectively to do what we can to improve the state of the Computer Science and Business programs through mentoring, offering internships and with our wallets.</p>
<p>It&#8217;s amazing how prevalent the Rails stuff has gotten. Every session we attended had a Rails tie-in it seemed. Open-source is the buzzword with the development community to be sure. Everyone is looking to maximize the dollars spent on tools with the excellent free offerings.</p>
<p>All in all, I wish I had been able to stay for the entire event, but holding the whole Mother&#8217;s Day weekend thing (and my mom&#8217;s birthday) threw a monkey wrench into the works.</p>
<p>Good stuff. Thanks to Ben and all who helped organize this thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.freemind.net/index.php/minnebar-2008/19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
