本文整理汇总了C#中Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.Query方法的典型用法代码示例。如果您正苦于以下问题:C# WorkItemStore.Query方法的具体用法?C# WorkItemStore.Query怎么用?C# WorkItemStore.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore
的用法示例。
在下文中一共展示了WorkItemStore.Query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorkItemTimeCollection
/// <summary>
/// Search all work items
/// </summary>
/// <param name="store"></param>
/// <param name="iterationPath"></param>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
public WorkItemTimeCollection(WorkItemStore store, string iterationPath, DateTime startDate, DateTime endDate)
{
this.IterationPath = iterationPath;
this.Data = new ObservableCollection<WorkItemTime>();
// Sets a list of dates to compute
_trackDates.Add(startDate.Date);
for (DateTime date = startDate.Date; date <= endDate.Date; date = date.AddDays(1))
{
_trackDates.Add(date.AddHours(23).AddMinutes(59));
}
// Gets all work items for each dates
foreach (DateTime asOfDate in _trackDates)
{
// Execute the query
var wiCollection = store.Query(this.GetQueryString(asOfDate));
// Iterate through all work items
foreach (WorkItem wi in wiCollection)
{
WorkItemTime time = new WorkItemTime(asOfDate, wi);
this.Data.Add(time);
}
}
}
示例2: GetWorkItem
private static WorkItem GetWorkItem(WorkItemStore workItemStore, string workItemType, int workItemId)
{
var queryResults = workItemStore.Query(string.Format(@"
Select [State], [Title]
From WorkItems
Where [Work Item Type] = '{0}' And Id = {1}
Order By [State] Asc, [Changed Date] Desc", workItemType, workItemId));
return queryResults.Count == 0 ? null : queryResults[0];
}
示例3: Get
public IEnumerable<FeatureEntity> Get(string project, string rootQuery, string query)
{
if (string.IsNullOrEmpty(project)) throw new NullReferenceException("project");
if (string.IsNullOrEmpty(rootQuery)) throw new NullReferenceException("rootQuery");
if (string.IsNullOrEmpty(query)) throw new NullReferenceException("query");
var tpc = new TfsTeamProjectCollection(new Uri(TfsUrl));
var workItemStore = new WorkItemStore(tpc);
var queryRoot = workItemStore.Projects[project].QueryHierarchy;
var folder = (QueryFolder)queryRoot[rootQuery];
QueryDefinition queryDef = null;
foreach (var q in query.Split('/'))
{
queryDef = (QueryDefinition)folder[q];
}
if (queryDef == null)
{
throw new Exception(string.Format("Query {0} was not found on the root {1}", query, rootQuery));
}
var queryResults = workItemStore.Query(queryDef.QueryText);
var result = new List<FeatureEntity>();
foreach (WorkItem wi in queryResults)
{
try
{
var targetDate = (DateTime)wi["Target Date"];
var targetEndDate = (DateTime)wi["Target End Date"];
result.Add(new FeatureEntity
{
Start = targetDate,
End = targetEndDate,
Group = wi["Group"].ToString(),
Title = wi.Title,
Url = string.Format("{0}/{1}/_workitems#_a=edit&id={2}", TfsUrl, project, wi.Id),
Risk = wi["Risk"] as string,
Tags = wi.Tags,
Priority = wi["Priority"].ToString(),
Requestor = wi["Requestor"].ToString(),
WIId = wi.Id,
ChildUSCount = GetAtivatedChildUsCount(workItemStore, wi),
Status = wi["Status"].ToString()
});
}
catch (Exception ex)
{
}
}
return result;
}
示例4: btnMicrosoftTeamFoundationWorkItemTrackingClientWorkItem_Click
private void btnMicrosoftTeamFoundationWorkItemTrackingClientWorkItem_Click(object sender, EventArgs e)
{
var tfs = new TfsTeamProjectCollection(new Uri(string.Format("http://{0}:8080/tfs", Environment.MachineName)), new TfsClientCredentials(new WindowsCredential(true), true));
var store = new WorkItemStore(tfs);
var workItemList = new List<WorkItem>(store.Query("SELECT Id, Title, [Work Item Type] FROM WorkItems").Cast<WorkItem>());
if (workItemList.Count > 0)
{
workItemList[0].PartialOpen();
workItemList[0].Title = string.Format("changed the title to show the date - {0}", DateTime.Now.ToString("dd MMM yyyy"));
workItemList[0].Description = "bob is the description";
}
Debugger.Break();
}
示例5: Main
static void Main(string[] args)
{
var tpc = new TfsTeamProjectCollection(new Uri("http://exptfs:8080/tfs/geneva"));
var workItemStore = new WorkItemStore(tpc);
var queryRoot = workItemStore.Projects["PSG Dashboard"].QueryHierarchy;
var folder = (QueryFolder)queryRoot["Shared Queries"];
var queryDef = (QueryDefinition)folder["All Active Features"];
var queryResults = workItemStore.Query(queryDef.QueryText);
foreach (WorkItem q in queryResults)
{
Console.WriteLine(q.Tags);
}
}
示例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();
}
}
示例7: getFeatureProductBacklogMapping
private static Dictionary<int, List<WorkItem>> getFeatureProductBacklogMapping(WorkItemStore query, List<int> relatedLinkIds)
{
Dictionary<int, List<WorkItem>> featureProductBacklogMapping = new Dictionary<int, List<WorkItem>>();
var wiqlBacklogs =
"SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.Id] IN ({0}) AND [System.WorkItemType] = '產品待處理項目'";
var queryBacklogs = query.Query(String.Format(wiqlBacklogs, String.Join(",", relatedLinkIds.ToArray())));
var backlogList = queryBacklogs.Cast<WorkItem>().ToList();
foreach (var productBacklog in backlogList)
{
foreach (
var linkId in
productBacklog.Links.OfType<RelatedLink>().Select(relatedLink => relatedLink.RelatedWorkItemId))
{
if (!featureProductBacklogMapping.ContainsKey(linkId))
{
featureProductBacklogMapping.Add(linkId, new List<WorkItem>());
}
featureProductBacklogMapping[linkId].Add(productBacklog);
}
}
return featureProductBacklogMapping;
}
示例8: GetWorkItemCollection
/// <summary>
/// Gets a work item collection.
/// </summary>
/// <param name="wiqlQueryFormat">The WIQL query format string</param>
/// <param name="args">The arguments for the format string</param>
private WorkItemCollection GetWorkItemCollection(WorkItemStore store, string wiqlQueryFormat, params object[] args)
{
var wiql = string.Format(wiqlQueryFormat, args);
return store.Query(wiql);
}
示例9: GetWorkItemByID
/// <summary>
/// Gets the work item by its ID.
/// </summary>
/// <param name="workItemID">The work item ID.</param>
private WorkItem GetWorkItemByID(WorkItemStore store, string workItemID)
{
var wiql = String.Format(@"SELECT [System.ID],
[System.Title],
[System.Description],
[System.State]
{0}
FROM WorkItems
WHERE [System.ID] = '{1}'",
String.IsNullOrEmpty(this.CustomReleaseNumberFieldName)
? ""
: ", [" + this.CustomReleaseNumberFieldName + "]",
workItemID);
var workItemCollection = store.Query(wiql);
if (workItemCollection.Count == 0) throw new Exception("There is no work item with the ID: " + workItemID);
if (workItemCollection.Count > 1) throw new Exception("There are multiple issues with the same ID: " + workItemID);
return workItemCollection[0];
}
示例10: Query4BBI
private WorkItemCollection Query4BBI(WorkItemStore _wis, string _teamProject, string _buildNumber)
{
StringBuilder _wiql = new StringBuilder();
_wiql.AppendLine("SELECT [System.ID], [System.Title]")
.AppendLine("FROM WORKITEMS")
.AppendLine("WHERE ([HIC.Build.Number] == '" + _buildNumber + "'")
.AppendLine("OR")
.AppendLine("[System.Title] == '" + _buildNumber + "')")
.AppendLine("AND")
.AppendLine("[System.TeamProject] == '" + _teamProject + "'")
.AppendLine("AND")
.AppendLine("[System.WorkItemType] == 'Build Backlog Item'");
return (_wis.Query(_wiql.ToString()));
}
示例11: getProductBacklogTaskMapping
private Dictionary<int, List<WorkItem>> getProductBacklogTaskMapping(WorkItemStore query)
{
var productBacklogTaskMapping = new Dictionary<int, List<WorkItem>>();
var wiqlTasks =
"SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.WorkItemType] = '工作' AND [System.State] = '完成' AND [Microsoft.VSTS.Common.StateChangeDate] >= @today - 30";
var queryTasks = query.Query(String.Format(wiqlTasks, howManyDays));
var taskList = queryTasks.Cast<WorkItem>().ToList();
convertTaskListIntoBacklogTaskMapping(taskList, productBacklogTaskMapping);
return productBacklogTaskMapping;
}
示例12: getFeatures
private static List<WorkItem> getFeatures(WorkItemStore query, Dictionary<int, List<WorkItem>> featureProductBacklogMapping)
{
List<WorkItem> features = new List<WorkItem>();
var wiqlFeatures =
"SELECT [System.Id], [System.Title] FROM WorkItems WHERE [System.Id] IN ({0}) AND [System.WorkItemType] = '特殊功能'";
var queryFeatures =
query.Query(String.Format(wiqlFeatures, String.Join(",", featureProductBacklogMapping.Keys.ToArray())));
features = queryFeatures.Cast<WorkItem>().ToList();
return features;
}
示例13: GetWorkItemListById
public static List<WorkItem> GetWorkItemListById(string idList)
{
_workItemStore = GetWorkItemStore;
WorkItemCollection workItemCollection = _workItemStore.Query(
"SELECT * FROM WorkItems WHERE [System.TeamProject] = 'LEAP'");
var _workItemList = new List<WorkItem>();
foreach(WorkItem wi in workItemCollection)
{
_workItemList.Add(wi);
}
return _workItemList;
}
示例14: Main
static void Main(string[] args)
{
var options = new Options();
if (!CommandLine.Parser.Default.ParseArguments(args, options))
{
Console.WriteLine(options.GetUsage());
return;
}
// Connect to the desired Team Foundation Server
TfsTeamProjectCollection tfsServer = new TfsTeamProjectCollection(new Uri(options.ServerNameUrl));
// Authenticate with the Team Foundation Server
tfsServer.Authenticate();
// Get a reference to a Work Item Store
var workItemStore = new WorkItemStore(tfsServer);
var project = GetProjectByName(workItemStore, options.ProjectName);
if (project == null)
{
Console.WriteLine($"Could not find project '{options.ProjectName}'");
return;
}
var query = GetWorkItemQueryByName(workItemStore, project, options.QueryPath);
if (query == null)
{
Console.WriteLine($"Could not find query '{options.QueryPath}' in project '{options.ProjectName}'");
return;
}
var queryText = query.QueryText.Replace("@project", $"'{project.Name}'");
Console.WriteLine($"Executing query '{options.QueryPath}' with text '{queryText}'");
var count = workItemStore.QueryCount(queryText);
Console.WriteLine($"Exporting {count} work items");
var workItems = workItemStore.Query(queryText);
foreach (WorkItem workItem in workItems)
{
StoreAttachments(workItem, options.OutputPath);
}
}
示例15: GetIDClause
private string GetIDClause(WorkItemStore store)
{
if (!string.IsNullOrEmpty(RequirementsQuery))
{
var query = FindQueryRecursive(store.Projects[ProjectName].QueryHierarchy);
if (query == null)
{
throw new ApplicationException(string.Format("Could not find query [{0}]", RequirementsQuery));
}
if (query.QueryType != QueryType.List)
{
throw new ApplicationException(string.Format("Query [{0}] is not a flat-list query - only flat-list queries are supported", RequirementsQuery));
}
var reqs = store.Query(query.QueryText, new Dictionary<string, object> { { "project", ProjectName } } );
var ids = reqs.Cast<WorkItem>().Select(w => w.Id.ToString()).Aggregate("", (w, s) => s + "," + w);
ids = ids.Substring(0, ids.Length - 1);
return string.Format("Source.[System.ID] IN ({0}) AND", ids);
}
return "";
}