<?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>stuartpreston.net &#187; Team Foundation Server</title>
	<atom:link href="http://stuartpreston.net/blog/tag/team-foundation-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://stuartpreston.net/blog</link>
	<description>Blog of Stuart Preston</description>
	<lastBuildDate>Sun, 23 Oct 2011 09:34:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TFS WIT hacks: Setting a DateTime field based on String value in another field</title>
		<link>http://stuartpreston.net/blog/2009/11/09/tfs-wit-hacks-setting-a-datetime-field-based-on-string-value-in-another-field/</link>
		<comments>http://stuartpreston.net/blog/2009/11/09/tfs-wit-hacks-setting-a-datetime-field-based-on-string-value-in-another-field/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 23:48:13 +0000</pubDate>
		<dc:creator>Stuart Preston</dc:creator>
				<category><![CDATA[Team Foundation Server]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[WIT]]></category>

		<guid isPermaLink="false">http://stuartpreston.net/blog/?p=24</guid>
		<description><![CDATA[I recently responded to a question on a Microsoft discussion list.  The question was (paraphrased):
I need to get the clock value assigned to “Field B” when the value of “Field A” is changed to a specific value.  Field A allows Yes, No values only.
I need the exact time “Field A” gets assigned Yes. When it [...]]]></description>
			<content:encoded><![CDATA[<p>I recently responded to a question on a Microsoft discussion list.  The question was (paraphrased):</p>
<blockquote><p><em>I need to get the clock value assigned to “Field B” when the value of “Field A” is changed to a specific value.  Field A allows Yes, No values only.</em></p>
<p><em>I need the exact time “Field A” gets assigned Yes. When it goes back to No, I must not do anything with the value stored in “Field B”. Then if “Field A” gets assigned Yes one more time, I need “Field B” updated with the DateTime of when this assignment happened and not losing the value until next time field A gets triggered to Yes.</em></p></blockquote>
<p>Well I remembered doing something similar during some prototyping on <a href="http://scrumforteamsystem.com">Scrum for Team System</a>.  The initial trap is that when you set up a &lt;COPY from=”clock” /&gt; rule on a TFS WIT field, then Team Explorer refreshed this time after the work item is saved.  This is not the behaviour we wanted to see.  After a bit of experimentation, success!</p>
<pre class="csharpcode">      <span class="kwrd">&lt;</span><span class="html">FIELD</span> <span class="attr">name</span><span class="kwrd">="FieldA"</span> <span class="attr">refname</span><span class="kwrd">="Playground.FieldA"</span> <span class="attr">type</span><span class="kwrd">="String"</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">COPY</span> <span class="attr">from</span><span class="kwrd">="value"</span> <span class="attr">value</span><span class="kwrd">="No"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">ALLOWEDVALUES</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">LISTITEM</span> <span class="attr">value</span><span class="kwrd">="Yes"</span> <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">LISTITEM</span> <span class="attr">value</span><span class="kwrd">="No"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">ALLOWEDVALUES</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">FIELD</span><span class="kwrd">&gt;</span>

      <span class="kwrd">&lt;</span><span class="html">FIELD</span> <span class="attr">name</span><span class="kwrd">="FieldB"</span> <span class="attr">refname</span><span class="kwrd">="Playground.FieldB"</span> <span class="attr">type</span><span class="kwrd">="DateTime"</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">WHEN</span> <span class="attr">field</span><span class="kwrd">="Playground.FieldA"</span> <span class="attr">value</span><span class="kwrd">="Yes"</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">COPY</span> <span class="attr">from</span><span class="kwrd">="clock"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">WHEN</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">WHEN</span> <span class="attr">field</span><span class="kwrd">="Playground.FieldA"</span> <span class="attr">value</span><span class="kwrd">="No"</span><span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span><span class="html">READONLY</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">WHEN</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;/</span><span class="html">FIELD</span><span class="kwrd">&gt;</span></pre>
<p>As you can see, the trick is to deliberately set FieldB to &lt;READONLY /&gt; when FieldA is “No”.  I thought I’d post this here in case anyone else needs to do something similar.  A view of the history on the Work Item I edited confirms the modification works as required:</p>
<p><a href="http://stuartpreston.net/blog/wp-content/uploads/2009/11/clip_image0026.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002[6]" src="http://stuartpreston.net/blog/wp-content/uploads/2009/11/clip_image0026_thumb.jpg" border="0" alt="clip_image002[6]" width="451" height="525" /></a></p>
<p>This sample should work on TFS2005, 2008 and all versions of 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://stuartpreston.net/blog/2009/11/09/tfs-wit-hacks-setting-a-datetime-field-based-on-string-value-in-another-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TFS2010 API: Retrieving a list of Process Templates on the server.</title>
		<link>http://stuartpreston.net/blog/2009/11/07/tfs2010-api-retrieving-a-list-of-process-templates-on-the-server/</link>
		<comments>http://stuartpreston.net/blog/2009/11/07/tfs2010-api-retrieving-a-list-of-process-templates-on-the-server/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 16:11:25 +0000</pubDate>
		<dc:creator>Stuart Preston</dc:creator>
				<category><![CDATA[Team Foundation Server]]></category>
		<category><![CDATA[ALM]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[TFS2010]]></category>
		<category><![CDATA[TFS2010 Beta 2]]></category>
		<category><![CDATA[VS2010]]></category>

		<guid isPermaLink="false">http://stuartpreston.net/blog/?p=12</guid>
		<description><![CDATA[I thought I’d post some utility code that I’ve been playing with to retrieve information about the Process Templates available on a TFS 2010 instance.
As you can see from the code, each TeamProjectCollection has its own store of Process Templates (in TFS 2008 there was in effect a single “Project Collection”) so we need to [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I’d post some utility code that I’ve been playing with to retrieve information about the Process Templates available on a TFS 2010 instance.</p>
<p>As you can see from the code, each TeamProjectCollection has its own store of Process Templates (in TFS 2008 there was in effect a single “Project Collection”) so we need to look through each collection to retrieve the templates that have been uploaded to it.</p>
<p>You’ll need references to Microsoft.TeamFoundation.dll, Microsoft.TeamFoundation.Client.dll, Microsoft.TeamFoundation.Common.dll.  On a machine with Visual Studio 2010 installed they should be found in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 <em>or</em> C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0 depending on whether you have a 64-bit version of Windows or not.  You’ll also need to set the Target Framework to .NET Framework 3.5 as the assemblies required are in the v2 GAC.</p>
<p>This code will work against TFS2010 Beta 2 but is not guaranteed to work in the RTM.</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Text;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Framework.Client;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Framework.Common;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Client;
<span class="kwrd">using</span> Microsoft.TeamFoundation.Server;

<span class="kwrd">namespace</span> TFSUtils
{
    <span class="kwrd">class</span> Program
    {
        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
        {
            <span class="rem">//replace this with the URL to your TFS instance.</span>
            Uri tfsUri = <span class="kwrd">new</span> Uri(<span class="str">"http://sptfs02:8080/tfs"</span>);

            TeamFoundationApplicationInstance tfai = <span class="kwrd">new</span> TeamFoundationApplicationInstance(tfsUri, <span class="kwrd">new</span> UICredentialsProvider());
            tfai.EnsureAuthenticated();

            ITeamProjectCollectionService collectionService = tfai.GetService&lt;ITeamProjectCollectionService&gt;();
            IList&lt;TeamProjectCollection&gt; collections = collectionService.GetCollections();

            <span class="kwrd">foreach</span> (TeamProjectCollection collection <span class="kwrd">in</span> collections)
            {
                <span class="kwrd">if</span> (collection.State == TeamFoundationServiceHostStatus.Started)
                {
                    Console.WriteLine(String.Format(<span class="str">"\nCollection: {0}"</span>, collection.Name));
                    IProcessTemplates processTemplates = tfai.GetTeamFoundationServer(collection.Id).GetService&lt;IProcessTemplates&gt;();
                    TemplateHeader[] templateHeaders = processTemplates.TemplateHeaders();
                    <span class="kwrd">foreach</span> (TemplateHeader header <span class="kwrd">in</span> templateHeaders)
                    {
                        Console.WriteLine(String.Format(<span class="str">"\t{0} {1}"</span>, header.TemplateId, header.Name));
                    }
                }
            }

            Console.WriteLine(<span class="str">"\nPress any key to continue."</span>);
            Console.ReadKey();
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://stuartpreston.net/blog/2009/11/07/tfs2010-api-retrieving-a-list-of-process-templates-on-the-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

