public bool CopyAttributes(Story pivotalstorySource, WorkItem destinationWorkItem)
 {
     destinationWorkItem.Fields[ConchangoTeamsystemScrumEstimatedeffort].Value = pivotalstorySource.Estimate;
     destinationWorkItem.Fields[ConchangoTeamsystemScrumBusinesspriority].Value = pivotalstorySource.Priority;
     destinationWorkItem.Fields[ConchangoTeamsystemScrumDeliveryorder].Value = pivotalstorySource.Priority;
     return true;
 }
Beispiel #2
0
 bool ITFS.DeletePivotalStoryFromTFS(Story storyToDelete, string projectname, string iterationPath)
 {
     var iteration = store.Projects[projectname].IterationRootNodes[iterationPath];
     if (iteration != null)
     {
         var nodes =
             store.Projects[projectname].IterationRootNodes[iterationPath].ChildNodes.GetEnumerator();
         while (nodes.MoveNext())
         {
             if (!((WorkItem) nodes.Current).History.Contains(string.Concat(Pivotalid, storyToDelete.Id))) continue;
             var workitem = ((WorkItem) nodes.Current);
             if (workitem == null) continue;
             workitem.Open();
             workitem.Reason = "Deleted in Pivotal.";
             workitem.State = "Closed";
             workitem.Save();
         }
     }
     return false;
 }
 public bool CopyAttributes(Story pivotalstorySource, WorkItem destinationWorkItem)
 {
     throw new NotImplementedException();
 }
 public bool CopyAttributes(Story pivotalstorySource, WorkItem destinationWorkItem)
 {
     destinationWorkItem.Fields[microsoftVstsSchedulingEffort].Value = pivotalstorySource.Estimate;
     destinationWorkItem.Fields[microsoftVstsCommonBacklogpriority].Value = pivotalstorySource.Priority;
     return true;
 }
Beispiel #5
0
 public void AddPivotalStoryToTFS(Story pivotalStoryToAdd, string projectname, string iterationPath, string subPath, IEnumerable<Story> additionalDefaultTask, bool kopieraÄvenPiovtalTasks)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
        public void AddPivotalStoryToTFS(Story pivotalStoryToAdd, string projectname, string iterationPath, string subPath, IEnumerable<Story> additionalDefaultTask, bool kopieraÄvenPiovtalTasks)
        {
            var workItemTypes = store.Projects[projectname].WorkItemTypes;

            var existingworkingItem = GetTFSBacklogItemByPivotalId(projectname, iterationPath, subPath,
                                                                   pivotalStoryToAdd.Id);
            if (existingworkingItem != null)
            {
                existingworkingItem.Title = pivotalStoryToAdd.Name;
                existingworkingItem.Description = string.Concat(pivotalStoryToAdd.URL, Environment.NewLine,
                                                                pivotalStoryToAdd.Description);
                existingworkingItem.Save();
                return;
            }

            var workItem = new WorkItem(workItemTypes[ProductBacklogItem]);

            if (pivotalStoryToAdd.Type == "bug")
            {
                workItem = new WorkItem(workItemTypes["Bug"]);
            }

            templateproxy.CopyPivotalStoryValuesToWorkItem(pivotalStoryToAdd, workItem);

            workItem.Description = string.Concat(pivotalStoryToAdd.URL, Environment.NewLine,
                                                 pivotalStoryToAdd.Description);
            workItem.Title = pivotalStoryToAdd.Name;
            workItem.IterationPath = string.Concat(projectname, "\\", iterationPath, "\\", subPath);
            workItem.Fields[HistoryField].Value = string.Concat(Pivotalid, pivotalStoryToAdd.Id, ":");

            //Add Hyper Link
            //Link most be valid!
            if (pivotalStoryToAdd.URL != null)
            {
                var hp = new Hyperlink(pivotalStoryToAdd.URL)
                    {
                        Comment = "Link to pivotal story."
                    };
                workItem.Links.Add(hp);
            }

            if (kopieraÄvenPiovtalTasks)
            {
                //add all existing pivotal tasks as linked workitems to this product backlog workitem.
                AddPivotalTasksAsLinkedWorkItems(workItemTypes, workItem, pivotalStoryToAdd);
            }

            //Add additional tasks.
            if (additionalDefaultTask != null)
                AddAdditionalTasks(workItemTypes, workItem, additionalDefaultTask);

            //Add Attachment
            //TFS will search for the file, so make sure it exists.

            //Attachment a = new Attachment(@"C:\FileToAdd.txt", "Comment....");
            //workItem.Attachments.Add(a);

            //Make sure your Work Item is Valid
            //After you finish adding all the wanted values into the Work Item make sure that all fields are Valid and your can save the Work Item, This step is to make sure that you prepare the Work Item Definition for the migration.

            var invalidFields = new ArrayList();
            foreach (var field in workItem.Fields.Cast<Field>().Where(field => !field.IsValid))
            {
                invalidFields.Add(field);
                Console.WriteLine(Resources.TFS_AddPivotalStoryToTFS_Invalid_Field, field.Name, field.Status);
                Console.WriteLine(Resources.TFS_AddPivotalStoryToTFS_Current_Value, field.Value);
            }
            //There are some Invalid Fields.

            if (invalidFields.Count > 0)
            {
                Console.WriteLine(Resources.TFS_AddPivotalStoryToTFS_Invalid_Bug_Track_ID, invalidFields.ToArray());
                return;
            }
            workItem.Save();
        }
Beispiel #7
0
        private static void AddPivotalTasksAsLinkedWorkItems(WorkItemTypeCollection workItemTypes, WorkItem workItem,
		                                                     Story pivotalStoryToAdd)
        {
            if (pivotalStoryToAdd.Tasks == null)
                return;
            foreach (var task in pivotalStoryToAdd.Tasks.tasks)
            {
                var workitemTask = new WorkItem(workItemTypes[SprintBacklogItem])
                    {
                        Title = task.Description,
                        IterationPath = workItem.IterationPath
                    };
                workitemTask.Fields[HistoryField].Value = workItem.Fields[HistoryField].Value;
                workitemTask.Save();
                workItem.Links.Add(new RelatedLink(workitemTask.Id));
            }
        }
Beispiel #8
0
 public bool CopyPivotalStoryValuesToWorkItem(Story source, WorkItem destination)
 {
     return (from templateMapper in templates.Values
             where IsCreatedFromTemplate(destination, templateMapper)
             select templateMapper.CopyAttributes(source, destination)).FirstOrDefault();
 }