Beispiel #1
0
        private string GetQuery()
        {
            var filterBuilder = new StringBuilder();

            if (State.Any())
            {
                filterBuilder.Append("(");
                var itemQuery = string.Join(",", State.Select(x => $"\"{x}\""));
                filterBuilder.Append($"[System.State] IN ({itemQuery})");
                filterBuilder.Append(")");
            }

            if (Tags.Any())
            {
                if (filterBuilder.Length > 0)
                {
                    filterBuilder.Append(" AND ");
                }

                filterBuilder.Append(string.Join(" AND ", Tags.Select(tag => $"[System.Tags] Contains \"{tag}\"")));
            }

            if (!string.IsNullOrWhiteSpace(WorkItemType))
            {
                if (filterBuilder.Length > 0)
                {
                    filterBuilder.Append(" AND ");
                }

                filterBuilder.Append($"[System.WorkItemType] = \"{WorkItemType.Normalize()}\"");
            }
            else if (WorkItemId.HasValue)
            {
                if (filterBuilder.Length > 0)
                {
                    filterBuilder.Append(" AND ");
                }

                filterBuilder.Append($"[System.Id] = \"{WorkItemId.Value}\"");
            }

            if (!string.IsNullOrWhiteSpace(AssignedTo))
            {
                if (filterBuilder.Length > 0)
                {
                    filterBuilder.Append(" AND ");
                }

                filterBuilder.Append($"[System.AssignedTo] CONTAINS \"{AssignedTo}\"");
            }

            if (filterBuilder.Length > 0)
            {
                filterBuilder.Insert(0, "AND ");
            }

            string workItemQuery = $"SELECT [System.Id] FROM workitems WHERE [System.TeamProject] = \"{ProjectName}\" {filterBuilder} ORDER BY [System.ChangedDate] DESC";

            return(workItemQuery);
        }
Beispiel #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = WorkItemId.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)QueryType;
         hashCode = (hashCode * 397) ^ MyWorkItems.GetHashCode();
         hashCode = (hashCode * 397) ^ (ProjectName != null ? ProjectName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (WorkItemType != null ? WorkItemType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AssignedTo != null ? AssignedTo.GetHashCode() : 0);
         return(hashCode);
     }
 }