public void Init()
        {
            _tx = new TransactionScope();

            _repository = new AdoWorkStepRepository(_connectionString);
            _ws = WorkStep.New("/path");
        }
Example #2
0
        private void Move(WorkItem workItem, WorkStep toStep)
        {
            var transition = new WorkItemTransition(workItem, toStep);

            ThrowIfMovingParallelLockedWorkItem(transition);

            ThrowIfMovingExpandLockedWorkItem(transition);

            ThrowIfViolatingWipLimit(transition);

            if (IsMovingWithinParallelStep(transition))
            {
                MoveToWithinParallelStep(transition);
            }
            else
            {
                ThrowIfMovingToWithinExpandStep(transition);

                ThrowIfMovingToStepWithWrongClass(transition);

                CleanUpIfMovingFromExpandStep(transition);

                transition = AttemptMergeIfMovingChildOfParallelledWorkItem(transition);

                transition = CreateTransitionIfMovingToExpandStep(transition);

                var resultTransition = DoMove(transition);

                TryUpdatingExpandLockIfMovingChildOfExpandedWorkItem(resultTransition);
            }
        }
 private static void ThrowIfUpdatingTransientStep(WorkStep workStep)
 {
     if (workStep.Type == WorkStepType.Transient)
     {
         throw new InvalidOperationException("Cannot update transient step");
     }
 }
Example #4
0
        private bool CheckWipExclusiveWorkItems(WorkStep workStep, IEnumerable <WorkItem> workItemsToExclude, int workItemsToAdd)
        {
            var      currentWorkStep = workStep;
            WorkStep childStep       = null;

            var wipCount     = workItemsToAdd;
            var fullWipCount = 0;

            while (currentWorkStep != null)
            {
                wipCount     += CountSubTree(currentWorkStep, workItemsToExclude, childStep);
                fullWipCount += CountSubTree(currentWorkStep, null, childStep);

                var allowed = !currentWorkStep.WipLimit.HasValue || currentWorkStep.WipLimit.Value >= wipCount || wipCount <= fullWipCount;
                if (!allowed)
                {
                    return(false);
                }

                childStep       = currentWorkStep;
                currentWorkStep = GetParentWorkStep(currentWorkStep);
            }

            return(true);
        }
Example #5
0
        private int CountSubTree(WorkStep workStep, IEnumerable <WorkItem> workItemsToExclude, WorkStep childWorkStepToExclude)
        {
            var wipCount = 0;

            foreach (var item in _workflowRepository.GetWorkItems(workStep.Path))
            {
                if (workItemsToExclude == null || !workItemsToExclude.Select(wi => wi.Id).Contains(item.Id))
                {
                    wipCount++;
                }
            }

            if (workStep.Type == WorkStepType.Parallel || workStep.Type == WorkStepType.Transient)
            {
                return(wipCount);
            }

            foreach (var childWorkStep in _workflowRepository.GetChildWorkSteps(workStep.Path))
            {
                if (childWorkStepToExclude != null && childWorkStepToExclude.Path == childWorkStep.Path)
                {
                    continue;
                }

                wipCount += CountSubTree(childWorkStep, workItemsToExclude, childWorkStepToExclude);
            }

            return(wipCount);
        }
Example #6
0
        public WorkStep UpdateFrom(WorkStep workStep)
        {
            var returnStep = new WorkStep(Path, ParentPath, Ordinal, Type, WorkItemClass, Title, WipLimit);

            if (workStep._ordinal.HasValue)
            {
                returnStep = returnStep.UpdateOrdinal(workStep._ordinal.Value);
            }
            if (workStep.Title != null)
            {
                returnStep = returnStep.UpdateTitle(workStep.Title);
            }
            if (workStep._type.HasValue)
            {
                returnStep = returnStep.UpdateType(workStep._type.Value);
            }
            if (workStep.WorkItemClass != null)
            {
                returnStep = returnStep.UpdateWorkItemClass(workStep.WorkItemClass);
            }
            if (workStep.WipLimit.HasValue)
            {
                returnStep = returnStep.UpdateWipLimit(workStep.WipLimit.Value);
            }

            return(returnStep);
        }
