5 // Joel Reed (joelwreed@gmail.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System
.Collections
;
31 using System
.Collections
.Generic
;
35 using Microsoft
.TeamFoundation
.Server
;
36 using Microsoft
.TeamFoundation
.Client
;
37 using Microsoft
.TeamFoundation
.VersionControl
.Common
;
38 using Microsoft
.TeamFoundation
.VersionControl
.Client
;
39 using System
.Web
.Services
;
40 using System
.Web
.Services
.Description
;
41 using System
.Web
.Services
.Discovery
;
42 using System
.Web
.Services
.Protocols
;
43 using Mono
.GetOptions
;
45 [System
.Web
.Services
.WebServiceBinding(Name
="AdminSoap", Namespace
="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03")]
46 public class AdminStats
: System
.Web
.Services
.Protocols
.SoapHttpClientProtocol
{
48 public AdminStats(string url
, ICredentials credentials
)
50 this.Url
= url
+ "/VersionControl/v1.0/administration.asmx";
51 this.Credentials
= credentials
;
54 [System
.Web
.Services
.Protocols
.SoapDocumentMethodAttribute("http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03/QueryRepositoryInformation", RequestNamespace
="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03", ResponseNamespace
="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03", ParameterStyle
=System
.Web
.Services
.Protocols
.SoapParameterStyle
.Wrapped
, Use
=System
.Web
.Services
.Description
.SoapBindingUse
.Literal
)]
55 public AdminRepositoryInfo
QueryRepositoryInformation()
57 object[] results
= this.Invoke("QueryRepositoryInformation", new object[0]);
58 return ((AdminRepositoryInfo
)(results
[0]));
62 [System
.Xml
.Serialization
.XmlTypeAttribute(Namespace
="http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03")]
63 public class AdminRepositoryInfo
{
65 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
68 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
69 public int GroupCount
;
71 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
72 public int WorkspaceCount
;
74 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
75 public int ShelvesetCount
;
77 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
80 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
81 public int FolderCount
;
83 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
84 public int MaxChangesetID
;
86 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
87 public int PendingChangeCount
;
89 [System
.Xml
.Serialization
.XmlAttributeAttribute(Namespace
="")]
90 public int ShelvesetDeletedCount
;
93 [Command("show", "Show information about build configuration, cache settings, identity info, usage statistics, or registered tools.", "[ build | cache | ident | stats | tools ]")]
94 class ShowCommand
: Command
96 public ShowCommand(Driver driver
, string[] args
): base(driver
, args
)
100 public void ShowStats()
102 string url
= Driver
.GetServerUrl();
103 AdminStats stats
= new AdminStats(url
, Driver
.GetCredentials(new Uri(url
), null));
104 AdminRepositoryInfo info
= stats
.QueryRepositoryInformation();
106 Console
.WriteLine("Files: " + info
.FileCount
);
107 Console
.WriteLine("Folders: " + info
.FolderCount
);
108 Console
.WriteLine("Groups: " + info
.GroupCount
);
109 Console
.WriteLine("Pending Changes: " + info
.PendingChangeCount
);
110 Console
.WriteLine("Shelvesets: " + info
.ShelvesetCount
);
111 Console
.WriteLine("Users: " + info
.UserCount
);
112 Console
.WriteLine("Workspaces: " + info
.WorkspaceCount
);
115 public class ProjectInfoComparer
: IComparer
<ProjectInfo
>
117 public int Compare(ProjectInfo x
, ProjectInfo y
)
119 return x
.Name
.CompareTo(y
.Name
);
123 public void ShowProjects()
125 ICommonStructureService css
= Driver
.TeamFoundationServer
.GetService(typeof(ICommonStructureService
)) as ICommonStructureService
;
126 ProjectInfo
[] projects
= css
.ListProjects();
127 Array
.Sort(projects
, new ProjectInfoComparer());
130 int maxName
= WindowWidth
- GUID_SIZE
- 2;
131 string line
= String
.Format("{0} {1}",
132 "Guid".PadRight(GUID_SIZE
),
133 "Name".PadRight(maxName
));
134 Console
.WriteLine(line
);
136 line
= String
.Format("{0} {1}",
137 "-".PadRight(GUID_SIZE
, '-'),
138 "-".PadRight(maxName
, '-'));
140 Console
.WriteLine(line
);
142 foreach (ProjectInfo pinfo
in (projects
))
144 int indx
= Math
.Max(pinfo
.Uri
.LastIndexOf('/') + 1, 0);
145 string guid
= pinfo
.Uri
.Substring(indx
);
146 Console
.WriteLine(guid
+ " " + pinfo
.Name
);
150 public void ShowTools()
152 RegistrationEntry
[] registrationEntries
= ((IRegistration
) Driver
.TeamFoundationServer
.GetService(typeof(IRegistration
))).GetRegistrationEntries("");
153 foreach (RegistrationEntry entry
in registrationEntries
)
155 Console
.WriteLine(entry
.Type
);
156 Console
.WriteLine(new String('-', WindowWidth
));
158 if (entry
.ArtifactTypes
.Length
> 0)
161 Console
.WriteLine("ArtifactTypes: ");
163 foreach (ArtifactType artifactType
in entry
.ArtifactTypes
)
165 Console
.WriteLine(" {0}", artifactType
.Name
);
166 foreach (OutboundLinkType outboundLinkType
in artifactType
.OutboundLinkTypes
)
168 Console
.WriteLine(" {0}: {1} {2}", outboundLinkType
.Name
,
169 outboundLinkType
.TargetArtifactTypeName
,
170 outboundLinkType
.TargetArtifactTypeTool
);
175 if (entry
.Databases
.Length
> 0)
178 Console
.WriteLine("Databases: ");
180 foreach (Database database
in entry
.Databases
)
182 Console
.WriteLine(" {0}: {1} on {2}", database
.Name
, database
.DatabaseName
, database
.SQLServerName
);
187 Console
.WriteLine("ServiceInterfaces: ");
190 foreach (ServiceInterface serviceInterface
in entry
.ServiceInterfaces
)
192 Console
.WriteLine(" {0}: {1}", serviceInterface
.Name
, serviceInterface
.Url
);
199 private void ShowCache()
201 Console
.WriteLine("Cached Workspaces");
203 string cpath
= Path
.Combine(TeamFoundationServer
.ClientSettingsDirectory
, "VersionControl.config");
204 Console
.WriteLine("File: " + cpath
);
207 WorkspaceInfo
[] infos
= Workstation
.Current
.GetAllLocalWorkspaceInfo();
208 foreach (WorkspaceInfo info
in infos
)
210 Console
.WriteLine("Name: " + info
.Name
);
211 Console
.WriteLine("Uri : " + info
.ServerUri
.ToString());
214 foreach (string path
in info
.MappedPaths
)
216 Console
.WriteLine(" Path: " + path
);
223 public void ShowBuild()
229 Console
.WriteLine("File Type Support: {0}", magic
);
231 bool keyring
= false;
232 #if HAVE_GNOME_KEYRING
235 Console
.WriteLine("Gnome Keyring Support: {0}", keyring
);
241 Console
.WriteLine("GUI Support: {0}", gui
);
243 bool highlight
= false;
244 #if HAVE_SYNTAX_HIGHLIGHTING
247 Console
.WriteLine("Syntax Highlighting: {0}", highlight
);
250 public void ShowIdentity()
252 IGroupSecurityService gss
= Driver
.TeamFoundationServer
.GetService(typeof(IGroupSecurityService
)) as IGroupSecurityService
;
253 Identity identity
= gss
.ReadIdentity(SearchFactor
.AccountName
, Driver
.Username
, QueryMembership
.Direct
);
254 Console
.WriteLine("Account Name: " + identity
.AccountName
);
255 Console
.WriteLine("Description: " + identity
.Description
);
256 Console
.WriteLine("DisplayName: " + identity
.DisplayName
);
257 Console
.WriteLine("Distinguished Name: " + identity
.DistinguishedName
);
258 Console
.WriteLine("Domain: " + identity
.Domain
);
259 Console
.WriteLine("Mail Address: " + identity
.MailAddress
);
260 Console
.WriteLine("Sid: " + identity
.Sid
);
261 Console
.WriteLine("Type: " + identity
.Type
);
264 public override void Run()
266 if (Arguments
.Length
< 1)
268 Console
.WriteLine("Usage: tf show [ build | cache | ident | stats | tools ]");
269 Environment
.Exit((int)ExitCode
.Failure
);
272 switch (Arguments
[0])
293 Console
.WriteLine("Unknown show option: '{0}'", Arguments
[0]);