2 using System
.Collections
.Generic
;
3 using System
.Diagnostics
;
7 using Microsoft
.TeamFoundation
.Client
;
8 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
10 namespace BasicSccExample
14 static void PrintWorkspace(Workspace w
)
16 Console
.WriteLine(w
.ToString());
19 static void Main(string[] args
)
21 // Verify that we have the arguments we require.
24 String appName
= Path
.GetFileName(Process
.GetCurrentProcess().MainModule
.FileName
);
25 Console
.Error
.WriteLine("Usage: {0} tfsServerName tfsTeamProjectPath", appName
);
26 Console
.Error
.WriteLine("Example: {0} http://tfsserver:8080 $/MyProject", appName
);
30 // Get a reference to our Team Foundation Server.
31 string serverUri
= "http://10.100.1.88:8080";
32 TeamFoundationServer tfs
= new TeamFoundationServer(serverUri
,
33 new NetworkCredential(args
[0], args
[1], args
[2]));
35 // Get a reference to Version Control.
36 VersionControlServer versionControl
= (VersionControlServer
) tfs
.GetService(typeof(VersionControlServer
));
40 Console
.WriteLine("versionControl.GetWorkspace(name, owner):");
41 Workspace workspace
= versionControl
.GetWorkspace(Workstation
.Current
.Name
, "jreed");
42 path
= workspace
.Folders
[0].LocalItem
;
43 PrintWorkspace(workspace
);
48 Console
.WriteLine("versionControl.GetWorkspace(path):");
49 Workspace workspace
= versionControl
.GetWorkspace(path
);
50 PrintWorkspace(workspace
);
55 WorkspaceInfo info
= Workstation
.Current
.GetLocalWorkspaceInfo(path
);
56 Console
.WriteLine("versionControl.GetWorkspace(info):");
57 Workspace workspace
= versionControl
.GetWorkspace(info
);
58 PrintWorkspace(workspace
);
62 // Listen for the Source Control events.
63 // versionControl.NonFatalError += Example.OnNonFatalError;
64 //versionControl.Getting += Example.OnGetting;
65 //versionControl.BeforeCheckinPendingChange += Example.OnBeforeCheckinPendingChange;
66 //versionControl.NewPendingChange += Example.OnNewPendingChange;
68 // Get the files from the repository.
72 internal static void OnNonFatalError(Object sender
, ExceptionEventArgs e
)
74 if (e
.Exception
!= null)
76 Console
.Error
.WriteLine("Non-fatal exception: " + e
.Exception
.Message
);
80 Console
.Error
.WriteLine("Non-fatal failure: " + e
.Failure
.Message
);
84 internal static void OnGetting(Object sender
, GettingEventArgs e
)
86 Console
.WriteLine("Getting: " + e
.TargetLocalItem
+ ", status: " + e
.Status
);
89 internal static void OnBeforeCheckinPendingChange(Object sender
, ProcessingChangeEventArgs e
)
91 Console
.WriteLine("Checking in " + e
.PendingChange
.LocalItem
);
94 internal static void OnNewPendingChange(Object sender
, PendingChangeEventArgs e
)
96 Console
.WriteLine("Pending " + PendingChange
.GetLocalizedStringForChangeType(e
.PendingChange
.ChangeType
) +
97 " on " + e
.PendingChange
.LocalItem
);