Example #7
0
 public void MoveWorkItem(WorkItem workItem, WorkStep toStep)
 {
     using (WorkflowRepository.BeginTransaction())
     {
         Move(workItem, toStep);
         WorkflowRepository.CommitTransaction();
     }
 }
        public void UpdateWorkStep(WorkStep workStep)
        {
            ThrowIfNotExists(workStep.Path);

            _innerRepository.UpdateWorkStep(workStep);

            _workSteps[workStep.Path] = workStep;
        }
 public void MoveWorkItem(WorkItem workItem, WorkStep toStep)
 {
     using(WorkflowRepository.BeginTransaction())
     {
         Move(workItem, toStep);
         WorkflowRepository.CommitTransaction();
     }
 }
 public void CreateWorkStep(WorkStep workStep)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         Create(connection, workStep);
     }
 }
        public void Render(Stream stream, WorkStep workStep)
        {
            using (var writer = new StreamWriter(stream))
            {
                writer.Write("[");

                RenderWorkStepsRecursively(writer, workStep, true);

                writer.Write("]");
            }
        }
Example #12
0
        public bool CanAcceptWorkStep(WorkStep addToStep, WorkStep stepWithWorkItems)
        {
            var newWorkItems     = _workflowRepository.GetWorkItemsRecursively(stepWithWorkItems);
            var currentWorkItems = _workflowRepository.GetWorkItemsRecursively(addToStep);

            var exclusivelyNewWorkItems = newWorkItems.Except(currentWorkItems);

            int count = exclusivelyNewWorkItems.Count();

            return(CheckWipExclusiveWorkItems(addToStep, null, count));
        }
