예제 #1
0
        private void BuildChildItemsList(IConfiguration configuration)
        {
            var backlogChildrenList = new List <BacklogChildren>();

            AllChildren = new List <WorkItem>();

            //keep a hash with the backlog items ids. It implies an additional iteration through the collection,
            //but we make up for this when searching for parents in constant time rather than linear
            HashSet <int> backLogIds = new HashSet <int>();

            BackLogItems.ForEach(wi => backLogIds.Add(wi.Id));

            // Iterate over all backlog items and get the list of child items.
            // Keep track of the relation between a backlog item and its child item via the BacklogChildren class.
            foreach (var backLogItem in BackLogItems)
            {
                var currentItem = backLogItem;
                // Get all the work items that the current item points to
                var childInfos = WorkItemLinkInfos.Where(info => info.SourceId == currentItem.Id).ToList();
                // Get the Ids of tht work items
                var childIds = (from WorkItemLinkInfo info in childInfos select info.TargetId).ToList();
                // Get the work items for that ids but only if they are not already in the backlog items list and if they match the child item setting

                // Note: Uncomment the following line and comment the line after in order to hide backlog items from the child area
                //var children = WorkItems.Cast<WorkItem>().Where(item => childIds.Contains(item.Id) && !backLogIds.Contains(item.Id) && configuration.ChildItems.Contains(item.Type.Name)).ToList();
                var children = WorkItems.Cast <WorkItem>().Where(item => childIds.Contains(item.Id) && configuration.ChildItems.Contains(item.Type.Name)).ToList();

                AllChildren.AddRange(children);
                var backlogChildren = new BacklogChildren(backLogItem, children, configuration.States);
                backlogChildrenList.Add(backlogChildren);
            }

            ApplyChildrenChangesOnUIThread(backlogChildrenList);
        }
예제 #2
0
 private bool VerifySaveRequest()
 {
     if (WorkItems != null)
     {
         var workItemsHaveChanges = WorkItems.Cast <WorkItem>().Any(workItem => workItem.IsDirty);
         if (workItemsHaveChanges)
         {
             var args = new RequestEventArgs();
             OnRequestSaveWorkItems(args);
             if (args.Cancel)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #3
0
        private void BuildBacklogItemsList(IConfiguration configuration)
        {
            List <String> backlogItemTypes = configuration.BacklogItems;

            if (!String.IsNullOrEmpty(configuration.SortFieldName))
            {
                if (configuration.SortDirection == SortDirection.Ascending)
                {
                    BackLogItems = WorkItems.Cast <WorkItem>().Where(item => backlogItemTypes.Contains(item.Type.Name) && item.Fields.Contains(configuration.SortFieldName)).OrderBy(b => b.Fields[configuration.SortFieldName].Value).ToList();
                }
                else
                {
                    BackLogItems = WorkItems.Cast <WorkItem>().Where(item => backlogItemTypes.Contains(item.Type.Name) && item.Fields.Contains(configuration.SortFieldName)).OrderByDescending(b => b.Fields[configuration.SortFieldName].Value).ToList();
                }
            }
            else
            {
                BackLogItems = WorkItems.Cast <WorkItem>().Where(item => backlogItemTypes.Contains(item.Type.Name)).ToList();
            }
        }