示例#1
0
        public IEnumerable <TfsStory> GetTfsStories()
        {
            if (_stories == null)
            {
                _stories = new List <TfsStory>();
                string wiql = @"Select [Id], [Title], [Assigned To], [Created Date], [Iteration Path], [State]  
                            From [WorkItems]
                            Where ([Work Item Type] = 'User Story' or [Work Item Type] = 'Product Backlog Item')
                            and [Team Project] = '{0}'";

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

                foreach (WorkItem item in queryResults)
                {
                    TfsStory story = null;

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

                    _stories.Add(story);
                }
            }

            return(_stories);
        }
        public static TfsStory ToTfsStory(this WorkItem workItem)
        {
            var item = new TfsStory()
            {
                Id = workItem.Id,
                AssignedTo = (string)workItem.Fields[CoreField.AssignedTo].Value,
                Title = workItem.Title,
                CreatedDate = workItem.CreatedDate,
                IterationPath = workItem.IterationPath,
                State = workItem.State
            };
            // put user story specific properties
            if (workItem.Type.Name == "User Story")
            {
                if (workItem.Fields.Contains("Story Points"))
                    item.StoryPoints = (double)(workItem.Fields["Story Points"].Value ?? 0d);
                if (workItem.Fields.Contains("Start Date"))
                    item.CreatedDate = (DateTime)(workItem.Fields["Created Date"].Value ?? DateTime.MinValue);
                if (workItem.Fields.Contains("Closed Date"))
                    item.ClosedDate = (DateTime?)workItem.Fields["Closed Date"].Value;


                List<Revision> revisions = workItem.Revisions.ToList();

                Revision initialEstimationRevision = (from revision in revisions
                                                      where revision.Fields["Story Points"].Value != null
                                                      select revision).FirstOrDefault();

                var initialEstimateSP = initialEstimationRevision != null ? initialEstimationRevision.Fields["Story Points"].Value : 0d;

                item.FirstEstimationDate = initialEstimationRevision != null && initialEstimationRevision.Fields.Contains("State Change Date") ? (DateTime?)(initialEstimationRevision.Fields["State Change Date"].Value) : null;

            }
            return item;
        }
示例#3
0
        public static TfsStory ToTfsStory(this WorkItem workItem)
        {
            var item = new TfsStory()
            {
                Id            = workItem.Id,
                AssignedTo    = (string)workItem.Fields[CoreField.AssignedTo].Value,
                Title         = workItem.Title,
                CreatedDate   = workItem.CreatedDate,
                IterationPath = workItem.IterationPath,
                State         = workItem.State
            };

            // put user story specific properties
            if (workItem.Type.Name == "User Story")
            {
                if (workItem.Fields.Contains("Story Points"))
                {
                    item.StoryPoints = (double)(workItem.Fields["Story Points"].Value ?? 0d);
                }
                if (workItem.Fields.Contains("Start Date"))
                {
                    item.CreatedDate = (DateTime)(workItem.Fields["Created Date"].Value ?? DateTime.MinValue);
                }
                if (workItem.Fields.Contains("Closed Date"))
                {
                    item.ClosedDate = (DateTime?)workItem.Fields["Closed Date"].Value;
                }


                List <Revision> revisions = workItem.Revisions.ToList();

                Revision initialEstimationRevision = (from revision in revisions
                                                      where revision.Fields["Story Points"].Value != null
                                                      select revision).FirstOrDefault();

                var initialEstimateSP = initialEstimationRevision != null ? initialEstimationRevision.Fields["Story Points"].Value : 0d;

                item.FirstEstimationDate = initialEstimationRevision != null && initialEstimationRevision.Fields.Contains("State Change Date") ? (DateTime?)(initialEstimationRevision.Fields["State Change Date"].Value) : null;
            }
            return(item);
        }