Ejemplo n.º 1
0
        /// <summary>
        /// Gets the TFS tasks.
        /// </summary>
        /// <param name="iterationPath">The iteration path.</param>
        /// <returns></returns>
        public IEnumerable <TfsTask> GetTfsTasks(string iterationPath)
        {
            if (_tasks == null)
            {
                _tasks = new List <TfsTask>();
                string wiql = @"Select [State], [Title] 
                            From [WorkItems]
                            Where [Work Item Type] = 'Task'
                            And [Team Project] = '{0}'
                            And [Iteration Path] = '{1}'";

                WorkItemCollection queryResults = TeamProject.Store.Query(
                    string.Format(wiql, TeamProject.ProjectName, iterationPath));

                foreach (WorkItem item in queryResults)
                {
                    TfsTask task = null;

                    task      = item.ToTfsTask();
                    task.Link = string.Format("{0}/{1}/_workitems/edit/{2}", TeamProject.Store.TeamProjectCollection.Uri.AbsoluteUri,
                                              TeamProject.ProjectName, item.Id);

                    _tasks.Add(task);
                }
            }
            return(_tasks);
        }
Ejemplo n.º 2
0
        public static TfsTask ToTfsTask(this WorkItem workItem)
        {
            var item = new TfsTask {
                Id          = workItem.Id,
                AssignedTo  = (string)workItem.Fields[CoreField.AssignedTo].Value,
                Title       = workItem.Title,
                Tags        = workItem.Tags,
                CreatedDate = workItem.CreatedDate
            };

            // put task specific properties
            if (workItem.Type.Name == "Task")
            {
                if (workItem.Fields.Contains("Original Estimate"))
                {
                    item.OriginalEstimate = (double)(workItem.Fields["Original Estimate"].Value ?? 0d);
                }
                if (workItem.Fields.Contains("Completed Work"))
                {
                    item.CompletedWork = (double)(workItem.Fields["Completed Work"].Value ?? 0d);
                }
                if (workItem.Fields.Contains("Remaining Work"))
                {
                    item.RemainingWork = (double)(workItem.Fields["Remaining Work"].Value ?? 0d);
                }

                var parent = workItem.WorkItemLinks.Cast <WorkItemLink>().
                             FirstOrDefault(link => link.LinkTypeEnd.Name.Equals("Parent"));

                if (parent != null)
                {
                    item.Parent = parent.TargetId;
                }
            }

            if (workItem.Fields.Contains("Story Points"))
            {
                item.OriginalEstimate = (double)(workItem.Fields["Story Points"].Value ?? 0d);
            }

            return(item);
        }
        public static TfsTask ToTfsTask(this WorkItem workItem)
        {
            var item = new TfsTask{
                Id = workItem.Id,
                AssignedTo = (string)workItem.Fields[CoreField.AssignedTo].Value,
                Title = workItem.Title,
                Tags = workItem.Tags,
                CreatedDate = workItem.CreatedDate
            };

            // put task specific properties
            if (workItem.Type.Name == "Task")
            {
                if (workItem.Fields.Contains("Original Estimate"))
                {
                    item.OriginalEstimate = (double)(workItem.Fields["Original Estimate"].Value ?? 0d);
                }
                if (workItem.Fields.Contains("Completed Work"))
                {
                    item.CompletedWork = (double)(workItem.Fields["Completed Work"].Value ?? 0d);
                }
                if (workItem.Fields.Contains("Remaining Work"))
                {
                    item.RemainingWork = (double)(workItem.Fields["Remaining Work"].Value ?? 0d);
                }

                var parent = workItem.WorkItemLinks.Cast<WorkItemLink>().
                    FirstOrDefault(link=>link.LinkTypeEnd.Name.Equals("Parent"));

                if (parent!= null)
                {
                    item.Parent = parent.TargetId;
                }
            }

            if (workItem.Fields.Contains("Story Points"))
                item.OriginalEstimate = (double)(workItem.Fields["Story Points"].Value ?? 0d);

            return item;
        }