コード例 #1
0
        private static Task CreateTask(HPMUniqueID uniqueID)
        {
            HPMUniqueID        uniqueTaskID = SdkSession.TaskRefGetTask(uniqueID);
            EHPMTaskLockedType lockedType   = SdkSession.TaskGetLockedType(uniqueTaskID);

            switch (lockedType)
            {
            case EHPMTaskLockedType.BacklogItem:
                if (SdkSession.UtilIsIDBacklogProject(SdkSession.TaskGetContainer(uniqueTaskID)))
                {
                    if (SdkSession.TaskGetMainReference(uniqueTaskID).m_ID == uniqueID.m_ID)
                    {
                        return(ProductBacklogItem.GetProductBacklogItem(uniqueID, uniqueTaskID));
                    }
                    else
                    {
                        return(ProductBacklogItemInSprint.GetProductBacklogItemInSprint(uniqueID, uniqueTaskID));
                    }
                }
                else
                {
                    return(SprintBacklogItem.GetSprintBacklogItem(uniqueID, uniqueTaskID));
                }

            case EHPMTaskLockedType.QABug:
                return(Bug.GetBug(uniqueID, uniqueTaskID));

            case EHPMTaskLockedType.SprintItem:
                return(Sprint.GetSprint(uniqueID, uniqueTaskID));

            case EHPMTaskLockedType.Normal:
            default:
                if (SdkSession.TaskGetForceSubProject(uniqueTaskID))
                {
                    return(SubProject.GetSubProject(uniqueID, uniqueTaskID));
                }
                else
                {
                    EHPMTaskType taskType = SdkSession.TaskGetType(uniqueTaskID);
                    switch (taskType)
                    {
                    case EHPMTaskType.Milestone:
                        return(Release.GetRelease(uniqueID, uniqueTaskID));

                    case EHPMTaskType.Planned:
                    default:
                        if (SdkSession.UtilIsIDBacklogProject(SdkSession.TaskGetContainer(uniqueTaskID)))
                        {
                            return(ProductBacklogItemInSchedule.GetProductBacklogItemInSchedule(uniqueID, uniqueTaskID));
                        }
                        else
                        {
                            return(ScheduledTask.GetScheduledTask(uniqueID, uniqueTaskID));
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Sort a list of ProdutcBacklogItems in the same order as they are displayed in the GUI in the priority vuew
        /// </summary>
        /// <param name="project">The Project that the ProductBacklogItems belong to.</param>
        /// <param name="unsorted">The ProductBacklogItems that should be sorted.</param>
        /// <returns></returns>
        public static List <ProductBacklogItem> SortByPriority(Project project, List <ProductBacklogItem> unsorted)
        {
            List <ProductBacklogItem> sorted = new List <ProductBacklogItem>();

            foreach (ProductBacklogItem anItem in unsorted)
            {
                if (anItem is ProductBacklogItemInSprint || anItem is ProductBacklogItemInSchedule)
                {
                    sorted.Add((ProductBacklogItem)Task.GetTask(anItem.Session.TaskGetMainReference(anItem.UniqueTaskID)));
                }
                else
                {
                    sorted.Add(anItem);
                }
            }

            List <HansoftItem> sortedBacklog = new List <HansoftItem>();
            List <HansoftItem> allLeaves     = project.ProductBacklog.DeepLeaves;
            ProductBacklogItem item          = (ProductBacklogItem)allLeaves.Find(leaf => !allLeaves.Exists(prevLeaf => prevLeaf.Session.TaskRefGetPreviousWorkPriorityID(prevLeaf.UniqueID).m_ID == leaf.UniqueID.m_ID));

            sortedBacklog.Add(item);
            HPMUniqueID nextId = item.Session.TaskRefGetPreviousWorkPriorityID(item.UniqueID);

            while (nextId != -2)
            {
                item = (ProductBacklogItem)Task.GetTask(nextId);
                sortedBacklog.Add(item);
                nextId = item.Session.TaskRefGetPreviousWorkPriorityID(item.UniqueID);
            }
            foreach (ProductBacklogItem aItem in sorted)
            {
                aItem.AbsolutePriority = sortedBacklog.FindIndex(ii => ii.UniqueID.m_ID == aItem.UniqueID.m_ID);
            }

            PriorityComparer comparer = new PriorityComparer();

            sorted.Sort(comparer);
            sorted.Reverse();

            return(sorted);
        }