当前位置: 首页>>代码示例>>C#>>正文


C# Query.RunQuery方法代码示例

本文整理汇总了C#中Query.RunQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Query.RunQuery方法的具体用法?C# Query.RunQuery怎么用?C# Query.RunQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query.RunQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetWorkItemsFrom

		public WorkItem[] GetWorkItemsFrom(string workItemNumber)
		{
			string query = string.Format(
					"SELECT * FROM workitems WHERE ([Team Project] = '{0}' AND [ID] >= {1} AND [Work Item Type] IN ({2}))",
					_settings.ProjectsMapping[0].Key,
					workItemNumber,
					_settings.EntityMapping.ToWorkItemsString());
			var workItemsQuery = new Query(_workItemStore, query, null, false);
			var workItems = workItemsQuery.RunQuery();
			return workItems.Cast<WorkItem>().ToArray();
		}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:11,代码来源:TfsWorkItemStoreClient.cs

示例2: GetWorkItemsBetween

		public WorkItem[] GetWorkItemsBetween(string projectName, string[] importedTypes, int minId, int maxId, DateTime lastSync)
		{
			string query = string.Format(
					"SELECT * FROM workitems WHERE ([Team Project] = '{0}' AND [ID] >= {1} AND [ID] <= {2} AND [Changed Date] > '{3}'  AND [Work Item Type] IN ({4}))",
					projectName,
					minId,
					maxId == -1 ? Int32.MaxValue : maxId,
					lastSync,
					importedTypes.ToString(x => string.Concat("'", x, "'"), ","));

			var workItemsQuery = new Query(_workItemStore, query, null, false);
			var workItems = workItemsQuery.RunQuery();
			return workItems.Cast<WorkItem>().ToArray();
		}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:14,代码来源:TfsWorkItemStoreClient.cs

示例3: ProcessWorkItemRelationships

        /// <summary>
        /// Method for processing work items down to the changesets that are related to them
        /// </summary>
        /// <param name="wi">Work Item to process</param>
        /// <param name="outputFile">File to write the dgml to</param>
        /// <param name="vcs">Version Control Server which contains the changesets</param>
        public void ProcessWorkItemRelationships()
        {
            _full = true;

            //Pull every work item for the project
            Query q = new Query(_wis, string.Format("SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], "
                + "[System.State] FROM WorkItems WHERE [System.TeamProject] = '{0}'", _projectName));
            WorkItemCollection wic = q.RunQuery();

            WorkItem[] workItems = new WorkItem[wic.Count];

            for (int i = 0; i < wic.Count; i++)
                workItems[i] = wic[i];

            Process(workItems);
        }
开发者ID:amccool,项目名称:WorkItemVisualization,代码行数:22,代码来源:ProcessFullAnalysis.cs

示例4: QueryWorkItems

        public List<WorkItem> QueryWorkItems(string queryPath, Action<int> progressReportHandler)
        {
            List<string> paths = queryPath.Split(Path.DirectorySeparatorChar).ToList();
            if (paths.Count == 1)
                paths = queryPath.Split(Path.AltDirectorySeparatorChar).ToList();

            Project project = m_workItemStore.Projects[paths[0]];
            paths.RemoveAt(0);

            QueryItem item = project.QueryHierarchy;
            foreach (string path in paths)
            {
                var queryFolder = item as QueryFolder;
                item = queryFolder[path];
            }
            if (item == null)
                throw new InvalidOperationException("Invalid Query Path.");

            string queryText = m_workItemStore.GetQueryDefinition(item.Id).QueryText.Replace("@project", "'" + project.Name + "'");
            var query = new Query(m_workItemStore, queryText);
            if (query.IsLinkQuery)
            {
                var queryResults = query.RunLinkQuery();
                var workItemIds = new List<int>();
                foreach (var queryResult in queryResults)
                {
                    workItemIds.Add(queryResult.SourceId);
                    workItemIds.Add(queryResult.TargetId);
                }
                using (var wiqlAccessor = new TfsWiqlAccessor(m_tfsAccessor))
                {
                    return wiqlAccessor.QueryWorkItemsByIds(workItemIds, progressReportHandler);
                }
            }
            var qResult = query.RunQuery();
            var result = new List<WorkItem>(qResult.Count);
            for (int i = 0; i < qResult.Count; i++)
            {
                result.Add(qResult[i]);
            }
            return result;
        }