Example #13
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);
        }
        public void UpdateWorkStep(WorkStep workStepUpdate)
        {
            var currentWorkStep = WorkflowRepository.GetWorkStep(workStepUpdate.Path);

            ThrowIfUpdatingTypeAndNotEmpty(currentWorkStep, workStepUpdate, WorkStepType.Expand);
            ThrowIfUpdatingTypeAndNotEmpty(currentWorkStep, workStepUpdate, WorkStepType.Parallel);
            ThrowIfUpdatingToTransientStep(workStepUpdate);
            ThrowIfUpdatingTransientStep(currentWorkStep);
            ThrowIfASiblingHasSameOrdinal(workStepUpdate);
            ThrowIfUpdatingWipLimitAndWipLimitIsViolated(currentWorkStep, workStepUpdate);

            WorkflowRepository.UpdateWorkStep(currentWorkStep.UpdateFrom(workStepUpdate));
        }
        public void MoveWorkStep(WorkStep stepToMove, WorkStep toStep)
        {
            if (stepToMove.WorkItemClass != toStep.WorkItemClass)
            {
                throw new InvalidOperationException("Cannot move work step. Work item classes are not compatible");
            }

            var siblings = _workflowRepository.GetChildWorkSteps(toStep.Path);

            if (siblings.Where(ws => ws.Ordinal == stepToMove.Ordinal).Count() > 0)
            {
                throw new InvalidOperationException("Cannot move work step. Conflicting ordinals");
            }

            if (_workflowRepository.IsWithinTransientStep(stepToMove))
            {
                throw new InvalidOperationException("Cannot move transient work step or step within transient work step");
            }

            var commonRoot = WorkflowPath.FindCommonRoot(stepToMove.Path, toStep.Path);

            foreach (var path in WorkflowPath.GetPathsBetween(commonRoot, stepToMove.Path))
            {
                if (path == commonRoot || path == stepToMove.Path)
                {
                    continue;
                }

                if (_workflowRepository.GetWorkStep(path).Type == WorkStepType.Expand)
                {
                    throw new InvalidOperationException("Cannot move work step within expand step outside expand step");
                }

                if (_workflowRepository.GetWorkStep(path).Type == WorkStepType.Parallel)
                {
                    throw new InvalidOperationException("Cannot move work step within expand step outside parallel step");
                }
            }

            var wipLimitChecker = new WipLimitChecker(_workflowRepository);

            if (!wipLimitChecker.CanAcceptWorkStep(toStep, stepToMove))
            {
                throw new InvalidOperationException("Cannot move work step when WIP limit of new ancestors are violated");
            }



            MoveWorkStepRecursively(stepToMove, toStep);
        }
        public IEnumerable<WorkItem> SplitForParallelism(WorkItem workItem, WorkStep parallelRootStep)
        {
            var childWorkItems = new List<WorkItem>();

            foreach (var subStep in _workflowRepository.GetChildWorkSteps(parallelRootStep.Path))
            {
                var childId = GetParallelId(workItem.Id, parallelRootStep, subStep);
                var childWorkItem = workItem.CreateChildItem(childId,WorkItemParentType.Parallelled).AddClass(subStep.WorkItemClass);

                childWorkItems.Add(childWorkItem);
            }

            return childWorkItems;
        }
        public static IEnumerable<WorkItem> GetWorkItemsRecursively(this IReadableWorkflowRepository workflowRepository, WorkStep workStep)
        {
            foreach (var childWorkStep in workflowRepository.GetChildWorkSteps(workStep.Path))
            {
                foreach (var workItem in GetWorkItemsRecursively(workflowRepository, childWorkStep))
                {
                    yield return workItem;
                }
            }

            foreach (var workItem in workflowRepository.GetWorkItems(workStep.Path))
            {
                yield return workItem;
            }
        }
        private void ThrowIfASiblingHasSameOrdinal(WorkStep workStep)
        {
            foreach (var childWorkStep in WorkflowRepository.GetChildWorkSteps(workStep.ParentPath))
            {
                if(childWorkStep.Path ==workStep.Path)
                {
                    continue;
                }

                if(childWorkStep.Ordinal==workStep.Ordinal)
                {
                    throw new InvalidOperationException("Cannot update to conflicting ordinal");
                }
            }
        }
        public IEnumerable <WorkItem> SplitForParallelism(WorkItem workItem, WorkStep parallelRootStep)
        {
            var childWorkItems = new List <WorkItem>();

            foreach (var subStep in _workflowRepository.GetChildWorkSteps(parallelRootStep.Path))
            {
                var childId       = GetParallelId(workItem.Id, parallelRootStep, subStep);
                var childWorkItem = workItem.CreateChildItem(childId, WorkItemParentType.Parallelled).AddClass(subStep.WorkItemClass);


                childWorkItems.Add(childWorkItem);
            }

            return(childWorkItems);
        }
        public void MoveWorkStep(WorkStep stepToMove, WorkStep toStep)
        {
            if(stepToMove.WorkItemClass!=toStep.WorkItemClass)
            {
                throw new InvalidOperationException("Cannot move work step. Work item classes are not compatible");
            }

            var siblings = _workflowRepository.GetChildWorkSteps(toStep.Path);
            if(siblings.Where(ws=>ws.Ordinal==stepToMove.Ordinal).Count()>0)
            {
                throw new InvalidOperationException("Cannot move work step. Conflicting ordinals");
            }

            if(_workflowRepository.IsWithinTransientStep(stepToMove))
            {
                throw new InvalidOperationException("Cannot move transient work step or step within transient work step");
            }

            var commonRoot = WorkflowPath.FindCommonRoot(stepToMove.Path, toStep.Path);

            foreach (var path in WorkflowPath.GetPathsBetween(commonRoot,stepToMove.Path))
            {
                if(path==commonRoot || path==stepToMove.Path)
                {
                    continue;
                }

                if(_workflowRepository.GetWorkStep(path).Type==WorkStepType.Expand)
                {
                    throw new InvalidOperationException("Cannot move work step within expand step outside expand step");
                }

                if (_workflowRepository.GetWorkStep(path).Type == WorkStepType.Parallel)
                {
                    throw new InvalidOperationException("Cannot move work step within expand step outside parallel step");
                }

            }

            var wipLimitChecker = new WipLimitChecker(_workflowRepository);

            if(!wipLimitChecker.CanAcceptWorkStep(toStep,stepToMove))
            {
                throw new InvalidOperationException("Cannot move work step when WIP limit of new ancestors are violated");
            }

            MoveWorkStepRecursively(stepToMove, toStep);
        }
        public void Render(Stream stream, WorkStep workStep)
        {
            using (var streamWriter = new StreamWriter(stream))
            {
                using (var htmlWriter = new HtmlTextWriter(streamWriter))
                {
                    htmlWriter.RenderBeginTag(HtmlTextWriterTag.Html);
                    htmlWriter.RenderBeginTag(HtmlTextWriterTag.Body);

                    RenderWorkStepsRecursively(htmlWriter, workStep);

                    htmlWriter.RenderEndTag(); //body
                    htmlWriter.RenderEndTag(); //html
                }
            }
        }
        public void Render(Stream stream, WorkStep workStep)
        {
            using (var writer = XmlWriter.Create(stream))
            {
                if(writer==null)
                {
                    throw new ArgumentException("Couldn't create XmlWriter");
                }

                writer.WriteStartDocument();

                RenderWorkSteps(writer, workStep);

                writer.WriteEndDocument();
            }
        }
