Пример #1
0
        private ReportingServiceProxy InitReportingServiceProxy()
        {
            if (TeamProjectCollection == null)
            {
                return(null);
            }

            var regService = TeamProjectCollection.GetService <IRegistration>();
            var proxy      = new ReportingServiceProxy(TeamProjectCollection);

            ReportServerUrl = proxy.ReportServiceUrl;
            ReportFolder    = GetReportFolder(regService);

            return(proxy);
        }
Пример #2
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));
        }
Пример #3
0
 public WorkItemLinkTypeCollection GetLinkTypes()
 {
     try
     {
         if (TeamProjectCollection == null)
         {
             return(null);
         }
         var store = TeamProjectCollection.GetService <WorkItemStore>();
         return(store != null ? store.WorkItemLinkTypes : null);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         HandleConnectionException(ex);
         throw;
     }
 }
Пример #4
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);
            }
        }
Пример #5
0
        public void ApplyConfiguration(IConfiguration configuration)
        {
            if (TeamProjectCollection == null)
            {
                return;
            }
            if (configuration == null)
            {
                return;
            }
            if (configuration.QueryId == Guid.Empty)
            {
                var errorMessage = StatusService.EnqueueStatusItem("InvalidQuery");
                errorMessage.Message = "There is no query defined in the configuration. Please choose a query by clicking \"Edit\"";
                return;
            }

            // Before refreshing the data we should verify whether there are unsaved changes that need to be saved
            if (!VerifySaveRequest())
            {
                return;
            }

            var statusItem = StatusService.EnqueueStatusItem("ApplyConfiguration");

            statusItem.Message                 = string.Format("Applying configuration for team project {0}", TeamProject.Name);
            statusItem.IsProgressing           = true;
            statusItem.IsProgressIndeterminate = true;
            // Run the query in order to provide the result data
            var store = TeamProjectCollection.GetService <WorkItemStore>();
            // Get the query based on the Id we keep in the configuration
            QueryDefinition queryDefinition = SaveGetQueryDefinition(store, configuration.QueryId);
            Query           query           = GetQuery(queryDefinition);

            // Only if the query is a link query we perform the fullblown request for data
            if ((query != null) && (query.IsLinkQuery))
            {
                // First get the linking information
                WorkItemLinkInfos = query.RunLinkQuery();
                // Get the configured link type in order to respect it when retrieving the work items
                var linkType = (!string.IsNullOrEmpty(configuration.LinkType)) ? store.WorkItemLinkTypes.FirstOrDefault(type => type.ReferenceName == configuration.LinkType) : null;
                // Now put all TargetIds into a BatchReadParameterCollection in order to get the work items for the links
                // Attention: Consider handling the link types correctly
                var batchReadParams = new BatchReadParameterCollection();
                foreach (var linkInfo in WorkItemLinkInfos)
                {
                    if (linkType == null)
                    {
                        // If there is no link type there is nothing we can check explicitly and therefor we respect any child
                        if (!batchReadParams.Contains(linkInfo.TargetId))
                        {
                            batchReadParams.Add(new BatchReadParameter(linkInfo.TargetId));
                        }
                    }
                    else
                    {
                        // Debug.WriteLink("Link: {0} Source: {1} Target: {2} RefName: {3} Forward: {4} Reverse: {5}", linkInfo.LinkTypeId, linkInfo.SourceId, linkInfo.TargetId, linkType.ReferenceName, linkType.ForwardEnd.Id, linkType.ReverseEnd.Id);
                        // We need to respect the link type.
                        if (IsValidLinkInfo(linkInfo, linkType))
                        {
                            // When the link info is valid according to the current configuration then we consider the work item in our query.
                            if (!batchReadParams.Contains(linkInfo.TargetId))
                            {
                                batchReadParams.Add(new BatchReadParameter(linkInfo.TargetId));
                            }
                        }
                        // When the link type is not valid we also do not consider the item.
                    }
                }
                // Now construct the query to get the work items
                string        batchQuery       = "SELECT {0} FROM WorkItems";
                List <string> displayFields    = (from FieldDefinition fieldDefinition in query.DisplayFieldList select fieldDefinition.ReferenceName).ToList();
                string        displayFieldPart = string.Join(",", displayFields.ToArray());
                if (batchReadParams.Count != 0)
                {
                    batchQuery = string.Format(batchQuery, displayFieldPart);
                    // Run the query and remember the results
                    WorkItems = store.Query(batchReadParams, batchQuery);
                    BuildBacklogItemsList(configuration);
                    BuildChildItemsList(configuration);
                }
                else
                {
                    ApplyChildrenChangesOnUIThread(new List <BacklogChildren>());
                }
            }
            else
            {
                WorkItemLinkInfos = null;
                WorkItems         = query != null?query.RunQuery() : null;

                if (AllChildren != null)
                {
                    AllChildren.Clear();
                }
                if (BacklogChildren.Count > 0)
                {
                    BacklogChildren.Clear();
                }
                if (BackLogItems != null)
                {
                    BackLogItems.Clear();
                }
            }
            PrepareTransitionsMap(configuration);
            OnConfigurationApplied();
        }