开发者ID:starkmsu,项目名称:TaskScheduler,代码行数:42,代码来源:TfsQueryAccessor.cs

示例5: RunQuery

        public IEnumerable<WorkItem> RunQuery(QueryDefinition queryDefinition)
        {
            QueryDefinition parsedQueryDefinition = macroParser.Replace(queryDefinition);

            var query = new Query(currentContext.CurrentWorkItemStore, parsedQueryDefinition.QueryText);

            if (query.IsLinkQuery)
            {
                var queryResults = query.RunLinkQuery();

                return from l in queryResults.OfType<WorkItemLinkInfo>()
                       select currentContext.CurrentWorkItemStore.GetWorkItem(l.TargetId);
            }
            else
            {
                var queryResults = query.RunQuery();

                return queryResults.OfType<WorkItem>();
            }
        }
开发者ID:ielcoro,项目名称:TFSWorkItemQueryToWebAPI,代码行数:20,代码来源:QueryRunner.cs

示例6: GetWorkItemsFromLinkQuery

        private static WorkItemCollection GetWorkItemsFromLinkQuery(WorkItemStore store, Query workItemQuery,
                                                                    IEnumerable<FieldDefinition> fieldDefinitions)
        {
            var workItemInfo = workItemQuery.RunLinkQuery();

            var allWorkItemIds = workItemInfo.Select(wi => wi.TargetId).Distinct().ToArray();

            if (fieldDefinitions == null)
            {
                return store.Query(allWorkItemIds, "SELECT * FROM WorkItems");
            }
            else
            {
                IEnumerable<string> numericFieldDefinitionNames =
                    fieldDefinitions.Select(fd => "[" + fd.ReferenceName + "]");
                string select = "SELECT " + string.Join(", ", numericFieldDefinitionNames) + " FROM WorkItems";

                var actualWorkItemQuery = new Query(store, select, allWorkItemIds);

                return actualWorkItemQuery.RunQuery();
            }
        }
开发者ID:cqse,项目名称:ScrumPowerTools,代码行数:22,代码来源:WorkItemStoreExtensions.cs

示例7: GetWorkItem

 private WorkItem GetWorkItem(int id)
 {
     Query q = new Query(workItemStore, "SELECT System.ID FROM WorkITems WHERE [System.ID] = '"+id+"'");
     WorkItemCollection wic = q.RunQuery();
     if (wic.Count != 0)
     {
         return wic[0];
     }
     else
     {
         return null;
     }
 }
开发者ID:tomvanwijk,项目名称:ToscaAddin,代码行数:13,代码来源:TFSConnector.cs