Example #23
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);
            }
        }
Example #24
0
        private WorkStep GetParentWorkStep(WorkStep currentWorkStep)
        {
            var parentPath = currentWorkStep.ParentPath;

            if (parentPath == WorkStep.Root.Path)
            {
                return(null);
            }

            currentWorkStep = _workflowRepository.GetWorkStep(parentPath);

            if (currentWorkStep.Type == WorkStepType.Parallel || currentWorkStep.Type == WorkStepType.Transient)
            {
                return(null);
            }

            return(currentWorkStep);
        }
        private void MoveWorkStepRecursively(WorkStep stepToMove, WorkStep toStep)
        {
            var leafDirectory = WorkflowPath.GetLeafDirectory(stepToMove.Path);

            var newPath = WorkflowPath.CombinePath(toStep.Path, leafDirectory);

            var newStep = stepToMove.UpdatePath(newPath);
            _workflowRepository.CreateWorkStep(newStep);

            foreach (var workItem in _workflowRepository.GetWorkItems(stepToMove.Path))
            {
                _workflowRepository.UpdateWorkItem(workItem.MoveTo(newStep,_timeSource.GetTime()));
            }

            foreach (var childWorkStep in _workflowRepository.GetChildWorkSteps(stepToMove.Path))
            {
                MoveWorkStep(childWorkStep, newStep);
            }

            _workflowRepository.DeleteWorkStep(stepToMove.Path);
        }
        private void ThrowIfUpdatingTypeAndNotEmpty(WorkStep currentWorkStep, WorkStep workStepUpdate,
                                                    WorkStepType workStepType)
        {
            if ((currentWorkStep.Type == workStepType && workStepUpdate.Type != workStepType) ||
                (currentWorkStep.Type != workStepType && workStepUpdate.Type == workStepType))
            {
                if (WorkflowRepository.GetChildWorkSteps(workStepUpdate.Path).Count() > 0)
                {
                    throw new InvalidOperationException(
                        string.Format("Cannot update workstep type from {0} to {1} workstep when it has children",
                                      currentWorkStep.Type, workStepUpdate.Type));
                }

                if (WorkflowRepository.GetWorkItems(workStepUpdate.Path).Count() > 0)
                {
                    throw new InvalidOperationException(
                        string.Format("Cannot update workstep type from {0} to {1} when it has work items",
                                      currentWorkStep.Type, workStepUpdate.Type));
                }
            }
        }
        private void MoveWorkStepRecursively(WorkStep stepToMove, WorkStep toStep)
        {
            var leafDirectory = WorkflowPath.GetLeafDirectory(stepToMove.Path);

            var newPath = WorkflowPath.CombinePath(toStep.Path, leafDirectory);

            var newStep = stepToMove.UpdatePath(newPath);

            _workflowRepository.CreateWorkStep(newStep);

            foreach (var workItem in _workflowRepository.GetWorkItems(stepToMove.Path))
            {
                _workflowRepository.UpdateWorkItem(workItem.MoveTo(newStep, _timeSource.GetTime()));
            }

            foreach (var childWorkStep in _workflowRepository.GetChildWorkSteps(stepToMove.Path))
            {
                MoveWorkStep(childWorkStep, newStep);
            }

            _workflowRepository.DeleteWorkStep(stepToMove.Path);
        }
