<?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>richard-slater.co.uk &#187; Sharepoint</title>
	<atom:link href="http://www.richard-slater.co.uk/archives/tag/sharepoint/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richard-slater.co.uk</link>
	<description>Jesus, Life, Programming and Systems Administration</description>
	<lastBuildDate>Fri, 16 Jul 2010 21:04:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Strange SPQuery Behaviour</title>
		<link>http://www.richard-slater.co.uk/archives/2009/02/13/strange-spquery-behaviour/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/02/13/strange-spquery-behaviour/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 12:31:43 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Diary]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CAML]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[WebParts]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=571</guid>
		<description><![CDATA[I have been working on a very simple web part for a long time, the actual code for the web part takes less than an hour to write and merely displays a colour coded letter based on a query from a SharePoint list taking the date as a parameter. It has taken a long time [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working on a very simple web part for a long time, the actual code for the web part takes less than an hour to write and merely displays a colour coded letter based on a query from a SharePoint list taking the date as a parameter.</p>
<p>It has taken a long time because of some strange behaviour with the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.aspx">SPQuery</a> object, initially there was a problem with every row in the table being returned irrespective of the query, the odd thing was that if you ran the query in <a href="http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315">U2U CAML Query Builder</a> it worked and the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemcollection.count.aspx">SPListItemCollection.count</a> method would return 1 suggesting the query was working.</p>
<p>After adding a copious number of debugging command, I built up a pattern of what was happening and why. However no matter what I changed it either threw an exception as expected or returned all of the rows. I started commenting out lines of code one at a time trying to find the culprit, eventually moving on to commenting out the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debug.writeline.aspx">Debug.WriteLine</a> statements, until I hit this line:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>86
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">Debug.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span>fetchCurrentWeek.<span style="color: #0000FF;">ViewXml</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>After commenting out this line the whole thing worked perfectly, I can put the date forward on the server and it will update I can change the source table and it reflects the changes after the cache has been cleared. I have looked over the Microsoft Documentation on <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.viewxml.aspx">SPQuery.ViewXml</a> and can&#8217;t find any reference to it actually affecting the functionality of the object.</p>
<p>I have included my code at the end of this post for anyone to see, feel free to experiment with it. If you figure it out please do let me know.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">&#40;</span>SPWeb site <span style="color: #008000;">=</span> SPControl.<span style="color: #0000FF;">GetContextSite</span><span style="color: #000000;">&#40;</span>Context<span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">OpenWeb</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
 SPList weekList <span style="color: #008000;">=</span> site.<span style="color: #0000FF;">GetList</span><span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">SourceList</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #008080; font-style: italic;">// sharepoint requires that we use a ISO8601 DateTime string,</span>
 <span style="color: #008080; font-style: italic;">// generate it and insert it into the query</span>
 <span style="color: #FF0000;">string</span> mondayOfCurrentWeek <span style="color: #008000;">=</span> SPUtility.<span style="color: #0000FF;">CreateISO8601DateTimeFromSystemDateTime</span><span style="color: #000000;">&#40;</span>GetMondayOfCurrentWeek<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Date</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 StringBuilder camlBuilder <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 camlBuilder.<span style="color: #0000FF;">AppendLine</span>  <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;Where&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 camlBuilder.<span style="color: #0000FF;">AppendLine</span>  <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;  &lt;Eq&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 camlBuilder.<span style="color: #0000FF;">AppendLine</span>  <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;    &lt;FieldRef Name='WeekCommencing'/&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 camlBuilder.<span style="color: #0000FF;">AppendFormat</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;    &lt;Value Type='DateTime'&gt;{0}&lt;/Value&gt;<span style="color: #008080; font-weight: bold;">\r</span><span style="color: #008080; font-weight: bold;">\n</span>&quot;</span>, mondayOfCurrentWeek<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 camlBuilder.<span style="color: #0000FF;">AppendLine</span>  <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;  &lt;/Eq&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 camlBuilder.<span style="color: #0000FF;">AppendLine</span>  <span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;/Where&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #FF0000;">string</span> getWeekCAML <span style="color: #008000;">=</span> camlBuilder.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 SPQuery fetchCurrentWeek <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SPQuery<span style="color: #000000;">&#40;</span>weekList.<span style="color: #0000FF;">DefaultView</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #008080; font-style: italic;">// fetch all of the matching weeks from the table</span>
 fetchCurrentWeek.<span style="color: #0000FF;">Query</span> <span style="color: #008000;">=</span> getWeekCAML<span style="color: #008000;">;</span>
 SPListItemCollection matchingWeeks <span style="color: #008000;">=</span> weekList.<span style="color: #0000FF;">GetItems</span><span style="color: #000000;">&#40;</span>fetchCurrentWeek<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// the results of the query should only ever equal 1 if it dosn't something is wrong</span>
 <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>matchingWeeks.<span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">1</span><span style="color: #000000;">&#41;</span>
 <span style="color: #000000;">&#123;</span>
  SPListItem week <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>SPListItem<span style="color: #000000;">&#41;</span>matchingWeeks<span style="color: #000000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
  WeekType <span style="color: #008000;">=</span> week<span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Week Type&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  WeekType <span style="color: #008000;">=</span> SPEncode.<span style="color: #0000FF;">HtmlEncode</span><span style="color: #000000;">&#40;</span>WeekType<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">// HtmlEncode the result to make sure it dosn't contain any nastys</span>
  <span style="color: #FF0000;">String</span> WeekNumber <span style="color: #008000;">=</span> week<span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Week Number&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  WeekNumber <span style="color: #008000;">=</span> SPEncode.<span style="color: #0000FF;">HtmlEncode</span><span style="color: #000000;">&#40;</span>WeekNumber<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  Debug.<span style="color: #0000FF;">WriteLine</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span>CultureInfo.<span style="color: #0000FF;">InvariantCulture</span>, <span style="color: #666666;">&quot;[WeekWidget] Found record for {0} as Week {1} - Number {2}&quot;</span>, mondayOfCurrentWeek, WeekType, WeekNumber<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008080; font-style: italic;">// cache the WeekType for 7 days from midnight on Monday as this is when the changeover between weeks happenswou</span>
  Context.<span style="color: #0000FF;">Cache</span>.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span>CACHE_WEEKTYPE, WeekType, <span style="color: #0600FF;">null</span>, GetMondayOfCurrentWeek<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">AddDays</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">7</span><span style="color: #000000;">&#41;</span>, TimeSpan.<span style="color: #0000FF;">Zero</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #000000;">&#125;</span> <span style="color: #008080; font-style: italic;">// end if matchingWeeks count equal to 1</span>
 <span style="color: #0600FF;">else</span>
 <span style="color: #000000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">// more than one week matched, we can not determine the output correctly</span>
  ErrorText.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;More than one week matched in the table, please check the table.&quot;</span><span style="color: #008000;">;</span>
  LogEvent<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;More than one week (&quot;</span> <span style="color: #008000;">+</span> matchingWeeks.<span style="color: #0000FF;">Count</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;) matched in the table, please check the table.&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #000000;">&#125;</span> <span style="color: #008080; font-style: italic;">// end else</span></pre></div></div>

<p>Happy Hunting</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/02/13/strange-spquery-behaviour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding VSeWSS 1.3 Solutions to Source Control</title>
		<link>http://www.richard-slater.co.uk/archives/2009/02/05/vsewss-13-solutions-to-source-control/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/02/05/vsewss-13-solutions-to-source-control/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 10:35:12 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sys. Admin.]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=556</guid>
		<description><![CDATA[Having done a little experimenting with Visual Studio Extensions for WSS (VSeWSS), I wanted to start actually developing features for our intranet site. I try and add everything that is even slightly important into source control (Subversion). VSeWSS creates normal looking solutions, however when you deploy your project to a SharePoint site it created an [...]]]></description>
			<content:encoded><![CDATA[<p>Having done a little experimenting with Visual Studio Extensions for WSS (VSeWSS), I wanted to start actually developing features for our intranet site. I try and add everything that is even slightly important into source control (Subversion). VSeWSS creates normal looking solutions, however when you deploy your project to a SharePoint site it created an additional directory alongside &#8220;bin&#8221; and &#8220;obj&#8221; called &#8220;pkg&#8221;.</p>
<p>This &#8220;pkg&#8221; folder contains the manifest.xml, soloution.xml and feature.xml files that are used to create the feature to be deployed into SharePoint. Initially I was including this folder in my commits however, I noticed that any tweaks made to feature.xml were overwritten when you deployed the package again. After some searching around I came across an article that suggests <a href="http://msmvps.com/blogs/brianmadsen/archive/2008/07/10/error-on-subsequent-deployment-of-web-part-for-vs2008-and-vsewss-1-2.aspx">deleting the &#8220;pkg&#8221; folder under certain circumstances</a>. From this I assume that the contents of the &#8220;pkg&#8221; folder is generated each and every time you package and deploy your solution (or indeed project), thus it does not need to be added to source control.</p>
<p>While writing this post I did come across another blog that <a href="http://oidatsmyleg.wordpress.com/2008/05/20/adding-required-files-vsewss-projects/">suggests adding the &#8220;pkg&#8221; folder to source control</a>. There does appear to be little advice out there regarding VSeWSS and Source Control. I would be interested to hear others experiences on the subject.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/02/05/vsewss-13-solutions-to-source-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Isolator For SharePoint</title>
		<link>http://www.richard-slater.co.uk/archives/2008/11/25/isolator-for-sharepoint/</link>
		<comments>http://www.richard-slater.co.uk/archives/2008/11/25/isolator-for-sharepoint/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 19:47:15 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Sys. Admin.]]></category>
		<category><![CDATA[Isolator]]></category>
		<category><![CDATA[Sharepoint]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=475</guid>
		<description><![CDATA[Typemock are offering their new product for unit testing SharePoint called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to unit test SharePoint without a SharePoint server. To learn more click here. The first 50 bloggers who blog this text in their blog and tell us about [...]]]></description>
			<content:encoded><![CDATA[<p>Typemock are offering their new product for <a href="http://www.typemock.com/sharepointpage.php?utm_source=sp_bb&amp;utm_medium=blog_4sp&amp;utm_campaign=sp_bb">unit testing SharePoint</a> called Isolator For SharePoint, for a special introduction price. it is the only tool that allows you to <a href="http://blog.typemock.com/2008/11/newisolatorforsharepointtoolforunittest.html?utm_source=typeblog&amp;utm_medium=sp_bb&amp;utm_campaign=typeblog">unit test SharePoint</a> without a SharePoint server. To learn more <a href="http://www.typemock.com/sharepointpage.php?utm_source=sp_bb&amp;utm_medium=blog_4sp&amp;utm_campaign=sp_bb">click here</a>.</p>
<p><strong>The first 50 bloggers </strong>who blog this text in their blog and tell us about it, will get <span style="color: #ff0000;">a Full Isolator license, Free</span>. for rules and info <a href="http://blog.typemock.com/2008/11/newisolatorforsharepointtoolforunittest.html">click here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2008/11/25/isolator-for-sharepoint/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