示例8: GetWorkItemTree

        private IList<WorkItemViewModel> GetWorkItemTree(string query)
        {
            var treeQuery = new Query(_workItemStore, query);
            var links = treeQuery.RunLinkQuery();

            var workItemIds = links.Select(l => l.TargetId).ToArray();

            query = "SELECT * FROM WorkItems";
            var flatQuery = new Query(_workItemStore, query, workItemIds);
            var workItemCollection = flatQuery.RunQuery();

            var workItemList = new List<WorkItemViewModel>();

            for (int i = 0; i < workItemCollection.Count; i++)
            {
                var workItem = workItemCollection[i];

                if (workItem.Type.Name == "Requirement")
                {
                    var model = new WorkItemViewModel()
                    {
                        Id = workItem.Id,
                        RequestNo = workItem.Fields["MyCompany.RequestNumber"].Value.ToString(),
                        Title = workItem.Title,
                        WorkItemType = workItem.Fields["MyCompany.WorkItemType"].Value.ToString(),
                        Priority = workItem.Fields["MyCompany.Priority"].Value.ToString()
                    };

                    workItemList.Add(model);
                }
                else
                {
                    switch (workItem.Type.Name)
                    {
                        case "Task":
                            var task = new TFSTask()
                            {
                                Name = workItem.Title,
                                Activity = workItem.Fields["MyCompany.Activity"].Value.ToString(),
                                Start = (DateTime?)workItem.Fields["MyCompany.ActivityStart"].Value,
                                Due = (DateTime?)workItem.Fields["MyCompany.ActivityFinish"].Value,
                                Status = workItem.State
                            };

                            workItemList.Last().Tasks.Add(task);
                            break;
                        case "Issue":
                            var issue = new TFSIssue()
                            {
                                Name = workItem.Title,
                                Created = workItem.CreatedDate,
                                Due = (DateTime?)workItem.Fields["MyCompany.ActivityDue"].Value,
                                Status = workItem.State
                            };
                            workItemList.Last().Issues.Add(issue);
                            break;
                        default:
                            break;
                    }
                }
            }

            return workItemList;
        }
开发者ID:prabuw,项目名称:Learning,代码行数:64,代码来源:TFSManager.cs

示例9: ExecuteQueryLinkTypes

        public static bool ExecuteQueryLinkTypes(QueryDefinition qdef, string ProjectName, out int[] qdata)
        {
            Hashtable context = new Hashtable();
            StringBuilder strb = new StringBuilder();
            List<int> lqdata = new List<int>();

            context.Add("project", ProjectName); //@me, @today are filled automatically
            var query = new Query(Utilities.wistore, qdef.QueryText, context);

            if (query.IsLinkQuery)
            {
                foreach (var wilnk in query.RunLinkQuery())
                {
                    lqdata.Add(wilnk.TargetId);
                    lqdata.Add(wilnk.SourceId);

                    Utilities.OutputCommandString(string.Format("ParentID={0}, WorkItemID={1}", wilnk.SourceId, wilnk.TargetId));
                }
                lqdata = lqdata.Distinct().ToList();
            }
            else
            {
                foreach (WorkItem wi in query.RunQuery())
                {
                    lqdata.Add(wi.Id);

                    Utilities.OutputCommandString(string.Format("WorkItemID={0}, Title={1}", wi.Id, wi.Title));
                }
            }

            qdata = lqdata.ToArray();

            return false;
        }
开发者ID:mirik123,项目名称:tfsprod,代码行数:34,代码来源:ChangeLinkTypesPackage.cs

示例10: BwDoWork

        private void BwDoWork(object sender, DoWorkEventArgs e)
        {
            //      Logger.Write("Entering BwDoWork method");

              var newWorkItems = new ObservableCollection<WorkItem>();

              if (!string.IsNullOrEmpty((string) e.Argument))
              {
            var queryString = string.Format("SELECT * FROM WorkItems WHERE [System.IterationPath] = '{0}'", e.Argument);

            var q = new Query(workItemStoreService, queryString);
            if (q.IsLinkQuery)
            {
              var queryResults = q.RunLinkQuery();
              foreach (WorkItemLinkInfo i in queryResults)
              {
            var wi = workItemStoreService.GetWorkItem(i.TargetId);
            newWorkItems.Add(wi);
              }
            }
            else
            {
              var queryResults = q.RunQuery();
              foreach (WorkItem workitem in queryResults)
              {
            newWorkItems.Add(workitem);
              }
            }
              }
              e.Result = newWorkItems;
        }
开发者ID:frederiksen,项目名称:Task-Card-Creator,代码行数:31,代码来源:TfsUserControl.xaml.cs