Example #28
0
        private WorkItemTransition TraversePathsForParallelStep(WorkItemTransition transition, IEnumerable <string> pathsBetweenRootAndTarget)
        {
            var currentWorkItem = transition.WorkItem;

            WorkStep parentWorkStep = null;

            foreach (var inBetweenPath in pathsBetweenRootAndTarget)
            {
                var currentWorkStep   = WorkflowRepository.GetWorkStep(inBetweenPath);
                var currentTransition = new WorkItemTransition(currentWorkItem, currentWorkStep);

                if (parentWorkStep != null && WorkflowRepository.IsParallelStep(parentWorkStep))
                {
                    var transitionToParallelRoot = new WorkItemTransition(currentWorkItem, parentWorkStep);
                    LockAndMoveToParallelRoot(transitionToParallelRoot);

                    currentWorkItem = CreateParallelledChildrenAndReturnWorkItemToMove(currentTransition, parentWorkStep);
                }

                parentWorkStep = currentWorkStep;
            }

            return(new WorkItemTransition(currentWorkItem, transition.WorkStep));
        }
        private string GetJson(WorkStep workStep)
        {
            MemoryStream readStream;

            using (var writeStream = new MemoryStream())
            {

                _jsonRenderer.Render(writeStream, workStep);
                readStream = new MemoryStream(writeStream.ToArray());
            }

            using (var reader = new StreamReader(readStream))
            {
                return reader.ReadToEnd();
            }
        }
Example #30
0
 public void CreateWorkStep(WorkStep workStep)
 {
     var creator = new WorkStepCreator(WorkflowRepository);
     creator.CreateWorkStep(workStep);
 }
Example #31
0
 public void MoveWorkStep(WorkStep stepToMove, WorkStep toStep)
 {
     var mover = new WorkStepMover(WorkflowRepository,TimeSource);
     mover.MoveWorkStep(stepToMove, toStep);
 }
Example #32
0
        private static bool TryLocateFirstAncestorStepOfType(this IReadableWorkStepRepository repository, WorkStep workStep, WorkStepType stepType, out WorkStep ancestorStep)
        {
            var currentPath = workStep.Path;

            do
            {
                var currentWorkStep = repository.GetWorkStep(currentPath);
                if (currentWorkStep.Type == stepType)
                {
                    ancestorStep = currentWorkStep;
                    return(true);
                }

                currentPath = currentWorkStep.ParentPath;
            }while (currentPath != WorkStep.Root.Path);

            ancestorStep = null;
            return(false);
        }
Example #33
0
 public static bool IsWithinParallelStep(this IReadableWorkflowRepository repository, WorkStep workStep, out WorkStep parallelStepRoot)
 {
     return(TryLocateFirstAncestorStepOfType(repository, workStep, WorkStepType.Parallel, out parallelStepRoot));
 }
Example #34
0
 public static bool IsExpandStep(this IReadableWorkflowRepository repository, WorkStep step)
 {
     return(step.Type == WorkStepType.Expand);
 }
Example #35
0
 public static bool IsValidWorkStepForWorkItem(this IReadableWorkflowRepository repository, WorkItem item, WorkStep workStep)
 {
     return(item.Classes.Contains(workStep.WorkItemClass));
 }
        private void RenderWorkStep(XmlWriter writer, WorkStep workStep)
        {
            writer.WriteStartElement("WorkStep");

            writer.WriteStartAttribute("id");
            writer.WriteValue(GenerateWorkStepId(workStep));
            writer.WriteEndAttribute();

            writer.WriteStartAttribute("workItemClass");
            writer.WriteValue(workStep.WorkItemClass);
            writer.WriteEndAttribute();

            RenderWorkSteps(writer, workStep);
            RenderWorkItems(writer, workStep);

            writer.WriteEndElement(); //WorkSteps
        }
        private void RenderWorkSteps(XmlWriter writer, WorkStep workStep)
        {
            writer.WriteStartElement("WorkSteps");

            foreach (var childWorkStep in _workflowRepository.GetChildWorkSteps(workStep.Path).OrderBy(ws => ws.Ordinal))
            {
                RenderWorkStep(writer, childWorkStep);
            }

            writer.WriteEndElement(); //WorkSteps
        }
