示例#1
0
        private void CreateTransientWorkSteps(WorkItem item, WorkStep expandStep)
        {
            Debug.Assert(expandStep.Type == WorkStepType.Expand);

            var transientRootPath = ExpandedWorkStep.GetTransientPath(expandStep, item);

            CreateTransientWorkStepsRecursively(transientRootPath, expandStep, item.Id);

            var workItemClass     = WorkItemClass.Combine(expandStep.WorkItemClass, item.Id);
            var transientWorkStep = WorkStep.New(transientRootPath).UpdateFrom(expandStep).UpdateType(WorkStepType.Transient).UpdateWorkItemClass(workItemClass);

            WorkflowRepository.CreateWorkStep(transientWorkStep);
        }
示例#2
0
        private void CreateTransientWorkStepsRecursively(string transientRootPath, WorkStep rootStep, string workItemId)
        {
            var subSteps = WorkflowRepository.GetChildWorkSteps(rootStep.Path).Where(ws => ws.Type != WorkStepType.Transient);

            foreach (var childStep in subSteps)
            {
                var offset = childStep.Path.Remove(0, rootStep.Path.Length);

                var childTransientPath = transientRootPath + offset;

                var workItemClass = WorkItemClass.Combine(childStep.WorkItemClass, workItemId);
                WorkflowRepository.CreateWorkStep(WorkStep.New(childTransientPath).UpdateFrom(childStep).UpdateWorkItemClass(workItemClass));

                CreateTransientWorkStepsRecursively(childTransientPath, childStep, workItemId);
            }
        }
示例#3
0
        public override int GetHashCode()
        {
            var hc = Path != null?Path.GetHashCode() : 2;

            hc ^= ParentPath != null?ParentPath.GetHashCode() : 4;

            hc ^= _ordinal.HasValue ? _ordinal.Value.GetHashCode() :8;
            hc ^= _type.HasValue ? _type.Value.GetHashCode() : 16;
            hc ^= WorkItemClass != null?WorkItemClass.GetHashCode() : 32;

            hc ^= Title != null?Title.GetHashCode() : 64;

            hc ^= WipLimit.HasValue ? WipLimit.Value.GetHashCode() : 128;

            return(hc);
        }
        private void Create(WorkItem newWorkItem)
        {
            var leafStep = WorkflowRepository.GetLeafStep(newWorkItem.Path);

            if (leafStep.Type != WorkStepType.Begin)
            {
                throw new InvalidOperationException("Can only create work items in begin step");
            }

            var classes = WorkflowRepository.GetWorkItemClasses(leafStep);

            newWorkItem = newWorkItem.MoveTo(leafStep, _timeSource.GetTime()).UpdateClasses(classes);

            WorkStep transientStep;

            if (WorkflowRepository.IsWithinTransientStep(leafStep, out transientStep))
            {
                var parentItem = GetTransientParentWorkItem(transientStep);
                WorkflowRepository.UpdateWorkItem(parentItem.UpdateStatus(WorkItemStatus.ExpandLocked));

                newWorkItem = newWorkItem.MoveTo(leafStep, _timeSource.GetTime()).UpdateParent(parentItem, WorkItemParentType.Expanded);

                foreach (var workItemClass in newWorkItem.Classes)
                {
                    foreach (var rootClass in WorkItemClass.FindRootClasses(workItemClass))
                    {
                        newWorkItem = newWorkItem.AddClass(rootClass);
                    }
                }
            }
            else if (WorkflowRepository.IsWithinExpandStep(leafStep))
            {
                throw new InvalidOperationException("Cannot create item directly under expand step");
            }

            if (!newWorkItem.Ordinal.HasValue)
            {
                newWorkItem = newWorkItem.UpdateOrdinal(WorkflowRepository.GetNextOrdinal(newWorkItem));
            }

            WorkflowRepository.CreateWorkItem(newWorkItem);
        }