示例11: RunQuery

        private List<WorkItem> RunQuery(Query query)
        {
            var queryResults = query.RunQuery();

            return queryResults.Cast<WorkItem>().ToList();
        }
开发者ID:ielcoro,项目名称:TFSWorkItemQueryToWebAPI,代码行数:6,代码来源:QueryExecutionTests.cs

示例12: Main

        static void Main(String[] args)
        {
            // Connect to Team Foundation Server
            //     Server is the name of the server that is running the application tier for Team Foundation.
            //     Port is the port that Team Foundation uses. The default port is 8080.
            //     VDir is the virtual path to the Team Foundation application. The default path is tfs.

            string tfsServerAddress = "http://tfs13dev:8080/tfs/";
       
            //Create class object
            ConnectionAndInformation.ConnectionAndInformation cai = new ConnectionAndInformation.ConnectionAndInformation();
            //create URI
            cai.createUriFromStringAddress(tfsServerAddress);
            //TfsConfigurationServer
            cai.createConfigurationServer(cai.uriGetSet);
            //create catalog of team project collections
            cai.createCatalogTeamProjectCollections(cai.tfsConfigurationServerGetSet);

            cai.getCatalogTeamProjects(cai.catalogNodesGetSet);
         
            List<string> list = new List<string>();
            string info = String.Empty;
            var qText = String.Format(@"SELECT * FROM WorkItems WHERE [System.TeamProject] = 'TSDL' ORDER BY [System.Id]");
                //TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs13dev:8080/tfs/"));
                var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfs13dev:8080/tfs/"));
                var service = tpc.GetService<WorkItemStore>();
                //TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://tfs13dev:8080/tfs/"));
                WorkItemStore workItemStore = (WorkItemStore)tpc.GetService(typeof(WorkItemStore));
               // WorkItemCollection queryResults = workItemStore.Query("SELECT * FROM WorkItems WHERE [System.TeamProject] = LEAP");
               // WorkItemCollection queryResults = workItemStore.Query("SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo] FROM WorkItems WHERE [System.TeamProject] = 'ODS' ORDER by [System.Id] desc");
                //WorkItemStore workItemStore = new WorkItemStore(tpc);
                //Project teamProject = workItemStore.Projects["ODS"];
                //WorkItemType wit = teamProject.WorkItemTypes[""];
                Project teamProject = workItemStore.Projects["TSDL"];
                /*
                WorkItemType workItemType = teamProject.WorkItemTypes["Requirement"];

                WorkItem userStory = new WorkItem(workItemType)
                {
                    Title = "Recently ordered menu",
                    Description = "As a return customer, I want to see items that I've recently ordered."


                };
                userStory.Save();
            */
                Query query = new Query(service, qText);

                var workItems = query.RunQuery(); 

                foreach(WorkItem workItem in workItems)
                {
                    list.Add(workItem.Id + " - " + workItem.Title);
                }

                list.ForEach(i => Console.Write("{0}\n", i));

            /*
                WorkItemCollection queryResults = workItemStore.Query("SELECT * FROM WorkItems WHERE [System.TeamProject] = 'TSDL' ORDER BY [System.Id]");

                foreach(WorkItem wi in queryResults)
                {
                    Console.WriteLine("QueryResults: " + wi);
                
                }
            */
                
                


        }
开发者ID:dwhudson,项目名称:TFS_Work_Intake_Interface,代码行数:71,代码来源:Program.cs

