private bool Connect() { EnsureConnection(); IsConnected = false; try { _tfContext = new Context(); _tfContext.ContextName = "TfsTfConnection"; _tfContext.ServerHost = Connection.ServerHost; _tfContext.UserName = Connection.UserName; _tfContext.Password = Connection.Password; _tfContext.UseSSL = Connection.UseHttps; _clientService = TeamForgeServiceFactory.CreateServiceClient<ICollabNetSvc>(_tfContext); var clientIdentifier = ""; _clientService.Login(clientIdentifier); _sessionKey = _tfContext.SessionKey; _currentProject = _clientService.GetProjectListForUser(Connection.UserName).Where( p => string.Compare(p.Title, Connection.ProjectName.Trim(), true) == 0).FirstOrDefault(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } IsConnected = _currentProject != null; return IsConnected; }
private void Disconnect() { if (_trackerService != null) { _trackerService.Dispose(); _trackerService = null; } if (_clientService != null) { _clientService.Dispose(); _clientService = null; } if (_tfContext != null) { _tfContext = null; } }