예제 #1
0
        /// <summary>
        /// Executes a WIQL query using the provided query, parameters. If useDefaultProject is set, then the query is
        /// constrained to the user's currently selected project.
        /// </summary>
        public IEnumerable <WorkItemSummary> ExecuteWiqlQuery(string query, Dictionary <string, object> parameters, bool useDefaultProject)
        {
            if (parameters == null)
            {
                parameters = new Dictionary <string, object>();
            }

            // Add the default project name if one is missing
            if (query.IndexOf("TeamProject") == -1 && useDefaultProject)
            {
                if (!parameters.ContainsKey("Project"))
                {
                    parameters.Add("Project", UserContext.Current.CurrentProject.Name);
                }
                else
                {
                    parameters["Project"] = UserContext.Current.CurrentProject.Name;
                }

                query += " AND System.TeamProject = @Project";
            }

            WorkItemCollection collection = UserContext.Current.WorkItemStore.Query(query, parameters);

            return(collection.ToSummaries());
        }
예제 #2
0
        /// <summary>
        /// Executes a stored query on the TFS server, returning a collection of <see cref="WorkItemSummary"/> objects.
        /// </summary>
        /// <param name="id">The id of the stored query to run.</param>
        public IEnumerable <WorkItemSummary> StoredQuery(Guid id)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("project", UserContext.Current.CurrentProject.Name);

            Project   project = UserContext.Current.WorkItemStore.Projects[UserContext.Current.CurrentProject.Name];
            QueryItem item    = project.QueryHierarchy.Find(id);

            WorkItemCollection collection = UserContext.Current.WorkItemStore.Query(project.StoredQueries[id].QueryText, parameters);

            return(collection.ToSummaries());
        }
예제 #3
0
        /// <summary>
        /// Executes the WIQL query that this instance of <see cref="QueryManager"/> represents, and returns the work items for it.
        /// </summary>
        public IEnumerable <WorkItemSummary> Execute()
        {
            // Filter by a type for the query.
            T summary = new T();

            ContrainType(summary.WIQLTypeName);

            string query = _builder.ToString();

            HttpContext.Current.Items["Query"] = MvcHtmlString.Create(query);             // should be done on the controllers
            WorkItemCollection collection = UserContext.Current.WorkItemStore.Query(query, _builder.Parameters);

            return(collection.ToSummaries());
        }
예제 #4
0
        /// <summary>
        /// Retrieves all work items for the user's currently selected project, area and iteration.
        /// </summary>
        public IEnumerable <WorkItemSummary> AllItems()
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("project", UserContext.Current.CurrentProject.Name);

            string query = string.Format("SELECT ID, Title from Issue WHERE " +
                                         "System.TeamProject = @project {0} " +
                                         "ORDER BY Id DESC", _builder.GenerateWiqlForPaths(parameters));

            WorkItemCollection collection = UserContext.Current.WorkItemStore.Query(query, parameters);

            return(collection.ToSummaries());
        }