예제 #1
0
        private void LogInAsync(object state)
        {
            // The  user is allowed to select only one project
            var tfsPicker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);

            if (tfsPicker.SelectedTeamProjectCollection == null)
            {
                var tResult = tfsPicker.ShowDialog();
            }

            //TfsConfigurationServer confServer = new TfsConfigurationServer(CurrentServer.ServerUrl);

            //ReadOnlyCollection<CatalogNode> collectionNodes = confServer.CatalogNode.QueryChildren(
            //    new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None);

            //if (collectionNodes == null || collectionNodes.Count() == 0) { throw new ApplicationException("Project list in TFS repo is empty"); }

            //// it returns collection, but it should be only one node for project. and we need first
            //var collectionNode = collectionNodes[0];

            //Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);

            //get current project from TFS repo
            //TeamProjectCollection = confServer.GetTeamProjectCollection(collectionId);

            TeamProjectCollection = tfsPicker.SelectedTeamProjectCollection;
            SelectedProjects      = tfsPicker.SelectedProjects;
            TeamProjectCollection.EnsureAuthenticated();
            BuildServer = TeamProjectCollection.GetService <IBuildServer>();

            TeamVersionControl = TeamProjectCollection.GetService <VersionControlServer>();
            if (TeamVersionControl != null)
            {
                //CurrentUser.Name = TeamVersionControl.AuthorizedUser;     //AuthorizedUser = '******'
                CurrentUser.Name = TeamVersionControl.AuthenticatedUser;    //AuthenticatedUser = '******'
            }

            if (LogInCompleted != null)
            {
                LogInCompleted(this, new LogInCompletedEventArgs()
                {
                    IsSucceeded = true, User = CurrentUser
                });
            }

            _backgroundTimer = new Timer(MonitorBuilds, null, new TimeSpan(0, 0, 10), new TimeSpan(0, 0, 10));
        }
예제 #2
0
        public void Connect()
        {
            IStatusItem statusItem = null;

            try
            {
                var args = new LoginDataEventArgs {
                    LoginData = LoginData
                };
                OnRequestLoginData(args);
                // If the request was canceled we will also cancel are connect attempt
                if (!args.Cancel)
                {
                    statusItem = StatusService.EnqueueStatusItem("AutoConnectMessage");
                    statusItem.IsProgressing           = true;
                    statusItem.IsProgressIndeterminate = true;
                    statusItem.Message = string.Format("Connecting to project {0} on server {1}.", LoginData.TeamProjectName,
                                                       LoginData.TeamProjectCollectionUri);

                    TeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(LoginData.TeamProjectCollectionUri, new UICredentialsProvider());
                    TeamProjectCollection.EnsureAuthenticated();

                    var workItemStore = TeamProjectCollection.GetService <WorkItemStore>();
                    TeamProject = workItemStore.Projects[LoginData.TeamProjectName];

                    InitReportingServiceProxy();

                    OnConnected();
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                OnConnectionFailed(ex.Message);
            }
            finally
            {
                if (statusItem != null)
                {
                    StatusService.DequeueStatusItem(statusItem);
                }
                FlushWindowsMessageQueue(false);
            }
        }
예제 #3
0
 private void ConnectToTeamProjectCollection()
 {
     TeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(TfsUri);
     TeamProjectCollection.EnsureAuthenticated();
 }