internal static List<WorkItem> GetNoShipBugs( string tfsUrl, string areaPath, string iterarion, Action<int> progressReportHandler) { var strBuilder = new StringBuilder(); strBuilder.Append("SELECT [System.Id] FROM WorkItemLinks"); strBuilder.Append(" WHERE Source.[System.WorkItemType] = 'Bug'"); strBuilder.Append(" AND Source.[System.AreaPath] UNDER '" + areaPath + "'"); strBuilder.Append(" AND Source.[System.IterationPath] UNDER '" + iterarion + "'"); strBuilder.Append(" AND Source.[System.State] <> 'Proposed'"); strBuilder.Append(" AND Source.[System.State] <> 'Active'"); strBuilder.Append(" AND Source.[System.Reason] <> 'Converted to Requirement'"); strBuilder.Append(" AND Source.[Completed Work] > 0"); strBuilder.Append(" AND Target.[System.WorkItemType] = 'Ship'"); strBuilder.Append(" MODE (DoesNotContain)"); List<WorkItem> result; using (var wiqlAccessor = new TfsWiqlAccessor(tfsUrl)) { var ids = wiqlAccessor.QueryIdsFromLinks( strBuilder.ToString(), null, null, null); if (ids.Count == 0) return new List<WorkItem>(0); strBuilder.Clear(); strBuilder.Append("SELECT [System.Id] FROM WorkItemLinks"); strBuilder.Append(" WHERE Source.[System.Id] IN (" + string.Join(",", ids.Keys) + ")"); strBuilder.Append(" AND [System.Links.LinkType] = 'Child'"); strBuilder.Append(" AND Target.[System.WorkItemType] = 'LeadTask'"); strBuilder.Append(" AND Target.[Microsoft.VSTS.Common.Discipline] = 'Development'"); strBuilder.Append(" MODE (DoesNotContain)"); ids = wiqlAccessor.QueryIdsFromLinks( strBuilder.ToString(), null, null, null); if (ids.Count == 0) return new List<WorkItem>(0); result = wiqlAccessor.QueryWorkItemsByIds( ids.Keys, "ORDER BY [Completed Work] DESC", progressReportHandler); } return result; }
private static Dictionary<int, int> GetWrongAreaPathBugs( TfsWiqlAccessor wiqlAccessor, string areaPath, string iterarion, bool ourBugs, Action<int> progressReportHandler) { var strBuilder = new StringBuilder(); strBuilder.Append("SELECT [System.Id] FROM WorkItemLinks"); strBuilder.Append(" WHERE Source.[System.WorkItemType] = 'Bug'"); strBuilder.Append(" AND Source.[System.AreaPath] " + (ourBugs ? "NOT UNDER '" : "UNDER '") + areaPath + "'"); strBuilder.Append(" AND Source.[System.IterationPath] UNDER '" + iterarion + "'"); strBuilder.Append(" AND Target.[System.WorkItemType] = 'Ship'"); strBuilder.Append(" AND Target.[System.AreaPath] " + (ourBugs ? "UNDER '" : "NOT UNDER '") + areaPath + "'"); strBuilder.Append(" AND Target.[System.IterationPath] UNDER '" + iterarion + "'"); strBuilder.Append(" MODE (MustContain)"); var bugsWithOtherShips = wiqlAccessor.QueryIdsFromLinks( strBuilder.ToString(), null, null, progressReportHandler); if (bugsWithOtherShips.Count == 0) return new Dictionary<int, int>(); strBuilder.Clear(); strBuilder.Append("SELECT [System.Id] FROM WorkItemLinks"); strBuilder.Append(" WHERE Source.[System.Id] IN (" + string.Join(",", bugsWithOtherShips.Keys) + ")"); strBuilder.Append(" AND Target.[System.WorkItemType] = 'Ship'"); strBuilder.Append(" AND Target.[System.AreaPath] " + (ourBugs ? "NOT UNDER '" : "UNDER '") + areaPath + "'"); strBuilder.Append(" AND Target.[System.IterationPath] UNDER '" + iterarion + "'"); strBuilder.Append(" MODE (DoesNotContain)"); var result = wiqlAccessor.QueryIdsFromLinks( strBuilder.ToString(), null, null, null); return result.ToDictionary(i => i.Key, i => bugsWithOtherShips[i.Key].First()); }
private static List<WorkItem> GetBugs( string tfsUrl, string areaPath, string iterarion, bool newFunc, bool sd, Action<int> progressReportHandler) { var strBuilder = new StringBuilder(); strBuilder.Append("SELECT [System.Id] FROM WorkItemLinks"); strBuilder.Append(" WHERE Source.[System.WorkItemType] = 'Bug'"); strBuilder.Append(" AND Source.[System.AreaPath] UNDER '" + areaPath + "'"); strBuilder.Append(" AND Source.[System.IterationPath] UNDER '" + iterarion + "'"); strBuilder.Append(" AND Source.[System.State] <> 'Proposed'"); strBuilder.Append(" AND Source.[System.State] <> 'Active'"); if (!sd) { strBuilder.Append(" AND Source.[Found On Level] <> '6 Product Testing'"); strBuilder.Append(" AND Source.[Regress] = '" + (newFunc ? "No" : "Yes") + "'"); } strBuilder.Append(" AND Source.[Service Desk] "+ (sd ? "=" : "<>") + " 'Yes'"); strBuilder.Append(" AND Source.[System.Reason] NOT IN ('Rejected', 'Deferred', 'Duplicate', 'Cannot Reproduce', 'Converted to Requirement')"); strBuilder.Append(" AND Target.[System.WorkItemType] = 'LeadTask'"); strBuilder.Append(" AND Target.[Microsoft.VSTS.Common.Discipline] = 'Development'"); strBuilder.Append(" AND [System.Links.LinkType] = 'Child'"); strBuilder.Append(" MODE (DoesNotContain)"); List<WorkItem> result; using (var wiqlAccessor = new TfsWiqlAccessor(tfsUrl)) { var ids = wiqlAccessor.QueryIdsFromLinks( strBuilder.ToString(), null, null, null); if (ids.Count == 0) return new List<WorkItem>(0); strBuilder.Clear(); strBuilder.Append("SELECT [System.Id] FROM WorkItemLinks"); strBuilder.Append(" WHERE Source.[System.Id] IN (" + string.Join(",", ids.Keys) + ")"); strBuilder.Append(" AND Target.[System.WorkItemType] = 'Ship'"); strBuilder.Append(" AND Target.[System.AreaPath] UNDER '" + areaPath + "'"); strBuilder.Append(" AND Target.[System.IterationPath] UNDER '" + iterarion + "'"); strBuilder.Append(" MODE (MustContain)"); ids = wiqlAccessor.QueryIdsFromLinks( strBuilder.ToString(), null, null, null); if (ids.Count == 0) return new List<WorkItem>(0); result = wiqlAccessor.QueryWorkItemsByIds( ids.Keys, "ORDER BY [Completed Work] DESC", progressReportHandler); } return result; }