Example #38
0
        public WorkStep UpdateFrom(WorkStep workStep)
        {
            var returnStep = new WorkStep(Path, ParentPath, Ordinal, Type, WorkItemClass, Title, WipLimit);

            if (workStep._ordinal.HasValue)
            {
                returnStep = returnStep.UpdateOrdinal(workStep._ordinal.Value);
            }
            if (workStep.Title != null)
            {
                returnStep = returnStep.UpdateTitle(workStep.Title);
            }
            if(workStep._type.HasValue)
            {
                returnStep = returnStep.UpdateType(workStep._type.Value);
            }
            if(workStep.WorkItemClass!=null)
            {
                returnStep = returnStep.UpdateWorkItemClass(workStep.WorkItemClass);
            }
            if(workStep.WipLimit.HasValue)
            {
                returnStep = returnStep.UpdateWipLimit(workStep.WipLimit.Value);
            }

            return returnStep;
        }
        private void RenderWorkItems(XmlWriter writer, WorkStep workStep)
        {
            writer.WriteStartElement("WorkItems");

            foreach (var workItem in _workflowRepository.GetWorkItems(workStep.Path).OrderBy(wi => wi.Ordinal))
            {
                RenderWorkItem(writer, workItem);
            }

            writer.WriteEndElement(); //WorkItems
        }
Example #40
0
 public static string GetTransientPath(WorkStep expandedWorkStep, WorkItem workItem)
 {
     return WorkflowPath.CombinePath(expandedWorkStep.Path, workItem.Id);
 }
        public static XmlDocument RenderToXmlDocument(this XmlRenderer xmlRenderer, WorkStep workStep)
        {
            var doc = new XmlDocument();
            using (var writeStream = new MemoryStream())
            {

                xmlRenderer.Render(writeStream, workStep);

                var readStream = new MemoryStream(writeStream.ToArray());
                doc.Load(readStream);
            }
            return doc;
        }
        private WorkItem CreateParallelledChildrenAndReturnWorkItemToMove(WorkItemTransition transition, WorkStep parallelStep)
        {
            var helper = new ParallelStepHelper(WorkflowRepository);

            var splitWorkItems = helper.SplitForParallelism(transition.WorkItem, parallelStep);

            foreach (var splitWorkItem in splitWorkItems)
            {
                WorkflowRepository.CreateWorkItem(splitWorkItem);

                WorkStep expandStep;
                var isInExpandStep = WorkflowRepository.IsInExpandStep(transition.WorkItem, out expandStep);
                if (isInExpandStep)
                {
                    CreateTransientWorkSteps(splitWorkItem, expandStep);
                }
            }

            var idToMove = ParallelStepHelper.GetParallelId(transition.WorkItem.Id, parallelStep, transition.WorkStep);
            var workItemToMove = splitWorkItems.First(wi => wi.Id == idToMove);

            return workItemToMove;
        }
Example #43
0
        public void MoveWorkStep(WorkStep stepToMove, WorkStep toStep)
        {
            var mover = new WorkStepMover(WorkflowRepository, TimeSource);

            mover.MoveWorkStep(stepToMove, toStep);
        }
Example #44
0
 public static bool IsLeafStep(this IReadableWorkflowRepository repository, WorkStep step)
 {
     return(GetLeafStep(repository, step).Path == step.Path);
 }
Example #45
0
        public void CreateWorkStep(WorkStep workStep)
        {
            var creator = new WorkStepCreator(WorkflowRepository);

            creator.CreateWorkStep(workStep);
        }
Example #46
0
 public static WorkStep GetLeafStep(this IReadableWorkflowRepository repository, WorkStep workStep)
 {
     return(GetLeafStep(repository, workStep.Path));
 }
Example #47
0
 public static bool IsParallelStep(this IReadableWorkflowRepository repository, WorkStep step)
 {
     return(step.Type == WorkStepType.Parallel);
 }
Example #48
0
        public static void DeleteWorkStepsRecursively(this IWorkflowRepository repository, WorkStep step)
        {
            foreach (var workStep in repository.GetChildWorkSteps(step.Path))
            {
                DeleteWorkStepsRecursively(repository, workStep);
            }

            repository.DeleteWorkStep(step.Path);
        }