示例13: RunQuery

        /// <summary>
        /// Executes the selected work item query
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RunQuery()
        {
            Mouse.OverrideCursor = Cursors.Wait;
            WorkItemCollection wic;
            string finalQuery = string.Empty;

            TreeNode item = (TreeNode)tvwQueries.SelectedItem;

            if (item.Tag.GetType() == typeof(QueryDefinition))
            {
                _queryResults = new List<WorkItemData>();

                //var projectName = cboProjects.Text;
                var si = cboProjects.SelectedItem as ProjectInfo;
                var projectName = si.Name;

                QueryDefinition qd = (QueryDefinition)item.Tag;
                //Replace the @Project and @Me options if they exist in the query
                finalQuery = qd.QueryText;
                if (finalQuery.IndexOf("@project") > 0)
                    finalQuery = finalQuery.Replace("@project", "'" + projectName + "'");
                if (finalQuery.IndexOf("@Me") > 0)
                    finalQuery = finalQuery.Replace("@Me", System.Security.Principal.WindowsIdentity.GetCurrent().Name);

                Query query = new Query(_wis, finalQuery);
                if (query.IsTreeQuery || query.IsLinkQuery)
                {
                    _queryResults = GetHierarchicalResults(query);
                }
                else
                {
                    wic = query.RunQuery();
                    for (int i = 0; i < wic.Count; i++)
                    {
                        _queryResults.Add(new WorkItemData() { ID = wic[i].Id, WI = wic[i] });
                    }
                }
                LoadListView(_queryResults, query);
            }
            Mouse.OverrideCursor = null;
        }
开发者ID:amccool,项目名称:WorkItemVisualization,代码行数:46,代码来源:MainWindow.xaml.cs

示例14: QueryWorkItems

        public List<WorkItem> QueryWorkItems(
			string wiqlString,
			Dictionary<string, object> paramValues,
			Dictionary<string, List<object>> complexParamValues,
			Action<int> progressReportHandler)
        {
            if (complexParamValues != null && complexParamValues.Count > 0)
                wiqlString = UpdateParams(wiqlString, paramValues, complexParamValues);

            var query = new Query(m_workItemStore, wiqlString, paramValues ?? new Dictionary<string, object>(0));

            var queryResult = query.RunQuery();
            var result = new List<WorkItem>(queryResult.Count);
            for (int i = 0; i < queryResult.Count; i++)
            {
                var wi = queryResult[i];
                wi.SyncToLatest();
                result.Add(wi);
                if (progressReportHandler != null)
                    progressReportHandler(i * 100 / queryResult.Count);
            }
            return result;
        }
开发者ID:starkmsu,项目名称:TfsRetrospectiveTool,代码行数:23,代码来源:TfsWiqlAccessor.cs

示例15: ItemOnSelected

        public void ItemOnSelected(object sender, RoutedEventArgs e)
        {
            try
            {
                var item = (TreeViewItem)sender;
                if (Query != null)
                {
                    var queryDef = (QueryDefinition)project.QueryHierarchy.Find((Guid)item.Tag);

                    queryDef.QueryText = queryDef.QueryText.Replace("@project", "'" + project.Name + "'");
                    Query(queryDef);


                    var query = new Query(ItemStore, queryDef.QueryText);
                    Int32 count = 0;
                    if (query.IsLinkQuery)
                    {
                        var queryResults = query.RunLinkQuery();
                        count = queryResults.Count();
                    }
                    else
                    {
                        var queryResults = query.RunQuery();
                        count = queryResults.Count;
                    }


                    QueryTypes type;

                    switch (queryDef.QueryType)
                    {
                        case QueryType.List: type = QueryTypes.FView; break;
                        case QueryType.OneHop: type = QueryTypes.DView; break;
                        case QueryType.Tree: type = QueryTypes.HView; break;
                        default: type = QueryTypes.None; break;
                    }
                    item.Header = CreateTreeItem(queryDef.Name + " [" + count + "]", type);
                    QueryReport.correctQuery = true;
                }
            }
            catch (InvalidQueryTextException ex)
            {
                MessageBox.Show(ex.Message, ResourceHelper.GetResourceString("ERROR_TEXT"), MessageBoxButton.OK, MessageBoxImage.Error);
                QueryReport.correctQuery = false;
            }
        }
开发者ID:nkravch,项目名称:SALMA-2.0,代码行数:46,代码来源:QueryManager.cs


注:本文中的Query.RunQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。