Example #1
0
        private void CreateUserStoryAndTask(TaskCreator taskCreator, string[] createStringArr)
        {
            TFS_Item userStoryItem = Utilities.DeepClone(_settings.TFSDefaults);

            userStoryItem.WorkItemType = WorkItemType.UserStory;
            ExtractCommonFields(userStoryItem, createStringArr);
            CleanTaskItem(userStoryItem, WorkItemType.UserStory);

            string workItemTitle = userStoryItem.Title.Length > 30 ? userStoryItem.Title.Substring(0, 30) : userStoryItem.Title;

            SetStatus($"Creating User Story: {workItemTitle}...");

            var userStoryItemResult = taskCreator.CreateWorkItem(userStoryItem);

            if (userStoryItemResult.Id.GetValueOrDefault() > 0)
            {
                TFS_Item taskItem = Utilities.DeepClone(_settings.TFSDefaults);
                taskItem.WorkItemType = WorkItemType.Task;
                taskItem.ParentID     = userStoryItemResult.Id.Value.ToString();
                ExtractCommonFields(taskItem, createStringArr);
                CleanTaskItem(taskItem, WorkItemType.Task);
                taskItem.OriginalEstimate = createStringArr[3]; // Hours for the task, used for Original Estimate and Remaining Hours

                SetStatus($"Creating Task: {workItemTitle}...");

                var taskItemResult = taskCreator.CreateWorkItem(taskItem);
                if (userStoryItemResult.Id.GetValueOrDefault() <= 0)
                {
                    MessageBox.Show($"Failed to create task: {taskItem.Title}", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        private void TestCreate()
        {
            TFS_Item    itemToCreate = CreateTestTFSItem(WorkItemType.Task);
            TaskCreator taskCreator  = new TaskCreator(_settings);
            var         result       = taskCreator.CreateWorkItem(itemToCreate);

            Console.WriteLine(result.Id);
        }
Example #3
0
 private static void ExtractCommonFields(TFS_Item item, string[] createStringArr)
 {
     item.Title = createStringArr[0];
     item.AcceptanceCriteria = createStringArr[1] + "<br>" + item.AcceptanceCriteria;
     item.StoryPoints        = createStringArr[2];
     item.SprintPoints       = item.StoryPoints;
     item.Description        = createStringArr[4];
 }
Example #4
0
 private void CleanTaskItem(TFS_Item item, WorkItemType type)
 {
     if (type == WorkItemType.UserStory)
     {
         item.Activity = null;
     }
     else if (type == WorkItemType.Task)
     {
         item.StoryType = null;
         item.ValueArea = null;
         item.CurrentSprintExpectation = null;
     }
 }