Example #49
0
 public static IEnumerable <string> GetWorkItemClasses(this IReadableWorkflowRepository repository, WorkStep workStep)
 {
     yield return(workStep.WorkItemClass);
 }
        private void Move(WorkItem workItem, WorkStep toStep)
        {
            var transition = new WorkItemTransition(workItem, toStep);

            ThrowIfMovingParallelLockedWorkItem(transition);

            ThrowIfMovingExpandLockedWorkItem(transition);

            ThrowIfViolatingWipLimit(transition);

            if (IsMovingWithinParallelStep(transition))
            {
                MoveToWithinParallelStep(transition);
            }
            else
            {
                ThrowIfMovingToWithinExpandStep(transition);

                ThrowIfMovingToStepWithWrongClass(transition);

                CleanUpIfMovingFromExpandStep(transition);

                transition = AttemptMergeIfMovingChildOfParallelledWorkItem(transition);

                transition = CreateTransitionIfMovingToExpandStep(transition);

                var resultTransition = DoMove(transition);

                TryUpdatingExpandLockIfMovingChildOfExpandedWorkItem(resultTransition);
            }
        }
Example #51
0
        public static bool IsMergeableParallelledChild(this IReadableWorkflowRepository repository, WorkItem item, WorkStep toStep)
        {
            if (!repository.IsChildOfParallelledWorkItem(item))
            {
                return(false);
            }

            var isMergeable = true;

            foreach (var childWorkItem in repository.GetChildWorkItems(item.Parent).Where(wi => wi.Id != item.Id))
            {
                isMergeable &= childWorkItem.Path == toStep.Path;
            }
            return(isMergeable);
        }
 public static string GetParallelId(string id, WorkStep parallelRootStep, WorkStep toStep)
 {
     return id+"-"+toStep.Path.Remove(0, parallelRootStep.Path.Length+1);
 }
Example #53
0
        public static IEnumerable <WorkItem> GetWorkItemsRecursively(this IReadableWorkflowRepository workflowRepository, WorkStep workStep)
        {
            foreach (var childWorkStep in workflowRepository.GetChildWorkSteps(workStep.Path))
            {
                foreach (var workItem in GetWorkItemsRecursively(workflowRepository, childWorkStep))
                {
                    yield return(workItem);
                }
            }

            foreach (var workItem in workflowRepository.GetWorkItems(workStep.Path))
            {
                yield return(workItem);
            }
        }
 private static string GenerateWorkStepId(WorkStep step)
 {
     return step.Path.Remove(0, 1).Replace('/', '.');
 }
Example #55
0
 public static bool IsWithinExpandStep(this IReadableWorkflowRepository repository, WorkStep workStep, out WorkStep expandStep)
 {
     return(TryLocateFirstAncestorStepOfType(repository, workStep, WorkStepType.Expand, out expandStep));
 }
        private XmlDocument GetDocument(WorkStep workStep)
        {
            var htmlRenderer = new HtmlRenderer(_wp);

            var doc = new XmlDocument();
            using (var writeStream = new MemoryStream())
            {

                htmlRenderer.Render(writeStream, workStep);

                var readStream = new MemoryStream(writeStream.ToArray());
                doc.Load(readStream);
            }
            return doc;
        }
Example #57
0
 public static bool IsWithinTransientStep(this IReadableWorkflowRepository repository, WorkStep workStep, out WorkStep transientStep)
 {
     return(TryLocateFirstAncestorStepOfType(repository, workStep, WorkStepType.Transient, out transientStep));
 }
Example #58
0
 public void UpdateWorkStep(WorkStep workStep)
 {
     var updater = new WorkStepUpdater(WorkflowRepository);
     updater.UpdateWorkStep(workStep);
 }
Example #59
0
        public static bool IsInExpandStep(this IReadableWorkflowRepository repository, WorkItem workItem, out WorkStep expandStep)
        {
            expandStep = null;
            bool isInExpandStep = repository.GetWorkStep(workItem.Path).Type == WorkStepType.Expand;

            if (isInExpandStep)
            {
                expandStep = repository.GetWorkStep(workItem.Path);
            }

            return(isInExpandStep);
        }
 public static void CreateWorkItem(this IWriteableWorkItemRepository repository, WorkStep workStep, params string[] ids)
 {
     ids.ToList().ForEach(id => repository.CreateWorkItem(WorkItem.New(id, workStep.Path)));
 }