/// <summary>
        /// Получить количество рабочих элементов удовлетворяющих условиям (без дочерних элементов).
        /// </summary>
        /// <param name="wis">Вспомагательный элемент для работы с рабочими элементами.</param>
        /// <param name="project">Наименование проекта в TFS.</param>
        /// <param name="wit">Тип рабочего элемента.</param>
        /// <param name="programmer">Человек, которому была назначена задача.</param>
        /// <param name="state">Состояние рабочего элемента.</param>
        /// <returns>Количество рабочих элементов.</returns>
        private int GetCountSimple(WorkItemStore wis, string project, string wit, string programmer, string state)
        {
            return(wis.QueryCount(
                       string.Format(
                           @"SELECT [System.Id] 
                    FROM WorkItems 
                    WHERE [System.TeamProject] = '{0}' 
	                    AND [System.WorkItemType] = '{1}' 
	                    AND [{2}] = '{3}' 
	                    AND [System.State] = '{4}' 
                    ORDER BY [System.Id]",
                           project,
                           wit,
                           wit == TFSCommonCollectionContsntans.ResponseWorkItemType ? "System.AssignedTo" : "Microsoft.VSTS.Common.ClosedBy",
                           programmer,
                           state)));
        }
Exemplo n.º 2
0
        public void Initialize(EndPoint env)
        {
            Trace.TraceInformation("TfsWITTestCaseAdapter: Initialize BEGIN");
            Trace.TraceInformation("ServerUrl: {0}", env.ServerUrl);
            Trace.TraceInformation("TeamProject: {0}", env.TeamProject);

            m_filterString = string.Empty;

            TeamFoundationServer tfs = new TeamFoundationServer(env.ServerUrl);

            WorkItemStore   = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
            TeamProjectName = env.TeamProject;
            Project         = WorkItemStore.Projects[TeamProjectName];
            m_witQueryCount = WorkItemStore.QueryCount("SELECT [System.Id] From WorkItems");

            Trace.TraceInformation("TfsWITTestCaseAdapter: Initialize END");
        }
        /// <summary>
        /// Получить количество рабочих элементов удовлетворяющих условиям (с дочерними элементами).
        /// </summary>
        /// <param name="wis">Вспомагательный элемент для работы с рабочими элементами.</param>
        /// <param name="project">Наименование проекта в TFS.</param>
        /// <param name="programmer">Человек, которому была назначена задача.</param>
        /// <param name="state">Состояние рабочего элемента.</param>
        /// <returns>Количество рабочих элементов.</returns>
        private int GetCountComplex(WorkItemStore wis, string project, string programmer, string state)
        {
            return(wis.QueryCount(
                       string.Format(
                           @"SELECT [System.Id] 
                    FROM WorkItemLinks 
                    WHERE ([Source].[System.TeamProject] = '{0}' 
		                    AND [Source].[System.WorkItemType] IN GROUP 'Категория запроса проверки кода' 
		                    AND [Source].[System.State] <> 'Закрыто' 
		                    AND [Source].[System.AssignedTo] = '{1}') 
	                    And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') 
	                    And ([Target].[System.WorkItemType] IN GROUP 'Категория ответа на проверку кода' 
		                    AND [Target].[System.State] = '{2}') 
                    ORDER BY [System.Id] mode(MustContain)",
                           project,
                           programmer,
                           state)) / 2);
        }
Exemplo n.º 4
0
        private static void FeedWorkItemData(ICollection <WorkItemDefinition> workItemDefinitionCollection,
                                             TfsTeamProjectCollection tpc, string projectName)
        {
            WorkItemStore wis = tpc.GetService <WorkItemStore>();

            Microsoft.TeamFoundation.WorkItemTracking.Client.Project project = wis.Projects[projectName];

            foreach (WorkItemType wit in project.WorkItemTypes)
            {
                WorkItemDefinition witDefinition = new WorkItemDefinition()
                {
                    Name = wit.Name, Description = wit.Description
                };

                IEnumerable <Category> categories = project.Categories.Where(x => x.WorkItemTypes.Contains(wit));
                foreach (Category item in categories)
                {
                    witDefinition.Categories.Add(item.Name);
                }

                FieldDefinition systemState = wit.FieldDefinitions.TryGetByName("System.State");
                foreach (string allowedValue in systemState.AllowedValues)
                {
                    int stateCount = wis.QueryCount("Select System.Id From WorkItems Where System.TeamProject = '"
                                                    + projectName
                                                    + "' And System.WorkItemType = '"
                                                    + witDefinition.Name
                                                    + "' And System.State = '"
                                                    + allowedValue
                                                    + "'");

                    witDefinition.StateCollection.Add(allowedValue, stateCount);
                }
                workItemDefinitionCollection.Add(witDefinition);
            }
        }