1: // Update the AppConfig with the URI of the Team Foundation Server you want to connect to, Make sure you have View Team Project Collection Details permissions on the server
2: private static string _myUri = ConfigurationManager.AppSettings["TfsUri"];
3: private static TwitterService _twitterService = null;
4:
5: private void button1_Click(object sender, EventArgs e)
6: {
7: lblNotes.Text = string.Empty;
8:
9: try
10: {
11: StringBuilder notes = new StringBuilder();
12:
13: _twitterService = Proxy.TwitterProxy.ConnectToTwitter();
14:
15: _twitterService.SendTweet("Hello World");
16:
17: TfsConfigurationServer configurationServer =
18: TfsConfigurationServerFactory.GetConfigurationServer(new Uri(_myUri));
19:
20: CatalogNode catalogNode = configurationServer.CatalogNode;
21:
22: ReadOnlyCollection<CatalogNode> tpcNodes = catalogNode.QueryChildren(
23: new Guid[] { CatalogResourceTypes.ProjectCollection },
24: false, CatalogQueryOptions.None);
25:
26: // tpc = Team Project Collection
27: foreach (CatalogNode tpcNode in tpcNodes)
28: {
29: Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
30: TfsTeamProjectCollection tpc = configurationServer.GetTeamProjectCollection(tpcId);
31:
32: notes.AppendFormat("{0} Team Project Collection : {1}{0}", Environment.NewLine, tpc.Name);
33: _twitterService.SendTweet(String.Format("http://Lunartech.codeplex.com - Connecting to Team Project Collection : {0} ", tpc.Name));
34:
35: // Get catalog of tp = 'Team Projects' for the tpc = 'Team Project Collection'
36: var tpNodes = tpcNode.QueryChildren(
37: new Guid[] { CatalogResourceTypes.TeamProject },
38: false, CatalogQueryOptions.None);
39:
40: foreach (var p in tpNodes)
41: {
42: notes.AppendFormat("{0} Team Project : {1} - {2}{0}", Environment.NewLine, p.Resource.DisplayName,
"This is an open source project hosted on codeplex");
43: _twitterService.SendTweet(String.Format(" Connected to Team Project: '{
0}' – '{1}' ", p.Resource.DisplayName, "This is an open source project hosted on codeplex"));
44: }
45: }
46: notes.AppendFormat("{0} Updates posted on Twitter : {1} {0}", Environment.NewLine, @"http://twitter.com/lunartech1");
47: lblNotes.Text = notes.ToString();
48: }
49: catch (Exception ex)
50: {
51: lblError.Text = " Message : " + ex.Message + (ex.InnerException != null ? " Inner Exception : " + ex.InnerException : string.Empty);
52: }
53: }